| 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 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 import 'dart:isolate'; | 7 import 'dart:isolate'; |
| 8 | 8 |
| 9 void testZLibDeflate() { | 9 void testZLibDeflate() { |
| 10 test(int level, List<int> expected) { | 10 test(int level, List<int> expected) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 void testZLibDeflateGZip() { | 51 void testZLibDeflateGZip() { |
| 52 var port = new ReceivePort(); | 52 var port = new ReceivePort(); |
| 53 var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | 53 var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
| 54 var controller = new StreamController(); | 54 var controller = new StreamController(); |
| 55 controller.stream.transform(new ZLibDeflater()) | 55 controller.stream.transform(new ZLibDeflater()) |
| 56 .reduce([], (buffer, data) { | 56 .reduce([], (buffer, data) { |
| 57 buffer.addAll(data); | 57 buffer.addAll(data); |
| 58 return buffer; | 58 return buffer; |
| 59 }) | 59 }) |
| 60 .then((data) { | 60 .then((data) { |
| 61 Expect.listEquals([31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 98, 96, 100, 98, | 61 Expect.equals(26, data.length); |
| 62 102, 97, 101, 99, 231, 224, 4, 0, 0, 0, 255, 255], | 62 Expect.listEquals([98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, |
| 63 data); | 63 0, 255, 255], |
| 64 // Skip header, as it can change. |
| 65 data.getRange(10, 16)); |
| 64 port.close(); | 66 port.close(); |
| 65 }); | 67 }); |
| 66 controller.add(data); | 68 controller.add(data); |
| 67 controller.close(); | 69 controller.close(); |
| 68 } | 70 } |
| 69 | 71 |
| 70 void testZLibDeflateInvalidLevel() { | 72 void testZLibDeflateInvalidLevel() { |
| 71 test2(gzip, level) { | 73 test2(gzip, level) { |
| 72 var port = new ReceivePort(); | 74 var port = new ReceivePort(); |
| 73 try { | 75 try { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 test(i); | 118 test(i); |
| 117 } | 119 } |
| 118 } | 120 } |
| 119 | 121 |
| 120 void main() { | 122 void main() { |
| 121 testZLibDeflate(); | 123 testZLibDeflate(); |
| 122 testZLibDeflateGZip(); | 124 testZLibDeflateGZip(); |
| 123 testZLibDeflateInvalidLevel(); | 125 testZLibDeflateInvalidLevel(); |
| 124 testZLibInflate(); | 126 testZLibInflate(); |
| 125 } | 127 } |
| OLD | NEW |