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

Side by Side Diff: tests/corelib/string_trimlr_test.dart

Issue 190853009: Add string.trimLeft/trimRight. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 // 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 import "package:expect/expect.dart";
6
7 const WHITESPACE = const [
Søren Gjesse 2014/03/10 16:50:03 A comment for each of these code points would be h
Lasse Reichstein Nielsen 2014/03/11 10:36:29 Done.
8 0x09,
9 0x0A,
10 0x0B,
11 0x0C,
12 0x0D,
13 0x20,
14 0x85,
15 0xA0,
16 0x1680,
17 0x180E,
18 0x2000,
19 0x2001,
20 0x2002,
21 0x2003,
22 0x2004,
23 0x2005,
24 0x2006,
25 0x2007,
26 0x2008,
27 0x2009,
28 0x200A,
29 0x202F,
30 0x205F,
31 0x3000,
32 0x2028,
33 0x2029,
34 0xFEFF,
35 ];
36
37 main() {
38 for (var ws in WHITESPACE) {
39 Expect.equals("", new String.fromCharCode(ws).trim());
40 }
41
42 // Test the whitespace in different positions.
43 test(ws) {
44 // trimLeft
45 Expect.equals("", ws.trimLeft());
46 Expect.equals("", (ws + ws).trimLeft());
47 Expect.equals("a" + ws, ("a" + ws).trimLeft());
48 Expect.equals("a", (ws + "a").trimLeft());
49 Expect.equals("a" + ws + ws, (ws + ws + "a" + ws + ws).trimLeft());
50 Expect.equals("a" + ws + "a", (ws + ws + "a" + ws + "a").trimLeft());
51 // trimRight
52 Expect.equals("", ws.trimRight());
53 Expect.equals("", (ws + ws).trimRight());
54 Expect.equals("a", ("a" + ws).trimRight());
55 Expect.equals(ws + "a", (ws + "a").trimRight());
56 Expect.equals(ws + ws + "a", (ws + ws + "a" + ws + ws).trimRight());
57 Expect.equals("a" + ws + "a", ("a" + ws + "a" + ws + ws).trimRight());
58 }
59
60 for (var ws in WHITESPACE) {
61 var c = new String.fromCharCode(ws);
62 test(c);
63 }
64 test(new String.fromCharCodes(WHITESPACE));
65 }
OLDNEW
« sdk/lib/_internal/lib/js_string.dart ('K') | « sdk/lib/core/string.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698