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

Side by Side Diff: tests/utils/uri_test.dart

Issue 12052038: Rename new Uri.fromString to Uri.parse. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload because of Error. Created 7 years, 11 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/io/web_socket_test.dart ('k') | utils/pub/command_lish.dart » ('j') | 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 library uriTest; 5 library uriTest;
6 6
7 import 'dart:utf'; 7 import 'dart:utf';
8 import 'dart:uri'; 8 import 'dart:uri';
9 9
10 testUri(String uri, bool isAbsolute) { 10 testUri(String uri, bool isAbsolute) {
11 Expect.equals(isAbsolute, new Uri.fromString(uri).isAbsolute()); 11 Expect.equals(isAbsolute, Uri.parse(uri).isAbsolute());
12 Expect.equals(isAbsolute, new Uri(uri).isAbsolute()); 12 Expect.equals(isAbsolute, new Uri(uri).isAbsolute());
13 Expect.stringEquals(uri, new Uri.fromString(uri).toString()); 13 Expect.stringEquals(uri, Uri.parse(uri).toString());
14 Expect.stringEquals(uri, new Uri(uri).toString()); 14 Expect.stringEquals(uri, new Uri(uri).toString());
15 15
16 // Test equals and hashCode members. 16 // Test equals and hashCode members.
17 Expect.equals(new Uri(uri), new Uri(uri)); 17 Expect.equals(new Uri(uri), new Uri(uri));
18 Expect.equals(new Uri(uri).hashCode, new Uri(uri).hashCode); 18 Expect.equals(new Uri(uri).hashCode, new Uri(uri).hashCode);
19 } 19 }
20 20
21 testEncodeDecode(String orig, String encoded) { 21 testEncodeDecode(String orig, String encoded) {
22 var e = encodeUri(orig); 22 var e = encodeUri(orig);
23 Expect.stringEquals(encoded, e); 23 Expect.stringEquals(encoded, e);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 fragment: "fragment").toString()); 106 fragment: "fragment").toString());
107 Expect.stringEquals("null://null@null/a/b/c/?null#null", 107 Expect.stringEquals("null://null@null/a/b/c/?null#null",
108 const Uri.fromComponents( 108 const Uri.fromComponents(
109 scheme: null, 109 scheme: null,
110 userInfo: null, 110 userInfo: null,
111 domain: null, 111 domain: null,
112 port: 0, 112 port: 0,
113 path: "/a/b/c/", 113 path: "/a/b/c/",
114 query: null, 114 query: null,
115 fragment: null).toString()); 115 fragment: null).toString());
116 Expect.stringEquals("file://", new Uri.fromString("file:").toString()); 116 Expect.stringEquals("file://", Uri.parse("file:").toString());
117 Expect.stringEquals("file://", new Uri("file:").toString()); 117 Expect.stringEquals("file://", new Uri("file:").toString());
118 Expect.stringEquals("/a/g", removeDotSegments("/a/b/c/./../../g")); 118 Expect.stringEquals("/a/g", removeDotSegments("/a/b/c/./../../g"));
119 Expect.stringEquals("mid/6", removeDotSegments("mid/content=5/../6")); 119 Expect.stringEquals("mid/6", removeDotSegments("mid/content=5/../6"));
120 Expect.stringEquals("a/b/e", removeDotSegments("a/b/c/d/../../e")); 120 Expect.stringEquals("a/b/e", removeDotSegments("a/b/c/d/../../e"));
121 Expect.stringEquals("a/b/e", removeDotSegments("../a/b/c/d/../../e")); 121 Expect.stringEquals("a/b/e", removeDotSegments("../a/b/c/d/../../e"));
122 Expect.stringEquals("a/b/e", removeDotSegments("./a/b/c/d/../../e")); 122 Expect.stringEquals("a/b/e", removeDotSegments("./a/b/c/d/../../e"));
123 Expect.stringEquals("a/b/e", removeDotSegments("../a/b/./c/d/../../e")); 123 Expect.stringEquals("a/b/e", removeDotSegments("../a/b/./c/d/../../e"));
124 Expect.stringEquals("a/b/e", removeDotSegments("./a/b/./c/d/../../e")); 124 Expect.stringEquals("a/b/e", removeDotSegments("./a/b/./c/d/../../e"));
125 Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/.")); 125 Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/."));
126 Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/./.")); 126 Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/./."));
127 Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/././.")); 127 Expect.stringEquals("a/b/e/", removeDotSegments("./a/b/./c/d/../../e/././."));
128 128
129 final urisSample = "http://a/b/c/d;p?q"; 129 final urisSample = "http://a/b/c/d;p?q";
130 Uri baseFromString = new Uri.fromString(urisSample); 130 Uri baseFromString = Uri.parse(urisSample);
131 testUriPerRFCs(baseFromString); 131 testUriPerRFCs(baseFromString);
132 Uri base = new Uri(urisSample); 132 Uri base = new Uri(urisSample);
133 testUriPerRFCs(base); 133 testUriPerRFCs(base);
134 134
135 Expect.stringEquals( 135 Expect.stringEquals(
136 "http://example.com", 136 "http://example.com",
137 new Uri.fromString("http://example.com/a/b/c").origin); 137 Uri.parse("http://example.com/a/b/c").origin);
138 Expect.stringEquals( 138 Expect.stringEquals(
139 "https://example.com", 139 "https://example.com",
140 new Uri.fromString("https://example.com/a/b/c").origin); 140 Uri.parse("https://example.com/a/b/c").origin);
141 Expect.stringEquals( 141 Expect.stringEquals(
142 "http://example.com:1234", 142 "http://example.com:1234",
143 new Uri.fromString("http://example.com:1234/a/b/c").origin); 143 Uri.parse("http://example.com:1234/a/b/c").origin);
144 Expect.stringEquals( 144 Expect.stringEquals(
145 "https://example.com:1234", 145 "https://example.com:1234",
146 new Uri.fromString("https://example.com:1234/a/b/c").origin); 146 Uri.parse("https://example.com:1234/a/b/c").origin);
147 Expect.throws( 147 Expect.throws(
148 () => new Uri.fromString("http:").origin, 148 () => Uri.parse("http:").origin,
149 (e) { return e is ArgumentError; }, 149 (e) { return e is ArgumentError; },
150 "origin for uri with empty domain should fail"); 150 "origin for uri with empty domain should fail");
151 Expect.throws( 151 Expect.throws(
152 () => const Uri.fromComponents( 152 () => const Uri.fromComponents(
153 scheme: "http", 153 scheme: "http",
154 userInfo: null, 154 userInfo: null,
155 domain: "", 155 domain: "",
156 port: 80, 156 port: 80,
157 path: "/a/b/c", 157 path: "/a/b/c",
158 query: "query", 158 query: "query",
(...skipping 16 matching lines...) Expand all
175 scheme: "http", 175 scheme: "http",
176 userInfo: null, 176 userInfo: null,
177 domain: null, 177 domain: null,
178 port: 80, 178 port: 80,
179 path: "/a/b/c", 179 path: "/a/b/c",
180 query: "query", 180 query: "query",
181 fragment: "fragment").origin, 181 fragment: "fragment").origin,
182 (e) { return e is ArgumentError; }, 182 (e) { return e is ArgumentError; },
183 "origin for uri with empty domain should fail"); 183 "origin for uri with empty domain should fail");
184 Expect.throws( 184 Expect.throws(
185 () => new Uri.fromString("http://:80").origin, 185 () => Uri.parse("http://:80").origin,
186 (e) { return e is ArgumentError; }, 186 (e) { return e is ArgumentError; },
187 "origin for uri with empty domain should fail"); 187 "origin for uri with empty domain should fail");
188 Expect.throws( 188 Expect.throws(
189 () => new Uri.fromString("file://localhost/test.txt").origin, 189 () => Uri.parse("file://localhost/test.txt").origin,
190 (e) { return e is ArgumentError; }, 190 (e) { return e is ArgumentError; },
191 "origin for non-http/https uri should fail"); 191 "origin for non-http/https uri should fail");
192 192
193 // URI encode tests 193 // URI encode tests
194 // Create a string with code point 0x10000 encoded as a surrogate pair. 194 // Create a string with code point 0x10000 encoded as a surrogate pair.
195 var s = decodeUtf8([0xf0, 0x90, 0x80, 0x80]); 195 var s = decodeUtf8([0xf0, 0x90, 0x80, 0x80]);
196 196
197 Expect.stringEquals("\u{10000}", s); 197 Expect.stringEquals("\u{10000}", s);
198 198
199 testEncodeDecode("A + B", "A+%2B+B"); 199 testEncodeDecode("A + B", "A+%2B+B");
200 testEncodeDecode("\uFFFE", "%EF%BF%BE"); 200 testEncodeDecode("\uFFFE", "%EF%BF%BE");
201 testEncodeDecode("\uFFFF", "%EF%BF%BF"); 201 testEncodeDecode("\uFFFF", "%EF%BF%BF");
202 testEncodeDecode("\uFFFE", "%EF%BF%BE"); 202 testEncodeDecode("\uFFFE", "%EF%BF%BE");
203 testEncodeDecode("\uFFFF", "%EF%BF%BF"); 203 testEncodeDecode("\uFFFF", "%EF%BF%BF");
204 testEncodeDecode("\x7f", "%7F"); 204 testEncodeDecode("\x7f", "%7F");
205 testEncodeDecode("\x80", "%C2%80"); 205 testEncodeDecode("\x80", "%C2%80");
206 testEncodeDecode("\u0800", "%E0%A0%80"); 206 testEncodeDecode("\u0800", "%E0%A0%80");
207 testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=%2B\$"); 207 testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=%2B\$");
208 testEncodeDecode(s, "%F0%90%80%80"); 208 testEncodeDecode(s, "%F0%90%80%80");
209 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); 209 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE");
210 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); 210 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF");
211 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); 211 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE");
212 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); 212 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF");
213 testEncodeDecodeComponent("\x7f", "%7F"); 213 testEncodeDecodeComponent("\x7f", "%7F");
214 testEncodeDecodeComponent("\x80", "%C2%80"); 214 testEncodeDecodeComponent("\x80", "%C2%80");
215 testEncodeDecodeComponent("\u0800", "%E0%A0%80"); 215 testEncodeDecodeComponent("\u0800", "%E0%A0%80");
216 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24"); 216 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24");
217 testEncodeDecodeComponent(s, "%F0%90%80%80"); 217 testEncodeDecodeComponent(s, "%F0%90%80%80");
218 } 218 }
OLDNEW
« no previous file with comments | « tests/standalone/io/web_socket_test.dart ('k') | utils/pub/command_lish.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698