Skip to content

Commit

Permalink
Make test work on browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Apr 30, 2024
1 parent b0bbf0c commit d31f10f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
14 changes: 5 additions & 9 deletions test/gzip_test.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';

import 'package:gzip/gzip.dart';
import 'package:test/test.dart';

import 'helper_mock.dart'
if (dart.library.io) 'helper_io.dart'
if (dart.library.js_interop) 'helper_web.dart';

const enc = Utf8Encoder();
void main() {
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);
final output = switchPlatformBit(outputList);
test(
'Compress $name',
() async => expect(await GZip().compress(input), output),
Expand Down
13 changes: 13 additions & 0 deletions test/helper_io.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'dart:io';
import 'dart:typed_data';

Uint8List switchPlatformBit(List<int> input) {
const osBit = 9;
input[osBit] = switch (Platform.operatingSystem) {
'linux' => 3,
'macos' => 19,
'windows' => 10,
String() => throw UnimplementedError('No id for this platform found'),
};
return Uint8List.fromList(input);
}
3 changes: 3 additions & 0 deletions test/helper_mock.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'dart:typed_data';

Uint8List switchPlatformBit(List<int> input) => throw UnimplementedError();
3 changes: 3 additions & 0 deletions test/helper_web.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'dart:typed_data';

Uint8List switchPlatformBit(List<int> input) => Uint8List.fromList(input);

0 comments on commit d31f10f

Please sign in to comment.