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.
- Loading branch information
Showing
4 changed files
with
196 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,45 @@ | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class DeadlineTest { | ||
@Test | ||
public void testDeadlinePrinting_correctFormat_success() throws DukeException { | ||
Task d = new Deadline("proj", "2019-10-15 2359"); | ||
assertEquals("[D][\u2718] proj (by: Tue, 15 Oct 2019, 23:59)", d.toString()); | ||
} | ||
|
||
@Test | ||
public void testDeadlinePrinting_wrongFormat_exceptionThrown() { | ||
try { | ||
Task d = new Deadline("project", "Sunday"); | ||
fail(); | ||
} catch (DukeException ex) { | ||
String error = "UHOH! You need to use the proper format!\n" | ||
+ "eg deadline return book /by 2019-10-15 2359"; | ||
assertEquals(error, ex.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void testDeadlinePrinting_doneDeadline_success() throws DukeException { | ||
Task d = new Deadline("proj", "2019-10-15 2359"); | ||
d.markDone(); | ||
assertEquals("[D][\u2713] proj (by: Tue, 15 Oct 2019, 23:59)", d.toString()); | ||
} | ||
|
||
@Test | ||
public void testToTaskData_doneDeadline_success() throws DukeException { | ||
Task d = new Deadline("proj", "2019-10-15 2359"); | ||
d.markDone(); | ||
assertEquals("D ; 1 ; proj ; 2019-10-15 2359", d.toTaskData()); | ||
} | ||
|
||
@Test | ||
public void testToTaskData_notDoneDeadline_success() throws DukeException { | ||
Task d = new Deadline("proj", "2019-10-15 2359"); | ||
assertEquals("D ; 0 ; proj ; 2019-10-15 2359", d.toTaskData()); | ||
} | ||
|
||
} |
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,44 @@ | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class EventTest { | ||
@Test | ||
public void testEventPrinting_correctFormat_success() throws DukeException { | ||
Task e = new Event("meeting", "2019-10-15 1200"); | ||
assertEquals("[E][\u2718] meeting (at: Tue, 15 Oct 2019, 12:00)", e.toString()); | ||
} | ||
|
||
@Test | ||
public void testEventPrinting_wrongFormat_exceptionThrown() { | ||
try { | ||
Task e = new Event("meeting", "Sunday"); | ||
fail(); | ||
} catch (DukeException ex) { | ||
String error = "UHOH! You need to use the proper format!\n" | ||
+ "eg event project meeting /at 2019-10-15 1200"; | ||
assertEquals(error, ex.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void testEventPrinting_doneEvent_success() throws DukeException { | ||
Task e = new Event("meeting", "2019-10-15 1200"); | ||
e.markDone(); | ||
assertEquals("[E][\u2713] meeting (at: Tue, 15 Oct 2019, 12:00)", e.toString()); | ||
} | ||
|
||
@Test | ||
public void testToTaskData_doneEvent_success() throws DukeException { | ||
Task e = new Event("meeting", "2019-10-15 1200"); | ||
e.markDone(); | ||
assertEquals("E ; 1 ; meeting ; 2019-10-15 1200", e.toTaskData()); | ||
} | ||
|
||
@Test | ||
public void testToTaskData_notDoneDeadline_success() throws DukeException { | ||
Task e = new Event("meeting", "2019-10-15 1200"); | ||
assertEquals("E ; 0 ; meeting ; 2019-10-15 1200", e.toTaskData()); | ||
} | ||
} |
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,76 @@ | ||
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_exitCommand_success() throws DukeException { | ||
assertEquals(true, Parser.parse("bye") instanceof ExitCommand); | ||
} | ||
|
||
@Test | ||
public void parse_helpCommand_success() throws DukeException { | ||
assertEquals(true, Parser.parse("help") instanceof HelpCommand); | ||
} | ||
|
||
@Test | ||
public void parse_listCommand_success() throws DukeException { | ||
assertEquals(true, Parser.parse("list") instanceof ListCommand); | ||
} | ||
|
||
@Test | ||
public void parse_doneCommand_success() throws DukeException { | ||
assertEquals(true, Parser.parse("done 1") instanceof DoneCommand); | ||
} | ||
|
||
@Test | ||
public void parse_doneCommand_exceptionThrown() { | ||
try { | ||
Parser.parse("done"); | ||
fail(); | ||
} catch (DukeException ex) { | ||
String error = "UHOH! You need to specify which task to mark done! \n" | ||
+ "eg done 1"; | ||
assertEquals(error, ex.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void parse_deleteCommand_success() throws DukeException { | ||
assertEquals(true, Parser.parse("delete 1") instanceof DeleteCommand); | ||
} | ||
|
||
@Test | ||
public void parse_deleteCommand_exceptionThrown() { | ||
try { | ||
Parser.parse("delete"); | ||
fail(); | ||
} catch (DukeException ex) { | ||
String error = "UHOH! You need to specify which task to delete!\n" | ||
+ "eg delete 1"; | ||
assertEquals(error, ex.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void parse_addCommand_success() throws DukeException { | ||
assertEquals(true, Parser.parse("todo read") instanceof AddCommand); | ||
assertEquals(true, | ||
Parser.parse("deadline project /by 2019-10-15 2359") instanceof AddCommand); | ||
assertEquals(true, | ||
Parser.parse("event meeting /at 2019-10-15 1200") instanceof AddCommand); | ||
} | ||
|
||
@Test | ||
public void parse_unknownCommand_exceptionThrown() { | ||
try { | ||
Parser.parse("hello"); | ||
fail(); | ||
} catch (DukeException ex) { | ||
String error = "UHOH! Sorry, I don't understand what you are saying! D=\n" | ||
+ "Type \"help\" to view the list of commands you can use!"; | ||
assertEquals(error, ex.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,31 @@ | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class TodoTest { | ||
@Test | ||
public void testTodoPrinting_doneTodo_success() { | ||
Task todo = new Todo("read"); | ||
todo.markDone(); | ||
assertEquals("[T][\u2713] read", todo.toString()); | ||
} | ||
|
||
@Test | ||
public void testTodoPrinting_notDoneTodo_success() { | ||
Task todo = new Todo("read"); | ||
assertEquals("[T][\u2718] read", todo.toString()); | ||
} | ||
|
||
@Test | ||
public void testToTaskData_doneTodo_success() { | ||
Task todo = new Todo("read"); | ||
todo.markDone(); | ||
assertEquals("T ; 1 ; read", todo.toTaskData()); | ||
} | ||
|
||
@Test | ||
public void testToTaskData_notDoneTodo_success() { | ||
Task todo = new Todo("read"); | ||
assertEquals("T ; 0 ; read", todo.toTaskData()); | ||
} | ||
} |