forked from nus-cs2103-AY2324S1/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Test Cases and Covered Abstraction
- Loading branch information
Showing
8 changed files
with
215 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
T | 0 | Go to the gym | ||
T | 1 | Go to the gym | ||
E | 1 | Go to Gym | Dec 12 2023 06:00 PM - Dec 12 2023 08:00 PM | ||
T | 0 | Head to school | ||
T | 1 | Say hello to Ann | ||
T | 0 | asdsad | ||
D | 0 | sdsdsd | Dec 10 2022 07:20 PM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package duke.parser; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import duke.commands.AddCommand; | ||
import duke.commands.Command; | ||
import duke.commands.ExitCommand; | ||
import duke.commands.IncorrectCommand; | ||
import duke.commands.ListCommand; | ||
|
||
public class ParserTest { | ||
|
||
@Test | ||
public void list_incorrectCommand() { | ||
Command c = Parser.parse("list xx"); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
public void list_correctCommand() { | ||
Command c = Parser.parse("list"); | ||
assertTrue(c instanceof ListCommand); | ||
} | ||
|
||
@Test | ||
public void exit_incorrectCommand() { | ||
Command c = Parser.parse("bye "); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
void exit_correctCommand() { | ||
Command c = Parser.parse("bye"); | ||
assertTrue(c instanceof ExitCommand); | ||
} | ||
|
||
@Test | ||
void todo_invalidTask_incorrectCommand() { | ||
Command c = Parser.parse("todo "); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
void todo_validTask_correctCommand() { | ||
Command c = Parser.parse("todo xxx"); | ||
assertTrue(c instanceof AddCommand); | ||
} | ||
|
||
@Test | ||
void deadline_validTaskAndInvalidDate_correctCommand() { | ||
Command c = Parser.parse("deadline xxx /by "); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
void deadline_invalidDeadline_incorrectCommand() { | ||
Command c = Parser.parse("deadline "); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
void deadline_missingTaskAndValidDate_incorrectCommand() { | ||
Command c = Parser.parse("deadline /by 21/06/02 1200"); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
void deadline_validTaskAndInvalidDate_incorrectCommand() { | ||
Command c = Parser.parse("deadline xx /by lorem"); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
void deadline_validDeadline_correctCommand() { | ||
Command c = Parser.parse("deadline xx /by 21/08/02 1900"); | ||
assertTrue(c instanceof AddCommand); | ||
} | ||
|
||
@Test | ||
void event_invalidEvent_incorrectCommand() { | ||
Command c = Parser.parse("event"); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
void event_validTaskAndInvalidDate_incorrectCommand() { | ||
Command c = Parser.parse("event xx"); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
void event_validTaskAndInvalidTo_incorrectCommand() { | ||
Command c = Parser.parse("event xx /from 21/05/02 1100"); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
void event_validEvent_correctCommand() { | ||
Command c = Parser.parse("event xx /from 21/05/02 1100 /to 21/05/02 1200"); | ||
assertTrue(c instanceof AddCommand); | ||
} | ||
|
||
@Test | ||
void event_invalidTaskAndValidDates_incorrectCommand() { | ||
Command c = Parser.parse("event /from 21/05/02 1100 /to 21/05/02 1200"); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
void event_validTaskAndInvalidFromAndInvalidTo_incorrectCommand() { | ||
Command c = Parser.parse("event go to the cafe /from xx /to yy"); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
@Test | ||
void event_validTaskAndInvalidRange_incorrectCommand() { | ||
Command c = Parser.parse("event go to library /from 21/05/02 1100 /to 21/05/02 1000"); | ||
assertTrue(c instanceof IncorrectCommand); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package duke.tasks; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class DeadlineTest { | ||
@Test | ||
public void toString_correctOutput() { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yy HHmm"); | ||
LocalDateTime by = LocalDateTime.parse("21/08/02 1900", formatter); | ||
Task task = new Deadline("Finish HW", by); | ||
task.completeTask(true); | ||
assertEquals("[D][X] Finish HW (by: Aug 21 2002 07:00 PM)", task.toString()); | ||
} | ||
|
||
@Test | ||
public void toFile_correctOutput() { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yy HHmm"); | ||
LocalDateTime by = LocalDateTime.parse("21/08/02 1900", formatter); | ||
Task task = new Deadline("Finish HW", by, "0"); | ||
assertEquals("D | 0 | Finish HW | Aug 21 2002 07:00 PM", task.toFile()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package duke.tasks; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class EventTest { | ||
@Test | ||
public void toString_correctOutput() { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yy HHmm"); | ||
LocalDateTime from = LocalDateTime.parse("21/08/02 1900", formatter); | ||
LocalDateTime to = LocalDateTime.parse("21/08/02 2000", formatter); | ||
Task task = new Event("Group Meeting", from, to, "0"); | ||
task.completeTask(true); | ||
assertEquals("[E][X] Group Meeting (from: Aug 21 2002 07:00 PM to: Aug 21 2002 08:00 PM)", | ||
task.toString()); | ||
} | ||
|
||
@Test | ||
public void toFile_correctOutput() { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yy HHmm"); | ||
LocalDateTime from = LocalDateTime.parse("21/08/02 1900", formatter); | ||
LocalDateTime to = LocalDateTime.parse("21/08/02 2000", formatter); | ||
Task task = new Event("Group Meeting", from, to, "0"); | ||
assertEquals("E | 0 | Group Meeting | Aug 21 2002 07:00 PM - Aug 21 2002 08:00 PM", task.toFile()); | ||
} | ||
|
||
@Test | ||
public void toString_wrongOutputIfFromDateIsAfterToDate() { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yy HHmm"); | ||
LocalDateTime from = LocalDateTime.parse("21/08/02 2000", formatter); | ||
LocalDateTime to = LocalDateTime.parse("21/08/02 1900", formatter); | ||
Task task = new Event("Group Meeting", from, to, "0"); | ||
task.completeTask(true); | ||
assertEquals("[E][X] Group Meeting (from: Aug 21 2002 08:00 PM to: Aug 21 2002 07:00 PM)", | ||
task.toString()); | ||
} | ||
} |