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

Unified 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 side-by-side diff with in-line comments
Download patch
« sdk/lib/_internal/lib/js_string.dart ('K') | « sdk/lib/core/string.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/string_trimlr_test.dart
diff --git a/tests/corelib/string_trimlr_test.dart b/tests/corelib/string_trimlr_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ac5a4b0356eb22eb34dfe5c9c4cc368e1bfafe64
--- /dev/null
+++ b/tests/corelib/string_trimlr_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+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.
+ 0x09,
+ 0x0A,
+ 0x0B,
+ 0x0C,
+ 0x0D,
+ 0x20,
+ 0x85,
+ 0xA0,
+ 0x1680,
+ 0x180E,
+ 0x2000,
+ 0x2001,
+ 0x2002,
+ 0x2003,
+ 0x2004,
+ 0x2005,
+ 0x2006,
+ 0x2007,
+ 0x2008,
+ 0x2009,
+ 0x200A,
+ 0x202F,
+ 0x205F,
+ 0x3000,
+ 0x2028,
+ 0x2029,
+ 0xFEFF,
+];
+
+main() {
+ for (var ws in WHITESPACE) {
+ Expect.equals("", new String.fromCharCode(ws).trim());
+ }
+
+ // Test the whitespace in different positions.
+ test(ws) {
+ // trimLeft
+ Expect.equals("", ws.trimLeft());
+ Expect.equals("", (ws + ws).trimLeft());
+ Expect.equals("a" + ws, ("a" + ws).trimLeft());
+ Expect.equals("a", (ws + "a").trimLeft());
+ Expect.equals("a" + ws + ws, (ws + ws + "a" + ws + ws).trimLeft());
+ Expect.equals("a" + ws + "a", (ws + ws + "a" + ws + "a").trimLeft());
+ // trimRight
+ Expect.equals("", ws.trimRight());
+ Expect.equals("", (ws + ws).trimRight());
+ Expect.equals("a", ("a" + ws).trimRight());
+ Expect.equals(ws + "a", (ws + "a").trimRight());
+ Expect.equals(ws + ws + "a", (ws + ws + "a" + ws + ws).trimRight());
+ Expect.equals("a" + ws + "a", ("a" + ws + "a" + ws + ws).trimRight());
+ }
+
+ for (var ws in WHITESPACE) {
+ var c = new String.fromCharCode(ws);
+ test(c);
+ }
+ test(new String.fromCharCodes(WHITESPACE));
+}
« 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