Skip to content

Commit

Permalink
Add 3 Junit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
howardwhw2 committed Jan 28, 2022
1 parent 8dad697 commit 1406857
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/van/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ public boolean executeCommand(Ui ui, TaskList taskList, Storage storage) {
ui.taskMessage(newTask, taskList.getTaskCount());
return false;
}

@Override
public String toString() {
return newTask.getStatus();
}
}
2 changes: 1 addition & 1 deletion src/main/java/van/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static Command parseCommand(String parameter) {
if (parameters.length != 2) {
throw new VanException("Invalid format. Please use: event <task> /at <date>");
}
taskArguments = parameters[1].split(" /by ");
taskArguments = parameters[1].split(" /at ");
if (taskArguments.length != 2) {
throw new VanException("Invalid format. Please use: event <task> /at <date>");
}
Expand Down
29 changes: 29 additions & 0 deletions src/test/java/van/ParserTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package van;

import org.junit.jupiter.api.Test;

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

public class ParserTest {
@Test
public void deadLineTester() {
Command deadLine = Parser.parseCommand("deadline eat /by 22-10-2022 18:00");

assertEquals("[D][ ] eat (by:Oct 22 2022 1800)"
, deadLine.toString());
}

@Test
public void eventTester() {
Command eventTest = Parser.parseCommand("event sleep /at 12-01-2022 06:00");
assertEquals("[E][ ] sleep (at:Jan 12 2022 0600)",
eventTest.toString());
}

@Test
public void toDoTester() {
Command toDoTest = Parser.parseCommand("todo study");
assertEquals("[T][ ] study", toDoTest.toString());
}

}

0 comments on commit 1406857

Please sign in to comment.