Skip to content

Instantly share code, notes, and snippets.

@reiddraper
Created July 30, 2013 23:03
Show Gist options
  • Save reiddraper/6117839 to your computer and use it in GitHub Desktop.
Save reiddraper/6117839 to your computer and use it in GitHub Desktop.
(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