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

Side by Side Diff: tests/standalone/src/ByteArrayTest.dart

Issue 9235067: Use ByteArray's native for Socket and File. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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
« runtime/lib/byte_array.dart ('K') | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 //
5 // Dart test program for testing native byte arrays.
6
7 void testCreateByteArray() {
8 ByteArray byteArray;
9
10 byteArray = new ByteArray(0);
11 Expect.equals(0, byteArray.length);
12
13 byteArray = new ByteArray(10);
14 Expect.equals(10, byteArray.length);
15 for (int i = 0; i < 10; i++) {
16 Expect.equals(0, byteArray[i]);
17 }
18 }
19
20 void testSetRange() {
21 ByteArray byteArray = new ByteArray(3);
22
23 List<int> list = [10, 11, 12];
24 byteArray.setRange(0, 3, list);
25 for (int i = 0; i < 3; i++) {
26 Expect.equals(10 + i, byteArray[i]);
27 }
28
29 byteArray[0] = 20;
30 byteArray[1] = 21;
31 byteArray[2] = 22;
32 list.setRange(0, 3, byteArray);
33 for (int i = 0; i < 3; i++) {
34 Expect.equals(20 + i, list[i]);
35 }
36
37 byteArray.setRange(1, 2, const [8, 9]);
38 Expect.equals(20, byteArray[0]);
39 Expect.equals(8, byteArray[1]);
40 Expect.equals(9, byteArray[2]);
41 }
42
43 void testIndexOutOfRange() {
44 ByteArray byteArray = new ByteArray(3);
45 List<int> list = const [0, 1, 2, 3];
46
47 Expect.throws(() {
48 byteArray.setRange(0, 4, list);
49 });
50
51 Expect.throws(() {
52 byteArray.setRange(3, 1, list);
53 });
54 }
55
56 main() {
57 testCreateByteArray();
58 testSetRange();
59 testIndexOutOfRange();
60 }
OLDNEW
« runtime/lib/byte_array.dart ('K') | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698