OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'package:expect/expect.dart'; |
| 6 import 'dart:uri'; |
| 7 |
| 8 |
| 9 void testValidIpv6Uri() { |
| 10 var path = 'http://[::1]:1234/path?query=5#now'; |
| 11 var uri = Uri.parse(path); |
| 12 Expect.equals('http', uri.scheme); |
| 13 Expect.equals('::1', uri.domain); |
| 14 Expect.equals(1234, uri.port); |
| 15 Expect.equals('/path', uri.path); |
| 16 Expect.equals('query=5', uri.query); |
| 17 Expect.equals('now', uri.fragment); |
| 18 Expect.equals(path, uri.toString()); |
| 19 |
| 20 path = 'http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html'; |
| 21 uri = Uri.parse(path); |
| 22 Expect.equals('http', uri.scheme); |
| 23 Expect.equals('FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', uri.domain); |
| 24 Expect.equals(80, uri.port); |
| 25 Expect.equals('/index.html', uri.path); |
| 26 Expect.equals(path, uri.toString()); |
| 27 |
| 28 path = 'http://[1080:0:0:0:8:800:200C:417A]/index.html'; |
| 29 uri = Uri.parse(path); |
| 30 Expect.equals('http', uri.scheme); |
| 31 Expect.equals('1080:0:0:0:8:800:200C:417A', uri.domain); |
| 32 Expect.equals(0, uri.port); |
| 33 Expect.equals('/index.html', uri.path); |
| 34 Expect.equals(path, uri.toString()); |
| 35 |
| 36 path = 'http://[3ffe:2a00:100:7031::1]'; |
| 37 uri = Uri.parse(path); |
| 38 Expect.equals('http', uri.scheme); |
| 39 Expect.equals('3ffe:2a00:100:7031::1', uri.domain); |
| 40 Expect.equals(0, uri.port); |
| 41 Expect.equals('', uri.path); |
| 42 Expect.equals(path, uri.toString()); |
| 43 |
| 44 path = 'http://[1080::8:800:200C:417A]/foo'; |
| 45 uri = Uri.parse(path); |
| 46 Expect.equals('http', uri.scheme); |
| 47 Expect.equals('1080::8:800:200C:417A', uri.domain); |
| 48 Expect.equals(0, uri.port); |
| 49 Expect.equals('/foo', uri.path); |
| 50 Expect.equals(path, uri.toString()); |
| 51 |
| 52 path = 'http://[::192.9.5.5]/ipng'; |
| 53 uri = Uri.parse(path); |
| 54 Expect.equals('http', uri.scheme); |
| 55 Expect.equals('::192.9.5.5', uri.domain); |
| 56 Expect.equals(0, uri.port); |
| 57 Expect.equals('/ipng', uri.path); |
| 58 Expect.equals(path, uri.toString()); |
| 59 |
| 60 path = 'http://[::FFFF:129.144.52.38]:80/index.html'; |
| 61 uri = Uri.parse(path); |
| 62 Expect.equals('http', uri.scheme); |
| 63 Expect.equals('::FFFF:129.144.52.38', uri.domain); |
| 64 Expect.equals(80, uri.port); |
| 65 Expect.equals('/index.html', uri.path); |
| 66 Expect.equals(path, uri.toString()); |
| 67 |
| 68 path = 'http://[2010:836B:4179::836B:4179]'; |
| 69 uri = Uri.parse(path); |
| 70 Expect.equals('http', uri.scheme); |
| 71 Expect.equals('2010:836B:4179::836B:4179', uri.domain); |
| 72 Expect.equals(0, uri.port); |
| 73 Expect.equals('', uri.path); |
| 74 Expect.equals(path, uri.toString()); |
| 75 } |
| 76 |
| 77 void main() { |
| 78 testValidIpv6Uri(); |
| 79 } |
| 80 |
OLD | NEW |