Skip to content

Commit 3a68cf0

Browse files
committed
added tests
1 parent 375d8b4 commit 3a68cf0

File tree

3 files changed

+55
-89
lines changed

3 files changed

+55
-89
lines changed

src/zlib_tiny/core.clj

Lines changed: 0 additions & 89 deletions
This file was deleted.

test/zlib_tiny/checksum.clj

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(ns zlib-tiny.checksum
2+
(:require [clojure.test :refer :all]
3+
[zlib-tiny.core :refer :all])
4+
(:import (org.apache.commons.codec.binary Hex)))
5+
6+
(def test-string "test it!")
7+
8+
(deftest checksums
9+
(testing "CRC32"
10+
(is (= 3421780262 (crc32 (.getBytes "123456789")))))
11+
(testing "CRC64"
12+
(is (= -7395533204333446662 (crc64 (.getBytes "123456789"))))))
13+
14+
(deftest digests
15+
(testing "MD5"
16+
(is (= "f4214812f0247f69661fd29e0fca6496" (-> test-string
17+
str->bytes
18+
md5
19+
Hex/encodeHex
20+
(String.)))))
21+
(testing "SHA1"
22+
(is (= "1393ce5dfcf39109a420eb583ecfdeacc28c783a"
23+
(-> test-string
24+
str->bytes
25+
sha-1
26+
Hex/encodeHex
27+
(String.)))))
28+
(testing "SHA256"
29+
(is (= "9c507d01834b2749d088122a7b3d200957f9b25579b5ce6b490e3b2067ee4f66"
30+
(-> test-string
31+
str->bytes
32+
sha-256
33+
Hex/encodeHex
34+
(String.))))))

test/zlib_tiny/compress.clj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(ns zlib-tiny.compress
2+
(:require [clojure.test :refer :all]
3+
[zlib-tiny.core :refer :all]))
4+
5+
(def test-string "test it!")
6+
7+
(deftest compressors
8+
(testing "Checking ZLib"
9+
(is (= test-string (-> test-string
10+
str->bytes
11+
deflate
12+
inflate
13+
force-byte-array
14+
bytes->str))))
15+
16+
(testing "Checking GZip"
17+
(is (= test-string (-> test-string
18+
str->bytes
19+
gzip
20+
gunzip
21+
bytes->str)))))

0 commit comments

Comments
 (0)