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

Unified Diff: tests/standalone/io/socket_ipv6_test.dart

Issue 14083007: Add new InternetAddress class with a static lookup function (including IPv6 results). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add Windows support and update ssl tests to use 'localhost'. Created 7 years, 8 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
Index: tests/standalone/io/socket_ipv6_test.dart
diff --git a/tests/standalone/io/socket_ipv6_test.dart b/tests/standalone/io/socket_ipv6_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4fe64f7cd1e62c53f74733f8832956ef6217e1b9
--- /dev/null
+++ b/tests/standalone/io/socket_ipv6_test.dart
@@ -0,0 +1,88 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:io';
+import 'dart:isolate';
+
+void testIPv6toIPv6() {
+ ServerSocket.bind("::0").then((server) {
+ server.listen((socket) {
+ socket.destroy();
+ server.close();
+ });
+ Socket.connect("::1", server.port).then((socket) {
+ socket.destroy();
+ });
+ });
+}
+
+void testIPv4toIPv6() {
+ ServerSocket.bind("::0").then((server) {
+ server.listen((socket) {
+ socket.destroy();
+ server.close();
+ });
+ Socket.connect("127.0.0.1", server.port).then((socket) {
+ socket.destroy();
+ });
+ });
+}
+
+void testIPv6toIPv4() {
+ ServerSocket.bind("127.0.0.1").then((server) {
+ server.listen((socket) {
+ throw "Unexpected socket";
+ });
+ Socket.connect("::1", server.port).catchError((e) {
+ server.close();
+ });
+ });
+}
+
+void testIPv4toIPv4() {
+ ServerSocket.bind("127.0.0.1").then((server) {
+ server.listen((socket) {
+ socket.destroy();
+ server.close();
+ });
+ Socket.connect("127.0.0.1", server.port).then((socket) {
+ socket.destroy();
+ });
+ });
+}
+
+void testIPv6Lookup() {
+ var port = new ReceivePort();
+ InternetAddress.lookup("::0").then((list) {
+ if (list.length < 0) throw "no addresse";
+ for (var entry in list) {
+ if (entry.type != InternetAddressType.IPv6) {
+ throw "Wrong IP type";
+ }
+ }
+ port.close();
+ });
+}
+
+void testIPv4Lookup() {
+ var port = new ReceivePort();
+ InternetAddress.lookup("127.0.0.1").then((list) {
+ if (list.length < 0) throw "no addresse";
Søren Gjesse 2013/04/22 15:02:08 addresse -> address
Anders Johnsen 2013/04/23 08:03:57 Done.
+ for (var entry in list) {
+ if (entry.type != InternetAddressType.IPv4) {
+ throw "Wrong IP type";
+ }
+ }
+ port.close();
+ });
+}
+
+void main() {
+ testIPv6toIPv6();
+ testIPv4toIPv6();
+ testIPv6toIPv4();
+ testIPv4toIPv4();
+ testIPv6Lookup();
+ testIPv4Lookup();
+}

Powered by Google App Engine
This is Rietveld 408576698