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

Side by Side Diff: tests/standalone/src/io/StringStreamTest.dart

Issue 9653026: Add writeString method to OutputStream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/standalone/src/io/ListOutputStreamTest.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 4
5 #import("dart:io"); 5 #import("dart:io");
6 6
7 void testUtf8() { 7 void testUtf8() {
8 List<int> data = [0x01, 8 List<int> data = [0x01,
9 0x7f, 9 0x7f,
10 0xc2, 0x80, 10 0xc2, 0x80,
(...skipping 19 matching lines...) Expand all
30 30
31 void testLatin1() { 31 void testLatin1() {
32 List<int> data = [0x01, 32 List<int> data = [0x01,
33 0x7f, 33 0x7f,
34 0x44, 0x61, 0x72, 0x74, 34 0x44, 0x61, 0x72, 0x74,
35 0x80, 35 0x80,
36 0xff]; 36 0xff];
37 InputStream s = new ListInputStream(); 37 InputStream s = new ListInputStream();
38 s.write(data); 38 s.write(data);
39 s.markEndOfStream(); 39 s.markEndOfStream();
40 StringInputStream stream = new StringInputStream(s, "ISO-8859-1"); 40 StringInputStream stream = new StringInputStream(s, Encoding.ISO_8859_1);
41 void stringData() { 41 void stringData() {
42 String s = stream.read(); 42 String s = stream.read();
43 Expect.equals(8, s.length); 43 Expect.equals(8, s.length);
44 Expect.equals(new String.fromCharCodes([0x01]), s[0]); 44 Expect.equals(new String.fromCharCodes([0x01]), s[0]);
45 Expect.equals(new String.fromCharCodes([0x7f]), s[1]); 45 Expect.equals(new String.fromCharCodes([0x7f]), s[1]);
46 Expect.equals("Dart", s.substring(2, 6)); 46 Expect.equals("Dart", s.substring(2, 6));
47 Expect.equals(new String.fromCharCodes([0x80]), s[6]); 47 Expect.equals(new String.fromCharCodes([0x80]), s[6]);
48 Expect.equals(new String.fromCharCodes([0xff]), s[7]); 48 Expect.equals(new String.fromCharCodes([0xff]), s[7]);
49 } 49 }
50 stream.onData = stringData; 50 stream.onData = stringData;
51 } 51 }
52 52
53 void testAscii() { 53 void testAscii() {
54 List<int> data = [0x01, 54 List<int> data = [0x01,
55 0x44, 0x61, 0x72, 0x74, 55 0x44, 0x61, 0x72, 0x74,
56 0x7f]; 56 0x7f];
57 InputStream s = new ListInputStream(); 57 InputStream s = new ListInputStream();
58 s.write(data); 58 s.write(data);
59 s.markEndOfStream(); 59 s.markEndOfStream();
60 StringInputStream stream = new StringInputStream(s, "ASCII"); 60 StringInputStream stream =
61 new StringInputStream(s, Encoding.ASCII);
61 void stringData() { 62 void stringData() {
62 String s = stream.read(); 63 String s = stream.read();
63 Expect.equals(6, s.length); 64 Expect.equals(6, s.length);
64 Expect.equals(new String.fromCharCodes([0x01]), s[0]); 65 Expect.equals(new String.fromCharCodes([0x01]), s[0]);
65 Expect.equals("Dart", s.substring(1, 5)); 66 Expect.equals("Dart", s.substring(1, 5));
66 Expect.equals(new String.fromCharCodes([0x7f]), s[5]); 67 Expect.equals(new String.fromCharCodes([0x7f]), s[5]);
67 } 68 }
68 stream.onData = stringData; 69 stream.onData = stringData;
69 } 70 }
70 71
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 s.write("Line1\nLine2\r\nLine3\rLi".charCodes()); 165 s.write("Line1\nLine2\r\nLine3\rLi".charCodes());
165 } 166 }
166 167
167 main() { 168 main() {
168 testUtf8(); 169 testUtf8();
169 testLatin1(); 170 testLatin1();
170 testAscii(); 171 testAscii();
171 testReadLine1(); 172 testReadLine1();
172 testReadLine2(); 173 testReadLine2();
173 } 174 }
OLDNEW
« no previous file with comments | « tests/standalone/src/io/ListOutputStreamTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698