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

Unified Diff: tests/standalone/src/FileTest.dart

Issue 9072003: Handle reading byte past the end of file (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/file.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/FileTest.dart
diff --git a/tests/standalone/src/FileTest.dart b/tests/standalone/src/FileTest.dart
index db9fdd43a2bd199ba7414a6bf32c0e4661c18b09..5d587f342e6b30ee8807b2d28924da6a1777cef5 100644
--- a/tests/standalone/src/FileTest.dart
+++ b/tests/standalone/src/FileTest.dart
@@ -265,6 +265,35 @@ class FileTest {
return 1;
}
+ static int testReadEmptyFileSync() {
+ String fileName = tempDirectory.path + "/empty_file_sync";
+ File file = new File(fileName);
+ file.createSync();
+ RandomAccessFile openedFile = file.openSync();
+ Expect.throws(() => openedFile.readByteSync(), (e) => e is FileIOException);
+ return 1;
+ }
+
+ static int testReadEmptyFile() {
+ String fileName = tempDirectory.path + "/empty_file";
+ File file = new File(fileName);
+ file.createHandler = () {
+ file.openHandler = (RandomAccessFile openedFile) {
+ openedFile.readByteHandler = (int byte) {
+ Expect.fail("Read byte from empty file");
+ };
+ openedFile.errorHandler = (String err) {
+ Expect.isTrue(err.indexOf("failed") != -1);
+ };
+ openedFile.readByte();
+ };
+ file.open();
+ };
+ asyncTestStarted();
+ file.create();
+ return 1;
+ }
+
// Test for file length functionality.
static int testLength() {
String filename = getFilename("tests/vm/data/fixed_length_file");
@@ -636,6 +665,8 @@ class FileTest {
Expect.equals(1, testReadWrite());
Expect.equals(1, testReadWriteSync());
Expect.equals(1, testReadWriteStream());
+ Expect.equals(1, testReadEmptyFileSync());
+ Expect.equals(1, testReadEmptyFile());
Expect.equals(1, testTruncate());
Expect.equals(1, testTruncateSync());
Expect.equals(1, testCloseException());
« no previous file with comments | « runtime/bin/file.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698