From f1f390ae7e06594c73f4d8f5faba23c4affd4073 Mon Sep 17 00:00:00 2001 From: Mark McGranaghan Date: Fri, 25 Dec 2009 13:01:19 -0500 Subject: [PATCH] Introduce assert-in. --- src/clj_unit/core_assertions.clj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/clj_unit/core_assertions.clj b/src/clj_unit/core_assertions.clj index 5b1bbad..583d00c 100644 --- a/src/clj_unit/core_assertions.clj +++ b/src/clj_unit/core_assertions.clj @@ -30,6 +30,13 @@ (< actual (+ expected delta))) (format "Expected %s +-%s, got %s" expected delta actual))) +(defn assert-in + "Assert that a value is one of given set." + [expected-from actual] + (assert-truth (contains? expected-from actual) + (format "Expected one of %s, got %s" + (pr-str expected-from) (pr-str actual)))) + (defn assert-that "Assert that a value is logically true - i.e. not nil or false." [val]