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

Unified Diff: tests/corelib/string_buffer_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/set_test.dart ('k') | tests/corelib/string_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/string_buffer_test.dart
diff --git a/tests/corelib/string_buffer_test.dart b/tests/corelib/string_buffer_test.dart
index 093c7ad11c8193e4f87d0664d4318999dccb6cb5..2c556f79109515b4842e543158575ec7a816db3e 100644
--- a/tests/corelib/string_buffer_test.dart
+++ b/tests/corelib/string_buffer_test.dart
@@ -8,10 +8,10 @@ import "package:expect/expect.dart";
void testConstructor() {
StringBuffer bf = new StringBuffer("");
- Expect.equals(true, bf.isEmpty);
+ testBufferLength(0, bf);
bf = new StringBuffer("abc");
- Expect.equals(3, bf.length);
+ testBufferLength(3, bf);
Expect.equals("abc", bf.toString());
bf = new StringBuffer("\x00");
@@ -22,7 +22,7 @@ void testWrite() {
Expect.equals(true, bf.isEmpty);
bf.write("a");
- Expect.equals(1, bf.length);
+ testBufferLength(1, bf);
Expect.equals("a", bf.toString());
bf = new StringBuffer("");
@@ -70,13 +70,13 @@ void testWrite() {
void testLength() {
StringBuffer bf = new StringBuffer("");
- Expect.equals(0, bf.length);
+ testBufferLength(0, bf);
bf.write("foo");
- Expect.equals(3, bf.length);
+ testBufferLength(3, bf);
bf.write("bar");
- Expect.equals(6, bf.length);
+ testBufferLength(6, bf);
bf.write("");
- Expect.equals(6, bf.length);
+ testBufferLength(6, bf);
}
void testIsEmpty() {
@@ -103,14 +103,14 @@ void testClear() {
bf.write("foo");
bf.clear();
Expect.equals("", bf.toString());
- Expect.equals(0, bf.length);
+ testBufferLength(0, bf);
bf.write("bar");
Expect.equals("bar", bf.toString());
- Expect.equals(3, bf.length);
+ testBufferLength(3, bf);
bf.clear();
Expect.equals("", bf.toString());
- Expect.equals(0, bf.length);
+ testBufferLength(0, bf);
}
void testToString() {
@@ -172,6 +172,12 @@ void testWriteCharCode() {
Expect.throws(() { bf2.writeCharCode(0x110000); });
}
+void testBufferLength(int length, StringBuffer bf) {
+ Expect.equals(length, bf.length);
+ (length == 0 ? Expect.isTrue : Expect.isFalse)(bf.isEmpty);
+ (length != 0 ? Expect.isTrue : Expect.isFalse)(bf.isNotEmpty);
+}
+
void main() {
testToString();
testConstructor();
« no previous file with comments | « tests/corelib/set_test.dart ('k') | tests/corelib/string_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698