| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'unicode_tests.dart'; | 8 import 'unicode_tests.dart'; |
| 9 import '../../async_helper.dart'; | 9 import "package:async_helper/async_helper.dart"; |
| 10 | 10 |
| 11 Stream<List<int>> encode(String string, int chunkSize) { | 11 Stream<List<int>> encode(String string, int chunkSize) { |
| 12 var controller; | 12 var controller; |
| 13 controller = new StreamController(onListen: () { | 13 controller = new StreamController(onListen: () { |
| 14 int i = 0; | 14 int i = 0; |
| 15 while (i < string.length) { | 15 while (i < string.length) { |
| 16 if (i + chunkSize <= string.length) { | 16 if (i + chunkSize <= string.length) { |
| 17 controller.add(string.substring(i, i + chunkSize)); | 17 controller.add(string.substring(i, i + chunkSize)); |
| 18 } else { | 18 } else { |
| 19 controller.add(string.substring(i)); | 19 controller.add(string.substring(i)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 main() { | 52 main() { |
| 53 for (var test in UNICODE_TESTS) { | 53 for (var test in UNICODE_TESTS) { |
| 54 var expected = test[0]; | 54 var expected = test[0]; |
| 55 var string = test[1]; | 55 var string = test[1]; |
| 56 testUnpaused(expected, encode(string, 1)); | 56 testUnpaused(expected, encode(string, 1)); |
| 57 testWithPauses(expected, encode(string, 1)); | 57 testWithPauses(expected, encode(string, 1)); |
| 58 testUnpaused(expected, encode(string, 2)); | 58 testUnpaused(expected, encode(string, 2)); |
| 59 testWithPauses(expected, encode(string, 2)); | 59 testWithPauses(expected, encode(string, 2)); |
| 60 } | 60 } |
| 61 } | 61 } |
| OLD | NEW |