Skip to content

Instantly share code, notes, and snippets.

@lbradstreet
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbradstreet/d266fee39103ab9a69de to your computer and use it in GitHub Desktop.
Save lbradstreet/d266fee39103ab9a69de to your computer and use it in GitHub Desktop.
Clojure test check uuid
(ns test-check-contrib.gen-uuid
(:require [clojure.string]
[clojure.test.check :as tc]
[clojure.test.check.generators :as gen]
[clojure.test.check.properties :as prop]
[clojure.test.check.clojure-test :refer [defspec]])
(:import [java.util UUID])
(:require [clojure.core :as core]))
(def gen-uuid-simple
(gen/fmap (fn [v] (UUID/randomUUID)) (gen/tuple)))
@jcf
Copy link

jcf commented Apr 1, 2015

If you're interested in a deterministic approach (that should work with shrinking) I've written a pure test.check version that relies on java.util.UUID/fromString.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment