Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
| 1 |
(ns digest-test |
| 2 |
(:require [clojure.string :refer [lower-case includes?]] |
| 3 |
[clojure.test :refer :all] |
| 4 |
[digest :refer :all]) |
| 5 |
(:import java.io.File)) |
| 6 |
|
| 7 |
(deftest md5-test |
| 8 |
(is (= (digest "md5" "foo") "acbd18db4cc2f85cedef654fccc4a4d8"))) |
| 9 |
|
| 10 |
(deftest sha-256-test |
| 11 |
(is (= (sha-256 "foo") |
| 12 |
"2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"))) |
| 13 |
|
| 14 |
(deftest algorithms-test |
| 15 |
(let [names (algorithms)] |
| 16 |
(is (not (empty? names))) |
| 17 |
(is (names "SHA-1")))) |
| 18 |
|
| 19 |
(deftest utils-test |
| 20 |
(for [name (algorithms)] |
| 21 |
(dorun (is (ns-resolve *ns* (symbol (lower-case name))))))) |
| 22 |
|
| 23 |
(deftest function-metadata-test |
| 24 |
(is (includes? (:doc (meta #'sha-256)) |
| 25 |
"SHA-256")) |
| 26 |
(is (= '([message]) |
| 27 |
(:arglists (meta #'md5))))) |
| 28 |
|
| 29 |
(def ^:dynamic *logo-md5* "38cf20fa3c9dc72be56965eb1c311dfa") |
| 30 |
(def ^:dynamic *logo-sha256* |
| 31 |
"42c2af2a0509832f39d0cef3ecd1612b7857c55abbe2170470eabb2a0318701c") |
| 32 |
|
| 33 |
(deftest file-test |
| 34 |
(let [f (File. "test/clojure.png")] |
| 35 |
(is (= (md5 f) *logo-md5*)) |
| 36 |
(is (= (sha-256 f) *logo-sha256*)))) |
| 37 |
|
| 38 |
; Just making sure that we don't explode on nil |
| 39 |
(deftest nil-test |
| 40 |
(md5 nil)) |
| 41 |
|
| 42 |
(deftest length-test |
| 43 |
(is (= (sha (File. "test/length.txt")) |
| 44 |
"007b65165b253172d054189e8e3175f3bcb9e28e"))) |