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

Unified Diff: tests/html/typed_arrays_dataview_test.dart

Issue 10539170: Fix DataView constructor and byte accessors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
« tests/html/html.status ('K') | « tests/html/html.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/typed_arrays_dataview_test.dart
diff --git a/tests/html/typed_arrays_dataview_test.dart b/tests/html/typed_arrays_dataview_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c1c641c9f4bda878672510cf9beb24d7650cfca3
--- /dev/null
+++ b/tests/html/typed_arrays_dataview_test.dart
@@ -0,0 +1,70 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#library('typed_arrays_dataview_test');
+#import('../../lib/unittest/unittest.dart');
+#import('../../lib/unittest/html_config.dart');
+#import('dart:html');
+
+main() {
+ useHtmlConfiguration();
+
+ test('access8', () {
+ var a1 = new Uint8Array.fromList([0,0,3,255,0,0,0,0,0,0]);
+
+ var dv = new DataView(a1.buffer, 2, 6);
+
+ expect(dv.getInt8(0), equals(3));
+ expect(dv.getInt8(1), equals(-1));
+ expect(dv.getUint8(0), equals(3));
+ expect(dv.getUint8(1), equals(255));
+
+ dv.setInt8(2, -56);
+ expect(dv.getInt8(2), equals(-56));
+ expect(dv.getUint8(2), equals(200));
+
+ dv.setUint8(3, 200);
vsm 2012/06/15 19:40:27 What happens now on a set with a value > 8 bits?
+ expect(dv.getInt8(3), equals(-56));
+ expect(dv.getUint8(3), equals(200));
+ });
+
+ test('access16', () {
+ var a1 = new Uint8Array.fromList([0,0,3,255,0,0,0,0,0,0]);
+
+ var dv = new DataView(a1.buffer, 2);
+
+ expect(dv.byteLength, equals(10 - 2));
+
+ expect(dv.getInt16(0), equals(1023));
+ expect(dv.getInt16(0, false), equals(1023));
+ expect(dv.getInt16(0, littleEndian: false), equals(1023));
+ expect(dv.getInt16(0, true), equals(-253));
+ expect(dv.getInt16(0, littleEndian: true), equals(-253));
+
+ expect(dv.getUint16(0), equals(1023));
+ expect(dv.getUint16(0, littleEndian: false), equals(1023));
+ expect(dv.getUint16(0, littleEndian: true), equals(0xFF03));
+
+ dv.setInt16(2, -1);
+ expect(dv.getInt16(2), equals(-1));
+ expect(dv.getUint16(2), equals(0xFFFF));
+ });
+
+ test('access32', () {
+ var a1 = new Uint8Array.fromList([0,0,3,255,0,0,0,0,0,0]);
+
+ var dv = new DataView(a1.buffer);
+
+ expect(dv.getInt32(0), equals(1023));
+ expect(dv.getInt32(0, false), equals(1023));
+ expect(dv.getInt32(0, littleEndian: false), equals(1023));
+ expect(dv.getInt32(0, true), equals(-0xFD0000));
+ expect(dv.getInt32(0, littleEndian: true), equals(-0xFD0000));
+
+ expect(dv.getUint32(0), equals(1023));
+ expect(dv.getUint32(0, littleEndian: false), equals(1023));
+ expect(dv.getUint32(0, littleEndian: true), equals(0xFF030000));
+ });
+
+}
« tests/html/html.status ('K') | « tests/html/html.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698