OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 import "package:expect/expect.dart"; | |
6 | |
7 testNormalizePath() { | |
8 test(String expected, String path) { | |
9 var uri = new Uri(path: path); | |
10 Expect.equals(expected, uri.path); | |
11 Expect.equals(expected, uri.toString()); | |
12 } | |
13 | |
14 var unreserved = "-._~0123456789" | |
15 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
16 "abcdefghijklmnopqrstuvwxyz"; | |
17 | |
18 test("A", "%41"); | |
19 test("AB", "%41%42"); | |
20 test("%40AB", "%40%41%42"); | |
21 test("a", "%61"); | |
22 test("ab", "%61%62"); | |
23 test("%60ab", "%60%61%62"); | |
24 test(unreserved, unreserved); | |
25 | |
26 var x = new StringBuffer(); | |
27 for (int i = 32; i < 128; i++) { | |
28 if (unreserved.indexOf(new String.fromCharCode(i)) != -1) { | |
29 x.writeCharCode(i); | |
30 } else { | |
31 x.write("%"); | |
32 x.write(i.toRadixString(16)); | |
33 } | |
34 } | |
35 print(x.toString().toUpperCase()); | |
36 Expect.equals(x.toString().toUpperCase(), new Uri(path: x.toString()).toString ().toUpperCase()); | |
floitsch
2013/05/24 20:37:27
long line.
Søren Gjesse
2013/05/27 10:47:21
Done.
| |
37 } | |
38 | |
39 main() { | |
40 testNormalizePath(); | |
41 } | |
OLD | NEW |