Index: tests/standalone/io/internet_address_test.dart |
diff --git a/tests/standalone/io/internet_address_test.dart b/tests/standalone/io/internet_address_test.dart |
index 0e937164744e4b862fe4502d8e7123eb3a9621fd..d8a997f897067aa0bbe55d3385e292ecf4691ea3 100644 |
--- a/tests/standalone/io/internet_address_test.dart |
+++ b/tests/standalone/io/internet_address_test.dart |
@@ -32,6 +32,76 @@ void testDefaultAddresses() { |
Expect.equals("::", any6.address); |
} |
+void testConstructor() { |
+ var loopback4 = new InternetAddress("127.0.0.1"); |
+ Expect.equals(InternetAddressType.IP_V4, loopback4.type); |
+ Expect.equals("127.0.0.1", loopback4.host); |
+ Expect.equals("127.0.0.1", loopback4.address); |
+ Expect.isFalse(loopback4.isMulticast); |
+ |
+ var loopback6 = new InternetAddress("::1"); |
+ Expect.equals(InternetAddressType.IP_V6, loopback6.type); |
+ Expect.equals("::1", loopback6.host); |
+ Expect.equals("::1", loopback6.address); |
+ Expect.isFalse(loopback6.isMulticast); |
+ |
+ var ip4 = new InternetAddress("10.20.30.40"); |
+ Expect.equals(InternetAddressType.IP_V4, ip4.type); |
+ Expect.equals("10.20.30.40", ip4.host); |
+ Expect.equals("10.20.30.40", ip4.address); |
+ Expect.isFalse(ip4.isMulticast); |
+ |
+ var ip6 = new InternetAddress("10:20::30:40"); |
+ Expect.equals(InternetAddressType.IP_V6, ip6.type); |
+ Expect.equals("10:20::30:40", ip6.host); |
+ Expect.equals("10:20::30:40", ip6.address); |
+ Expect.isFalse(ip6.isMulticast); |
+ |
+ var multicast4 = new InternetAddress("224.1.2.3"); |
+ Expect.equals(InternetAddressType.IP_V4, multicast4.type); |
+ Expect.isTrue(multicast4.isMulticast); |
+ |
+ var multicast6 = new InternetAddress("FF00::1:2:3"); |
+ Expect.equals(InternetAddressType.IP_V6, multicast6.type); |
+ Expect.isTrue(multicast6.isMulticast); |
+ |
+ Expect.throws(() => new InternetAddress("1.2.3"), |
+ (e) => e is ArgumentError); |
+ Expect.throws(() => new InternetAddress("::FFFF::1"), |
+ (e) => e is ArgumentError); |
+} |
+ |
+void testEquality() { |
+ Expect.equals(new InternetAddress("127.0.0.1"), |
+ new InternetAddress("127.0.0.1")); |
+ Expect.equals(new InternetAddress("127.0.0.1"), |
+ InternetAddress.LOOPBACK_IP_V4); |
+ Expect.equals(new InternetAddress("::1"), |
+ new InternetAddress("::1")); |
+ Expect.equals(new InternetAddress("::1"), |
+ InternetAddress.LOOPBACK_IP_V6); |
+ Expect.equals(new InternetAddress("1:2:3:4:5:6:7:8"), |
+ new InternetAddress("1:2:3:4:5:6:7:8")); |
+ Expect.equals(new InternetAddress("1::2"), |
+ new InternetAddress("1:0:0:0:0:0:0:2")); |
+ Expect.equals(new InternetAddress("::FFFF:0:0:16.32.48.64"), |
+ new InternetAddress("::FFFF:0:0:1020:3040")); |
+ |
+ var set = new Set(); |
+ set.add(new InternetAddress("127.0.0.1")); |
+ set.add(new InternetAddress("::1")); |
+ set.add(new InternetAddress("1:2:3:4:5:6:7:8")); |
+ Expect.isTrue(set.contains(new InternetAddress("127.0.0.1"))); |
+ Expect.isTrue(set.contains(InternetAddress.LOOPBACK_IP_V4)); |
+ Expect.isFalse(set.contains(new InternetAddress("127.0.0.2"))); |
+ Expect.isTrue(set.contains(new InternetAddress("::1"))); |
+ Expect.isTrue(set.contains(InternetAddress.LOOPBACK_IP_V6)); |
+ Expect.isFalse(set.contains(new InternetAddress("::2"))); |
+ Expect.isTrue(set.contains(new InternetAddress("1:2:3:4:5:6:7:8"))); |
+ Expect.isFalse(set.contains(new InternetAddress("1:2:3:4:5:6:7:9"))); |
+ Expect.isFalse(set.contains(new InternetAddress("0:2:3:4:5:6:7:8"))); |
+} |
+ |
void testLookup() { |
InternetAddress.lookup("127.0.0.1").then((addresses) { |
Expect.equals(1, addresses.length); |
@@ -62,6 +132,8 @@ void testReverseLookup() { |
void main() { |
testDefaultAddresses(); |
+ testConstructor(); |
+ testEquality(); |
testLookup(); |
testReverseLookup(); |
} |