Index: recipes/test/core/strings/incrementally_building_test.dart |
diff --git a/recipes/test/core/strings/incrementally_building_test.dart b/recipes/test/core/strings/incrementally_building_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..91069769a32679893ab1ab4971d092020324aae4 |
--- /dev/null |
+++ b/recipes/test/core/strings/incrementally_building_test.dart |
@@ -0,0 +1,24 @@ |
+library incrementally_building; |
+ |
+import 'package:unittest/unittest.dart'; |
+ |
+void main() { |
+ group('incrementally building a string using a StringBuffer', () { |
+ test("using write()", () { |
+ var sb = new StringBuffer(); |
+ sb.write("John, "); |
+ sb.write("Paul, "); |
+ sb.write("George, "); |
+ sb.write("and Ringo"); |
+ expect(sb.toString(), equals("John, Paul, George, and Ringo")); |
+ }); |
+ |
+ test('using several methods', () { |
+ var sb = new StringBuffer(); |
+ sb.writeln("The Beatles:"); |
+ sb.writeAll(['John, ', 'Paul, ', 'George, and Ringo']); |
+ sb.writeCharCode(33); // charCode for '!'. |
+ expect(sb.toString(), equals('The Beatles:\nJohn, Paul, George, and Ringo!')); |
+ }); |
+ }); |
+} |