From 3a9d742cd783435f8ab3b3c6ba193b1cd573d55f Mon Sep 17 00:00:00 2001 From: Jakub Kalinowski Date: Sun, 11 Dec 2022 17:54:27 +0100 Subject: [PATCH] Corrected HabitBullCSV3 test and added a new one --- uhabits-core/assets/test/habitbull4.csv | 3 +++ .../org/isoron/uhabits/core/io/ImportTest.kt | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 uhabits-core/assets/test/habitbull4.csv diff --git a/uhabits-core/assets/test/habitbull4.csv b/uhabits-core/assets/test/habitbull4.csv new file mode 100644 index 000000000..b2fdf504a --- /dev/null +++ b/uhabits-core/assets/test/habitbull4.csv @@ -0,0 +1,3 @@ +HabitName,HabitDescription,HabitCategory,CalendarDate,Value,CommentText +Caffeine,,Coffee Consumption,2022-11-21,80, +Caffeine,,Coffee Consumption,2022-11-22,80, diff --git a/uhabits-core/src/jvmTest/java/org/isoron/uhabits/core/io/ImportTest.kt b/uhabits-core/src/jvmTest/java/org/isoron/uhabits/core/io/ImportTest.kt index b8949d4b0..9c53d149c 100644 --- a/uhabits-core/src/jvmTest/java/org/isoron/uhabits/core/io/ImportTest.kt +++ b/uhabits-core/src/jvmTest/java/org/isoron/uhabits/core/io/ImportTest.kt @@ -85,8 +85,8 @@ class ImportTest : BaseUnitTest() { assertThat(habit.type, equalTo(HabitType.NUMERICAL)) assertThat(habit.description, equalTo("")) assertThat(habit.frequency, equalTo(Frequency.DAILY)) - assertThat(getValue(habit, 2021, 9, 1), equalTo(30)) - assertThat(getValue(habit, 2022, 1, 8), equalTo(100)) + assertThat(getValue(habit, 2021, 9, 1), equalTo(30000)) + assertThat(getValue(habit, 2022, 1, 8), equalTo(100000)) val habit2 = habitList.getByPosition(1) assertThat(habit2.name, equalTo("run")) @@ -98,6 +98,21 @@ class ImportTest : BaseUnitTest() { assertTrue(isChecked(habit2, 2022, 1, 19)) } + @Test + @Throws(IOException::class) + fun testHabitBullCSV4() { + importFromFile("habitbull4.csv") + assertThat(habitList.size(), equalTo(1)) + + val habit = habitList.getByPosition(0) + assertThat(habit.name, equalTo("Caffeine")) + assertThat(habit.type, equalTo(HabitType.NUMERICAL)) + assertThat(habit.description, equalTo("")) + assertThat(habit.frequency, equalTo(Frequency.DAILY)) + assertThat(getValue(habit, 2022, 11, 21), equalTo(80000)) + assertThat(getValue(habit, 2022, 11, 22), equalTo(80000)) + } + @Test @Throws(IOException::class) fun testLoopDB() {