From 798dd44440690a82df74056e05162b2422ff304c Mon Sep 17 00:00:00 2001 From: Ambrose Bonnaire-Sergeant Date: Fri, 15 Nov 2024 02:31:57 -0600 Subject: [PATCH] tests --- test/malli/constraint/number_test.cljc | 27 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/test/malli/constraint/number_test.cljc b/test/malli/constraint/number_test.cljc index 99f00a276..940aa5e72 100644 --- a/test/malli/constraint/number_test.cljc +++ b/test/malli/constraint/number_test.cljc @@ -21,23 +21,27 @@ (is (= ["should be at least 1"] (me/humanize (explain [:int {:min 1}] 0)) (me/humanize (explain [:int {:min 1 :max 10}] 0)) - (me/humanize (explain [:int {:and [[:min 1]]}] 0)))) + (me/humanize (explain [:int {:and [[:min 1]]}] 0)) + (me/humanize (explain [:int {:and [[:min 1] [:min -5]]}] 0)))) (is (= ["should be at least 2"] (me/humanize (explain [:int {:min 2}] 0)) (me/humanize (explain [:int {:min 2 :max 10}] 0)) - (me/humanize (explain [:int {:and [[:min 2]]}] 0)))) + (me/humanize (explain [:int {:and [[:min 2]]}] 0)) + (me/humanize (explain [:int {:and [[:min -2] [:min 2]]}] 0)))) (is (= ["should be at most 1"] (me/humanize (explain [:int {:max 1}] 2)) (me/humanize (explain [:int {:max 1}] 2)) (me/humanize (explain [:int {:min 0 :max 1}] 2)) - (me/humanize (explain [:int {:and [[:max 1]]}] 2)))) + (me/humanize (explain [:int {:and [[:max 1] [:max 23]]}] 2)))) (is (= ["should be at most 2"] (me/humanize (explain [:int {:max 2}] 3)) (me/humanize (explain [:int {:min 1 :max 2}] 3)) - (me/humanize (explain [:int {:and [[:max 2]]}] 3)))) + (me/humanize (explain [:int {:and [[:max 23] [:max 2]]}] 3)))) (is (= ["should be 1"] (me/humanize (explain [:int {:min 1 :max 1}] 3)) - (me/humanize (explain [:int {:and [[:min 1] [:max 1]]}] 3)))))) + (me/humanize (explain [:int {:and [[:min 1] [:max 1]]}] 3)) + (me/humanize (explain [:int {:and [[:min 1] [:max 1] + [:min 0] [:max 2]]}] 3)))))) (deftest double+float-constraint-test (doseq [type [:double :float]] @@ -48,20 +52,23 @@ (is (= ["should be at least 1.0"] (me/humanize (explain [type {:min 1.0}] 0.0)) (me/humanize (explain [type {:min 1.0 :max 10.0}] 0.0)) - (me/humanize (explain [type {:and [[:min 1.0]]}] 0.0)))) + (me/humanize (explain [type {:and [[:min 1.0]]}] 0.0)) + (me/humanize (explain [type {:and [[:min 1.0] [:min -1.0]]}] 0.0)))) (is (= ["should be at least 2.0"] (me/humanize (explain [type {:min 2.0}] 0.0)) (me/humanize (explain [type {:min 2.0 :max 10.0}] 0.0)) - (me/humanize (explain [type {:and [[:min 2.0]]}] 0.0)))) + (me/humanize (explain [type {:and [[:min 2.0]]}] 0.0)) + (me/humanize (explain [type {:and [[:min 0.0] [:min 2.0]]}] 0.0)))) (is (= ["should be at most 1.0"] (me/humanize (explain [type {:max 1.0}] 2.0)) (me/humanize (explain [type {:max 1.0}] 2.0)) (me/humanize (explain [type {:min 0.0 :max 1.0}] 2.0)) - (me/humanize (explain [type {:and [[:max 1.0]]}] 2.0)))) + (me/humanize (explain [type {:and [[:max 1.0] [:max 23.0]]}] 2.0)))) (is (= ["should be at most 2.0"] (me/humanize (explain [type {:max 2.0}] 3.0)) (me/humanize (explain [type {:min 1.0 :max 2.0}] 3.0)) - (me/humanize (explain [type {:and [[:max 2.0]]}] 3.0)))) + (me/humanize (explain [type {:and [[:max 23.0] [:max 2.0]]}] 3.0)))) (is (= ["should be 1.0"] (me/humanize (explain [type {:min 1.0 :max 1.0}] 3.0)) - (me/humanize (explain [type {:and [[:min 1.0] [:max 1.0]]}] 3.0))))))) + (me/humanize (explain [type {:and [[:min 1.0] [:max 1.0] + [:min 0.0] [:max 2.0]]}] 3.0)))))))