From 620aba55ae762e6b25fc42c1fa792789f7c7662f Mon Sep 17 00:00:00 2001 From: David Hoepelman Date: Mon, 25 Nov 2024 08:43:42 +0100 Subject: [PATCH] Add tests for int overloads --- .../validation/constraints/ConstraintsTest.kt | 68 ++++++++++++------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/src/commonTest/kotlin/io/konform/validation/constraints/ConstraintsTest.kt b/src/commonTest/kotlin/io/konform/validation/constraints/ConstraintsTest.kt index 3c2b505..e764511 100644 --- a/src/commonTest/kotlin/io/konform/validation/constraints/ConstraintsTest.kt +++ b/src/commonTest/kotlin/io/konform/validation/constraints/ConstraintsTest.kt @@ -148,32 +148,37 @@ class ConstraintsTest { fun maximumConstraint() { assertEquals( Valid(10), - Validation { maximum(10) }(10) + Validation { maximum(10) }(10), ) assertEquals( Valid(10), - Validation { maximum(10) }(10) + Validation { maximum(10) }(10), ) assertEquals( Valid(10.0f), - Validation { maximum(10) }(10.0f) + Validation { maximum(10) }(10.0f), ) assertEquals( Valid(10.0), - Validation { maximum(10) }(10.0) + Validation { maximum(10) }(10.0), ) assertEquals( Valid("a"), - Validation { maximum("b") }("a") + Validation { maximum("b") }("a"), ) assertEquals( Valid("b"), - Validation { maximum("b") }("b") + Validation { maximum("b") }("b"), + ) + + assertEquals( + Valid(10.0), + Validation { maximum(10) }(10.0), ) val validation = Validation { maximum(10.0) } @@ -184,7 +189,7 @@ class ConstraintsTest { assertEquals(Valid(Double.NEGATIVE_INFINITY), validation(Double.NEGATIVE_INFINITY)) assertEquals( Valid(Double.POSITIVE_INFINITY), - Validation { maximum(Double.POSITIVE_INFINITY) }(Double.POSITIVE_INFINITY) + Validation { maximum(Double.POSITIVE_INFINITY) }(Double.POSITIVE_INFINITY), ) assertEquals(1, countFieldsWithErrors(validation(10.00001))) @@ -198,27 +203,32 @@ class ConstraintsTest { fun exclusiveMaximumConstraint() { assertEquals( Valid(9), - Validation { exclusiveMaximum(10) }(9) + Validation { exclusiveMaximum(10) }(9), ) assertEquals( Valid(9), - Validation { exclusiveMaximum(10) }(9) + Validation { exclusiveMaximum(10) }(9), ) assertEquals( Valid(9.0f), - Validation { exclusiveMaximum(10) }(9.0f) + Validation { exclusiveMaximum(10) }(9.0f), ) assertEquals( Valid(9.0), - Validation { exclusiveMaximum(10) }(9.0) + Validation { exclusiveMaximum(10) }(9.0), ) assertEquals( Valid("a"), - Validation { exclusiveMaximum("b") }("a") + Validation { exclusiveMaximum("b") }("a"), + ) + + assertEquals( + Valid(10.0), + Validation { exclusiveMaximum(11) }(10.0), ) val validation = Validation { exclusiveMaximum(10.0) } @@ -244,32 +254,37 @@ class ConstraintsTest { fun minimumConstraint() { assertEquals( Valid(10), - Validation { minimum(10) }(10) + Validation { minimum(10) }(10), ) assertEquals( Valid(10), - Validation { minimum(10) }(10) + Validation { minimum(10) }(10), ) assertEquals( Valid(10.0f), - Validation { minimum(10) }(10.0f) + Validation { minimum(10) }(10.0f), ) assertEquals( Valid(10.0), - Validation { minimum(10) }(10.0) + Validation { minimum(10) }(10.0), ) assertEquals( Valid("b"), - Validation { minimum("a") }("b") + Validation { minimum("a") }("b"), ) assertEquals( Valid("a"), - Validation { minimum("a") }("a") + Validation { minimum("a") }("a"), + ) + + assertEquals( + Valid(10.0), + Validation { minimum(10) }(10.0), ) val validation = Validation { minimum(10.0) } @@ -279,7 +294,7 @@ class ConstraintsTest { assertEquals(Valid(Double.POSITIVE_INFINITY), validation(Double.POSITIVE_INFINITY)) assertEquals( Valid(Double.NEGATIVE_INFINITY), - Validation { minimum(Double.NEGATIVE_INFINITY) }(Double.NEGATIVE_INFINITY) + Validation { minimum(Double.NEGATIVE_INFINITY) }(Double.NEGATIVE_INFINITY), ) assertEquals(1, countFieldsWithErrors(validation(9.99999))) @@ -293,27 +308,32 @@ class ConstraintsTest { fun exclusiveMinimumConstraint() { assertEquals( Valid(11), - Validation { exclusiveMinimum(10) }(11) + Validation { exclusiveMinimum(10) }(11), ) assertEquals( Valid(11), - Validation { exclusiveMinimum(10) }(11) + Validation { exclusiveMinimum(10) }(11), ) assertEquals( Valid(11.0f), - Validation { exclusiveMinimum(10) }(11.0f) + Validation { exclusiveMinimum(10) }(11.0f), ) assertEquals( Valid(11.0), - Validation { exclusiveMinimum(10) }(11.0) + Validation { exclusiveMinimum(10) }(11.0), ) assertEquals( Valid("b"), - Validation { exclusiveMinimum("a") }("b") + Validation { exclusiveMinimum("a") }("b"), + ) + + assertEquals( + Valid(10.0), + Validation { minimum(9) }(10.0), ) val validation = Validation { exclusiveMinimum(10.0) }