Browse Source

added a test for Socket.bind()

Alexander Kuzmenko 8 years ago
parent
commit
e79f5a072e
2 changed files with 30 additions and 0 deletions
  1. 1 0
      tests/sys/src/Main.hx
  2. 29 0
      tests/sys/src/net/TestSocket.hx

+ 1 - 0
tests/sys/src/Main.hx

@@ -9,6 +9,7 @@ class Main {
 		runner.addCase(new io.TestFile());
 		runner.addCase(new io.TestFileInput());
 		runner.addCase(new io.TestProcess());
+		runner.addCase(new net.TestSocket());
 		Report.create(runner);
 		runner.run();
 	}

+ 29 - 0
tests/sys/src/net/TestSocket.hx

@@ -0,0 +1,29 @@
+package net;
+
+import sys.net.*;
+import utest.Assert;
+
+class TestSocket {
+	var registeredSockets:Array<Socket> = [];
+
+	public function register<T:Socket>(socket:T):T {
+		registeredSockets.push(socket);
+		return socket;
+	}
+
+	public function tearDown() {
+		for(socket in registeredSockets) {
+			if(socket == null) continue;
+			socket.close();
+		}
+		registeredSockets = [];
+	}
+
+	public function new() { }
+
+	public function testBind() {
+		var socket = register(new Socket());
+		socket.bind(new Host('localhost'), 34567);
+		Assert.pass();
+	}
+}