Merge remote-tracking branch 'origin/dev' into refactor
This commit is contained in:
commit
643f140cd1
|
@ -3,14 +3,13 @@ package info.nightscout.androidaps.heartrate
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.hardware.Sensor
|
import android.hardware.Sensor
|
||||||
import android.hardware.SensorManager
|
import android.hardware.SensorManager
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.rx.AapsSchedulers
|
import info.nightscout.rx.AapsSchedulers
|
||||||
import info.nightscout.rx.weardata.EventData.ActionHeartRate
|
import info.nightscout.rx.weardata.EventData.ActionHeartRate
|
||||||
import info.nightscout.sharedtests.AAPSLoggerTest
|
import info.nightscout.sharedtests.AAPSLoggerTest
|
||||||
import io.reactivex.rxjava3.core.Scheduler
|
import io.reactivex.rxjava3.core.Scheduler
|
||||||
import io.reactivex.rxjava3.disposables.Disposable
|
import io.reactivex.rxjava3.disposables.Disposable
|
||||||
import org.junit.jupiter.api.AfterEach
|
import org.junit.jupiter.api.AfterEach
|
||||||
import org.junit.jupiter.api.Assertions.assertEquals
|
|
||||||
import org.junit.jupiter.api.Assertions.assertNull
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.ArgumentMatchers.any
|
import org.mockito.ArgumentMatchers.any
|
||||||
|
@ -80,14 +79,13 @@ internal class HeartRateListenerTest {
|
||||||
val d2 = 20_000L
|
val d2 = 20_000L
|
||||||
val listener = create(start)
|
val listener = create(start)
|
||||||
|
|
||||||
assertNull(listener.currentHeartRateBpm)
|
assertThat(listener.currentHeartRateBpm).isNull()
|
||||||
sendSensorEvent(listener, start + d1, 80)
|
sendSensorEvent(listener, start + d1, 80)
|
||||||
assertEquals(0, heartRates.size)
|
assertThat(heartRates).isEmpty()
|
||||||
assertEquals(80, listener.currentHeartRateBpm)
|
assertThat(listener.currentHeartRateBpm).isEqualTo(80)
|
||||||
|
|
||||||
listener.send(start + d2)
|
listener.send(start + d2)
|
||||||
assertEquals(1, heartRates.size)
|
assertThat(heartRates).containsExactly(ActionHeartRate(d2, start + d2, 80.0, device))
|
||||||
assertEquals(ActionHeartRate(d2, start + d2, 80.0, device), heartRates.first())
|
|
||||||
listener.dispose()
|
listener.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,16 +97,15 @@ internal class HeartRateListenerTest {
|
||||||
val listener = create(start)
|
val listener = create(start)
|
||||||
|
|
||||||
sendSensorEvent(listener, start, 80)
|
sendSensorEvent(listener, start, 80)
|
||||||
assertEquals(0, heartRates.size)
|
assertThat(heartRates).isEmpty()
|
||||||
assertEquals(80, listener.currentHeartRateBpm)
|
assertThat(listener.currentHeartRateBpm).isEqualTo(80)
|
||||||
sendSensorEvent(listener, start + d1, 100)
|
sendSensorEvent(listener, start + d1, 100)
|
||||||
assertEquals(0, heartRates.size)
|
assertThat(heartRates).isEmpty()
|
||||||
assertEquals(100, listener.currentHeartRateBpm)
|
assertThat(listener.currentHeartRateBpm).isEqualTo(100)
|
||||||
|
|
||||||
|
|
||||||
listener.send(start + d2)
|
listener.send(start + d2)
|
||||||
assertEquals(1, heartRates.size)
|
assertThat(heartRates).containsExactly(ActionHeartRate(d2, start + d2, 95.0, device))
|
||||||
assertEquals(ActionHeartRate(d2, start + d2, 95.0, device), heartRates.first())
|
|
||||||
listener.dispose()
|
listener.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,15 +118,15 @@ internal class HeartRateListenerTest {
|
||||||
|
|
||||||
sendSensorEvent(listener, start, 80)
|
sendSensorEvent(listener, start, 80)
|
||||||
listener.send(start + d1)
|
listener.send(start + d1)
|
||||||
assertEquals(1, heartRates.size)
|
assertThat(heartRates).hasSize(1)
|
||||||
|
|
||||||
sendSensorEvent(listener, start + d1, 100)
|
sendSensorEvent(listener, start + d1, 100)
|
||||||
assertEquals(1, heartRates.size)
|
assertThat(heartRates).hasSize(1)
|
||||||
listener.send(start + d2)
|
listener.send(start + d2)
|
||||||
assertEquals(2, heartRates.size)
|
assertThat(heartRates).containsExactly(
|
||||||
|
ActionHeartRate(d1, start + d1, 80.0, device),
|
||||||
assertEquals(ActionHeartRate(d1, start + d1, 80.0, device), heartRates[0])
|
ActionHeartRate(d2 - d1, start + d2, 100.0, device),
|
||||||
assertEquals(ActionHeartRate(d2 - d1, start + d2, 100.0, device), heartRates[1])
|
).inOrder()
|
||||||
listener.dispose()
|
listener.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,11 +139,10 @@ internal class HeartRateListenerTest {
|
||||||
|
|
||||||
sendSensorEvent(listener, start, 80)
|
sendSensorEvent(listener, start, 80)
|
||||||
sendSensorEvent(listener, start + d1, 100, accuracy = SensorManager.SENSOR_STATUS_NO_CONTACT)
|
sendSensorEvent(listener, start + d1, 100, accuracy = SensorManager.SENSOR_STATUS_NO_CONTACT)
|
||||||
assertNull(listener.currentHeartRateBpm)
|
assertThat(listener.currentHeartRateBpm).isNull()
|
||||||
listener.send(start + d2)
|
listener.send(start + d2)
|
||||||
|
|
||||||
assertEquals(1, heartRates.size)
|
assertThat(heartRates).containsExactly(ActionHeartRate(d2, start + d2, 80.0, device))
|
||||||
assertEquals(ActionHeartRate(d2, start + d2, 80.0, device), heartRates.first())
|
|
||||||
listener.dispose()
|
listener.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,8 +159,7 @@ internal class HeartRateListenerTest {
|
||||||
sendSensorEvent(listener, start + d2, 100)
|
sendSensorEvent(listener, start + d2, 100)
|
||||||
listener.send(start + d3)
|
listener.send(start + d3)
|
||||||
|
|
||||||
assertEquals(1, heartRates.size)
|
assertThat(heartRates).containsExactly(ActionHeartRate(d3, start + d3, 95.0, device))
|
||||||
assertEquals(ActionHeartRate(d3, start + d3, 95.0, device), heartRates.first())
|
|
||||||
listener.dispose()
|
listener.dispose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.androidaps.interaction.utils
|
package info.nightscout.androidaps.interaction.utils
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.WearTestBase
|
import info.nightscout.androidaps.WearTestBase
|
||||||
import info.nightscout.androidaps.data.RawDisplayData
|
import info.nightscout.androidaps.data.RawDisplayData
|
||||||
import info.nightscout.androidaps.testing.mockers.RawDataMocker
|
import info.nightscout.androidaps.testing.mockers.RawDataMocker
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
|
@ -32,142 +32,142 @@ class DisplayFormatTest : WearTestBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun shortTimeSinceTest() {
|
@Test fun shortTimeSinceTest() {
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 0, 0)), "0'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 0, 0))).isEqualTo("0'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 0, 5)), "0'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 0, 5))).isEqualTo("0'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 0, 55)), "0'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 0, 55))).isEqualTo("0'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 1, 0)), "1'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 1, 0))).isEqualTo("1'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 1, 59)), "1'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 1, 59))).isEqualTo("1'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 2, 0)), "2'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 2, 0))).isEqualTo("2'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 3, 0)), "3'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 3, 0))).isEqualTo("3'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 4, 0)), "4'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 4, 0))).isEqualTo("4'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 10, 0)), "10'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 10, 0))).isEqualTo("10'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 30, 0)), "30'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 30, 0))).isEqualTo("30'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 59, 0)), "59'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 59, 0))).isEqualTo("59'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 0, 59, 59)), "59'")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 0, 59, 59))).isEqualTo("59'")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 1, 0, 0)), "1h")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 1, 0, 0))).isEqualTo("1h")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 1, 30, 0)), "1h")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 1, 30, 0))).isEqualTo("1h")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 1, 59, 59)), "1h")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 1, 59, 59))).isEqualTo("1h")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 2, 0, 0)), "2h")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 2, 0, 0))).isEqualTo("2h")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 3, 0, 0)), "3h")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 3, 0, 0))).isEqualTo("3h")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 4, 0, 0)), "4h")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 4, 0, 0))).isEqualTo("4h")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 5, 0, 0)), "5h")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 5, 0, 0))).isEqualTo("5h")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 12, 0, 0)), "12h")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 12, 0, 0))).isEqualTo("12h")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 18, 0, 0)), "18h")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 18, 0, 0))).isEqualTo("18h")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(0, 23, 59, 59)), "23h")
|
assertThat(displayFormat.shortTimeSince(backInTime(0, 23, 59, 59))).isEqualTo("23h")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(1, 0, 0, 0)), "1d")
|
assertThat(displayFormat.shortTimeSince(backInTime(1, 0, 0, 0))).isEqualTo("1d")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(1, 12, 0, 0)), "1d")
|
assertThat(displayFormat.shortTimeSince(backInTime(1, 12, 0, 0))).isEqualTo("1d")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(1, 23, 59, 59)), "1d")
|
assertThat(displayFormat.shortTimeSince(backInTime(1, 23, 59, 59))).isEqualTo("1d")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(2, 0, 0, 0)), "2d")
|
assertThat(displayFormat.shortTimeSince(backInTime(2, 0, 0, 0))).isEqualTo("2d")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(3, 0, 0, 0)), "3d")
|
assertThat(displayFormat.shortTimeSince(backInTime(3, 0, 0, 0))).isEqualTo("3d")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(4, 0, 0, 0)), "4d")
|
assertThat(displayFormat.shortTimeSince(backInTime(4, 0, 0, 0))).isEqualTo("4d")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(5, 0, 0, 0)), "5d")
|
assertThat(displayFormat.shortTimeSince(backInTime(5, 0, 0, 0))).isEqualTo("5d")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(6, 0, 0, 0)), "6d")
|
assertThat(displayFormat.shortTimeSince(backInTime(6, 0, 0, 0))).isEqualTo("6d")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(6, 23, 59, 59)), "6d")
|
assertThat(displayFormat.shortTimeSince(backInTime(6, 23, 59, 59))).isEqualTo("6d")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(7, 0, 0, 0)), "1w")
|
assertThat(displayFormat.shortTimeSince(backInTime(7, 0, 0, 0))).isEqualTo("1w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(8, 0, 0, 0)), "1w")
|
assertThat(displayFormat.shortTimeSince(backInTime(8, 0, 0, 0))).isEqualTo("1w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(9, 0, 0, 0)), "1w")
|
assertThat(displayFormat.shortTimeSince(backInTime(9, 0, 0, 0))).isEqualTo("1w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(13, 23, 59, 59)), "1w")
|
assertThat(displayFormat.shortTimeSince(backInTime(13, 23, 59, 59))).isEqualTo("1w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(14, 0, 0, 0)), "2w")
|
assertThat(displayFormat.shortTimeSince(backInTime(14, 0, 0, 0))).isEqualTo("2w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(21, 0, 0, 0)), "3w")
|
assertThat(displayFormat.shortTimeSince(backInTime(21, 0, 0, 0))).isEqualTo("3w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(28, 0, 0, 0)), "4w")
|
assertThat(displayFormat.shortTimeSince(backInTime(28, 0, 0, 0))).isEqualTo("4w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(31, 0, 0, 0)), "4w")
|
assertThat(displayFormat.shortTimeSince(backInTime(31, 0, 0, 0))).isEqualTo("4w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(32, 0, 0, 0)), "4w")
|
assertThat(displayFormat.shortTimeSince(backInTime(32, 0, 0, 0))).isEqualTo("4w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(35, 0, 0, 0)), "5w")
|
assertThat(displayFormat.shortTimeSince(backInTime(35, 0, 0, 0))).isEqualTo("5w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(100, 0, 0, 0)), "14w")
|
assertThat(displayFormat.shortTimeSince(backInTime(100, 0, 0, 0))).isEqualTo("14w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(200, 0, 0, 0)), "28w")
|
assertThat(displayFormat.shortTimeSince(backInTime(200, 0, 0, 0))).isEqualTo("28w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(365, 0, 0, 0)), "52w")
|
assertThat(displayFormat.shortTimeSince(backInTime(365, 0, 0, 0))).isEqualTo("52w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(366, 0, 0, 0)), "52w")
|
assertThat(displayFormat.shortTimeSince(backInTime(366, 0, 0, 0))).isEqualTo("52w")
|
||||||
Assertions.assertEquals(displayFormat.shortTimeSince(backInTime(367, 0, 0, 0)), "52w")
|
assertThat(displayFormat.shortTimeSince(backInTime(367, 0, 0, 0))).isEqualTo("52w")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun shortTrendTest() {
|
@Test fun shortTrendTest() {
|
||||||
val raw = RawDisplayData()
|
val raw = RawDisplayData()
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(raw), "-- Δ--")
|
assertThat(displayFormat.shortTrend(raw)).isEqualTo("-- Δ--")
|
||||||
raw.singleBg.timeStamp = backInTime(0, 0, 2, 0)
|
raw.singleBg.timeStamp = backInTime(0, 0, 2, 0)
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(raw), "2' Δ--")
|
assertThat(displayFormat.shortTrend(raw)).isEqualTo("2' Δ--")
|
||||||
Mockito.`when`(sp.getBoolean("complication_unicode", true)).thenReturn(true)
|
Mockito.`when`(sp.getBoolean("complication_unicode", true)).thenReturn(true)
|
||||||
|
|
||||||
// shortening
|
// shortening
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(2, "1.2")), "2' Δ1.2")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(2, "1.2"))).isEqualTo("2' Δ1.2")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(11, "1.2")), "11' 1.2")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(11, "1.2"))).isEqualTo("11' 1.2")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(12, "0.7")), "12' Δ.7")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(12, "0.7"))).isEqualTo("12' Δ.7")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(10, "1.0")), "10' Δ1")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(10, "1.0"))).isEqualTo("10' Δ1")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(14, "-5.0")), "14' Δ-5")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(14, "-5.0"))).isEqualTo("14' Δ-5")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(13, "-5.1")), "13' -5")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(13, "-5.1"))).isEqualTo("13' -5")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(15, "0.87")), "15' .87")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(15, "0.87"))).isEqualTo("15' .87")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(10, "-1.78")), "10' -2")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(10, "-1.78"))).isEqualTo("10' -2")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(3, "2.549")), "3' 2.55")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(3, "2.549"))).isEqualTo("3' 2.55")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(1, "-1.563")), "1' -1.6")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(1, "-1.563"))).isEqualTo("1' -1.6")
|
||||||
|
|
||||||
// preserving separator
|
// preserving separator
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(2, "1,2")), "2' Δ1,2")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(2, "1,2"))).isEqualTo("2' Δ1,2")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(15, "0,87")), "15' ,87")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(15, "0,87"))).isEqualTo("15' ,87")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(3, "+2,549")), "3' 2,55")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(3, "+2,549"))).isEqualTo("3' 2,55")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(1, "-1,563")), "1' -1,6")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(1, "-1,563"))).isEqualTo("1' -1,6")
|
||||||
|
|
||||||
// UTF-off mode - without delta symbol
|
// UTF-off mode - without delta symbol
|
||||||
Mockito.`when`(sp.getBoolean("complication_unicode", true)).thenReturn(false)
|
Mockito.`when`(sp.getBoolean("complication_unicode", true)).thenReturn(false)
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(2, "1.2")), "2' 1.2")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(2, "1.2"))).isEqualTo("2' 1.2")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(12, "0.7")), "12' 0.7")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(12, "0.7"))).isEqualTo("12' 0.7")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(10, "1.0")), "10' 1.0")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(10, "1.0"))).isEqualTo("10' 1.0")
|
||||||
Assertions.assertEquals(displayFormat.shortTrend(rawDataMocker.rawDelta(14, "-5.0")), "14' -5")
|
assertThat(displayFormat.shortTrend(rawDataMocker.rawDelta(14, "-5.0"))).isEqualTo("14' -5")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun longGlucoseLine() {
|
@Test fun longGlucoseLine() {
|
||||||
Assertions.assertEquals(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("125", 2, "1.2")), "125→ Δ1.2 (2')")
|
assertThat(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("125", 2, "1.2"))).isEqualTo("125→ Δ1.2 (2')")
|
||||||
Assertions.assertEquals(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("97", 11, "5.2")), "97↗ Δ5.2 (11')")
|
assertThat(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("97", 11, "5.2"))).isEqualTo("97↗ Δ5.2 (11')")
|
||||||
Assertions.assertEquals(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("110", 12, "0.7")), "110→ Δ.7 (12')")
|
assertThat(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("110", 12, "0.7"))).isEqualTo("110→ Δ.7 (12')")
|
||||||
Assertions.assertEquals(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("65", 10, "7.0")), "65↗ Δ7 (10')")
|
assertThat(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("65", 10, "7.0"))).isEqualTo("65↗ Δ7 (10')")
|
||||||
Assertions.assertEquals(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("215", 14, "-5.0")), "215↘ Δ-5 (14')")
|
assertThat(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("215", 14, "-5.0"))).isEqualTo("215↘ Δ-5 (14')")
|
||||||
Assertions.assertEquals(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("8.3", 13, "-5.1")), "8.3↘ Δ-5.1 (13')")
|
assertThat(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("8.3", 13, "-5.1"))).isEqualTo("8.3↘ Δ-5.1 (13')")
|
||||||
Assertions.assertEquals(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("6.8", 15, "10.83")), "6.8↑ Δ10.83 (15')")
|
assertThat(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("6.8", 15, "10.83"))).isEqualTo("6.8↑ Δ10.83 (15')")
|
||||||
Assertions.assertEquals(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("13.2", 10, "-11.78")), "13.2↓ Δ-11.78 (10')")
|
assertThat(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("13.2", 10, "-11.78"))).isEqualTo("13.2↓ Δ-11.78 (10')")
|
||||||
Assertions.assertEquals(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("3.9", 3, "2.549")), "3.9→ Δ2.549 (3')")
|
assertThat(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("3.9", 3, "2.549"))).isEqualTo("3.9→ Δ2.549 (3')")
|
||||||
Assertions.assertEquals(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("11.1", 1, "-15.563")), "11.1↓ Δ-15.563 (1')")
|
assertThat(displayFormat.longGlucoseLine(rawDataMocker.rawSgv("11.1", 1, "-15.563"))).isEqualTo("11.1↓ Δ-15.563 (1')")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun longDetailsLineTest() {
|
@Test fun longDetailsLineTest() {
|
||||||
Mockito.`when`(sp.getBoolean("complication_unicode", true)).thenReturn(true)
|
Mockito.`when`(sp.getBoolean("complication_unicode", true)).thenReturn(true)
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("0g", "0U", "3.5U/h")), "0g ⁞ 0U ⁞ ⎍ 3.5U/h")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("0g", "0U", "3.5U/h"))).isEqualTo("0g ⁞ 0U ⁞ ⎍ 3.5U/h")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("50g", "7.56U", "0%")), "50g ⁞ 7.56U ⁞ ⎍ 0%")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("50g", "7.56U", "0%"))).isEqualTo("50g ⁞ 7.56U ⁞ ⎍ 0%")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("12g", "3.23U", "120%")), "12g ⁞ 3.23U ⁞ 120%")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("12g", "3.23U", "120%"))).isEqualTo("12g ⁞ 3.23U ⁞ 120%")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("2(40)g", "-1.5U", "0.55U/h")), "2(40)g ⁞ -2U ⁞ 0.55U/h")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("2(40)g", "-1.5U", "0.55U/h"))).isEqualTo("2(40)g ⁞ -2U ⁞ 0.55U/h")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("0(24)g", "0.05U", "160%")), "0(24)g ⁞ 0.05U ⁞ 160%")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("0(24)g", "0.05U", "160%"))).isEqualTo("0(24)g ⁞ 0.05U ⁞ 160%")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("47g", "13.87U", "220%")), "47g ⁞ 13.87U ⁞ 220%")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("47g", "13.87U", "220%"))).isEqualTo("47g ⁞ 13.87U ⁞ 220%")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("13(5)g", "5.90U", "300%")), "13(5)g ⁞ 5.90U ⁞ 300%")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("13(5)g", "5.90U", "300%"))).isEqualTo("13(5)g ⁞ 5.90U ⁞ 300%")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("11(50)g", "0U", "70%")), "11(50)g ⁞ 0U ⁞ 70%")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("11(50)g", "0U", "70%"))).isEqualTo("11(50)g ⁞ 0U ⁞ 70%")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("7g", "0.54U", "30%")), "7g ⁞ 0.54U ⁞ ⎍ 30%")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("7g", "0.54U", "30%"))).isEqualTo("7g ⁞ 0.54U ⁞ ⎍ 30%")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("19(38)g", "35.545U", "12.9U/h")), "19g ⁞ 36U ⁞ 12.9U/h")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("19(38)g", "35.545U", "12.9U/h"))).isEqualTo("19g ⁞ 36U ⁞ 12.9U/h")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("100(1)g", "12.345U", "6.98647U/h")), "100g 12U 6.98647U/h")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("100(1)g", "12.345U", "6.98647U/h"))).isEqualTo("100g 12U 6.98647U/h")
|
||||||
Mockito.`when`(sp.getBoolean("complication_unicode", true)).thenReturn(false)
|
Mockito.`when`(sp.getBoolean("complication_unicode", true)).thenReturn(false)
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("0g", "0U", "3.5U/h")), "0g | 0U | 3.5U/h")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("0g", "0U", "3.5U/h"))).isEqualTo("0g | 0U | 3.5U/h")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("50g", "7.56U", "0%")), "50g | 7.56U | 0%")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("50g", "7.56U", "0%"))).isEqualTo("50g | 7.56U | 0%")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("12g", "3.23U", "120%")), "12g | 3.23U | 120%")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("12g", "3.23U", "120%"))).isEqualTo("12g | 3.23U | 120%")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("7g", "0.54U", "30%")), "7g | 0.54U | 30%")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("7g", "0.54U", "30%"))).isEqualTo("7g | 0.54U | 30%")
|
||||||
Assertions.assertEquals(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("19(38)g", "35.545U", "12.9U/h")), "19g | 36U | 12.9U/h")
|
assertThat(displayFormat.longDetailsLine(rawDataMocker.rawCobIobBr("19(38)g", "35.545U", "12.9U/h"))).isEqualTo("19g | 36U | 12.9U/h")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun detailedIobTest() {
|
@Test fun detailedIobTest() {
|
||||||
Assertions.assertEquals(displayFormat.detailedIob(rawDataMocker.rawIob("-1.29U", "(0,910|-2,20)")), Pair.create("-1.29U", ",91 -2"))
|
assertThat(displayFormat.detailedIob(rawDataMocker.rawIob("-1.29U", "(0,910|-2,20)"))).isEqualTo(Pair.create("-1.29U", ",91 -2"))
|
||||||
Assertions.assertEquals(displayFormat.detailedIob(rawDataMocker.rawIob("3.50U", "")), Pair.create("3.50U", ""))
|
assertThat(displayFormat.detailedIob(rawDataMocker.rawIob("3.50U", ""))).isEqualTo(Pair.create("3.50U", ""))
|
||||||
Assertions.assertEquals(displayFormat.detailedIob(rawDataMocker.rawIob("12.5U", "(+1,4|-4.78)")), Pair.create("12.5U", "1,4 -5"))
|
assertThat(displayFormat.detailedIob(rawDataMocker.rawIob("12.5U", "(+1,4|-4.78)"))).isEqualTo(Pair.create("12.5U", "1,4 -5"))
|
||||||
Assertions.assertEquals(displayFormat.detailedIob(rawDataMocker.rawIob("0.67U", "some junks")), Pair.create(".67U", ""))
|
assertThat(displayFormat.detailedIob(rawDataMocker.rawIob("0.67U", "some junks"))).isEqualTo(Pair.create(".67U", ""))
|
||||||
Assertions.assertEquals(displayFormat.detailedIob(rawDataMocker.rawIob("-11.0U", "(broken|data)")), Pair.create("-11U", "-- --"))
|
assertThat(displayFormat.detailedIob(rawDataMocker.rawIob("-11.0U", "(broken|data)"))).isEqualTo(Pair.create("-11U", "-- --"))
|
||||||
Assertions.assertEquals(displayFormat.detailedIob(rawDataMocker.rawIob("5.52U", "(0,5439|wrong)")), Pair.create("5.52U", ",54 --"))
|
assertThat(displayFormat.detailedIob(rawDataMocker.rawIob("5.52U", "(0,5439|wrong)"))).isEqualTo(Pair.create("5.52U", ",54 --"))
|
||||||
Assertions.assertEquals(displayFormat.detailedIob(rawDataMocker.rawIob("-8.1U", "(|-8,1)")), Pair.create("-8.1U", "-- -8"))
|
assertThat(displayFormat.detailedIob(rawDataMocker.rawIob("-8.1U", "(|-8,1)"))).isEqualTo(Pair.create("-8.1U", "-- -8"))
|
||||||
Assertions.assertEquals(displayFormat.detailedIob(rawDataMocker.rawIob("-8.1U", "(|-8,1)")), Pair.create("-8.1U", "-- -8"))
|
assertThat(displayFormat.detailedIob(rawDataMocker.rawIob("-8.1U", "(|-8,1)"))).isEqualTo(Pair.create("-8.1U", "-- -8"))
|
||||||
Assertions.assertEquals(displayFormat.detailedIob(rawDataMocker.rawIob("7.6U", "(malformed)")), Pair.create("7.6U", ""))
|
assertThat(displayFormat.detailedIob(rawDataMocker.rawIob("7.6U", "(malformed)"))).isEqualTo(Pair.create("7.6U", ""))
|
||||||
Assertions.assertEquals(displayFormat.detailedIob(rawDataMocker.rawIob("-4.26U", "(6,97|1,3422|too much)")), Pair.create("-4.26U", "7 1,3"))
|
assertThat(displayFormat.detailedIob(rawDataMocker.rawIob("-4.26U", "(6,97|1,3422|too much)"))).isEqualTo(Pair.create("-4.26U", "7 1,3"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun detailedCobTest() {
|
@Test fun detailedCobTest() {
|
||||||
Assertions.assertEquals(displayFormat.detailedCob(rawDataMocker.rawCob("0g")), Pair.create("0g", ""))
|
assertThat(displayFormat.detailedCob(rawDataMocker.rawCob("0g"))).isEqualTo(Pair.create("0g", ""))
|
||||||
Assertions.assertEquals(displayFormat.detailedCob(rawDataMocker.rawCob("50g")), Pair.create("50g", ""))
|
assertThat(displayFormat.detailedCob(rawDataMocker.rawCob("50g"))).isEqualTo(Pair.create("50g", ""))
|
||||||
Assertions.assertEquals(displayFormat.detailedCob(rawDataMocker.rawCob("2(40)g")), Pair.create("2g", "40g"))
|
assertThat(displayFormat.detailedCob(rawDataMocker.rawCob("2(40)g"))).isEqualTo(Pair.create("2g", "40g"))
|
||||||
Assertions.assertEquals(displayFormat.detailedCob(rawDataMocker.rawCob("0(24)g")), Pair.create("0g", "24g"))
|
assertThat(displayFormat.detailedCob(rawDataMocker.rawCob("0(24)g"))).isEqualTo(Pair.create("0g", "24g"))
|
||||||
Assertions.assertEquals(displayFormat.detailedCob(rawDataMocker.rawCob("13(5)g")), Pair.create("13g", "5g"))
|
assertThat(displayFormat.detailedCob(rawDataMocker.rawCob("13(5)g"))).isEqualTo(Pair.create("13g", "5g"))
|
||||||
Assertions.assertEquals(displayFormat.detailedCob(rawDataMocker.rawCob("11(50)g")), Pair.create("11g", "50g"))
|
assertThat(displayFormat.detailedCob(rawDataMocker.rawCob("11(50)g"))).isEqualTo(Pair.create("11g", "50g"))
|
||||||
Assertions.assertEquals(displayFormat.detailedCob(rawDataMocker.rawCob("19(38)g")), Pair.create("19g", "38g"))
|
assertThat(displayFormat.detailedCob(rawDataMocker.rawCob("19(38)g"))).isEqualTo(Pair.create("19g", "38g"))
|
||||||
Assertions.assertEquals(displayFormat.detailedCob(rawDataMocker.rawCob("100(1)g")), Pair.create("100g", "1g"))
|
assertThat(displayFormat.detailedCob(rawDataMocker.rawCob("100(1)g"))).isEqualTo(Pair.create("100g", "1g"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.interaction.utils
|
package info.nightscout.androidaps.interaction.utils
|
||||||
|
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import org.junit.Assert
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class PairTest {
|
class PairTest {
|
||||||
|
@ -19,14 +18,14 @@ class PairTest {
|
||||||
val no4: Pair<*, *> = Pair.create(12, 345L)
|
val no4: Pair<*, *> = Pair.create(12, 345L)
|
||||||
|
|
||||||
// THEN
|
// THEN
|
||||||
Assert.assertNotEquals(left, right)
|
assertThat(right).isNotEqualTo(left)
|
||||||
Assert.assertEquals(left, another)
|
assertThat(another).isEqualTo(left)
|
||||||
Assert.assertNotEquals(left, samePos1)
|
assertThat(samePos1).isNotEqualTo(left)
|
||||||
Assert.assertNotEquals(left, samePos2)
|
assertThat(samePos2).isNotEqualTo(left)
|
||||||
Assert.assertNotEquals(no1, no2)
|
assertThat(no2).isNotEqualTo(no1)
|
||||||
Assert.assertNotEquals(no1, no3)
|
assertThat(no3).isNotEqualTo(no1)
|
||||||
Assert.assertEquals(no1, no4)
|
assertThat(no4).isEqualTo(no1)
|
||||||
Assert.assertNotEquals("aa bbb", left.toString())
|
assertThat(left.toString()).isNotEqualTo("aa bbb")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun pairHashTest() {
|
@Test fun pairHashTest() {
|
||||||
|
@ -46,4 +45,4 @@ class PairTest {
|
||||||
assertThat(pair.toString()).contains("the-first")
|
assertThat(pair.toString()).contains("the-first")
|
||||||
assertThat(pair.toString()).contains("2nd")
|
assertThat(pair.toString()).contains("2nd")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue