OLD | NEW |
(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 <test> of "double" & ' |
| 12 ''single' values'; |
| 13 |
| 14 // const _ATTRIBUTE_MODE = "A <test> of "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; |
OLD | NEW |