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

Unified Diff: tests/corelib/string_test.dart

Issue 15263004: Adding isNotEmpty property to collection and string. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix template generation Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/corelib/string_buffer_test.dart ('k') | tests/html/custom_element_bindings_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/string_test.dart
diff --git a/tests/corelib/string_test.dart b/tests/corelib/string_test.dart
index fd73feae9e2c53690b96331fdb401474f0fc8719..dbcd630c6f3413872a77a2cc405acf68be3c0f40 100644
--- a/tests/corelib/string_test.dart
+++ b/tests/corelib/string_test.dart
@@ -24,6 +24,14 @@ class StringTest {
testCharCodes();
}
+ static void testLength() {
+ String str = "";
+ for (var i = 0; i < 20; i++) {
+ testStringLength(i, str);
+ str += " ";
+ }
+ }
+
static void testOutOfRange() {
String a = "Hello";
bool exception_caught = false;
@@ -53,7 +61,7 @@ class StringTest {
String str = "string";
for (int i = 0; i < str.length; i++) {
Expect.equals(true, str[i] is String);
- Expect.equals(1, str[i].length);
+ testStringLength(1, str[i]);
}
}
@@ -68,7 +76,7 @@ class StringTest {
var a = "One";
var b = "Four";
var c = a + b;
- Expect.equals(7, c.length);
+ testStringLength(7, c);
Expect.equals("OneFour", c);
}
@@ -286,6 +294,12 @@ class StringTest {
}
}
+void testStringLength(int length, String str) {
+ Expect.equals(length, str.length);
+ (length == 0 ? Expect.isTrue : Expect.isFalse)(str.isEmpty);
+ (length != 0 ? Expect.isTrue : Expect.isFalse)(str.isNotEmpty);
+}
+
main() {
StringTest.testMain();
}
« no previous file with comments | « tests/corelib/string_buffer_test.dart ('k') | tests/html/custom_element_bindings_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698