Skip to content

Commit

Permalink
Merge pull request #4 from gachia/branch-A-Assertions
Browse files Browse the repository at this point in the history
Added Assertion
  • Loading branch information
gachia authored Sep 12, 2019
2 parents 45369b6 + d4b851d commit 876b4dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test {

run {
standardInput = System.in;
enableAssertions = true;
}

application {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public String addTask(Task task) {
* @return confirmation message of task being deleted
*/
public String deleteTask(int deleteIndex) {
assert deleteIndex < list.size() : "deleteIndex should not be larger than amount of tasks in list";
Task temp = list.remove(deleteIndex - 1);
String message = "Noted. I've removed this task:\n" + temp
+ "\nNow you have " + list.size() + " tasks in the list.";
Expand Down Expand Up @@ -97,6 +98,11 @@ public String searchTaskList(String searchTerm) {
* @return confirmation message of task being done
*/
public String setDoneTask(int doneIndex) {
/*
// Code for testing assertion
doneIndex = 20;
*/
assert doneIndex < list.size() : "doneIndex should not be larger than amount of tasks in list";
list.get(doneIndex - 1).markAsDone();
String message = "Nice! I've marked this task as done:\n"
+ list.get(doneIndex - 1);
Expand Down

0 comments on commit 876b4dd

Please sign in to comment.