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

Side by Side Diff: runtime/tests/vm/dart/byte_array_test.dart

Issue 14332002: Add endian parameter to the get/set functions in ByteData. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Library tag to be able to run in html test framework. 5 // Library tag to be able to run in html test framework.
6 library byte_array_test; 6 library byte_array_test;
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import 'dart:typeddata'; 9 import 'dart:typeddata';
10 10
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 Expect.equals(0xFFFF, byte_array.getUint16(0)); 984 Expect.equals(0xFFFF, byte_array.getUint16(0));
985 Expect.equals(-1, byte_array.getInt32(0)); 985 Expect.equals(-1, byte_array.getInt32(0));
986 Expect.equals(0xFFFFFFFF, byte_array.getUint32(0)); 986 Expect.equals(0xFFFFFFFF, byte_array.getUint32(0));
987 Expect.equals(-1, byte_array.getInt64(0)); 987 Expect.equals(-1, byte_array.getInt64(0));
988 Expect.equals(0xFFFFFFFFFFFFFFFF, byte_array.getUint64(0)); 988 Expect.equals(0xFFFFFFFFFFFFFFFF, byte_array.getUint64(0));
989 Expect.isTrue(byte_array.getFloat32(0).isNaN); 989 Expect.isTrue(byte_array.getFloat32(0).isNaN);
990 Expect.isTrue(byte_array.getFloat64(0).isNaN); 990 Expect.isTrue(byte_array.getFloat64(0).isNaN);
991 for (int i = 0; i < array.length; ++i) { 991 for (int i = 0; i < array.length; ++i) {
992 array[i] = 0xFF - i; 992 array[i] = 0xFF - i;
993 } 993 }
994 byte_array.setUint32(0, 0xBF800000); 994 byte_array.setUint32(0, 0xBF800000, Endianness.LITTLE_ENDIAN);
995 Expect.equals(0, byte_array.getInt8(0)); 995 Expect.equals(0, byte_array.getInt8(0));
996 Expect.equals(0, byte_array.getInt8(1)); 996 Expect.equals(0, byte_array.getInt8(1));
997 Expect.equals(-128, byte_array.getInt8(2)); 997 Expect.equals(-128, byte_array.getInt8(2));
998 Expect.equals(-65, byte_array.getInt8(3)); 998 Expect.equals(-65, byte_array.getInt8(3));
999 Expect.equals(-5, byte_array.getInt8(4)); 999 Expect.equals(-5, byte_array.getInt8(4));
1000 Expect.equals(-6, byte_array.getInt8(5)); 1000 Expect.equals(-6, byte_array.getInt8(5));
1001 Expect.equals(-7, byte_array.getInt8(6)); 1001 Expect.equals(-7, byte_array.getInt8(6));
1002 Expect.equals(-8, byte_array.getInt8(7)); 1002 Expect.equals(-8, byte_array.getInt8(7));
1003 Expect.equals(0x00, byte_array.getUint8(0)); 1003 Expect.equals(0x00, byte_array.getUint8(0));
1004 Expect.equals(0x00, byte_array.getUint8(1)); 1004 Expect.equals(0x00, byte_array.getUint8(1));
1005 Expect.equals(0x80, byte_array.getUint8(2)); 1005 Expect.equals(0x80, byte_array.getUint8(2));
1006 Expect.equals(0xBF, byte_array.getUint8(3)); 1006 Expect.equals(0xBF, byte_array.getUint8(3));
1007 Expect.equals(0xFB, byte_array.getUint8(4)); 1007 Expect.equals(0xFB, byte_array.getUint8(4));
1008 Expect.equals(0xFA, byte_array.getUint8(5)); 1008 Expect.equals(0xFA, byte_array.getUint8(5));
1009 Expect.equals(0xF9, byte_array.getUint8(6)); 1009 Expect.equals(0xF9, byte_array.getUint8(6));
1010 Expect.equals(0xF8, byte_array.getUint8(7)); 1010 Expect.equals(0xF8, byte_array.getUint8(7));
1011 Expect.equals(0, byte_array.getInt16(0)); 1011 Expect.equals(0, byte_array.getInt16(0));
1012 Expect.equals(-16512, byte_array.getInt16(2)); 1012 Expect.equals(-16512, byte_array.getInt16(2, Endianness.LITTLE_ENDIAN));
1013 Expect.equals(-1285, byte_array.getInt16(4)); 1013 Expect.equals(-1285, byte_array.getInt16(4, Endianness.LITTLE_ENDIAN));
1014 Expect.equals(-1799, byte_array.getInt16(6)); 1014 Expect.equals(-1799, byte_array.getInt16(6, Endianness.LITTLE_ENDIAN));
1015 Expect.equals(0x0000, byte_array.getUint16(0)); 1015 Expect.equals(0x0000, byte_array.getUint16(0, Endianness.LITTLE_ENDIAN));
1016 Expect.equals(0xBF80, byte_array.getUint16(2)); 1016 Expect.equals(0xBF80, byte_array.getUint16(2, Endianness.LITTLE_ENDIAN));
1017 Expect.equals(0xFAFB, byte_array.getUint16(4)); 1017 Expect.equals(0xFAFB, byte_array.getUint16(4, Endianness.LITTLE_ENDIAN));
1018 Expect.equals(0xF8F9, byte_array.getUint16(6)); 1018 Expect.equals(0xF8F9, byte_array.getUint16(6, Endianness.LITTLE_ENDIAN));
1019 Expect.equals(-1082130432, byte_array.getInt32(0)); 1019 Expect.equals(-1082130432,
1020 Expect.equals(0xBF800000, byte_array.getUint32(0)); 1020 byte_array.getInt32(0, Endianness.LITTLE_ENDIAN));
1021 Expect.equals(-506097523945897984, byte_array.getInt64(0)); 1021 Expect.equals(0xBF800000,
1022 Expect.equals(0xF8F9FAFBBF800000, byte_array.getUint64(0)); 1022 byte_array.getUint32(0, Endianness.LITTLE_ENDIAN));
1023 Expect.equals(-1.0, byte_array.getFloat32(0)); 1023 Expect.equals(-506097523945897984,
1024 byte_array.getInt64(0, Endianness.LITTLE_ENDIAN));
1025 Expect.equals(0xF8F9FAFBBF800000,
1026 byte_array.getUint64(0, Endianness.LITTLE_ENDIAN));
1027 Expect.equals(-1.0, byte_array.getFloat32(0, Endianness.LITTLE_ENDIAN));
1024 // TODO: byte_array.getFloat64(0) 1028 // TODO: byte_array.getFloat64(0)
1025 } 1029 }
1026 1030
1027 static testInt8ListViewImpl(var array) { 1031 static testInt8ListViewImpl(var array) {
1028 Expect.equals(12, array.length); 1032 Expect.equals(12, array.length);
1029 Expect.equals(1, array.elementSizeInBytes); 1033 Expect.equals(1, array.elementSizeInBytes);
1030 Expect.equals(12, array.lengthInBytes); 1034 Expect.equals(12, array.lengthInBytes);
1031 for (int i = 0; i < array.length; ++i) { 1035 for (int i = 0; i < array.length; ++i) {
1032 array[i] = 0xFF; 1036 array[i] = 0xFF;
1033 } 1037 }
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 2377
2374 testByteList(); 2378 testByteList();
2375 } 2379 }
2376 } 2380 }
2377 2381
2378 main() { 2382 main() {
2379 for (var i=0; i<1000; i++) { 2383 for (var i=0; i<1000; i++) {
2380 ByteArrayTest.testMain(); 2384 ByteArrayTest.testMain();
2381 } 2385 }
2382 } 2386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698