Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(834)

Unified Diff: tests/standalone/io/system_encoding_test.dart

Issue 1194883002: Improve the encoding/decoding to/from system encoding on Windows (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: A few more comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« runtime/bin/utils_win.cc ('K') | « runtime/bin/utils_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/system_encoding_test.dart
diff --git a/tests/standalone/io/system_encoding_test.dart b/tests/standalone/io/system_encoding_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e457d451eca4e6271d041d869120e868cad7a829
--- /dev/null
+++ b/tests/standalone/io/system_encoding_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:io';
+import 'dart:convert';
+
+import "package:expect/expect.dart";
+
+testEncodeDecode(str) {
+ Expect.equals(
+ SYSTEM_ENCODING.decoder.convert(
+ SYSTEM_ENCODING.encoder.convert(str)), str);
+}
+
+testDecodeEncode(bytes) {
+ Expect.listEquals(
+ SYSTEM_ENCODING.encoder.convert(
+ SYSTEM_ENCODING.decoder.convert(bytes)), bytes);
+}
+
+test(bytes) {
kustermann 2015/06/22 11:11:21 Please add types to the parameters.
Søren Gjesse 2015/06/23 11:17:59 Done.
+ var str = new String.fromCharCodes(bytes);
+ Expect.equals(SYSTEM_ENCODING.decoder.convert(bytes), str);
+ Expect.listEquals(SYSTEM_ENCODING.encoder.convert(str), bytes);
+ testDecodeEncode(bytes);
+ testEncodeDecode(str);
+}
+
+main() {
+ test([65, 66, 67]);
+ test([65, 0, 67]);
+ test([0, 65, 0, 67, 0]);
+ test([0, 0, 0]);
+ test(new Iterable.generate(128, (i) => i).toList());
+ testEncodeDecode('\u00c6\u00d8\u00c5');
+ if (Platform.isWindows) {
+ Expect.listEquals(
+ SYSTEM_ENCODING.encoder.convert('\u1234\u5678\u9abc'),
+ '???'.codeUnits);
kustermann 2015/06/22 11:11:21 Could you add a comment here to explain the differ
Lasse Reichstein Nielsen 2015/06/22 12:08:34 WHat kind of silly encoding is that? :)
Søren Gjesse 2015/06/23 11:17:59 That is what you get!
Søren Gjesse 2015/06/23 11:17:59 Done.
+ } else {
Lasse Reichstein Nielsen 2015/06/22 12:08:34 So all non-windows systems use UTF-8? So far. :)
Søren Gjesse 2015/06/23 11:17:59 Yes, added comment.
+ Expect.listEquals(
+ SYSTEM_ENCODING.encoder.convert('\u1234\u5678\u9abc'),
+ UTF8.encoder.convert('\u1234\u5678\u9abc'));
+ }
+}
« runtime/bin/utils_win.cc ('K') | « runtime/bin/utils_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698