OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "dart:convert"; | 6 import "dart:convert"; |
7 import "dart:typed_data"; | 7 import "dart:typed_data"; |
8 | 8 |
9 main() { | 9 main() { |
10 testMediaType(); | 10 testMediaType(); |
11 | 11 |
12 testRoundTrip(""); | 12 testRoundTrip(""); |
13 testRoundTrip("a"); | 13 testRoundTrip("a"); |
14 testRoundTrip("ab"); | 14 testRoundTrip("ab"); |
15 testRoundTrip("abc"); | 15 testRoundTrip("abc"); |
16 testRoundTrip("abcd"); | 16 testRoundTrip("abcd"); |
17 testRoundTrip("Content with special%25 characters: # ? = % # ? = %"); | 17 testRoundTrip("Content with special%25 characters: # ? = % # ? = %"); |
18 testRoundTrip("blåbærgrød", UTF8); | 18 testRoundTrip("blåbærgrød", UTF8); |
19 testRoundTrip("blåbærgrød", LATIN1); | 19 testRoundTrip("blåbærgrød", LATIN1); |
20 | 20 |
| 21 testUriEquals("data:,abc?d#e"); |
| 22 testUriEquals("DATA:,ABC?D#E"); |
| 23 testUriEquals("data:,a%20bc?d#e"); |
| 24 testUriEquals("DATA:,A%20BC?D#E"); |
| 25 testUriEquals("data:,a%62c?d#e"); |
| 26 testUriEquals("DATA:,A%42C?D#E"); |
| 27 |
21 testUtf8Encoding("\u1000\uffff"); | 28 testUtf8Encoding("\u1000\uffff"); |
22 testBytes(); | 29 testBytes(); |
23 testInvalidCharacters(); | 30 testInvalidCharacters(); |
24 testErrors(); | 31 testErrors(); |
25 } | 32 } |
26 | 33 |
27 void testMediaType() { | 34 void testMediaType() { |
28 for (var mimeType in ["", "text/plain", "text/javascript"]) { | 35 for (var mimeType in ["", "text/plain", "text/javascript"]) { |
29 for (var charset in ["", ";charset=US-ASCII", ";charset=UTF-8"]) { | 36 for (var charset in ["", ";charset=US-ASCII", ";charset=UTF-8"]) { |
30 for (var base64 in ["", ";base64"]) { | 37 for (var base64 in ["", ";base64"]) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 Expect.equals(expect.userInfo, actual.userInfo, "userInfo"); | 250 Expect.equals(expect.userInfo, actual.userInfo, "userInfo"); |
244 Expect.equals(expect.host, actual.host, "host"); | 251 Expect.equals(expect.host, actual.host, "host"); |
245 Expect.equals(expect.hasPort, actual.hasPort, "hasPort"); | 252 Expect.equals(expect.hasPort, actual.hasPort, "hasPort"); |
246 Expect.equals(expect.port, actual.port, "port"); | 253 Expect.equals(expect.port, actual.port, "port"); |
247 Expect.equals(expect.port, actual.port, "port"); | 254 Expect.equals(expect.port, actual.port, "port"); |
248 Expect.equals(expect.hasQuery, actual.hasQuery, "hasQuery"); | 255 Expect.equals(expect.hasQuery, actual.hasQuery, "hasQuery"); |
249 Expect.equals(expect.query, actual.query, "query"); | 256 Expect.equals(expect.query, actual.query, "query"); |
250 Expect.equals(expect.hasFragment, actual.hasFragment, "hasFragment"); | 257 Expect.equals(expect.hasFragment, actual.hasFragment, "hasFragment"); |
251 Expect.equals(expect.fragment, actual.fragment, "fragment"); | 258 Expect.equals(expect.fragment, actual.fragment, "fragment"); |
252 } | 259 } |
| 260 |
| 261 void testUriEquals(String uriText) { |
| 262 var data = UriData.parse(uriText); |
| 263 var uri = Uri.parse(uriText); |
| 264 Expect.equals(data.uri, uri); |
| 265 Expect.equals(data.toString(), uri.data.toString()); |
| 266 Expect.equals(data.toString(), uri.toString()); |
| 267 } |
OLD | NEW |