| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(srdjan): Move StringBuffer to visible names. | 5 // TODO(srdjan): Move StringBuffer to visible names. |
| 6 | 6 |
| 7 class StringBufferTest { | 7 class StringBufferTest { |
| 8 static testConstructor() { | 8 static testConstructor() { |
| 9 StringBuffer bf = new StringBuffer(""); | 9 StringBuffer bf = new StringBuffer(""); |
| 10 Expect.equals(true, bf.isEmpty()); | 10 Expect.equals(true, bf.isEmpty); |
| 11 | 11 |
| 12 bf = new StringBuffer("abc"); | 12 bf = new StringBuffer("abc"); |
| 13 Expect.equals(3, bf.length); | 13 Expect.equals(3, bf.length); |
| 14 Expect.equals("abc", bf.toString()); | 14 Expect.equals("abc", bf.toString()); |
| 15 } | 15 } |
| 16 | 16 |
| 17 static testAdd() { | 17 static testAdd() { |
| 18 StringBuffer bf = new StringBuffer(""); | 18 StringBuffer bf = new StringBuffer(""); |
| 19 Expect.equals(true, bf.isEmpty()); | 19 Expect.equals(true, bf.isEmpty); |
| 20 | 20 |
| 21 bf.add("a"); | 21 bf.add("a"); |
| 22 Expect.equals(1, bf.length); | 22 Expect.equals(1, bf.length); |
| 23 Expect.equals("a", bf.toString()); | 23 Expect.equals("a", bf.toString()); |
| 24 | 24 |
| 25 bf = new StringBuffer(""); | 25 bf = new StringBuffer(""); |
| 26 bf.add("a"); | 26 bf.add("a"); |
| 27 bf.add("b"); | 27 bf.add("b"); |
| 28 Expect.equals("ab", bf.toString()); | 28 Expect.equals("ab", bf.toString()); |
| 29 | 29 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 bf.add("foo"); | 73 bf.add("foo"); |
| 74 Expect.equals(3, bf.length); | 74 Expect.equals(3, bf.length); |
| 75 bf.add("bar"); | 75 bf.add("bar"); |
| 76 Expect.equals(6, bf.length); | 76 Expect.equals(6, bf.length); |
| 77 bf.add(""); | 77 bf.add(""); |
| 78 Expect.equals(6, bf.length); | 78 Expect.equals(6, bf.length); |
| 79 } | 79 } |
| 80 | 80 |
| 81 static testIsEmpty() { | 81 static testIsEmpty() { |
| 82 StringBuffer bf = new StringBuffer(""); | 82 StringBuffer bf = new StringBuffer(""); |
| 83 Expect.equals(true, bf.isEmpty()); | 83 Expect.equals(true, bf.isEmpty); |
| 84 bf.add("foo"); | 84 bf.add("foo"); |
| 85 Expect.equals(false, bf.isEmpty()); | 85 Expect.equals(false, bf.isEmpty); |
| 86 } | 86 } |
| 87 | 87 |
| 88 static testAddAll() { | 88 static testAddAll() { |
| 89 StringBuffer bf = new StringBuffer(""); | 89 StringBuffer bf = new StringBuffer(""); |
| 90 bf.addAll(["foo", "bar", "a", "b", "c"]); | 90 bf.addAll(["foo", "bar", "a", "b", "c"]); |
| 91 Expect.equals("foobarabc", bf.toString()); | 91 Expect.equals("foobarabc", bf.toString()); |
| 92 | 92 |
| 93 bf.addAll([]); | 93 bf.addAll([]); |
| 94 Expect.equals("foobarabc", bf.toString()); | 94 Expect.equals("foobarabc", bf.toString()); |
| 95 | 95 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 testAdd(); | 148 testAdd(); |
| 149 testAddAll(); | 149 testAddAll(); |
| 150 testClear(); | 150 testClear(); |
| 151 testChaining(); | 151 testChaining(); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 main() { | 155 main() { |
| 156 StringBufferTest.testMain(); | 156 StringBufferTest.testMain(); |
| 157 } | 157 } |
| OLD | NEW |