test/test_socket.rb in rbczmq-0.8 vs test/test_socket.rb in rbczmq-0.9

- old
+ new

@@ -129,10 +129,25 @@ assert(req.state & ZMQ::Socket::CONNECTED) ensure ctx.destroy end + def test_connect_all + ctx = ZMQ::Context.new + rep = ctx.socket(:PAIR) + port = rep.bind("inproc://test.socket-connect") + req = ctx.socket(:PAIR) + assert(req.state & ZMQ::Socket::PENDING) + req.connect_all("inproc://test.socket-connect") + assert req.fd != -1 + assert(req.state & ZMQ::Socket::CONNECTED) + + # TODO - test SRV lookups - insufficient infrastructure for resolver tests + ensure + ctx.destroy + end + def test_bind_connect_errors ctx = ZMQ::Context.new req = ctx.socket(:REQ) rep = ctx.socket(:REP) assert_raises Errno::EINVAL do @@ -154,10 +169,16 @@ assert(req.state & ZMQ::Socket::PENDING) req.connect("tcp://127.0.0.1:#{port}") assert_equal "PAIR socket", sock.to_s assert_equal "REP socket bound to tcp://127.0.0.1:*", rep.to_s assert_equal "REQ socket connected to tcp://127.0.0.1:#{port}", req.to_s + + + port2 = rep.bind("tcp://127.0.0.1:*") + req.connect("tcp://127.0.0.1:#{port2}") + assert_equal "REP socket bound to tcp://127.0.0.1:*, tcp://127.0.0.1:*", rep.to_s + assert_equal "REQ socket connected to tcp://127.0.0.1:#{port}, tcp://127.0.0.1:#{port2}", req.to_s ensure ctx.destroy end def test_endpoint @@ -170,10 +191,27 @@ assert_equal "tcp://127.0.0.1:#{port}", req.endpoint ensure ctx.destroy end + def test_endpoints + ctx = ZMQ::Context.new + rep = ctx.socket(:REP) + port = rep.bind("tcp://127.0.0.1:*") + req = ctx.socket(:REQ) + req.connect("tcp://127.0.0.1:#{port}") + assert_equal ["tcp://127.0.0.1:*"], rep.endpoints + assert_equal ["tcp://127.0.0.1:#{port}"], req.endpoints + + port2 = rep.bind("tcp://127.0.0.1:*") + req.connect("tcp://127.0.0.1:#{port2}") + assert_equal ["tcp://127.0.0.1:*", "tcp://127.0.0.1:*"], rep.endpoints + assert_equal ["tcp://127.0.0.1:#{port}", "tcp://127.0.0.1:#{port2}"], req.endpoints + ensure + ctx.destroy + end + def test_close ctx = ZMQ::Context.new sock = ctx.socket(:REP) port = sock.bind("tcp://127.0.0.1:*") assert sock.fd != -1 @@ -449,6 +487,6 @@ sub_sock.subscribe("ruby") sub_sock.unsubscribe("ruby") ensure ctx.destroy end -end \ No newline at end of file +end