Index: tests/lib/convert/html_escape_test.dart |
diff --git a/tests/lib/convert/html_escape_test.dart b/tests/lib/convert/html_escape_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cbcac516de1a7db89f3168f667e8fb1c45736097 |
--- /dev/null |
+++ b/tests/lib/convert/html_escape_test.dart |
@@ -0,0 +1,57 @@ |
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+import "package:expect/expect.dart"; |
+import 'dart:async'; |
+import 'dart:convert'; |
+ |
+const _TEST_INPUT = 'A <test> of \u00A0 "double" & \'single\' values'; |
+ |
+const _OUTPUT_UNKNOWN = 'A <test> of "double" & ' |
+ ''single' values'; |
+ |
+// const _ATTRIBUTE_MODE = "A <test> of "double&double; and 'single' values"; |
+ |
+void main() { |
+ testDefault(); |
+ testChunkedConvert(_OUTPUT_UNKNOWN); |
+} |
+ |
+void testDefault() { |
+ var output = HTML_ESCAPE.convert(_TEST_INPUT); |
+ Expect.equals(_OUTPUT_UNKNOWN, output); |
+} |
+ |
+void testChunkedConvert(String expected) { |
+ var controller = new StreamController(sync: true); |
+ |
+ var stream = controller.stream |
+ .transform(HTML_ESCAPE); |
+ |
+ var done = false; |
+ int count = 0; |
+ |
+ void stringData(value) { |
+ Expect.equals(expected, value); |
+ count++; |
+ } |
+ |
+ void streamClosed() { |
+ done = true; |
+ } |
+ |
+ stream.listen( |
+ stringData, |
+ onDone: streamClosed); |
+ |
+ |
+ for(var i = 0; i < _COUNT; i++) { |
+ controller.add(_TEST_INPUT); |
+ } |
+ controller.close(); |
+ Expect.isTrue(done); |
+ Expect.equals(_COUNT, count); |
+} |
+ |
+const _COUNT = 3; |