Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library json_unicode_tests; | |
| 6 import 'unicode_tests.dart'; | |
| 7 | |
| 8 const _QUOTE = 0x22; // " | |
| 9 const _COLON = 0x3a; // : | |
| 10 const _COMMA = 0x2c; // , | |
| 11 const _BRACE_OPEN = 0x7b; // { | |
| 12 const _BRACE_CLOSE = 0x7d; // } | |
| 13 const _BRACKET_OPEN = 0x5b; // [ | |
| 14 const _BRACKET_CLOSE = 0x5d; // ] | |
| 15 | |
| 16 _expandUnicodeTests() { | |
| 17 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.
| |
| 18 var bytes = test[0]; | |
| 19 var string = test[1]; | |
| 20 var expanded = []; | |
| 21 var inQuotesBytes = []; | |
| 22 inQuotesBytes.add(_QUOTE); | |
| 23 inQuotesBytes.addAll(bytes); | |
| 24 inQuotesBytes.add(_QUOTE); | |
| 25 expanded.add([inQuotesBytes, string]); | |
| 26 | |
| 27 var listExpected = [[[string]]]; // triple nested string. | |
| 28 var inListBytes = []; | |
| 29 inListBytes.addAll([_BRACKET_OPEN, _BRACKET_OPEN, _BRACKET_OPEN]); | |
| 30 inListBytes.addAll(inQuotesBytes); | |
| 31 inListBytes.addAll([_BRACKET_CLOSE, _BRACKET_CLOSE, _BRACKET_CLOSE]); | |
| 32 expanded.add([inListBytes, listExpected]); | |
| 33 | |
| 34 // Same, but duplicated. | |
| 35 var listLongerExpected = [listExpected, listExpected, listExpected]; | |
| 36 var listLongerBytes = []; | |
| 37 listLongerBytes.add(_BRACKET_OPEN); | |
| 38 listLongerBytes.addAll(inListBytes); | |
| 39 listLongerBytes.add(_COMMA); | |
| 40 listLongerBytes.addAll(inListBytes); | |
| 41 listLongerBytes.add(_COMMA); | |
| 42 listLongerBytes.addAll(inListBytes); | |
| 43 listLongerBytes.add(_BRACKET_CLOSE); | |
| 44 expanded.add([listLongerBytes, listLongerExpected]); | |
| 45 | |
| 46 // in Map. | |
| 47 var mapExpected = new Map(); | |
| 48 mapExpected[string] = listLongerExpected; | |
| 49 var mapBytes = []; | |
| 50 mapBytes.add(_BRACE_OPEN); | |
| 51 mapBytes.addAll(inQuotesBytes); | |
| 52 mapBytes.add(_COLON); | |
| 53 mapBytes.addAll(listLongerBytes); | |
| 54 mapBytes.add(_BRACE_CLOSE); | |
| 55 expanded.add([mapBytes, mapExpected]); | |
| 56 | |
| 57 return expanded; | |
| 58 }).toList(); | |
| 59 } | |
| 60 | |
| 61 final JSON_UNICODE_TESTS = _expandUnicodeTests(); | |
| OLD | NEW |