Skip to content

Commit

Permalink
Test isFailedToday
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqua authored and iSoron committed Aug 6, 2021
1 parent f8c7abf commit 13e57b5
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ class HabitTest : BaseUnitTest() {
assertTrue(h.isCompletedToday())
}

@Test
@Throws(Exception::class)
fun test_isFailed() {
val h = modelFactory.buildHabit()
assertFalse(h.isFailedToday())
h.originalEntries.add(Entry(getToday(), Entry.NO))
h.recompute()
assertTrue(h.isFailedToday())
}

@Test
@Throws(Exception::class)
fun test_isCompleted_numerical() {
Expand Down Expand Up @@ -109,6 +119,35 @@ class HabitTest : BaseUnitTest() {
assertTrue(h.isCompletedToday())
}

@Test
@Throws(Exception::class)
fun test_isFailedNumerical() {
val h = modelFactory.buildHabit()
h.type = HabitType.NUMERICAL
h.targetType = NumericalHabitType.AT_LEAST
h.targetValue = 100.0
assertTrue(h.isFailedToday())
h.originalEntries.add(Entry(getToday(), 200000))
h.recompute()
assertFalse(h.isFailedToday())
h.originalEntries.add(Entry(getToday(), 100000))
h.recompute()
assertFalse(h.isFailedToday())
h.originalEntries.add(Entry(getToday(), 50000))
h.recompute()
assertTrue(h.isFailedToday())
h.targetType = NumericalHabitType.AT_MOST
h.originalEntries.add(Entry(getToday(), 200000))
h.recompute()
assertTrue(h.isFailedToday())
h.originalEntries.add(Entry(getToday(), 100000))
h.recompute()
assertFalse(h.isFailedToday())
h.originalEntries.add(Entry(getToday(), 50000))
h.recompute()
assertFalse(h.isFailedToday())
}

@Test
@Throws(Exception::class)
fun testURI() {
Expand Down

0 comments on commit 13e57b5

Please sign in to comment.