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

Unified Diff: tests/standalone/io/file_test.dart

Issue 10913005: Better handling of reading empty files (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changed the aproach slightly Created 8 years, 4 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/tests/vm/data/empty_file ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/file_test.dart
diff --git a/tests/standalone/io/file_test.dart b/tests/standalone/io/file_test.dart
index 5078f5fa184f9b60b9aa57218ae582cc6d3b332b..794a9cf4714279d5d9e0ce759d469cc0ae2fc8f3 100644
--- a/tests/standalone/io/file_test.dart
+++ b/tests/standalone/io/file_test.dart
@@ -1003,6 +1003,19 @@ class FileTest {
});
}
+ static void testReadAsBytesEmptyFile() {
+ var port = new ReceivePort();
+ port.receive((result, replyTo) {
+ port.close();
+ Expect.equals(0, result);
+ });
+ var name = getFilename("tests/vm/data/empty_file");
+ var f = new File(name);
+ f.readAsBytes().then((bytes) {
+ port.toSendPort().send(bytes.length);
+ });
+ }
+
static void testReadAsBytesSync() {
var name = getFilename("tests/vm/data/fixed_length_file");
var bytes = new File(name).readAsBytesSync();
@@ -1010,6 +1023,12 @@ class FileTest {
Expect.equals(bytes.length, 42);
}
+ static void testReadAsBytesSyncEmptyFile() {
+ var name = getFilename("tests/vm/data/empty_file");
+ var bytes = new File(name).readAsBytesSync();
+ Expect.equals(bytes.length, 0);
+ }
+
static void testReadAsText() {
var port = new ReceivePort();
port.receive((result, replyTo) {
@@ -1044,6 +1063,20 @@ class FileTest {
});
}
+ static void testReadAsTextEmptyFile() {
+ var port = new ReceivePort();
+ port.receive((result, replyTo) {
+ port.close();
+ Expect.equals(0, result);
+ });
+ var name = getFilename("tests/vm/data/empty_file");
+ var f = new File(name);
+ f.readAsText(Encoding.UTF_8).then((text) {
+ port.toSendPort().send(text.length);
+ return true;
+ });
+ }
+
static void testReadAsTextSync() {
var name = getFilename("tests/vm/data/fixed_length_file");
var text = new File(name).readAsTextSync();
@@ -1061,6 +1094,12 @@ class FileTest {
Expect.listEquals(expected, text.charCodes());
}
+ static void testReadAsTextSyncEmptyFile() {
+ var name = getFilename("tests/vm/data/empty_file");
+ var text = new File(name).readAsTextSync();
+ Expect.equals(0, text.length);
+ }
+
static void testReadAsLines() {
var port = new ReceivePort();
port.receive((result, replyTo) {
@@ -1201,9 +1240,13 @@ class FileTest {
testOpenDirectoryAsFileSync();
testOpenFileFromPath();
testReadAsBytes();
+ testReadAsBytesEmptyFile();
testReadAsBytesSync();
+ testReadAsBytesSyncEmptyFile();
testReadAsText();
+ testReadAsTextEmptyFile();
testReadAsTextSync();
+ testReadAsTextSyncEmptyFile();
testReadAsLines();
testReadAsLinesSync();
testReadAsErrors();
« no previous file with comments | « runtime/tests/vm/data/empty_file ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698