Skip to content

Commit

Permalink
test: Cover value extension for RefinedTypeOps
Browse files Browse the repository at this point in the history
  • Loading branch information
Iltotore committed Oct 2, 2023
1 parent 6878dc9 commit 2e1bb7e
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ object RefinedTypeOpsSuite extends TestSuite:

test("option") {
val fromWithFailingPredicate = Temperature.option(-5.0)
assert(fromWithFailingPredicate == None)
assert(fromWithFailingPredicate.isEmpty)
val fromWithSucceedingPredicate = Temperature.option(100)
assert(fromWithSucceedingPredicate == Some(Temperature(100)))
assert(fromWithSucceedingPredicate.contains(Temperature(100)))
}

test("applyUnsafe") {
Expand All @@ -63,8 +63,8 @@ object RefinedTypeOpsSuite extends TestSuite:
test - assert(Moisture(positive) == moisture)
test - assert(Moisture.either(-5.0) == Left("Should be strictly positive"))
test - assert(Moisture.either(100) == Right(Moisture(100)))
test - assert(Moisture.option(-5.0) == None)
test - assert(Moisture.option(100) == Some(Moisture(100)))
test - assert(Moisture.option(-5.0).isEmpty)
test - assert(Moisture.option(100).contains(Moisture(100)))
}

test("mirror") {
Expand All @@ -74,4 +74,9 @@ object RefinedTypeOpsSuite extends TestSuite:
assertGiven[mirror.ConstraintType =:= Positive]
assertGiven[mirror.FinalType =:= Temperature]
}

test("value") {
val temperature = Temperature(10)
assert(temperature.value == 10)
}
}

0 comments on commit 2e1bb7e

Please sign in to comment.