| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 void testCreateByteArray() { | 7 void testCreateByteArray() { |
| 8 Uint8List byteArray; | 8 Uint8List byteArray; |
| 9 | 9 |
| 10 byteArray = new Uint8List(0); | 10 byteArray = new Uint8List(0); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 Expect.throws(() { | 47 Expect.throws(() { |
| 48 byteArray.setRange(0, 4, list); | 48 byteArray.setRange(0, 4, list); |
| 49 }); | 49 }); |
| 50 | 50 |
| 51 Expect.throws(() { | 51 Expect.throws(() { |
| 52 byteArray.setRange(3, 1, list); | 52 byteArray.setRange(3, 1, list); |
| 53 }); | 53 }); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void testIndexOf() { |
| 57 var list = new Uint8List(10); |
| 58 for (int i = 0; i < list.length; i++) { |
| 59 list[i] = i + 10; |
| 60 } |
| 61 Expect.equals(0, list.indexOf(10)); |
| 62 Expect.equals(5, list.indexOf(15)); |
| 63 Expect.equals(9, list.indexOf(19)); |
| 64 Expect.equals(-1, list.indexOf(20)); |
| 65 |
| 66 list = new Float32List(10); |
| 67 for (int i = 0; i < list.length; i++) { |
| 68 list[i] = i + 10.0; |
| 69 } |
| 70 Expect.equals(0, list.indexOf(10.0)); |
| 71 Expect.equals(5, list.indexOf(15.0)); |
| 72 Expect.equals(9, list.indexOf(19.0)); |
| 73 Expect.equals(-1, list.indexOf(20.0)); |
| 74 } |
| 75 |
| 56 main() { | 76 main() { |
| 57 for (int i = 0; i < 2000; i++) { | 77 for (int i = 0; i < 2000; i++) { |
| 58 testCreateByteArray(); | 78 testCreateByteArray(); |
| 59 testSetRange(); | 79 testSetRange(); |
| 60 testIndexOutOfRange(); | 80 testIndexOutOfRange(); |
| 81 testIndexOf(); |
| 61 } | 82 } |
| 62 } | 83 } |
| OLD | NEW |