Skip to content

Commit

Permalink
Fix unit test being corrupted on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0gramista committed Feb 25, 2024
1 parent 50a2e7b commit ccc8585
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/charset_converter_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:charset_converter/charset_converter.dart';
Expand All @@ -11,9 +13,18 @@ void main() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
if (methodCall.method == "encode") {
if (Platform.isLinux) {
return Uint8List.fromList(
[...(methodCall.arguments["data"] as Uint8List), 0]);
}
return Uint8List.fromList(
(methodCall.arguments["data"] as String).codeUnits);
} else if (methodCall.method == "decode") {
if (Platform.isLinux) {
return String.fromCharCodes(
(methodCall.arguments["data"] as Uint8List).sublist(
0, (methodCall.arguments["data"] as Uint8List).length - 1));
}
return String.fromCharCodes(methodCall.arguments["data"]);
} else if (methodCall.method == "availableCharsets") {
return ["windows1250", "Big5", "GBK"];
Expand Down

0 comments on commit ccc8585

Please sign in to comment.