* Add tests for markdown-clj and tools.namespace
See comment for why only one markdown test could be run.
Closes #1069 and #1064
* Convert 10 test libs using add-libtest
Also improved add-libtest to only require maven artifact
and rely on clojars for getting git-url most of the time
* Convert 8 more test libs using add-libtest
Also updated table and added comment for newline test
* Fix doric test
* Disable tools.namespace test that fails on windows
* Added dozen manual test libs and converted 2 test libs
add-libtest.clj supports manually-added and test-directories options
* Converts last tests to test namespaces and write libraries.csv
* Add a number of library tests from projects.md
Also add more docs around adding test libs and tweak add script
* Use :sha for gitlib and older clojure cli
* Revert "Use :sha for gitlib and older clojure cli"
This reverts commit c663ab8368.
* Fix and disable failing tests
Disabled tests that fail consistently and fixed windows one
52 lines
1.6 KiB
Clojure
52 lines
1.6 KiB
Clojure
(ns io.aviso.binary-test
|
|
"Tests for the io.aviso.binary namespace."
|
|
(:use io.aviso.binary
|
|
clojure.test)
|
|
(:import (java.nio ByteBuffer)))
|
|
|
|
(defn ^:private format-string-as-byte-array [str]
|
|
(format-binary (.getBytes str)))
|
|
|
|
(deftest format-byte-array-test
|
|
|
|
(are [input expected]
|
|
(= expected (format-string-as-byte-array input))
|
|
|
|
"Hello" "0000: 48 65 6C 6C 6F\n"
|
|
|
|
"This is a longer text that spans to a second line."
|
|
"0000: 54 68 69 73 20 69 73 20 61 20 6C 6F 6E 67 65 72 20 74 65 78 74 20 74 68 61 74 20 73 70 61 6E 73\n0020: 20 74 6F 20 61 20 73 65 63 6F 6E 64 20 6C 69 6E 65 2E\n"))
|
|
|
|
(deftest format-string-as-byte-data
|
|
(are [input expected]
|
|
(= expected (format-binary input))
|
|
"" ""
|
|
|
|
"Hello" "0000: 48 65 6C 6C 6F\n"
|
|
|
|
"This is a longer text that spans to a second line."
|
|
|
|
"0000: 54 68 69 73 20 69 73 20 61 20 6C 6F 6E 67 65 72 20 74 65 78 74 20 74 68 61 74 20 73 70 61 6E 73\n0020: 20 74 6F 20 61 20 73 65 63 6F 6E 64 20 6C 69 6E 65 2E\n"))
|
|
|
|
(deftest nil-is-an-empty-data
|
|
(is (= (format-binary nil) "")))
|
|
|
|
(deftest byte-buffer
|
|
(let [bb (ByteBuffer/wrap (.getBytes "Duty Now For The Future" "UTF-8"))]
|
|
(is (= "0000: 44 75 74 79 20 4E 6F 77 20 46 6F 72 20 54 68 65 20 46 75 74 75 72 65\n"
|
|
(format-binary bb)))
|
|
|
|
(is (= "0000: 44 75 74 79\n"
|
|
(-> bb
|
|
(.position 5)
|
|
(.limit 9)
|
|
format-binary)))
|
|
|
|
(is (= "0000: 46 6F 72\n"
|
|
(-> bb
|
|
(.position 9)
|
|
(.limit 12)
|
|
.slice
|
|
format-binary)))
|
|
|
|
))
|