binary file r/w

This commit is contained in:
randogoth 2026-06-07 16:18:52 +03:00
parent 8c165edc0c
commit c14de9c3e9
2 changed files with 38 additions and 0 deletions

View file

@ -1,4 +1,5 @@
import 'dart:io';
import 'dart:typed_data';
import 'package:actors/actors.dart';
import 'package:swarm/swarm.dart';
import 'package:test/test.dart';
@ -38,5 +39,21 @@ void main() {
throwsA(isA<PathNotFoundException>()),
);
});
test('saves binary file', () async {
final path = '${tempDir.path}/data.bin';
final bytes = Uint8List.fromList([0x00, 0xFF, 0x89, 0x50, 0x4E, 0x47]);
final result = await actor.send(SaveBinaryFile(path, bytes));
expect(result, isA<FileSaved>());
});
test('loads a saved binary file', () async {
final path = '${tempDir.path}/data.bin';
final bytes = Uint8List.fromList([0x00, 0xFF, 0x89, 0x50, 0x4E, 0x47]);
await actor.send(SaveBinaryFile(path, bytes));
final result = await actor.send(LoadBinaryFile(path));
expect(result, isA<BinaryFileLoaded>());
expect((result as BinaryFileLoaded).bytes, equals(bytes));
});
});
}