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

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

Issue 11345025: Use the encoding parameter for writeString on RandomAccessFile objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
« runtime/bin/file_impl.dart ('K') | « runtime/bin/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_test.dart
diff --git a/tests/standalone/io/file_test.dart b/tests/standalone/io/file_test.dart
index 4fd426a75a74d90346bc7b051c07c3ca94ae5c6a..e0f2d17d308dec6a2d5b77748f4861d7005de103 100644
--- a/tests/standalone/io/file_test.dart
+++ b/tests/standalone/io/file_test.dart
@@ -1218,6 +1218,59 @@ class FileTest {
Expect.isFalse(file.existsSync());
}
+ static void testWriteStringUtf8() {
+ var file = new File('${tempDirectory.path}/out_write_string');
+ var string = new String.fromCharCodes([0x192]);
+ file.open(FileMode.WRITE).then((openedFile) {
+ openedFile.writeString(string).then((_) {
+ openedFile.length().then((l) {
+ Expect.equals(2, l);
+ openedFile.close().then((_) {
+ file.open(FileMode.APPEND).then((openedFile) {
+ openedFile.setPosition(2).then((_) {
+ openedFile.writeString(string).then((_) {
+ openedFile.length().then((l) {
+ Expect.equals(4, l);
+ openedFile.close().then((_) {
+ file.readAsText().then((readBack) {
+ Expect.stringEquals(readBack, '$string$string');
+ file.delete().then((_) {
+ file.exists().then((e) {
+ Expect.isFalse(e);
+ asyncTestDone("testWriteStringUtf8");
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ asyncTestStarted();
+ }
+
+ static void testWriteStringUtf8Sync() {
+ var file = new File('${tempDirectory.path}/out_write_string_sync');
+ var string = new String.fromCharCodes([0x192]);
+ var openedFile = file.openSync(FileMode.WRITE);
+ openedFile.writeStringSync(string);
+ Expect.equals(2, openedFile.lengthSync());
+ openedFile.closeSync();
+ openedFile = file.openSync(FileMode.APPEND);
+ openedFile.setPositionSync(2);
+ openedFile.writeStringSync(string);
+ Expect.equals(4, openedFile.lengthSync());
+ openedFile.closeSync();
+ var readBack = file.readAsTextSync();
+ Expect.stringEquals(readBack, '$string$string');
+ file.deleteSync();
+ Expect.isFalse(file.existsSync());
+ }
+
// Helper method to be able to run the test from the runtime
// directory, or the top directory.
static String getFilename(String path) =>
@@ -1273,6 +1326,8 @@ class FileTest {
testWriteVariousLists();
testDirectory();
testDirectorySync();
+ testWriteStringUtf8();
+ testWriteStringUtf8Sync();
});
}
}
« runtime/bin/file_impl.dart ('K') | « runtime/bin/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698