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

Unified Diff: tests/lib/convert/json_unicode_tests.dart

Issue 20374003: Add transformer support to Converters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Provide better types for bind. Created 7 years, 5 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
Index: tests/lib/convert/json_unicode_tests.dart
diff --git a/tests/lib/convert/json_unicode_tests.dart b/tests/lib/convert/json_unicode_tests.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5b55301dfa51eeac12cf65ec763e09e652ad2e2a
--- /dev/null
+++ b/tests/lib/convert/json_unicode_tests.dart
@@ -0,0 +1,61 @@
+// 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.
+
+library json_unicode_tests;
+import 'unicode_tests.dart';
+
+const _QUOTE = 0x22; // "
+const _COLON = 0x3a; // :
+const _COMMA = 0x2c; // ,
+const _BRACE_OPEN = 0x7b; // {
+const _BRACE_CLOSE = 0x7d; // }
+const _BRACKET_OPEN = 0x5b; // [
+const _BRACKET_CLOSE = 0x5d; // ]
+
+_expandUnicodeTests() {
+ return UNICODE_TESTS.expand((test) {
Søren Gjesse 2013/07/26 07:37:23 Please add a comment listing the different JSONs g
floitsch 2013/07/26 10:35:32 Done.
+ var bytes = test[0];
+ var string = test[1];
+ var expanded = [];
+ var inQuotesBytes = [];
+ inQuotesBytes.add(_QUOTE);
+ inQuotesBytes.addAll(bytes);
+ inQuotesBytes.add(_QUOTE);
+ expanded.add([inQuotesBytes, string]);
+
+ var listExpected = [[[string]]]; // triple nested string.
+ var inListBytes = [];
+ inListBytes.addAll([_BRACKET_OPEN, _BRACKET_OPEN, _BRACKET_OPEN]);
+ inListBytes.addAll(inQuotesBytes);
+ inListBytes.addAll([_BRACKET_CLOSE, _BRACKET_CLOSE, _BRACKET_CLOSE]);
+ expanded.add([inListBytes, listExpected]);
+
+ // Same, but duplicated.
+ var listLongerExpected = [listExpected, listExpected, listExpected];
+ var listLongerBytes = [];
+ listLongerBytes.add(_BRACKET_OPEN);
+ listLongerBytes.addAll(inListBytes);
+ listLongerBytes.add(_COMMA);
+ listLongerBytes.addAll(inListBytes);
+ listLongerBytes.add(_COMMA);
+ listLongerBytes.addAll(inListBytes);
+ listLongerBytes.add(_BRACKET_CLOSE);
+ expanded.add([listLongerBytes, listLongerExpected]);
+
+ // in Map.
+ var mapExpected = new Map();
+ mapExpected[string] = listLongerExpected;
+ var mapBytes = [];
+ mapBytes.add(_BRACE_OPEN);
+ mapBytes.addAll(inQuotesBytes);
+ mapBytes.add(_COLON);
+ mapBytes.addAll(listLongerBytes);
+ mapBytes.add(_BRACE_CLOSE);
+ expanded.add([mapBytes, mapExpected]);
+
+ return expanded;
+ }).toList();
+}
+
+final JSON_UNICODE_TESTS = _expandUnicodeTests();

Powered by Google App Engine
This is Rietveld 408576698