Skip to content

Commit

Permalink
Test isFailedToday
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqua committed Aug 5, 2021
1 parent 46c3c27 commit c8d77e7
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.AtLeast
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.AtMost
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 c8d77e7

Please sign in to comment.