| OLD | NEW |
| 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 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 | 8 |
| 9 void testIllegalArguments() { |
| 10 var args = [ |
| 11 null, 1, 1.1, new Object(), [], {'a' : '127.0.0.1'}, |
| 12 "", "." , ":", ":::"]; |
| 13 args.forEach((arg) { |
| 14 Expect.throws(() => new InternetAddress(arg), |
| 15 (e) => e is ArgumentError); |
| 16 }); |
| 17 } |
| 18 |
| 9 void testDefaultAddresses() { | 19 void testDefaultAddresses() { |
| 10 var loopback4 = InternetAddress.LOOPBACK_IP_V4; | 20 var loopback4 = InternetAddress.LOOPBACK_IP_V4; |
| 11 Expect.isNotNull(loopback4); | 21 Expect.isNotNull(loopback4); |
| 12 Expect.equals(InternetAddressType.IP_V4, loopback4.type); | 22 Expect.equals(InternetAddressType.IP_V4, loopback4.type); |
| 13 Expect.equals("127.0.0.1", loopback4.host); | 23 Expect.equals("127.0.0.1", loopback4.host); |
| 14 Expect.equals("127.0.0.1", loopback4.address); | 24 Expect.equals("127.0.0.1", loopback4.address); |
| 15 | 25 |
| 16 var loopback6 = InternetAddress.LOOPBACK_IP_V6; | 26 var loopback6 = InternetAddress.LOOPBACK_IP_V6; |
| 17 Expect.isNotNull(loopback6); | 27 Expect.isNotNull(loopback6); |
| 18 Expect.equals(InternetAddressType.IP_V6, loopback6.type); | 28 Expect.equals(InternetAddressType.IP_V6, loopback6.type); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 InternetAddress.lookup('127.0.0.1').then((addrs) { | 134 InternetAddress.lookup('127.0.0.1').then((addrs) { |
| 125 Expect.equals('127.0.0.1', addrs.first.host); | 135 Expect.equals('127.0.0.1', addrs.first.host); |
| 126 addrs.first.reverse().then((addr) { | 136 addrs.first.reverse().then((addr) { |
| 127 Expect.isNotNull(addr.host); | 137 Expect.isNotNull(addr.host); |
| 128 Expect.notEquals('127.0.0.1', addr.host); | 138 Expect.notEquals('127.0.0.1', addr.host); |
| 129 }); | 139 }); |
| 130 }); | 140 }); |
| 131 } | 141 } |
| 132 | 142 |
| 133 void main() { | 143 void main() { |
| 144 testIllegalArguments(); |
| 134 testDefaultAddresses(); | 145 testDefaultAddresses(); |
| 135 testConstructor(); | 146 testConstructor(); |
| 136 testEquality(); | 147 testEquality(); |
| 137 testLookup(); | 148 testLookup(); |
| 138 testReverseLookup(); | 149 testReverseLookup(); |
| 139 } | 150 } |
| OLD | NEW |