diff --git a/test/gzip_test.dart b/test/gzip_test.dart index a42081b..08c7d99 100644 --- a/test/gzip_test.dart +++ b/test/gzip_test.dart @@ -1,25 +1,21 @@ import 'dart:convert'; +import 'dart:io'; import 'dart:typed_data'; import 'package:gzip/gzip.dart'; import 'package:test/test.dart'; -const dec = Base64Decoder(); const enc = Utf8Encoder(); void main() { - for (final (:name, :input, :output) in [ - ( - name: 'Simple ASCII', - input: enc.convert('Hello World'), - output: dec.convert('H4sIAAAAAAAAA/NIzcnJVwjPL8pJAQBWsRdKCwAAAA=='), - ), - ( - name: 'More complex', - input: enc.convert('éàöñ 漢 こんにちは به متنی©®€£µ¥'), - output: dec.convert('H4sIAAAAAAAAAwE3AMj/w6nDoMO2w7Eg5ryiIOOBk+OCk+OBq+O' - 'BoeOBryDYqNmHINmF2KrZhtuMwqnCruKCrMKjwrXCpXqkccQ3AAAA'), - ), - ]) { + for (final (:name, :input, output: outputList) in cases) { + const osBit = 9; + outputList[osBit] = switch (Platform.operatingSystem) { + 'linux' => 3, + 'macos' => 19, + 'windows' => 10, + String() => throw UnimplementedError('No id for this platform found'), + }; + final output = Uint8List.fromList(outputList); test( 'Compress $name', () async => expect(await GZip().compress(input), output), @@ -44,3 +40,127 @@ void main() { ); } } + +final cases = [ + ( + name: 'Simple ASCII', + input: enc.convert('Hello World'), + output: [ + 31, + 139, + 8, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 243, + 72, + 205, + 201, + 201, + 87, + 8, + 207, + 47, + 202, + 73, + 1, + 0, + 86, + 177, + 23, + 74, + 11, + 0, + 0, + 0 + ], + ), + ( + name: 'More complex', + input: enc.convert('éàöñ 漢 こんにちは به متنی©®€£µ¥'), + output: [ + 31, + 139, + 8, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 1, + 55, + 0, + 200, + 255, + 195, + 169, + 195, + 160, + 195, + 182, + 195, + 177, + 32, + 230, + 188, + 162, + 32, + 227, + 129, + 147, + 227, + 130, + 147, + 227, + 129, + 171, + 227, + 129, + 161, + 227, + 129, + 175, + 32, + 216, + 168, + 217, + 135, + 32, + 217, + 133, + 216, + 170, + 217, + 134, + 219, + 140, + 194, + 169, + 194, + 174, + 226, + 130, + 172, + 194, + 163, + 194, + 181, + 194, + 165, + 122, + 164, + 113, + 196, + 55, + 0, + 0, + 0 + ], + ), +];