Skip to content

Commit

Permalink
Assert commandOutput to be non-empty after a command is run
Browse files Browse the repository at this point in the history
  • Loading branch information
pPris committed Feb 9, 2021
1 parent d0757be commit 1a4f0f9
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ checkstyle {

run{
standardInput = System.in
enableAssertions = true
}
6 changes: 6 additions & 0 deletions src/data/tasks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ T;;eruiear;;false
T;;awosdu;;false
T;;hkadsd;;false
T;;sadoi;;false
T;;128390;;false
T;;12389;;false
T;;1238904;;false
T;;123784;;false
T;;1234;;false
T;;1234;;false
3 changes: 2 additions & 1 deletion src/main/java/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void setTaskList() {
Ui.print(new String[]{"Something went wrong in loading the task file and parsing",
e.getMessage()});
}
// todo ensure a tasklist is always created?
}


Expand Down Expand Up @@ -127,7 +128,7 @@ String getResponse(String input) {
}
}

c.debug();
// c.debug();
return "Duke heard: " + c.getCommandOutputMsg();
}
}
2 changes: 2 additions & 0 deletions src/main/java/commands/ByeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ public void run(TaskList taskList) {
} else {
handleTooManyArgs(); // should this be in try-catch block
}

assert !this.commandOutputMsg.isEmpty() : "empty command output in " + this.commandName;
}
}
2 changes: 2 additions & 0 deletions src/main/java/commands/DeadlineCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ public void run(TaskList taskList) {
} catch (Exception e) {
handleException(e);
}

assert !this.commandOutputMsg.isEmpty() : "empty command output in " + this.commandName;
}
}
2 changes: 1 addition & 1 deletion src/main/java/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public void run(TaskList taskList) {
handleException(e);
}

assert !this.commandOutputMsg.isEmpty();
assert !this.commandOutputMsg.isEmpty() : "empty command output in " + this.commandName;
}
}
2 changes: 1 addition & 1 deletion src/main/java/commands/DoneCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public void run(TaskList taskList) {
handleException(e);
}

assert !this.commandOutputMsg.isEmpty();
assert !this.commandOutputMsg.isEmpty() : "empty command output in " + this.commandName;
}
}
2 changes: 1 addition & 1 deletion src/main/java/commands/EventCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public void run(TaskList taskList) {
handleException(e);
}

assert !this.commandOutputMsg.isEmpty();
assert !this.commandOutputMsg.isEmpty() : "empty command output in " + this.commandName;
}
}
2 changes: 1 addition & 1 deletion src/main/java/commands/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public void run(TaskList taskList) {
} else {
handleTooManyArgs();
}
assert this.commandOutputMsg != null;
assert !this.commandOutputMsg.isEmpty() : "empty command output in " + this.commandName;
}
}
4 changes: 4 additions & 0 deletions src/main/java/commands/TodoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ public void run(TaskList taskList) {
} catch (MissingArgumentException e) {
handleException(e);
}

System.out.println(this.commandOutputMsg);
System.out.println(this.commandOutputMsg.isEmpty());
assert !this.commandOutputMsg.isEmpty() : "empty command output in " + this.commandName;
}
}

0 comments on commit 1a4f0f9

Please sign in to comment.