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

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

Issue 8818009: Add chunked input stream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ Created 9 years 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/src/ChunkedStreamTest.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) 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 // Testing FileInputStream, VM-only, standalone test. 4 // Testing FileInputStream, VM-only, standalone test.
5 5
6 // Helper method to be able to run the test from the runtime 6 // Helper method to be able to run the test from the runtime
7 // directory, or the top directory. 7 // directory, or the top directory.
8 String getFilename(String path) => 8 String getFilename(String path) =>
9 new File(path).existsSync() ? path : '../' + path; 9 new File(path).existsSync() ? path : '../' + path;
10 10
11 main() { 11 void testStringInputStream() {
12 String fName = getFilename("tests/standalone/src/readuntil_test.dat"); 12 String fileName = getFilename("tests/standalone/src/readuntil_test.dat");
13 // File contains "Hello Dart\nwassup!" 13 // File contains "Hello Dart\nwassup!"
14 File file = new File(fName); 14 File file = new File(fileName);
15 file.openSync(); 15 file.openSync();
16 StringInputStream x = new StringInputStream(file.openInputStream()); 16 StringInputStream x = new StringInputStream(file.openInputStream());
17 String line = x.readLine(); 17 String line = x.readLine();
18 Expect.equals("Hello Dart", line); 18 Expect.equals("Hello Dart", line);
19 file.closeSync(); 19 file.closeSync();
20 line = x.readLine(); 20 line = x.readLine();
21 Expect.equals("wassup!", line); 21 Expect.equals("wassup!", line);
22 } 22 }
23
24 void testChunkedInputStream() {
25 String fileName = getFilename("tests/standalone/src/readuntil_test.dat");
26 // File contains 19 bytes ("Hello Dart\nwassup!")
27 File file = new File(fileName);
28 file.openSync();
29 ChunkedInputStream x = new ChunkedInputStream(file.openInputStream());
30 x.chunkSize = 9;
31 List<int> chunk = x.read();
32 Expect.equals(9, chunk.length);
33 file.closeSync();
34 x.chunkSize = 5;
35 chunk = x.read();
36 Expect.equals(5, chunk.length);
37 chunk = x.read();
38 Expect.equals(5, chunk.length);
39 chunk = x.read();
40 Expect.equals(null, chunk);
41 }
42
43 main() {
44 testStringInputStream();
45 testChunkedInputStream();
46 }
OLDNEW
« no previous file with comments | « tests/standalone/src/ChunkedStreamTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698