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

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

Issue 12315129: Make File.readSync return only the bytes read (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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/bin/file.cc ('K') | « sdk/lib/io/file_impl.dart ('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
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 file I/O. 5 // Dart test program for testing file I/O.
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 10
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 Expect.equals(32, buffer[2]); // represents ' ' in the file. 237 Expect.equals(32, buffer[2]); // represents ' ' in the file.
238 Expect.equals(67, buffer[3]); // represents 'C' in the file. 238 Expect.equals(67, buffer[3]); // represents 'C' in the file.
239 Expect.equals(111, buffer[4]); // represents 'o' in the file. 239 Expect.equals(111, buffer[4]); // represents 'o' in the file.
240 Expect.equals(112, buffer[5]); // represents 'p' in the file. 240 Expect.equals(112, buffer[5]); // represents 'p' in the file.
241 Expect.equals(121, buffer[6]); // represents 'y' in the file. 241 Expect.equals(121, buffer[6]); // represents 'y' in the file.
242 Expect.equals(114, buffer[7]); // represents 'r' in the file. 242 Expect.equals(114, buffer[7]); // represents 'r' in the file.
243 Expect.equals(105, buffer[8]); // represents 'i' in the file. 243 Expect.equals(105, buffer[8]); // represents 'i' in the file.
244 Expect.equals(103, buffer[9]); // represents 'g' in the file. 244 Expect.equals(103, buffer[9]); // represents 'g' in the file.
245 Expect.equals(104, buffer[10]); // represents 'h' in the file. 245 Expect.equals(104, buffer[10]); // represents 'h' in the file.
246 Expect.equals(116, buffer[11]); // represents 't' in the file. 246 Expect.equals(116, buffer[11]); // represents 't' in the file.
247
248 filename = getFilename("tests/vm/data/fixed_length_file");
249 file = new File(filename);
250 int len = file.lengthSync();
251 Expect.equals(0, file.openSync().readSync(0).length);
252 Expect.equals(1, file.openSync().readSync(1).length);
253 Expect.equals(len - 1, file.openSync().readSync(len - 1).length);
254 Expect.equals(len, file.openSync().readSync(len).length);
255 Expect.equals(len, file.openSync().readSync(len + 1).length);
256 Expect.equals(len, file.openSync().readSync(len * 2).length);
257 Expect.equals(len, file.openSync().readSync(len * 10).length);
247 } 258 }
248 259
249 // Test for file read and write functionality. 260 // Test for file read and write functionality.
250 static void testReadWrite() { 261 static void testReadWrite() {
251 // Read a file. 262 // Read a file.
252 String inFilename = getFilename("tests/vm/data/fixed_length_file"); 263 String inFilename = getFilename("tests/vm/data/fixed_length_file");
253 final File file = new File(inFilename); 264 final File file = new File(inFilename);
254 file.open(FileMode.READ).then((openedFile) { 265 file.open(FileMode.READ).then((openedFile) {
255 List<int> buffer1 = new List<int>(42); 266 List<int> buffer1 = new List<int>(42);
256 openedFile.readList(buffer1, 0, 42).then((bytes_read) { 267 openedFile.readList(buffer1, 0, 42).then((bytes_read) {
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 testDirectorySync(); 1232 testDirectorySync();
1222 testWriteStringUtf8(); 1233 testWriteStringUtf8();
1223 testWriteStringUtf8Sync(); 1234 testWriteStringUtf8Sync();
1224 }); 1235 });
1225 } 1236 }
1226 } 1237 }
1227 1238
1228 main() { 1239 main() {
1229 FileTest.testMain(); 1240 FileTest.testMain();
1230 } 1241 }
OLDNEW
« runtime/bin/file.cc ('K') | « sdk/lib/io/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698