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

Unified Diff: tests/standalone/typed_data_test.dart

Issue 13529005: Fix view creation for byte-size types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix checked mode problems Created 7 years, 9 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
« no previous file with comments | « runtime/lib/typeddata.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/typed_data_test.dart
diff --git a/tests/standalone/typed_data_test.dart b/tests/standalone/typed_data_test.dart
index 665e05c61ecec07ce8f44269355a1ea78e6db8ef..cdbf3bf02184953c52e9867c69ed6bf8add36e3d 100644
--- a/tests/standalone/typed_data_test.dart
+++ b/tests/standalone/typed_data_test.dart
@@ -279,6 +279,40 @@ void testSetAtIndex(TypedData list,
validate(false);
}
+testViewCreation() {
+ var bytes = new Uint8List(1024);
+ var view = new ByteData.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+ view = new Uint8List.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+ view = new Int8List.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+ view = new Uint8ClampedList.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+ view = new Uint16List.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+ view = new Int16List.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+ view = new Uint32List.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+ view = new Int32List.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+ view = new Uint64List.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+ view = new Int64List.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+ view = new Float32List.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+ view = new Float64List.view(bytes, 24);
+ Expect.equals(1000, view.lengthInBytes);
+}
+
+testWhere() {
+ var bytes = new Uint8List(13);
+ bytes.setRange(0, 5, [1, 1, 1, 1, 1]);
+ Expect.equals(5, bytes.where((v) => v > 0).length);
+}
+
main() {
for (int i = 0; i < 2000; i++) {
testCreateUint8TypedData();
@@ -335,5 +369,7 @@ main() {
testTypedDataRange(true);
testUnsignedTypedDataRange(true);
testExternalClampedUnsignedTypedDataRange(true);
+ testViewCreation();
+ testWhere();
}
« no previous file with comments | « runtime/lib/typeddata.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698