forked from nus-cs2103-AY2021S1/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 unit tests for Parser and TaskList
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class ParserTest { | ||
|
||
@Test | ||
public void parse_noDescription_exceptionThrown() { | ||
try { | ||
Parser.parse("event"); | ||
fail(); | ||
} catch (DukeException e) { | ||
assertEquals(" OOPS!!! The description of a event cannot be empty.", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void parse_wrongCommand_exceptionThrown() { | ||
try { | ||
Parser.parse("random"); | ||
fail(); | ||
} catch (DukeException e) { | ||
assertEquals(" OOPS!!! I'm sorry, but I don't know what that means :-(", e.getMessage()); | ||
} | ||
} | ||
} |
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,19 @@ | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class TaskListTest { | ||
|
||
@Test | ||
public void handleDeadline_wrongDateFormat_exceptionThrown() { | ||
try { | ||
TaskList tasks = new TaskList(); | ||
CommandName deadline = CommandName.DEADLINE; | ||
tasks.addTask(deadline, "desc", "2020/10/10"); | ||
fail(); | ||
} catch (DukeException e) { | ||
assertEquals(" OOPS!!! Pass in a date in yyyy-mm-dd :-(", e.getMessage()); | ||
} | ||
} | ||
} |