test/test_socket.rb in rbczmq-0.9 vs test/test_socket.rb in rbczmq-1.0
- old
+ new
@@ -16,11 +16,15 @@
end
def test_send_timeout
ctx = ZMQ::Context.new
rep = ctx.socket(:REP)
- rep.hwm = 1
+ if ZMQ.version3?
+ rep.sndhwm = 1
+ else
+ rep.hwm = 1
+ end
rep.bind("inproc://test.socket-send-timeout")
req = ctx.connect(:REQ, "inproc://test.socket-send-timeout")
# Cannot test much other than normal transfer's not disrupted
req.sndtimeo = 100
req.send "msg"
@@ -406,40 +410,65 @@
ctx.destroy
end
def test_sock_options
ctx = ZMQ::Context.new
- sock = ctx.socket(:PAIR)
+ sock = ctx.socket(:ROUTER)
sock.verbose = true
- assert_equal 0, sock.hwm
- sock.hwm = 1000
- assert_equal 1000, sock.hwm
- assert_equal 0, sock.swap
- sock.swap = 1000
- assert_equal 1000, sock.swap
+ if ZMQ.version3?
+ assert_equal 1000, sock.sndhwm
+ sock.sndhwm = 10000
+ assert_equal 10000, sock.sndhwm
+ assert_equal 1000, sock.rcvhwm
+ sock.rcvhwm = 10000
+ assert_equal 10000, sock.rcvhwm
+ else
+ assert_equal 0, sock.hwm
+ sock.hwm = 1000
+ assert_equal 1000, sock.hwm
+
+ assert_equal 0, sock.swap
+ sock.swap = 1000
+ assert_equal 1000, sock.swap
+
+ assert_equal(-1, sock.recovery_ivl_msec)
+ sock.recovery_ivl_msec = 20
+ assert_equal 20, sock.recovery_ivl_msec
+ end
+
assert_equal 0, sock.affinity
sock.affinity = 1
assert_equal 1, sock.affinity
- assert_equal 40000, sock.rate
- sock.rate = 50000
- assert_equal 50000, sock.rate
+ if ZMQ.version3?
+ assert_equal 100, sock.rate
+ sock.rate = 50000
+ assert_equal 50000, sock.rate
+ else
+ assert_equal 40000, sock.rate
+ sock.rate = 50000
+ assert_equal 50000, sock.rate
+ end
- assert_equal 10, sock.recovery_ivl
- sock.recovery_ivl = 20
- assert_equal 20, sock.recovery_ivl
+ if ZMQ.version3?
+ assert_equal 10000, sock.recovery_ivl
+ sock.recovery_ivl = 20
+ assert_equal 20, sock.recovery_ivl
+ else
+ assert_equal 10, sock.recovery_ivl
+ sock.recovery_ivl = 20
+ assert_equal 20, sock.recovery_ivl
+ end
- assert_equal(-1, sock.recovery_ivl_msec)
- sock.recovery_ivl_msec = 20
- assert_equal 20, sock.recovery_ivl_msec
+ if ZMQ.version2?
+ assert_equal true, sock.mcast_loop?
+ sock.mcast_loop = false
+ assert !sock.mcast_loop?
+ end
- assert_equal true, sock.mcast_loop?
- sock.mcast_loop = false
- assert !sock.mcast_loop?
-
assert_equal 0, sock.sndbuf
sock.sndbuf = 1000
assert_equal 1000, sock.sndbuf
assert_equal 0, sock.rcvbuf
@@ -468,20 +497,24 @@
assert_equal -1, sock.sndtimeo
sock.sndtimeo = 200
assert_equal 200, sock.sndtimeo
+if sock.respond_to?(:raw=)
+ sock.raw = true
+end
+
sock.identity = "anonymous"
assert_raises ZMQ::Error do
sock.identity = ""
end
assert_raises ZMQ::Error do
sock.identity = ("*" * 256)
end
assert !sock.rcvmore?
- assert_equal 0, sock.events
+ assert_equal 2, sock.events
sub_sock = ctx.socket(:SUB)
sub_sock.verbose = true
sub_sock.subscribe("ruby")
sub_sock.unsubscribe("ruby")