From f639a78ff4f151cd2ac80d6d4a9db3cac1b98064 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Fri, 8 Sep 2023 19:14:28 -0700 Subject: [PATCH] Rewrites IobTest with matchers Issue #2745 --- .../java/info/nightscout/core/data/IobTest.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/main/src/test/java/info/nightscout/core/data/IobTest.kt b/core/main/src/test/java/info/nightscout/core/data/IobTest.kt index 754bd50591..e9c850b613 100644 --- a/core/main/src/test/java/info/nightscout/core/data/IobTest.kt +++ b/core/main/src/test/java/info/nightscout/core/data/IobTest.kt @@ -1,7 +1,7 @@ package info.nightscout.core.data +import com.google.common.truth.Truth.assertThat import info.nightscout.interfaces.iob.Iob -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test class IobTest { @@ -10,23 +10,23 @@ class IobTest { val a = Iob().iobContrib(1.0).activityContrib(2.0) val b = Iob().iobContrib(3.0).activityContrib(4.0) a.plus(b) - Assertions.assertEquals(4.0, a.iobContrib, 0.01) - Assertions.assertEquals(6.0, a.activityContrib, 0.01) + assertThat(a.iobContrib).isWithin(0.01).of(4.0) + assertThat(a.activityContrib).isWithin(0.01).of(6.0) } @Test fun equalTest() { val a1 = Iob().iobContrib(1.0).activityContrib(2.0) val a2 = Iob().iobContrib(1.0).activityContrib(2.0) val b = Iob().iobContrib(3.0).activityContrib(4.0) - Assertions.assertTrue(a1 == a2) - Assertions.assertFalse(a1 == b) - @Suppress("SENSELESS_COMPARISON") - Assertions.assertFalse(a1 == null) - Assertions.assertFalse(a1 == Any()) + assertThat(a1).isEqualTo(a1) + assertThat(a1).isEqualTo(a2) + assertThat(a1).isNotEqualTo(b) + assertThat(a1).isNotNull() + assertThat(a1).isNotEqualTo(Any()) } @Test fun hashCodeTest() { val a = Iob().iobContrib(1.0).activityContrib(2.0) - Assertions.assertNotEquals(0, a.hashCode().toLong()) + assertThat(a.hashCode().toLong()).isNotEqualTo(0L) } -} \ No newline at end of file +}