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

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

Issue 8413034: New OutputStream interface (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ Created 9 years, 1 month 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
OLDNEW
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 file I/O. 5 // Dart test program for testing file I/O.
6 6
7 7
8 class FileTest { 8 class FileTest {
9 // Test for file read functionality. 9 // Test for file read functionality.
10 static int testReadStream() { 10 static int testReadStream() {
(...skipping 29 matching lines...) Expand all
40 File file = new File(inFilename); 40 File file = new File(inFilename);
41 FileInputStream input = file.openInputStream(); 41 FileInputStream input = file.openInputStream();
42 List<int> buffer1 = new List<int>(42); 42 List<int> buffer1 = new List<int>(42);
43 int bytesRead = input.readInto(buffer1, 0, 42); 43 int bytesRead = input.readInto(buffer1, 0, 42);
44 Expect.equals(42, bytesRead); 44 Expect.equals(42, bytesRead);
45 input.close(); 45 input.close();
46 // Write the contents of the file just read into another file. 46 // Write the contents of the file just read into another file.
47 String outFilename = getFilename("tests/vm/data/fixed_length_file_out"); 47 String outFilename = getFilename("tests/vm/data/fixed_length_file_out");
48 file = new File(outFilename); 48 file = new File(outFilename);
49 OutputStream output = file.openOutputStream(); 49 OutputStream output = file.openOutputStream();
50 bool writeDone = output.write(buffer1, 0, 42, null); 50 bool writeDone = output.writeFrom(buffer1, 0, 42);
51 Expect.equals(true, writeDone); 51 Expect.equals(true, writeDone);
52 output.close(); 52 output.close();
53 // Now read the contents of the file just written. 53 // Now read the contents of the file just written.
54 List<int> buffer2 = new List<int>(42); 54 List<int> buffer2 = new List<int>(42);
55 file = new File(outFilename); 55 file = new File(outFilename);
56 input = file.openInputStream(); 56 input = file.openInputStream();
57 bytesRead = input.readInto(buffer2, 0, 42); 57 bytesRead = input.readInto(buffer2, 0, 42);
58 input.close(); 58 input.close();
59 Expect.equals(42, bytesRead); 59 Expect.equals(42, bytesRead);
60 // Now compare the two buffers to check if they are identical. 60 // Now compare the two buffers to check if they are identical.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 List<int> buffer = new List<int>(42); 252 List<int> buffer = new List<int>(42);
253 input.readInto(buffer, 0, 12); 253 input.readInto(buffer, 0, 12);
254 } catch (FileIOException ex) { 254 } catch (FileIOException ex) {
255 exceptionCaught = true; 255 exceptionCaught = true;
256 } catch (Exception ex) { 256 } catch (Exception ex) {
257 wrongExceptionCaught = true; 257 wrongExceptionCaught = true;
258 } 258 }
259 Expect.equals(true, exceptionCaught); 259 Expect.equals(true, exceptionCaught);
260 Expect.equals(true, !wrongExceptionCaught); 260 Expect.equals(true, !wrongExceptionCaught);
261 exceptionCaught = false; 261 exceptionCaught = false;
262 FileOutputStream output = file.openOutputStream(); 262 OutputStream output = file.openOutputStream();
263 output.close(); 263 output.close();
264 try { 264 try {
265 List<int> buffer = new List<int>(42); 265 List<int> buffer = new List<int>(42);
266 bool readDone = output.write(buffer, 0, 12, null); 266 bool readDone = output.writeFrom(buffer, 0, 12);
267 } catch (FileIOException ex) { 267 } catch (FileIOException ex) {
268 exceptionCaught = true; 268 exceptionCaught = true;
269 } catch (Exception ex) { 269 } catch (Exception ex) {
270 wrongExceptionCaught = true; 270 wrongExceptionCaught = true;
271 } 271 }
272 Expect.equals(true, exceptionCaught); 272 Expect.equals(true, exceptionCaught);
273 Expect.equals(true, !wrongExceptionCaught); 273 Expect.equals(true, !wrongExceptionCaught);
274 return 1; 274 return 1;
275 } 275 }
276 276
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 Expect.equals(1, testPosition()); 387 Expect.equals(1, testPosition());
388 Expect.equals(1, testCloseException()); 388 Expect.equals(1, testCloseException());
389 Expect.equals(1, testCloseExceptionStream()); 389 Expect.equals(1, testCloseExceptionStream());
390 Expect.equals(1, testBufferOutOfBoundsException()); 390 Expect.equals(1, testBufferOutOfBoundsException());
391 } 391 }
392 } 392 }
393 393
394 main() { 394 main() {
395 FileTest.testMain(); 395 FileTest.testMain();
396 } 396 }
OLDNEW
« no previous file with comments | « tests/standalone/src/EchoServerStreamTest.dart ('k') | tests/standalone/src/ProcessStderrTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698