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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/corelib/uri_ipv4_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/uri_ipv6_test.dart
diff --git a/tests/corelib/uri_ipv6_test.dart b/tests/corelib/uri_ipv6_test.dart
index 1ec9d57589776d58c59ef1e3b272ccd03347c0bb..c5f105f7101c6e7a1cf3788752efdc7f717c97c3 100644
--- a/tests/corelib/uri_ipv6_test.dart
+++ b/tests/corelib/uri_ipv6_test.dart
@@ -107,7 +107,45 @@ void testValidIpv6Uri() {
Expect.equals(path, uri.toString());
}
+
+void testParseIPv6Address() {
+ void pass(String host, List<int> expected) {
+ Expect.listEquals(expected, Uri.parseIPv6Address(host));
+ }
+ void fail(String host) {
+ Expect.throws(() => Uri.parseIPv6Address(host),
+ (e) => e is FormatException);
+ }
+
+ pass('::127.0.0.1', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 1]);
+ pass('0::127.0.0.1', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 1]);
+ pass('::', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
+ pass('0::', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
+ fail(':0::127.0.0.1');
+ fail('0:::');
+ fail(':::');
+ fail('::0:');
+ fail('::0::');
+ fail('::0::0');
+ fail('00000::0');
+ fail('-1::0');
+ fail('-AAA::0');
+ fail('0::127.0.0.1:0');
+ fail('0::127.0.0');
+ pass('0::1111', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17]);
+ pass('2010:836B:4179::836B:4179',
+ [32, 16, 131, 107, 65, 121, 0, 0, 0, 0, 0, 0, 131, 107, 65, 121] );
+ fail('2010:836B:4179:0000:127.0.0.1');
+ fail('2010:836B:4179:0000:0000:127.0.0.1');
+ fail('2010:836B:4179:0000:0000:0000::127.0.0.1');
+ fail('2010:836B:4179:0000:0000:0000:0000:127.0.0.1');
+ pass('2010:836B:4179:0000:0000:0000:127.0.0.1',
+ [32, 16, 131, 107, 65, 121, 0, 0, 0, 0, 0, 0, 127, 0, 0, 1] );
+}
+
+
void main() {
testValidIpv6Uri();
+ testParseIPv6Address();
}
« 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