Skip to content

Commit 7b9cc1b

Browse files
committed
multiple-arity round-trip to account for compat
1 parent 99186bb commit 7b9cc1b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/msgpack/core_test.clj

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@
3636
(defn- ext [type bytes]
3737
(msg/->Ext type (unsigned-byte-array bytes)))
3838

39-
(defmacro round-trip [obj expected-bytes]
40-
`(let [obj# ~obj
41-
expected-bytes# (unsigned-bytes ~expected-bytes)]
42-
(is (= expected-bytes# (seq (msg/pack obj#))))
43-
(is (= (normalize obj#) (normalize (msg/unpack expected-bytes#))))))
39+
(defn- round-trip-helper
40+
([obj expected-bytes] (round-trip-helper obj expected-bytes expected-bytes))
41+
([obj expected-bytes expected-compat-bytes]
42+
`(let [obj# ~obj
43+
expected-bytes# (unsigned-bytes (if (msg/get-compatibility-mode)
44+
~expected-compat-bytes
45+
~expected-bytes))]
46+
(is (= expected-bytes# (seq (msg/pack obj#))))
47+
(is (= (normalize obj#) (normalize (msg/unpack expected-bytes#)))))))
48+
49+
(defmacro round-trip [& args] (apply round-trip-helper args))
4450

4551
(deftest nil-test
4652
(testing "nil"

0 commit comments

Comments
 (0)