| OLD | NEW |
| 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 // Dart test program for testing native byte arrays. | 5 // Dart test program for testing native byte arrays. |
| 6 | 6 |
| 7 // Library tag to be able to run in html test framework. | 7 // Library tag to be able to run in html test framework. |
| 8 library ByteArrayTest; | 8 library ByteArrayTest; |
| 9 | 9 |
| 10 import 'dart:scalarlist'; | 10 import 'dart:scalarlist'; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 Expect.isTrue(externalClampedByteArray is Uint8ClampedList); | 47 Expect.isTrue(externalClampedByteArray is Uint8ClampedList); |
| 48 Expect.isFalse(externalClampedByteArray is Uint8List); | 48 Expect.isFalse(externalClampedByteArray is Uint8List); |
| 49 Expect.equals(0, externalClampedByteArray.length); | 49 Expect.equals(0, externalClampedByteArray.length); |
| 50 Expect.equals(0, externalClampedByteArray.lengthInBytes()); | 50 Expect.equals(0, externalClampedByteArray.lengthInBytes()); |
| 51 | 51 |
| 52 externalClampedByteArray = new Uint8ClampedList.transferable(10); | 52 externalClampedByteArray = new Uint8ClampedList.transferable(10); |
| 53 Expect.equals(10, externalClampedByteArray.length); | 53 Expect.equals(10, externalClampedByteArray.length); |
| 54 for (int i = 0; i < 10; i++) { | 54 for (int i = 0; i < 10; i++) { |
| 55 Expect.equals(0, externalClampedByteArray[i]); | 55 Expect.equals(0, externalClampedByteArray[i]); |
| 56 } | 56 } |
| 57 | 57 for (int i = 0; i < 10; i++) { |
| 58 externalClampedByteArray[i] = i + 250; |
| 59 } |
| 60 for (int i = 0; i < 10; i++) { |
| 61 Expect.equals(i + 250 > 255 ? 255 : i + 250, externalClampedByteArray[i]); |
| 62 } |
| 58 } | 63 } |
| 59 | 64 |
| 60 void testUnsignedByteArrayRange(bool check_throws) { | 65 void testUnsignedByteArrayRange(bool check_throws) { |
| 61 Uint8List byteArray; | 66 Uint8List byteArray; |
| 62 byteArray = new Uint8List(10); | 67 byteArray = new Uint8List(10); |
| 63 | 68 |
| 64 byteArray[1] = 255; | 69 byteArray[1] = 255; |
| 65 Expect.equals(255, byteArray[1]); | 70 Expect.equals(255, byteArray[1]); |
| 66 byteArray[1] = 0; | 71 byteArray[1] = 0; |
| 67 Expect.equals(0, byteArray[1]); | 72 Expect.equals(0, byteArray[1]); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 testSetRange(); | 276 testSetRange(); |
| 272 testIndexOutOfRange(); | 277 testIndexOutOfRange(); |
| 273 testIndexOf(); | 278 testIndexOf(); |
| 274 testSubArray(); | 279 testSubArray(); |
| 275 } | 280 } |
| 276 testByteArrayRange(true); | 281 testByteArrayRange(true); |
| 277 testUnsignedByteArrayRange(true); | 282 testUnsignedByteArrayRange(true); |
| 278 testExternalClampedUnsignedByteArrayRange(true); | 283 testExternalClampedUnsignedByteArrayRange(true); |
| 279 } | 284 } |
| 280 | 285 |
| OLD | NEW |