Skip to content
Browse files

wrap zmq_msg_move()

  • Loading branch information...
1 parent cef29b4 commit 28ddd4edd7bceee9bb8a11d0ef71858aef4331b5 @galdor galdor committed Oct 6, 2011
Showing with 22 additions and 1 deletion.
  1. +1 −1 src/packages.lisp
  2. +5 −0 src/zmq.lisp
  3. +16 −0 test/main.lisp
View
2 src/packages.lisp
@@ -15,7 +15,7 @@
:msg-init :msg-init-size :msg-init-data :msg-close
:with-msg-init :with-msg-init-size :with-msg-init-data
:msg-size :msg-data :msg-data-string :msg-data-array
- :msg-copy
+ :msg-copy :msg-move
:send :recv
:with-poll-items
View
5 src/zmq.lisp
@@ -319,6 +319,11 @@ using the character coding schema ENCODING."
"Copy the content of the message SOURCE to the message DESTINATION."
(call-ffi -1 '%msg-copy destination source))
+(defun msg-move (destination source)
+ "Move the content of the message SOURCE to the message DESTINATION. After
+the call, SOURCE is an empty message."
+ (call-ffi -1 '%msg-move destination source))
+
(defun send (socket message &optional flags)
"Queue MESSAGE to be on SOCKET."
(call-ffi -1 '%send socket message
View
16 test/main.lisp
@@ -71,6 +71,22 @@
(is (string= (zmq:msg-data-string msg-copy) ""))
(is (equalp (zmq:msg-data-array msg-copy) (byte-array #()))))))
+(test moved-message
+ (zmq:with-msg-init-data (msg "test")
+ (zmq:with-msg-init (new-msg)
+ (zmq:msg-move new-msg msg)
+ (is (= (zmq:msg-size new-msg) 4))
+ (is (zerop (zmq:msg-size msg)))
+ (is (string= (zmq:msg-data-string new-msg) "test")))))
+
+(test moved-empty-message
+ (zmq:with-msg-init-data (msg "")
+ (zmq:with-msg-init (new-msg)
+ (zmq:msg-move new-msg msg)
+ (is (zerop (zmq:msg-size new-msg)))
+ (is (zerop (zmq:msg-size msg)))
+ (is (string= (zmq:msg-data-string new-msg) "")))))
+
(test int-socket-options
(zmq:with-context (context 0)
(zmq:with-socket (socket context :sub)

0 comments on commit 28ddd4e

Please sign in to comment.
Something went wrong with that request. Please try again.