Skip to content

Commit

Permalink
Add tests for byte buffer wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
athos committed Nov 13, 2023
1 parent 07a16f7 commit 8a615ab
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/cljam/io/util/byte_buffer_test.clj
Original file line number Diff line number Diff line change
@@ -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)))))

0 comments on commit 8a615ab

Please sign in to comment.