Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 class StringCaseTest { | 7 main() { |
| 8 | 8 testLowerUpper(); |
| 9 static testMain() { | 9 testSpecialCases(); |
| 10 testLowerUpper(); | |
| 11 } | |
| 12 | |
| 13 static testLowerUpper() { | |
| 14 var a = "Stop! Smell the Roses."; | |
| 15 var allLower = "stop! smell the roses."; | |
| 16 var allUpper = "STOP! SMELL THE ROSES."; | |
| 17 Expect.equals(allUpper, a.toUpperCase()); | |
| 18 Expect.equals(allLower, a.toLowerCase()); | |
| 19 } | |
| 20 } | 10 } |
| 21 | 11 |
| 22 main() { | 12 void testLowerUpper() { |
| 23 StringCaseTest.testMain(); | 13 var a = "Stop! Smell the Roses."; |
| 14 var allLower = "stop! smell the roses."; | |
| 15 var allUpper = "STOP! SMELL THE ROSES."; | |
| 16 Expect.equals(allUpper, a.toUpperCase()); | |
| 17 Expect.equals(allLower, a.toLowerCase()); | |
| 24 } | 18 } |
| 19 | |
| 20 void testSpecialCases() { | |
| 21 // Letters in Latin-1 where the upper case is not in Latin-1. | |
| 22 | |
| 23 // Small letter y diaresis. | |
| 24 Expect.equals("\u0178", "\xff".toUpperCase()); /// 03: ok | |
| 25 Expect.equals("\xff", "\xff".toLowerCase()); | |
| 26 Expect.equals("\xff", "\xff".toUpperCase().toLowerCase()); /// 03: continued | |
| 27 // German sharp s. Upper case variant is "SS". | |
| 28 Expect.equals("SS", "\xdf".toUpperCase()); /// 01: ok | |
| 29 Expect.equals("\xdf", "\xdf".toLowerCase()); | |
| 30 Expect.equals("ss", "\xdf".toUpperCase().toLowerCase()); /// 01: continued | |
| 31 // Micro sign (not same as lower-case Greek letter mu, U+03BC). | |
| 32 Expect.equals("\u039c", "\xb5".toUpperCase()); /// 02: ok | |
| 33 Expect.equals("\xb5", "\xb5".toLowerCase()); | |
| 34 Expect.equals("\u03Bc", "\xb5".toUpperCase().toLowerCase()); /// 02: continue d | |
|
Anders Johnsen
2014/04/07 11:43:43
Long line.
Lasse Reichstein Nielsen
2014/04/07 12:12:13
Done.
| |
| 35 // Zero. | |
|
Anders Johnsen
2014/04/07 11:43:43
Do you have a test that would have spotted the 0xf
Lasse Reichstein Nielsen
2014/04/07 12:12:13
It should be detected by the "\xff".toUpperCase()
| |
| 36 Expect.equals("\x00", "\x00".toLowerCase()); | |
| 37 Expect.equals("\x00", "\x00".toUpperCase()); | |
| 38 } | |
| OLD | NEW |