Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
source-c committed Jul 31, 2021
1 parent 375d8b4 commit 3a68cf0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 89 deletions.
89 changes: 0 additions & 89 deletions src/zlib_tiny/core.clj

This file was deleted.

34 changes: 34 additions & 0 deletions test/zlib_tiny/checksum.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(ns zlib-tiny.checksum
(:require [clojure.test :refer :all]
[zlib-tiny.core :refer :all])
(:import (org.apache.commons.codec.binary Hex)))

(def test-string "test it!")

(deftest checksums
(testing "CRC32"
(is (= 3421780262 (crc32 (.getBytes "123456789")))))
(testing "CRC64"
(is (= -7395533204333446662 (crc64 (.getBytes "123456789"))))))

(deftest digests
(testing "MD5"
(is (= "f4214812f0247f69661fd29e0fca6496" (-> test-string
str->bytes
md5
Hex/encodeHex
(String.)))))
(testing "SHA1"
(is (= "1393ce5dfcf39109a420eb583ecfdeacc28c783a"
(-> test-string
str->bytes
sha-1
Hex/encodeHex
(String.)))))
(testing "SHA256"
(is (= "9c507d01834b2749d088122a7b3d200957f9b25579b5ce6b490e3b2067ee4f66"
(-> test-string
str->bytes
sha-256
Hex/encodeHex
(String.))))))
21 changes: 21 additions & 0 deletions test/zlib_tiny/compress.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(ns zlib-tiny.compress
(:require [clojure.test :refer :all]
[zlib-tiny.core :refer :all]))

(def test-string "test it!")

(deftest compressors
(testing "Checking ZLib"
(is (= test-string (-> test-string
str->bytes
deflate
inflate
force-byte-array
bytes->str))))

(testing "Checking GZip"
(is (= test-string (-> test-string
str->bytes
gzip
gunzip
bytes->str)))))

0 comments on commit 3a68cf0

Please sign in to comment.