| 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 30 matching lines...) Expand all Loading... |
| 41 255, 255]); | 41 255, 255]); |
| 42 test(7, [120, 218, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0, | 42 test(7, [120, 218, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0, |
| 43 255, 255]); | 43 255, 255]); |
| 44 test(8, [120, 218, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0, | 44 test(8, [120, 218, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0, |
| 45 255, 255]); | 45 255, 255]); |
| 46 test(9, [120, 218, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0, | 46 test(9, [120, 218, 98, 96, 100, 98, 102, 97, 101, 99, 231, 224, 4, 0, 0, 0, |
| 47 255, 255]); | 47 255, 255]); |
| 48 } | 48 } |
| 49 | 49 |
| 50 | 50 |
| 51 void testZLibDeflateEmpty() { |
| 52 var port = new ReceivePort(); |
| 53 var controller = new StreamController(); |
| 54 controller.stream.transform(new ZLibDeflater(gzip: false, level: 6)) |
| 55 .reduce([], (buffer, data) { |
| 56 buffer.addAll(data); |
| 57 return buffer; |
| 58 }) |
| 59 .then((data) { |
| 60 print(data); |
| 61 Expect.listEquals([120, 156, 2, 0, 0, 0, 255, 255], data); |
| 62 port.close(); |
| 63 }); |
| 64 controller.close(); |
| 65 } |
| 66 |
| 67 |
| 51 void testZLibDeflateGZip() { | 68 void testZLibDeflateGZip() { |
| 52 var port = new ReceivePort(); | 69 var port = new ReceivePort(); |
| 53 var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | 70 var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
| 54 var controller = new StreamController(); | 71 var controller = new StreamController(); |
| 55 controller.stream.transform(new ZLibDeflater()) | 72 controller.stream.transform(new ZLibDeflater()) |
| 56 .reduce([], (buffer, data) { | 73 .reduce([], (buffer, data) { |
| 57 buffer.addAll(data); | 74 buffer.addAll(data); |
| 58 return buffer; | 75 return buffer; |
| 59 }) | 76 }) |
| 60 .then((data) { | 77 .then((data) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 test2(false, level); | 131 test2(false, level); |
| 115 test2(true, level); | 132 test2(true, level); |
| 116 } | 133 } |
| 117 for (int i = -1; i < 10; i++) { | 134 for (int i = -1; i < 10; i++) { |
| 118 test(i); | 135 test(i); |
| 119 } | 136 } |
| 120 } | 137 } |
| 121 | 138 |
| 122 void main() { | 139 void main() { |
| 123 testZLibDeflate(); | 140 testZLibDeflate(); |
| 141 testZLibDeflateEmpty(); |
| 124 testZLibDeflateGZip(); | 142 testZLibDeflateGZip(); |
| 125 testZLibDeflateInvalidLevel(); | 143 testZLibDeflateInvalidLevel(); |
| 126 testZLibInflate(); | 144 testZLibInflate(); |
| 127 } | 145 } |
| OLD | NEW |