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

Side by Side Diff: tests/standalone/io/file_invalid_arguments_test.dart

Issue 14018007: Rename RandomAccessFile.readList and RandomAccessFile.writeList to RandomAccessFile.readInto and Ra… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge 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
« no previous file with comments | « tests/standalone/io/file_fuzz_test.dart ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import "dart:io"; 6 import "dart:io";
7 import "dart:isolate"; 7 import "dart:isolate";
8 8
9 void testReadInvalidArgs(arg) { 9 void testReadInvalidArgs(arg) {
10 var port = new ReceivePort(); 10 var port = new ReceivePort();
(...skipping 15 matching lines...) Expand all
26 errors++; 26 errors++;
27 Expect.isTrue(e.error is FileIOException); 27 Expect.isTrue(e.error is FileIOException);
28 Expect.isTrue(e.error.toString().contains('Invalid arguments')); 28 Expect.isTrue(e.error.toString().contains('Invalid arguments'));
29 file.close().then((ignore) { 29 file.close().then((ignore) {
30 Expect.equals(1, errors); 30 Expect.equals(1, errors);
31 port.close(); 31 port.close();
32 }); 32 });
33 }); 33 });
34 } 34 }
35 35
36 void testReadListInvalidArgs(buffer, offset, length) { 36 void testReadIntoInvalidArgs(buffer, start, end) {
37 var port = new ReceivePort(); 37 var port = new ReceivePort();
38 String filename = getFilename("tests/vm/data/fixed_length_file"); 38 String filename = getFilename("tests/vm/data/fixed_length_file");
39 var file = (new File(filename)).openSync(); 39 var file = (new File(filename)).openSync();
40 try { 40 try {
41 file.readListSync(buffer, offset, length); 41 file.readIntoSync(buffer, start, end);
42 Expect.fail('exception expected'); 42 Expect.fail('exception expected');
43 } catch (e) { 43 } catch (e) {
44 Expect.isTrue(e is FileIOException); 44 Expect.isTrue(e is FileIOException);
45 Expect.isTrue(e.toString().contains('Invalid arguments')); 45 Expect.isTrue(e.toString().contains('Invalid arguments'));
46 } 46 }
47 47
48 var errors = 0; 48 var errors = 0;
49 var readListFuture = file.readList(buffer, offset, length); 49 var readIntoFuture = file.readInto(buffer, start, end);
50 readListFuture.then((bytes) { 50 readIntoFuture.then((bytes) {
51 Expect.fail('exception expected'); 51 Expect.fail('exception expected');
52 }).catchError((e) { 52 }).catchError((e) {
53 errors++; 53 errors++;
54 Expect.isTrue(e.error is FileIOException); 54 Expect.isTrue(e.error is FileIOException);
55 Expect.isTrue(e.error.toString().contains('Invalid arguments')); 55 Expect.isTrue(e.error.toString().contains('Invalid arguments'));
56 file.close().then((ignore) { 56 file.close().then((ignore) {
57 Expect.equals(1, errors); 57 Expect.equals(1, errors);
58 port.close(); 58 port.close();
59 }); 59 });
60 }); 60 });
(...skipping 16 matching lines...) Expand all
77 Expect.fail('exception expected'); 77 Expect.fail('exception expected');
78 }).catchError((s) { 78 }).catchError((s) {
79 Expect.isTrue(s.error is FileIOException); 79 Expect.isTrue(s.error is FileIOException);
80 Expect.isTrue(s.error.toString().contains('Invalid argument')); 80 Expect.isTrue(s.error.toString().contains('Invalid argument'));
81 file.close().then((ignore) { 81 file.close().then((ignore) {
82 port.close(); 82 port.close();
83 }); 83 });
84 }); 84 });
85 } 85 }
86 86
87 void testWriteListInvalidArgs(buffer, offset, bytes) { 87 void testWriteFromInvalidArgs(buffer, start, end) {
88 var port = new ReceivePort(); 88 var port = new ReceivePort();
89 String filename = getFilename("tests/vm/data/fixed_length_file"); 89 String filename = getFilename("tests/vm/data/fixed_length_file");
90 var file = (new File("${filename}_out")).openSync(mode: FileMode.WRITE); 90 var file = (new File("${filename}_out")).openSync(mode: FileMode.WRITE);
91 try { 91 try {
92 file.writeListSync(buffer, offset, bytes); 92 file.writeFromSync(buffer, start, end);
93 Expect.fail('exception expected'); 93 Expect.fail('exception expected');
94 } catch (e) { 94 } catch (e) {
95 Expect.isTrue(e is FileIOException); 95 Expect.isTrue(e is FileIOException);
96 Expect.isTrue(e.toString().contains('Invalid arguments')); 96 Expect.isTrue(e.toString().contains('Invalid arguments'));
97 } 97 }
98 98
99 var writeListFuture = file.writeList(buffer, offset, bytes); 99 var writeFromFuture = file.writeFrom(buffer, start, end);
100 writeListFuture.then((ignore) { 100 writeFromFuture.then((ignore) {
101 Expect.fail('exception expected'); 101 Expect.fail('exception expected');
102 }).catchError((s) { 102 }).catchError((s) {
103 Expect.isTrue(s.error is FileIOException); 103 Expect.isTrue(s.error is FileIOException);
104 Expect.isTrue(s.error.toString().contains('Invalid arguments')); 104 Expect.isTrue(s.error.toString().contains('Invalid arguments'));
105 file.close().then((ignore) { 105 file.close().then((ignore) {
106 port.close(); 106 port.close();
107 }); 107 });
108 }); 108 });
109 } 109 }
110 110
(...skipping 18 matching lines...) Expand all
129 }); 129 });
130 }); 130 });
131 } 131 }
132 132
133 String getFilename(String path) { 133 String getFilename(String path) {
134 return new File(path).existsSync() ? path : 'runtime/$path'; 134 return new File(path).existsSync() ? path : 'runtime/$path';
135 } 135 }
136 136
137 main() { 137 main() {
138 testReadInvalidArgs('asdf'); 138 testReadInvalidArgs('asdf');
139 testReadListInvalidArgs(12, 0, 1); 139 testReadIntoInvalidArgs(12, 0, 1);
140 testReadListInvalidArgs(new List(10), '0', 1); 140 testReadIntoInvalidArgs(new List(10), '0', 1);
141 testReadListInvalidArgs(new List(10), 0, '1'); 141 testReadIntoInvalidArgs(new List(10), 0, '1');
142 testWriteByteInvalidArgs('asdf'); 142 testWriteByteInvalidArgs('asdf');
143 testWriteListInvalidArgs(12, 0, 1); 143 testWriteFromInvalidArgs(12, 0, 1);
144 testWriteListInvalidArgs(new List(10), '0', 1); 144 testWriteFromInvalidArgs(new List(10), '0', 1);
145 testWriteListInvalidArgs(new List(10), 0, '1'); 145 testWriteFromInvalidArgs(new List(10), 0, '1');
146 testWriteStringInvalidArgs("Hello, world", 42); 146 testWriteStringInvalidArgs("Hello, world", 42);
147 } 147 }
OLDNEW
« no previous file with comments | « tests/standalone/io/file_fuzz_test.dart ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698