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

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

Issue 23904004: Accept IPv6 addresses in Uri.http and Uri.https, and correctly nest IPv6 addresses in '[' and ']'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixing comments. Created 7 years, 3 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 | « tests/corelib/uri_ipv4_test.dart ('k') | no next file » | 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 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 6
7 7
8 void testValidIpv6Uri() { 8 void testValidIpv6Uri() {
9 var path = 'http://[::1]:1234/path?query=5#now'; 9 var path = 'http://[::1]:1234/path?query=5#now';
10 var uri = Uri.parse(path); 10 var uri = Uri.parse(path);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 path = 'http://[2010:836B:4179::836B:4179]'; 101 path = 'http://[2010:836B:4179::836B:4179]';
102 uri = Uri.parse(path); 102 uri = Uri.parse(path);
103 Expect.equals('http', uri.scheme); 103 Expect.equals('http', uri.scheme);
104 Expect.equals('2010:836B:4179::836B:4179', uri.host); 104 Expect.equals('2010:836B:4179::836B:4179', uri.host);
105 Expect.equals(0, uri.port); 105 Expect.equals(0, uri.port);
106 Expect.equals('', uri.path); 106 Expect.equals('', uri.path);
107 Expect.equals(path, uri.toString()); 107 Expect.equals(path, uri.toString());
108 } 108 }
109 109
110
111 void testParseIPv6Address() {
112 void pass(String host, List<int> expected) {
113 Expect.listEquals(expected, Uri.parseIPv6Address(host));
114 }
115 void fail(String host) {
116 Expect.throws(() => Uri.parseIPv6Address(host),
117 (e) => e is FormatException);
118 }
119
120 pass('::127.0.0.1', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 1]);
121 pass('0::127.0.0.1', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 1]);
122 pass('::', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
123 pass('0::', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
124 fail(':0::127.0.0.1');
125 fail('0:::');
126 fail(':::');
127 fail('::0:');
128 fail('::0::');
129 fail('::0::0');
130 fail('00000::0');
131 fail('-1::0');
132 fail('-AAA::0');
133 fail('0::127.0.0.1:0');
134 fail('0::127.0.0');
135 pass('0::1111', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17]);
136 pass('2010:836B:4179::836B:4179',
137 [32, 16, 131, 107, 65, 121, 0, 0, 0, 0, 0, 0, 131, 107, 65, 121] );
138 fail('2010:836B:4179:0000:127.0.0.1');
139 fail('2010:836B:4179:0000:0000:127.0.0.1');
140 fail('2010:836B:4179:0000:0000:0000::127.0.0.1');
141 fail('2010:836B:4179:0000:0000:0000:0000:127.0.0.1');
142 pass('2010:836B:4179:0000:0000:0000:127.0.0.1',
143 [32, 16, 131, 107, 65, 121, 0, 0, 0, 0, 0, 0, 127, 0, 0, 1] );
144 }
145
146
110 void main() { 147 void main() {
111 testValidIpv6Uri(); 148 testValidIpv6Uri();
149 testParseIPv6Address();
112 } 150 }
113 151
OLDNEW
« no previous file with comments | « tests/corelib/uri_ipv4_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698