Skip to content

Commit

Permalink
Merge branch 'A-JUnit'
Browse files Browse the repository at this point in the history
  • Loading branch information
swtan346 committed Feb 2, 2024
2 parents b406800 + d31f4d3 commit 206a3e9
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/main/java/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public boolean isExit() {
return false;
}

public String addToDo(TaskList tasks, String input) throws WeiException {
private String addToDo(TaskList tasks, String input) throws WeiException {
if (input.length() < 5) {
throw new WeiException("please tell me what is your task about");
}
ToDo todo = new ToDo(input.substring(5));
return tasks.add(todo);
}

public String addDeadline(TaskList tasks, String input) throws WeiException {
private String addDeadline(TaskList tasks, String input) throws WeiException {
try {
int index = input.indexOf("/");
String task = input.substring(9, index - 1);
Expand All @@ -56,7 +56,7 @@ public String addDeadline(TaskList tasks, String input) throws WeiException {
}
}

public String addEvent(TaskList tasks, String input) throws WeiException {
private String addEvent(TaskList tasks, String input) throws WeiException {
try {
int firstIndex = input.indexOf("/");
int secondIndex = input.lastIndexOf("/");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tasks/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Deadline(String task, String date, boolean status) {
@Override
public String stringify() {
String formattedDate = this.date.format(DateTimeFormatter.ofPattern("MMM d yyyy"));
return "[D]" + super.stringify() + "(by: " + formattedDate + ")";
return "[D]" + super.stringify() + " (by: " + formattedDate + ")";
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class Ui {
public void showLine() {
System.out.println("______________________________");
System.out.println("________________________________________");
}

public void greet() {
Expand Down
25 changes: 25 additions & 0 deletions src/test/java/tasks/DeadlineTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package tasks;

import org.junit.jupiter.api.Test;

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

public class DeadlineTest {
@Test
public void testStringify_(){
Deadline deadline = new Deadline("read book", "2024-02-03");
assertEquals("[D][ ] read book (by: Feb 3 2024)", deadline.stringify());

Deadline markedDeadline = new Deadline("play", "2024-02-03", true);
assertEquals("[D][X] play (by: Feb 3 2024)", markedDeadline.stringify());
}

@Test
public void testToString(){
Deadline deadline = new Deadline("read book", "2024-02-03");
assertEquals("D | O | read book | 2024-02-03", deadline.toString());

Deadline markedDeadline = new Deadline("play", "2024-02-03", true);
assertEquals("D | X | play | 2024-02-03", markedDeadline.toString());
}
}
25 changes: 25 additions & 0 deletions src/test/java/tasks/TodoTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package tasks;

import org.junit.jupiter.api.Test;

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

public class TodoTest {
@Test
public void testStringify_(){
ToDo todo = new ToDo("read book");
assertEquals("[T][ ] read book", todo.stringify());

ToDo markedTodo = new ToDo("play", true);
assertEquals("[T][X] play", markedTodo.stringify());
}

@Test
public void testToString(){
ToDo todo = new ToDo("read book");
assertEquals("T | O | read book", todo.toString());

ToDo markedTodo = new ToDo("play", true);
assertEquals("T | X | play", markedTodo.toString());
}
}

0 comments on commit 206a3e9

Please sign in to comment.