Skip to content

Commit 6088e73

Browse files
committed
Add Junit tests for Parser and Event Classes
1 parent 75ff8ea commit 6088e73

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test {
2929
}
3030

3131
application {
32-
mainClass.set("seedu.duke.Duke")
32+
mainClass.set("duke.Duke")
3333
}
3434

3535
shadowJar {

src/test/java/duke/ParserTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package duke;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import java.time.LocalDateTime;
6+
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
public class ParserTest {
9+
@Test
10+
public void parseDate_correctFormat_success() {
11+
String input1 = "09/02/2024 1800";
12+
LocalDateTime expectedDate = LocalDateTime.of(2024, 2, 9, 18,00);
13+
LocalDateTime testDate = Parser.parseDate(input1);
14+
assertEquals(testDate, expectedDate);
15+
}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package duke.task;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import java.time.LocalDateTime;
6+
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
public class EventTest {
9+
@Test
10+
public void getData_success() {
11+
LocalDateTime testFrom = LocalDateTime.of(2024, 2, 9, 18,00);
12+
LocalDateTime testTo = LocalDateTime.of(2024, 2, 10, 9,00);
13+
Event event = new Event("Test Event", testFrom, testTo);
14+
String expectedData = "E | 0 | Test Event | 09/02/2024 1800 | 10/02/2024 0900";
15+
assertEquals(event.getData(), expectedData);
16+
}
17+
}

0 commit comments

Comments
 (0)