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

Side by Side Diff: tests/corelib/uri_query_test.dart

Issue 16812004: Make some HTTP utility functions public (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: One more status file update Created 7 years, 6 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 | « sdk/lib/io/http_utils.dart ('k') | tests/lib/analyzer/analyze_tests.status » ('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) 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 11 matching lines...) Expand all
22 test(String query, Map<String, String> parameters, [String normalizedQuery]) { 22 test(String query, Map<String, String> parameters, [String normalizedQuery]) {
23 if (normalizedQuery == null) normalizedQuery = query; 23 if (normalizedQuery == null) normalizedQuery = query;
24 check(uri) { 24 check(uri) {
25 Expect.equals(normalizedQuery, uri.query); 25 Expect.equals(normalizedQuery, uri.query);
26 if (query.isEmpty) { 26 if (query.isEmpty) {
27 Expect.equals(normalizedQuery, uri.toString()); 27 Expect.equals(normalizedQuery, uri.toString());
28 } else { 28 } else {
29 Expect.equals("?$normalizedQuery", uri.toString()); 29 Expect.equals("?$normalizedQuery", uri.toString());
30 } 30 }
31 if (parameters.containsValue(null)) { 31 if (parameters.containsValue(null)) {
32 var map = new Map.from(parameters);
33 map.forEach((k, v) { if (v == null) map[k] = ""; });
34 Expect.mapEquals(map, uri.queryParameters);
32 } else { 35 } else {
33 Expect.mapEquals(parameters, uri.queryParameters); 36 Expect.mapEquals(parameters, uri.queryParameters);
34 } 37 }
35 } 38 }
36 39
37 var uri1 = new Uri(queryParameters: parameters); 40 var uri1 = new Uri(queryParameters: parameters);
38 var uri2 = new Uri(query: query); 41 var uri2 = new Uri(query: query);
39 var uri3 = Uri.parse("?$query"); 42 var uri3 = Uri.parse("?$query");
40 check(uri1); 43 check(uri1);
41 check(uri2); 44 check(uri2);
42 check(uri3); 45 check(uri3);
43 Expect.equals(uri1, uri3); 46 Expect.equals(uri1, uri3);
44 Expect.equals(uri2, uri3); 47 Expect.equals(uri2, uri3);
48 if (parameters.containsValue(null)) {
49 var map = new Map.from(parameters);
50 map.forEach((k, v) { if (v == null) map[k] = ""; });
51 Expect.mapEquals(map, Uri.splitQueryString(query));
52 } else {
53 Expect.mapEquals(parameters, Uri.splitQueryString(query));
54 }
45 } 55 }
46 56
47 test("", {}); 57 test("", {});
48 test("A", {"A": null}); 58 test("A", {"A": null});
49 test("%25", {"%": null}); 59 test("%25", {"%": null});
50 test("%41", {"A": null}, "A"); 60 test("%41", {"A": null}, "A");
51 test("%41A", {"AA": null}, "AA"); 61 test("%41A", {"AA": null}, "AA");
52 test("A", {"A": ""}); 62 test("A", {"A": ""});
53 test("%25", {"%": ""}); 63 test("%25", {"%": ""});
54 test("%41", {"A": ""}, "A"); 64 test("%41", {"A": ""}, "A");
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 test(new Uri(queryParameters: {"a": "b", "c": "d"}).queryParameters); 170 test(new Uri(queryParameters: {"a": "b", "c": "d"}).queryParameters);
161 } 171 }
162 172
163 main() { 173 main() {
164 testInvalidArguments(); 174 testInvalidArguments();
165 testEncodeQueryComponent(); 175 testEncodeQueryComponent();
166 testQueryParameters(); 176 testQueryParameters();
167 testInvalidQueryParameters(); 177 testInvalidQueryParameters();
168 testQueryParametersImmutableMap(); 178 testQueryParametersImmutableMap();
169 } 179 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_utils.dart ('k') | tests/lib/analyzer/analyze_tests.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698