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

Side by Side 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, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 import "package:expect/expect.dart";
6 import 'dart:async';
7 import 'dart:convert';
8
9 const _TEST_INPUT = 'A <test> of \u00A0 "double" & \'single\' values';
10
11 const _OUTPUT_UNKNOWN = 'A &lt;test&gt; of &nbsp; &quot;double&quot; &amp; '
12 '&apos;single&apos; values';
13
14 // const _ATTRIBUTE_MODE = "A <test> of &nbsp; &quot;double&double; and 'single' values";
15
16 void main() {
17 testDefault();
18 testChunkedConvert(_OUTPUT_UNKNOWN);
19 }
20
21 void testDefault() {
22 var output = HTML_ESCAPE.convert(_TEST_INPUT);
23 Expect.equals(_OUTPUT_UNKNOWN, output);
24 }
25
26 void testChunkedConvert(String expected) {
27 var controller = new StreamController(sync: true);
28
29 var stream = controller.stream
30 .transform(HTML_ESCAPE);
31
32 var done = false;
33 int count = 0;
34
35 void stringData(value) {
36 Expect.equals(expected, value);
37 count++;
38 }
39
40 void streamClosed() {
41 done = true;
42 }
43
44 stream.listen(
45 stringData,
46 onDone: streamClosed);
47
48
49 for(var i = 0; i < _COUNT; i++) {
50 controller.add(_TEST_INPUT);
51 }
52 controller.close();
53 Expect.isTrue(done);
54 Expect.equals(_COUNT, count);
55 }
56
57 const _COUNT = 3;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698