| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, 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 class StringEscapesTest { | |
| 6 | |
| 7 static testMain() { | |
| 8 testDelimited(); | |
| 9 testFixed2(); | |
| 10 testFixed4(); | |
| 11 testEscapes(); | |
| 12 testLiteral(); | |
| 13 } | |
| 14 | |
| 15 static testDelimited() { | |
| 16 String str = "Foo\u{1}Bar\u{000001}Baz\u{D7FF}Boo"; | |
| 17 Expect.equals(15, str.length); | |
| 18 Expect.equals(1, str.charCodeAt(3)); | |
| 19 Expect.equals(1, str.charCodeAt(7)); | |
| 20 Expect.equals(0xD7FF, str.charCodeAt(11)); | |
| 21 Expect.equals('B'.charCodeAt(0), str.charCodeAt(12)); | |
| 22 } | |
| 23 | |
| 24 static testEscapes() { | |
| 25 String str = "Foo\fBar\vBaz\bBoo"; | |
| 26 Expect.equals(15, str.length); | |
| 27 Expect.equals(12, str.charCodeAt(3)); | |
| 28 Expect.equals('B'.charCodeAt(0), str.charCodeAt(4)); | |
| 29 Expect.equals(11, str.charCodeAt(7)); | |
| 30 Expect.equals('z'.charCodeAt(0), str.charCodeAt(10)); | |
| 31 Expect.equals(8, str.charCodeAt(11)); | |
| 32 Expect.equals('o'.charCodeAt(0), str.charCodeAt(14)); | |
| 33 str = "Abc\rDef\nGhi\tJkl"; | |
| 34 Expect.equals(15, str.length); | |
| 35 Expect.equals(13, str.charCodeAt(3)); | |
| 36 Expect.equals('D'.charCodeAt(0), str.charCodeAt(4)); | |
| 37 Expect.equals(10, str.charCodeAt(7)); | |
| 38 Expect.equals('G'.charCodeAt(0), str.charCodeAt(8)); | |
| 39 Expect.equals(9, str.charCodeAt(11)); | |
| 40 Expect.equals('J'.charCodeAt(0), str.charCodeAt(12)); | |
| 41 } | |
| 42 | |
| 43 static testFixed2() { | |
| 44 String str = "Foo\xFFBar"; | |
| 45 Expect.equals(7, str.length); | |
| 46 Expect.equals(255, str.charCodeAt(3)); | |
| 47 Expect.equals('B'.charCodeAt(0), str.charCodeAt(4)); | |
| 48 } | |
| 49 | |
| 50 static testFixed4() { | |
| 51 String str = "Foo\u0001Bar"; | |
| 52 Expect.equals(7, str.length); | |
| 53 Expect.equals(1, str.charCodeAt(3)); | |
| 54 Expect.equals('B'.charCodeAt(0), str.charCodeAt(4)); | |
| 55 } | |
| 56 | |
| 57 static testLiteral() { | |
| 58 String str = "\a\c\d\e\g\h\i\j\k\l\$\{\}\""; | |
| 59 Expect.equals(@'acdeghijkl${}"', str); | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 main() { | |
| 64 StringEscapesTest.testMain(); | |
| 65 } | |
| OLD | NEW |