Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: tests/standalone/byte_array_test.dart

Issue 11098065: Fix bug in ByteArray.subByteArray implementation for omitted length. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« runtime/lib/byte_array.dart ('K') | « runtime/lib/byte_array.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
}
+
« runtime/lib/byte_array.dart ('K') | « runtime/lib/byte_array.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698