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 void testEncodeQueryComponent() { | 9 void testEncodeQueryComponent() { |
10 // This exact data is from posting a form in Chrome 26 with the one | 10 // This exact data is from posting a form in Chrome 26 with the one |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 encoded.write(i.toRadixString(16).toUpperCase()); | 93 encoded.write(i.toRadixString(16).toUpperCase()); |
94 } | 94 } |
95 if (i == 32) { | 95 if (i == 32) { |
96 allEncoded.write("+"); | 96 allEncoded.write("+"); |
97 } else { | 97 } else { |
98 allEncoded.write("%"); | 98 allEncoded.write("%"); |
99 allEncoded.write(i.toRadixString(16).toUpperCase()); | 99 allEncoded.write(i.toRadixString(16).toUpperCase()); |
100 } | 100 } |
101 unencoded.writeCharCode(i); | 101 unencoded.writeCharCode(i); |
102 } | 102 } |
103 encoded = encoded.toString(); | 103 String encodedStr = encoded.toString(); |
104 unencoded = unencoded.toString(); | 104 String unencodedStr = unencoded.toString(); |
Bob Nystrom
2017/07/20 00:13:07
"var" for these?
bkonyi
2017/07/20 15:05:50
Done.
| |
105 test("a=$encoded", {"a": unencoded}); | 105 test("a=$encodedStr", {"a": unencodedStr}); |
106 test("a=$encoded&b=$encoded", {"a": unencoded, "b": unencoded}); | 106 test("a=$encodedStr&b=$encodedStr", {"a": unencodedStr, "b": unencodedStr}); |
107 | 107 |
108 var map = new Map(); | 108 var map = new Map(); |
109 map[unencoded] = unencoded; | 109 map[unencodedStr] = unencodedStr; |
110 test("$encoded=$encoded", map); | 110 test("$encodedStr=$encodedStr", map); |
111 test("$encoded=$allEncoded", map, "$encoded=$encoded"); | 111 test("$encodedStr=$allEncoded", map, "$encodedStr=$encodedStr"); |
112 test("$allEncoded=$encoded", map, "$encoded=$encoded"); | 112 test("$allEncoded=$encodedStr", map, "$encodedStr=$encodedStr"); |
113 test("$allEncoded=$allEncoded", map, "$encoded=$encoded"); | 113 test("$allEncoded=$allEncoded", map, "$encodedStr=$encodedStr"); |
114 map[unencoded] = null; | 114 map[unencodedStr] = null; |
115 test("$encoded", map); | 115 test("$encodedStr", map); |
116 map[unencoded] = ""; | 116 map[unencodedStr] = ""; |
117 test("$encoded", map); | 117 test("$encodedStr", map); |
118 } | 118 } |
119 | 119 |
120 testInvalidQueryParameters() { | 120 testInvalidQueryParameters() { |
121 test(String query, Map<String, String> parameters) { | 121 test(String query, Map<String, String> parameters) { |
122 check(uri) { | 122 check(uri) { |
123 Expect.equals(query, uri.query); | 123 Expect.equals(query, uri.query); |
124 if (query.isEmpty) { | 124 if (query.isEmpty) { |
125 Expect.equals(query, uri.toString()); | 125 Expect.equals(query, uri.toString()); |
126 } else { | 126 } else { |
127 Expect.equals("?$query", uri.toString()); | 127 Expect.equals("?$query", uri.toString()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 Expect.equals(2, map.length); | 167 Expect.equals(2, map.length); |
168 Expect.isFalse(map.isEmpty); | 168 Expect.isFalse(map.isEmpty); |
169 Expect.isTrue(map.isNotEmpty); | 169 Expect.isTrue(map.isNotEmpty); |
170 } | 170 } |
171 | 171 |
172 test(Uri.parse("?a=b&c=d").queryParameters); | 172 test(Uri.parse("?a=b&c=d").queryParameters); |
173 test(new Uri(queryParameters: {"a": "b", "c": "d"}).queryParameters); | 173 test(new Uri(queryParameters: {"a": "b", "c": "d"}).queryParameters); |
174 } | 174 } |
175 | 175 |
176 main() { | 176 main() { |
177 testInvalidArguments(); | 177 //testInvalidArguments(); |
178 testEncodeQueryComponent(); | 178 //testEncodeQueryComponent(); |
179 testQueryParameters(); | 179 testQueryParameters(); |
180 testInvalidQueryParameters(); | 180 //testInvalidQueryParameters(); |
181 testQueryParametersImmutableMap(); | 181 //testQueryParametersImmutableMap(); |
Bob Nystrom
2017/07/20 00:13:07
Oops!
bkonyi
2017/07/20 15:05:49
Oops indeed! For sure thought I had uncommented th
| |
182 } | 182 } |
OLD | NEW |