Skip to content

Commit

Permalink
Test per platform
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Apr 30, 2024
1 parent 10f5d9c commit b0bbf0c
Showing 1 changed file with 134 additions and 14 deletions.
148 changes: 134 additions & 14 deletions test/gzip_test.dart
Original file line number Diff line number Diff line change
@@ -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),
Expand All @@ -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
],
),
];

0 comments on commit b0bbf0c

Please sign in to comment.