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

Side by Side Diff: tests/standalone/io/url_encoding_test.dart

Issue 11659009: Reapply "Fix URI encoding/decoding of + and space"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated tests Created 7 years, 12 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/uri/encode_decode.dart ('k') | tests/utils/uri_test.dart » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "dart:utf"; 5 import "dart:utf";
6 part "../../../sdk/lib/io/input_stream.dart"; 6 part "../../../sdk/lib/io/input_stream.dart";
7 part "../../../sdk/lib/io/output_stream.dart"; 7 part "../../../sdk/lib/io/output_stream.dart";
8 part "../../../sdk/lib/io/chunked_stream.dart"; 8 part "../../../sdk/lib/io/chunked_stream.dart";
9 part "../../../sdk/lib/io/string_stream.dart"; 9 part "../../../sdk/lib/io/string_stream.dart";
10 part "../../../sdk/lib/io/stream_util.dart"; 10 part "../../../sdk/lib/io/stream_util.dart";
11 part "../../../sdk/lib/io/http.dart"; 11 part "../../../sdk/lib/io/http.dart";
12 part "../../../sdk/lib/io/http_impl.dart"; 12 part "../../../sdk/lib/io/http_impl.dart";
13 part "../../../sdk/lib/io/http_parser.dart"; 13 part "../../../sdk/lib/io/http_parser.dart";
14 part "../../../sdk/lib/io/http_utils.dart"; 14 part "../../../sdk/lib/io/http_utils.dart";
15 15
16 void testParseEncodedString() { 16 void testParseEncodedString() {
17 String encodedString = 'foo+bar%20foobar%25%26'; 17 String encodedString = 'foo+bar%20foobar%25%26';
18 Expect.equals(_HttpUtils.decodeUrlEncodedString(encodedString), 18 Expect.equals(_HttpUtils.decodeUrlEncodedString(encodedString),
19 'foo bar foobar%&'); 19 'foo bar foobar%&');
20 encodedString = 'A+%2B+B';
21 Expect.equals(_HttpUtils.decodeUrlEncodedString(encodedString),
22 'A + B');
20 } 23 }
21 24
22 void testParseQueryString() { 25 void testParseQueryString() {
23 // The query string includes escaped "?"s, "&"s, "%"s and "="s. 26 // The query string includes escaped "?"s, "&"s, "%"s and "="s.
24 // These should not affect the splitting of the string. 27 // These should not affect the splitting of the string.
25 String queryString = 28 String queryString =
26 '%3F=%3D&foo=bar&%26=%25&sqrt2=%E2%88%9A2&name=Franti%C5%A1ek'; 29 '%3F=%3D&foo=bar&%26=%25&sqrt2=%E2%88%9A2&name=Franti%C5%A1ek';
27 Map<String, String> map = _HttpUtils.splitQueryString(queryString); 30 Map<String, String> map = _HttpUtils.splitQueryString(queryString);
28 for (String key in map.keys) { 31 for (String key in map.keys) {
29 Expect.equals(map[key], { '&' : '%', 32 Expect.equals(map[key], { '&' : '%',
30 'foo' : 'bar', 33 'foo' : 'bar',
31 '?' : '=', 34 '?' : '=',
32 'sqrt2' : '\u221A2', 35 'sqrt2' : '\u221A2',
33 'name' : 'Franti\u0161ek'}[key]); 36 'name' : 'Franti\u0161ek'}[key]);
34 } 37 }
35 Expect.setEquals(map.keys, ['&', '?', 'foo', 'sqrt2', 'name']); 38 Expect.setEquals(map.keys, ['&', '?', 'foo', 'sqrt2', 'name']);
36 } 39 }
37 40
38 void main() { 41 void main() {
39 testParseEncodedString(); 42 testParseEncodedString();
40 testParseQueryString(); 43 testParseQueryString();
41 } 44 }
OLDNEW
« no previous file with comments | « sdk/lib/uri/encode_decode.dart ('k') | tests/utils/uri_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698