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(); |