Skip to content

Commit

Permalink
test: Add tests for Long / Float / Double for VssProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrylo committed Nov 1, 2023
1 parent 6fe1ab9 commit 3d774bf
Showing 1 changed file with 63 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,44 +67,95 @@ class VssSpecificationCopyTest : BehaviorSpec({
}

and("values for arithmetic operations") {
val valueInt = VssValueInt(value = 100)
val valueFloat = VssValueFloat(value = 100f)
val valueLong = VssValueLong(value = 100L)
val valueDouble = VssValueDouble(value = 100.0)

val values = listOf<Number>(5, 5L, 5f, 5.0)

`when`("a plus operation is done") {
val newValues = values.map { driverHeartRate + it }
val newValues = values.map {
listOf(
valueInt + it,
valueFloat + it,
valueLong + it,
valueDouble + it,
)
}

then("it should correctly add the values") {
newValues.forEach {
it.value shouldBe 105
newValues.forEach { properties ->
properties.forEach {
it.value shouldBe 105
}
}
}
}

`when`("a minus operation is done") {
val newValues = values.map { driverHeartRate - it }
val newValues = values.map {
listOf(
valueInt - it,
valueFloat - it,
valueLong - it,
valueDouble - it,
)
}

then("it should correctly subtract the values") {
newValues.forEach {
it.value shouldBe 95
newValues.forEach { properties ->
properties.forEach {
it.value shouldBe 95
}
}
}
}

`when`("a divide operation with zero is done") {
val exception = shouldThrow<ArithmeticException> {
valueInt / 0
}

then("it should throw an exception") {
exception.message shouldStartWith "/ by zero"
}
}

`when`("a divide operation is done") {
val newValues = values.map { driverHeartRate / it }
val newValues = values.map {
listOf(
valueInt / it,
valueFloat / it,
valueLong / it,
valueDouble / it,
)
}

then("it should correctly divide the values") {
newValues.forEach {
it.value shouldBe 20
newValues.forEach { properties ->
properties.forEach {
it.value shouldBe 20
}
}
}
}

`when`("a multiply operation is done") {
val newValues = values.map { driverHeartRate * it }
val newValues = values.map {
listOf(
valueInt * it,
valueFloat * it,
valueLong * it,
valueDouble * it,
)
}

then("it should correctly multiply the values") {
newValues.forEach {
it.value shouldBe 500
newValues.forEach { properties ->
properties.forEach {
it.value shouldBe 500
}
}
}
}
Expand Down

0 comments on commit 3d774bf

Please sign in to comment.