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

Unified Diff: tests/lib/convert/html_escape_test.dart

Issue 23492002: adding HtmlEscape to dart:convert (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: chunked conversion Created 7 years, 4 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
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 &lt;test&gt; of &nbsp; &quot;double&quot; &amp; '
+ '&apos;single&apos; values';
+
+// const _ATTRIBUTE_MODE = "A <test> of &nbsp; &quot;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;

Powered by Google App Engine
This is Rietveld 408576698