Skip to content

Commit

Permalink
A-JUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
greyguy21 committed Aug 27, 2021
1 parent 6ca1f9b commit b3baa72
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 5 deletions.
Binary file added lib/kotlin-reflect-sources.jar
Binary file not shown.
Binary file added lib/kotlin-reflect.jar
Binary file not shown.
Binary file added lib/kotlin-stdlib-jdk7-sources.jar
Binary file not shown.
Binary file added lib/kotlin-stdlib-jdk7.jar
Binary file not shown.
Binary file added lib/kotlin-stdlib-jdk8-sources.jar
Binary file not shown.
Binary file added lib/kotlin-stdlib-jdk8.jar
Binary file not shown.
Binary file added lib/kotlin-stdlib-sources.jar
Binary file not shown.
Binary file added lib/kotlin-stdlib.jar
Binary file not shown.
Binary file added lib/kotlin-test-sources.jar
Binary file not shown.
Binary file added lib/kotlin-test.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions src/main/java/duke/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ public int getSize() {
public Task getTask(int i) {
return list.get(i);
}

public ArrayList<Task> getList() {
return list;
}
}
5 changes: 0 additions & 5 deletions src/main/java/duke/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,4 @@ public void markAsDone() {
}

public abstract String toStringInStorage();

@Override
public String toString() {
return String.format("[%s] %s", this.getStatusIcon(), this.name);
}
}
55 changes: 55 additions & 0 deletions src/test/java/TaskListTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import duke.TaskList;
import duke.task.Deadline;
import duke.task.Event;
import duke.task.Task;
import duke.task.ToDo;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;

class TaskListTest {
@Test
public void test_add_task() {
ToDo todo = new ToDo("read book");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
Deadline deadline = new Deadline("return book", LocalDateTime.parse("2021-09-03 18:00", formatter));
Event event = new Event("project meeting", LocalDateTime.parse("2021-08-30 19:00", formatter));

TaskList taskList = new TaskList();
taskList.addTask(todo);
taskList.addTask(deadline);
taskList.addTask(event);

ArrayList<Task> expected = new ArrayList<>();
expected.add(todo);
expected.add(deadline);
expected.add(event);

assertEquals(expected, taskList.getList());
}

@Test
public void test_delete_task() {
ToDo todo = new ToDo("read book");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
Deadline deadline = new Deadline("return book", LocalDateTime.parse("2021-09-03 18:00", formatter));
Event event = new Event("project meeting", LocalDateTime.parse("2021-08-30 19:00", formatter));

TaskList taskList = new TaskList();
taskList.addTask(todo);
taskList.addTask(deadline);
taskList.addTask(event);
taskList.deleteTask(todo);

ArrayList<Task> expected = new ArrayList<>();
expected.add(todo);
expected.add(deadline);
expected.add(event);
expected.remove(todo);

assertEquals(expected, taskList.getList());
}
}
13 changes: 13 additions & 0 deletions src/test/java/ToDoTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import duke.task.ToDo;
import org.junit.jupiter.api.Test;

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

public class ToDoTest {
@Test
public void test_todo_done() {
ToDo toDo = new ToDo("test", false);
toDo.markAsDone();
assertEquals("X", toDo.getStatusIcon());
}
}

0 comments on commit b3baa72

Please sign in to comment.