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

Side by Side Diff: utils/tests/string_encoding/unicode_core_tests.dart

Issue 10154010: test rename overhaul: step 3 _tests.dart => _test.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env dart
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file.
5
6 #library("unicode_core_tests");
7 #import("dunit.dart");
8 #import("../../string_encoding/unicode_core.dart");
9
10 void main() {
11 TestSuite suite = new TestSuite();
12 suite.registerTestClass(new UnicodeCoreTests());
13 suite.run();
14 }
15
16 class UnicodeCoreTests extends TestClass {
17 void registerTests(TestSuite suite) {
18 register("testPlatform", testPlatform, suite);
19 register("testCodepointsToUtf16CodeUnits",
20 testCodepointsToUtf16CodeUnits, suite);
21 register("testUtf16bytesToCodepoints", testUtf16bytesToCodepoints, suite);
22 }
23
24 void testPlatform() {
25 Expect.isFalse(is16BitCodeUnit());
26 }
27
28 void testCodepointsToUtf16CodeUnits() {
29 // boundary conditions
30 Expect.listEquals([], codepointsToUtf16CodeUnits([]), "no input");
31 Expect.listEquals([0x0], codepointsToUtf16CodeUnits([0x0]), "0");
32 Expect.listEquals([0xd800, 0xdc00],
33 codepointsToUtf16CodeUnits([0x10000]), "10000");
34
35 Expect.listEquals([0xffff],
36 codepointsToUtf16CodeUnits([0xffff]), "ffff");
37 Expect.listEquals([0xdbff, 0xdfff],
38 codepointsToUtf16CodeUnits([0x10ffff]), "10ffff");
39
40 Expect.listEquals([0xd7ff],
41 codepointsToUtf16CodeUnits([0xd7ff]), "d7ff");
42 Expect.listEquals([0xe000],
43 codepointsToUtf16CodeUnits([0xe000]), "e000");
44
45 Expect.listEquals([UNICODE_REPLACEMENT_CHARACTER_CODEPOINT],
46 codepointsToUtf16CodeUnits([0xd800]), "d800");
47 Expect.listEquals([UNICODE_REPLACEMENT_CHARACTER_CODEPOINT],
48 codepointsToUtf16CodeUnits([0xdfff]), "dfff");
49 }
50
51 void testUtf16bytesToCodepoints() {
52 // boundary conditions: First possible values
53 Expect.listEquals([], utf16CodeUnitsToCodepoints([]), "no input");
54 Expect.listEquals([0x0], utf16CodeUnitsToCodepoints([0x0]), "0");
55 Expect.listEquals([0x10000],
56 utf16CodeUnitsToCodepoints([0xd800, 0xdc00]), "10000");
57
58 // boundary conditions: Last possible sequence of a certain length
59 Expect.listEquals([0xffff],
60 utf16CodeUnitsToCodepoints([0xffff]), "ffff");
61 Expect.listEquals([0x10ffff],
62 utf16CodeUnitsToCodepoints([0xdbff, 0xdfff]), "10ffff");
63
64 // other boundary conditions
65 Expect.listEquals([0xd7ff],
66 utf16CodeUnitsToCodepoints([0xd7ff]), "d7ff");
67 Expect.listEquals([0xe000],
68 utf16CodeUnitsToCodepoints([0xe000]), "e000");
69
70 // unexpected continuation bytes
71 Expect.listEquals([0xfffd],
72 utf16CodeUnitsToCodepoints([0xdc00]),
73 "dc00 first unexpected continuation byte");
74 Expect.listEquals([0xfffd],
75 utf16CodeUnitsToCodepoints([0xdfff]),
76 "dfff last unexpected continuation byte");
77 Expect.listEquals([0xfffd],
78 utf16CodeUnitsToCodepoints([0xdc00]),
79 "1 unexpected continuation bytes");
80 Expect.listEquals([0xfffd, 0xfffd],
81 utf16CodeUnitsToCodepoints([0xdc00, 0xdc00]),
82 "2 unexpected continuation bytes");
83 Expect.listEquals([0xfffd, 0xfffd ,0xfffd],
84 utf16CodeUnitsToCodepoints([0xdc00, 0xdc00, 0xdc00]),
85 "3 unexpected continuation bytes");
86
87 // incomplete sequences
88 Expect.listEquals([0xfffd], utf16CodeUnitsToCodepoints([0xd800]),
89 "d800 last byte missing");
90 Expect.listEquals([0xfffd], utf16CodeUnitsToCodepoints([0xdbff]),
91 "dbff last byte missing");
92
93 // concatenation of incomplete sequences
94 Expect.listEquals([0xfffd, 0xfffd],
95 utf16CodeUnitsToCodepoints([0xd800, 0xdbff]),
96 "d800 dbff last byte missing");
97
98 // impossible bytes
99 Expect.listEquals([0xfffd], utf16CodeUnitsToCodepoints([0x110000]),
100 "110000 out of bounds");
101
102 // overlong sequences not possible in utf16 (nothing < x10000)
103 // illegal code positions d800-dfff not encodable (< x10000)
104 }
105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698