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

Side by Side Diff: tests/standalone/io/internet_address_test.dart

Issue 101913008: Add argument checking to InternetAddress constructor (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | « runtime/bin/socket_patch.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) 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
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 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698