Chromium Code Reviews| Index: tests/standalone/byte_array_test.dart |
| diff --git a/tests/standalone/byte_array_test.dart b/tests/standalone/byte_array_test.dart |
| index 2f60f29d18995376bba405495ea19845989a6886..11bccddb661fa517078e41cee997fd76e2502776 100644 |
| --- a/tests/standalone/byte_array_test.dart |
| +++ b/tests/standalone/byte_array_test.dart |
| @@ -78,11 +78,48 @@ void testIndexOf() { |
| Expect.equals(-1, list.indexOf(20.0)); |
| } |
| +void testSubArray() { |
| + var list = new Uint8List(10); |
| + var array = list.asByteArray(); |
| + Expect.equals(0, array.subByteArray(0, 0).lengthInBytes()); |
| + Expect.equals(0, array.subByteArray(5, 0).lengthInBytes()); |
| + Expect.equals(0, array.subByteArray(10, 0).lengthInBytes()); |
| + Expect.equals(0, array.subByteArray(10).lengthInBytes()); |
| + Expect.equals(0, array.subByteArray(10, null).lengthInBytes()); |
|
karlklose
2012/10/11 08:18:18
I am not sure this is what we want and since we ca
|
| + Expect.equals(5, array.subByteArray(0, 5).lengthInBytes()); |
| + Expect.equals(5, array.subByteArray(5, 5).lengthInBytes()); |
| + Expect.equals(5, array.subByteArray(5).lengthInBytes()); |
| + Expect.equals(5, array.subByteArray(5, null).lengthInBytes()); |
| + Expect.equals(10, array.subByteArray(0, 10).lengthInBytes()); |
| + Expect.equals(10, array.subByteArray(0).lengthInBytes()); |
| + Expect.equals(10, array.subByteArray(0, null).lengthInBytes()); |
| + Expect.equals(10, array.subByteArray().lengthInBytes()); |
| + testThrowsIndex(function) { |
| + Expect.throws(function, (e) => e is IndexOutOfRangeException); |
| + } |
| + testThrowsIndex(() => array.subByteArray(0, -1)); |
| + testThrowsIndex(() => array.subByteArray(1, -1)); |
| + testThrowsIndex(() => array.subByteArray(10, -1)); |
| + testThrowsIndex(() => array.subByteArray(-1, 0)); |
| + testThrowsIndex(() => array.subByteArray(-1)); |
| + testThrowsIndex(() => array.subByteArray(-1, null)); |
| + testThrowsIndex(() => array.subByteArray(11, 0)); |
| + testThrowsIndex(() => array.subByteArray(11)); |
| + testThrowsIndex(() => array.subByteArray(11, null)); |
| + testThrowsIndex(() => array.subByteArray(6, 5)); |
| + Expect.throws(() => array.subByteArray(0, "5"), (e) => e is ArgumentError); |
| + Expect.throws(() => array.subByteArray("0", 5), (e) => e is ArgumentError); |
| + Expect.throws(() => array.subByteArray("0"), (e) => e is ArgumentError); |
| + Expect.throws(() => array.subByteArray(null), (e) => e is ArgumentError); |
| +} |
| + |
| main() { |
| for (int i = 0; i < 2000; i++) { |
| testCreateByteArray(); |
| testSetRange(); |
| testIndexOutOfRange(); |
| testIndexOf(); |
| + testSubArray(); |
| } |
| } |
| + |