Skip to content

Commit

Permalink
Update JUnit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnnnnnnnn committed Feb 23, 2024
1 parent e32b0ae commit d7cb44d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/test/java/badgpt/util/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@ public void parse_validCommandFormat_success() throws Exception {
BadGpt bot = new BadGpt(new Gui());
TaskList taskList = new TaskList(new TasksUi(out, new ByteArrayOutputStream()));
taskList.store(new Task("return book"));
out.reset();

Parser.parse("mark 1", bot, taskList);
assertEquals("____________________________________________________________\r\n" +
assertEquals("_____________________________________________________\r\n" +
"Nice! I've marked this task as done:\n" +
"[X] return book\r\n" +
"____________________________________________________________\r\n", out.toString());
"_____________________________________________________\r\n", out.toString());

out.reset();

Parser.parse("unmark 1", bot, taskList);
assertEquals("____________________________________________________________\r\n" +
assertEquals("_____________________________________________________\r\n" +
"wyd bro why undo\n" +
"[ ] return book\r\n" +
"____________________________________________________________\r\n", out.toString());
"_____________________________________________________\r\n", out.toString());
}

@Test
Expand All @@ -53,15 +54,15 @@ public void parse_invalidCommandFormat_notSuccess() {
fail();
} catch (BadException e) {
assertEquals("Please type in the command as follows: mark taskNum\n" +
"Example: mark 2", e.toString());
"Example usage: mark 2", e.toString());
}

// Try unmark command without a number
try {
Parser.parse("unmark", bot, taskList);
} catch (BadException e) {
assertEquals("Please type in the command as follows: unmark taskNum\n" +
"Example: unmark 2", e.toString());
"Example usage: unmark 2", e.toString());
}
}
}
7 changes: 4 additions & 3 deletions src/test/java/badgpt/util/TaskListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ public void listTasks_nonEmpty_success() throws Exception {

TaskList taskList = new TaskList(new TasksUi(out, new ByteArrayOutputStream()));
taskList.store(new Task("return book"));
out.reset();

taskList.listTasks();

// Lists the newly added task
assertEquals("____________________________________________________________\r\n" +
assertEquals("_____________________________________________________\r\n" +
"Here are the tasks in your list:\r\n" +
"1. [ ] return book\r\n" +
"____________________________________________________________\r\n", out.toString());
"[ ] return book\r\n" +
"_____________________________________________________\r\n", out.toString());
}

@Test
Expand Down

0 comments on commit d7cb44d

Please sign in to comment.