Rewrites ComparatorTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-04 21:01:49 -07:00
parent 11fa9f6539
commit 38c01372ee

View file

@ -1,35 +1,35 @@
package app.aaps.plugins.automation.elements
import app.aaps.plugins.automation.triggers.TriggerTestBase
import org.junit.jupiter.api.Assertions
import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.Test
class ComparatorTest : TriggerTestBase() {
@Test
fun checkTest() {
Assertions.assertTrue(Comparator.Compare.IS_EQUAL.check(1, 1))
Assertions.assertTrue(Comparator.Compare.IS_LESSER.check(1, 2))
Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_LESSER.check(1, 2))
Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 2))
Assertions.assertTrue(Comparator.Compare.IS_GREATER.check(2, 1))
Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 1))
Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 2))
Assertions.assertFalse(Comparator.Compare.IS_LESSER.check(2, 1))
Assertions.assertFalse(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 1))
Assertions.assertFalse(Comparator.Compare.IS_GREATER.check(1, 2))
Assertions.assertFalse(Comparator.Compare.IS_EQUAL_OR_GREATER.check(1, 2))
// Assertions.assertTrue(Comparator.Compare.IS_NOT_AVAILABLE.check<Int?>(1, null))
assertThat(Comparator.Compare.IS_EQUAL.check(1, 1)).isTrue()
assertThat(Comparator.Compare.IS_LESSER.check(1, 2)).isTrue()
assertThat(Comparator.Compare.IS_EQUAL_OR_LESSER.check(1, 2)).isTrue()
assertThat(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 2)).isTrue()
assertThat(Comparator.Compare.IS_GREATER.check(2, 1)).isTrue()
assertThat(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 1)).isTrue()
assertThat(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 2)).isTrue()
assertThat(Comparator.Compare.IS_LESSER.check(2, 1)).isFalse()
assertThat(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 1)).isFalse()
assertThat(Comparator.Compare.IS_GREATER.check(1, 2)).isFalse()
assertThat(Comparator.Compare.IS_EQUAL_OR_GREATER.check(1, 2)).isFalse()
// assertThat(Comparator.Compare.IS_NOT_AVAILABLE.check<Int?>(1, null)).isTrue()
}
@Test
fun labelsTest() {
Assertions.assertEquals(6, Comparator.Compare.labels(rh).size)
assertThat(Comparator.Compare.labels(rh)).hasSize(6)
}
@Test
fun setValueTest() {
val c: Comparator = Comparator(rh).setValue(Comparator.Compare.IS_EQUAL_OR_GREATER)
Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_GREATER, c.value)
assertThat(c.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_GREATER)
}
}
}