diff --git a/test/cljam/io/util/byte_buffer_test.clj b/test/cljam/io/util/byte_buffer_test.clj new file mode 100644 index 00000000..ae8d8391 --- /dev/null +++ b/test/cljam/io/util/byte_buffer_test.clj @@ -0,0 +1,27 @@ +(ns cljam.io.util.byte-buffer-test + (:require [clojure.test :refer [deftest is]] + [cljam.io.util.byte-buffer :as bb])) + +(deftest make-lsb-byte-buffer-test + (let [bb (bb/make-lsb-byte-buffer (byte-array [0x01 0x23 0x45 0x67]))] + (is (= 0x67452301 (.getInt bb))))) + +(deftest make-msb-byte-buffer-test + (let [bb (bb/make-msb-byte-buffer (byte-array [0x01 0x23 0x45 0x67]))] + (is (= 0x01234567 (.getInt bb))))) + +(deftest allocate-lsb-byte-buffer-test + (let [bb (doto (bb/allocate-lsb-byte-buffer 8) + (.mark) + (.putLong 0x789ABCDEF0123456) + (.reset))] + (is (= (int 0xF0123456) (.getInt bb))) + (is (= (int 0x789ABCDE) (.getInt bb))))) + +(deftest allocate-msb-byte-buffer-test + (let [bb (doto (bb/allocate-msb-byte-buffer 8) + (.mark) + (.putLong 0x789ABCDEF0123456) + (.reset))] + (is (= (int 0x789ABCDE) (.getInt bb))) + (is (= (int 0xF0123456) (.getInt bb)))))