Skip to content

Commit

Permalink
Update test file imports and output format
Browse files Browse the repository at this point in the history
  • Loading branch information
adipanda2002 committed Sep 15, 2024
1 parent a66bdd5 commit 2703afc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
18 changes: 12 additions & 6 deletions src/test/java/tasks/EventTest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package tasks;

import pandabot.exceptions.InputException;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.time.LocalDateTime;

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

import pandabot.exceptions.InputException;
import pandabot.tasks.Event;
import pandabot.tasks.Task;


/**
* Unit tests for the Event class.
* This class tests the functionality of the Event class, including creating tasks,
Expand All @@ -22,9 +26,10 @@ class EventTest {
*/
@Test
void testCreateTaskValid() throws InputException {
Task task = new Event("", LocalDateTime.now(), LocalDateTime.now()).createTask("Meeting /from 01/01/2024 0900 /to 01/01/2024 1700");
Task task = new Event("", LocalDateTime.now(), LocalDateTime.now())
.createTask("Meeting /from 01/01/2024 0900 /to 01/01/2024 1700");
assertNotNull(task);
assertEquals("[E][ ] Meeting (from: Jan 1 2024, 9:00 am to: Jan 1 2024, 5:00 pm)", task.toString());
assertEquals("[E][ ] Meeting (from: Jan 1 2024, 9:00 am, to: Jan 1 2024, 5:00 pm)", task.toString());
}

/**
Expand All @@ -33,7 +38,8 @@ void testCreateTaskValid() throws InputException {
*/
@Test
void testCreateTaskInvalid() {
assertThrows(InputException.class, () -> new Event("", LocalDateTime.now(), LocalDateTime.now()).createTask("event"));
assertThrows(InputException.class, () -> new Event("", LocalDateTime.now(),
LocalDateTime.now()).createTask("event"));
}

/**
Expand Down
9 changes: 6 additions & 3 deletions src/test/java/tasks/TaskTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package tasks;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import pandabot.tasks.Task;
import pandabot.tasks.ToDo;

Expand Down Expand Up @@ -64,7 +66,7 @@ void testParseDeadline() {
void testParseEvent() {
String[] details = {"E", "0", "Test Event task", "12/12/2024 1800", "13/12/2024 1800"};
Task task = Task.parse(details);
assertEquals("[E][ ] Test Event task (from: Dec 12 2024, 6:00 pm to: Dec 13 2024, 6:00 pm)", task.toString());
assertEquals("[E][ ] Test Event task (from: Dec 12 2024, 6:00 pm, to: Dec 13 2024, 6:00 pm)", task.toString());
}

/**
Expand All @@ -74,6 +76,7 @@ void testParseEvent() {
@Test
void testParseInvalidInput() {
String[] details = {"X", "0", "Test Invalid task"};
assertThrows(IllegalArgumentException.class, () -> Task.parse(details), "An invalid task type should throw an exception.");
assertThrows(IllegalArgumentException.class, () -> Task.parse(details),
"An invalid task type should throw an exception.");
}
}

0 comments on commit 2703afc

Please sign in to comment.