From a35e5db9a89774e50757a467732459c1930f0830 Mon Sep 17 00:00:00 2001 From: Evande1 Date: Fri, 26 Aug 2022 08:52:06 +0800 Subject: [PATCH] A-JUnit --- src/test/java/duke/task/DeadlineTest.java | 24 +++++++++++++++++++++++ src/test/java/duke/task/EventsTest.java | 19 ++++++++++++++++++ src/test/java/duke/task/ToDosTest.java | 19 ++++++++++++++++++ text-ui-test/input.txt | 2 +- 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/test/java/duke/task/DeadlineTest.java create mode 100644 src/test/java/duke/task/EventsTest.java create mode 100644 src/test/java/duke/task/ToDosTest.java diff --git a/src/test/java/duke/task/DeadlineTest.java b/src/test/java/duke/task/DeadlineTest.java new file mode 100644 index 0000000000..7fd4c8191d --- /dev/null +++ b/src/test/java/duke/task/DeadlineTest.java @@ -0,0 +1,24 @@ +package duke.task; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class DeadlineTest { + @Test + public void deadlineTestToString() { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HHmm"); + Deadline test = new Deadline("test", LocalDateTime.parse("01/01/2025 1600",formatter)); + assertEquals("[D][ ] test (by: Jan 1 2025 1600)", test.toString()); + } + + @Test + public void deadlineTestTextFormat() { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HHmm"); + Deadline test = new Deadline("test", LocalDateTime.parse("01/01/2025 1600",formatter)); + assertEquals("D|0|test|2025-01-01T16:00", test.textFormat()); + } +} diff --git a/src/test/java/duke/task/EventsTest.java b/src/test/java/duke/task/EventsTest.java new file mode 100644 index 0000000000..d3c3ed52ed --- /dev/null +++ b/src/test/java/duke/task/EventsTest.java @@ -0,0 +1,19 @@ +package duke.task; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class EventsTest { + @Test + public void EventsTestToString() { + Events test = new Events("test", "test"); + assertEquals("[E][ ] test (by: test)", test.toString()); + } + + @Test + public void EventsTestTextFormat() { + Events test = new Events("test", "test"); + assertEquals("E|0|test|test", test.textFormat()); + } +} diff --git a/src/test/java/duke/task/ToDosTest.java b/src/test/java/duke/task/ToDosTest.java new file mode 100644 index 0000000000..c21c6925a7 --- /dev/null +++ b/src/test/java/duke/task/ToDosTest.java @@ -0,0 +1,19 @@ +package duke.task; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ToDosTest { + @Test + public void ToDosTestToString() { + ToDos test = new ToDos("test"); + assertEquals("[T][ ] test", test.toString()); + } + + @Test + public void ToDosTextFormat() { + ToDos test = new ToDos("test"); + assertEquals("T|0|test", test.textFormat()); + } +} diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index 5b9e97762f..8d3731d893 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -1,4 +1,4 @@ todo borrow book list -deadline return book /by Sunday +deadline return book /by event project meeting /at Mon 2-4pm \ No newline at end of file