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

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

Issue 23953004: Throw FileExceptions when in File when reading as String and decoding fails. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | « sdk/lib/io/file_impl.dart ('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_read_encoded_test.dart
diff --git a/tests/standalone/io/file_read_encoded_test.dart b/tests/standalone/io/file_read_encoded_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..23715c041245b14350861dbdb58c18277df1b936
--- /dev/null
+++ b/tests/standalone/io/file_read_encoded_test.dart
@@ -0,0 +1,50 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
+import 'dart:io';
+
+void testReadAsString() {
+ var tmp = new Directory('').createTempSync();
+
+ var file = new File('${tmp.path}/file');
+ file.createSync();
+
+ file.writeAsBytesSync([0xb0]);
+
+ Expect.throws(file.readAsStringSync, (e) => e is FileException);
+
+ asyncStart();
+ file.readAsString().then((_) {
+ Expect.fail("expected exception");
+ }).catchError((e) {
+ tmp.deleteSync(recursive: true);
+ asyncEnd();
+ }, test: (e) => e is FileException);
+}
+
+void testReadAsLines() {
+ var tmp = new Directory('').createTempSync();
+
+ var file = new File('${tmp.path}/file');
+ file.createSync();
+
+ file.writeAsBytesSync([0xb0]);
+
+ Expect.throws(file.readAsLinesSync, (e) => e is FileException);
+
+ asyncStart();
+ file.readAsLines().then((_) {
+ Expect.fail("expected exception");
+ }).catchError((e) {
+ tmp.deleteSync(recursive: true);
+ asyncEnd();
+ }, test: (e) => e is FileException);
+}
+
+void main() {
+ testReadAsString();
+ testReadAsLines();
+}
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698