Created
July 30, 2013 23:03
-
-
Save reiddraper/6117839 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[simple-check.core :as sc]) | |
(require '[simple-check.generators :as gen]) | |
(require '[simple-check.properties :as prop]) | |
(use 'byte-transforms) | |
(def compression-type (gen/elements ["lz4" "snappy" "gzip" "zlib"])) | |
;; a simple round-trip compression property... | |
;; for all byte-arrays `b`, compressiong with | |
;; any compression type and then decompressing with | |
;; the same type should equal `b`. | |
(def property | |
(prop/for-all [b gen/bytes ;; this generator doesn't exist yet, but will be in simple-check soon | |
comp-type compression-type] | |
(= b (-> b (compress comp-type) (decompress comp-type))))) | |
;; run the test | |
(sc/quick-check 1000 property) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment