OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 | 6 |
7 void testInvalidArguments() { | 7 void testInvalidArguments() { |
8 } | 8 } |
9 | 9 |
10 void testEncodeQueryComponent() { | 10 void testEncodeQueryComponent() { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 } else if (unreserved.indexOf(new String.fromCharCode(i)) != -1) { | 64 } else if (unreserved.indexOf(new String.fromCharCode(i)) != -1) { |
65 encoded.writeCharCode(i); | 65 encoded.writeCharCode(i); |
66 } else { | 66 } else { |
67 encoded.write("%"); | 67 encoded.write("%"); |
68 encoded.write(i.toRadixString(16).toUpperCase()); | 68 encoded.write(i.toRadixString(16).toUpperCase()); |
69 } | 69 } |
70 unencoded.writeCharCode(i); | 70 unencoded.writeCharCode(i); |
71 } | 71 } |
72 encoded = encoded.toString(); | 72 encoded = encoded.toString(); |
73 unencoded = unencoded.toString(); | 73 unencoded = unencoded.toString(); |
74 print(encoded); | |
75 print(unencoded); | |
76 test("a=$encoded", {"a": unencoded}); | 74 test("a=$encoded", {"a": unencoded}); |
77 test("a=$encoded&b=$encoded", {"a": unencoded, "b": unencoded}); | 75 test("a=$encoded&b=$encoded", {"a": unencoded, "b": unencoded}); |
78 | 76 |
79 var map = new Map(); | 77 var map = new Map(); |
80 map[unencoded] = unencoded; | 78 map[unencoded] = unencoded; |
81 test("$encoded=$encoded", map); | 79 test("$encoded=$encoded", map); |
82 } | 80 } |
83 | 81 |
84 testInvalidQueryParameters() { | 82 testInvalidQueryParameters() { |
85 test(String query, Map<String, String> parameters) { | 83 test(String query, Map<String, String> parameters) { |
(...skipping 20 matching lines...) Expand all Loading... | |
106 test("=", {}); | 104 test("=", {}); |
107 test("=xxx", {}); | 105 test("=xxx", {}); |
108 test("===", {}); | 106 test("===", {}); |
109 test("=xxx=yyy=zzz", {}); | 107 test("=xxx=yyy=zzz", {}); |
110 test("=&=&=", {}); | 108 test("=&=&=", {}); |
111 test("=xxx&=yyy&=zzz", {}); | 109 test("=xxx&=yyy&=zzz", {}); |
112 test("&=&=&", {}); | 110 test("&=&=&", {}); |
113 test("&=xxx&=xxx&", {}); | 111 test("&=xxx&=xxx&", {}); |
114 } | 112 } |
115 | 113 |
114 testQueryParametersParsedOnce() { | |
115 var uri = Uri.parse("?a=b&c=d"); | |
116 Expect.isTrue(identical(uri.queryParameters, uri.queryParameters)); | |
Lasse Reichstein Nielsen
2013/05/30 11:57:50
Ditto here, don't specify it and don't test for it
Søren Gjesse
2013/05/30 13:38:25
Done.
| |
117 | |
118 var map = {"a": "b", "c": "d"}; | |
119 uri = new Uri(queryParameters: map); | |
120 Expect.isFalse(identical(map, uri.queryParameters)); | |
121 Expect.isTrue(identical(uri.queryParameters, uri.queryParameters)); | |
122 } | |
123 | |
116 main() { | 124 main() { |
117 testInvalidArguments(); | 125 testInvalidArguments(); |
118 testEncodeQueryComponent(); | 126 testEncodeQueryComponent(); |
119 testQueryParameters(); | 127 testQueryParameters(); |
120 testInvalidQueryParameters(); | 128 testInvalidQueryParameters(); |
129 testQueryParametersParsedOnce(); | |
121 } | 130 } |
OLD | NEW |