forked from nus-cs2103-AY2021S1/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
033440c
commit 519c264
Showing
6 changed files
with
143 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import command.DeadlineCommand; | ||
import command.TodoCommand; | ||
import duke.Parser; | ||
import exception.DukeException; | ||
import exception.InvalidDateException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ParserTest { | ||
|
||
@Test | ||
public void parseDateTest1() throws InvalidDateException { | ||
assertEquals(Parser.parseDate("12/12/2019 0910"), LocalDateTime.of(2019, 12, 12, 9, 10)); | ||
} | ||
|
||
@Test | ||
public void parseDateTest2() throws InvalidDateException { | ||
assertEquals(Parser.parseDate("2/5/2020 1700"), LocalDateTime.of(2020, 5, 2, 17, 0)); | ||
} | ||
|
||
@Test | ||
public void parseTest1() throws DukeException { | ||
assertEquals(Parser.parse("todo Eat lunch"), new TodoCommand("Eat lunch")); | ||
} | ||
|
||
@Test | ||
public void parseTest2() throws DukeException { | ||
assertEquals(Parser.parse("deadline finish assignment /by 12/12/2019 0910"), | ||
new DeadlineCommand("finish assignment", LocalDateTime.of(2019, 12, 12, 9, 10))); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import duke.Storage; | ||
import duke.TaskList; | ||
import exception.DukeException; | ||
import org.junit.jupiter.api.Test; | ||
import task.DeadlineTask; | ||
import task.Task; | ||
import task.TodoTask; | ||
|
||
import java.io.File; | ||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
public class StorageTest { | ||
|
||
@Test | ||
public void TestReadValidFile() throws DukeException { | ||
assertEquals(new Storage("data/duke.txt").readFile(), new File("data/duke.txt")); | ||
} | ||
|
||
@Test | ||
public void TestLoad() throws DukeException { | ||
List<Task> arrayList = new Storage("data/duke.txt").load(); | ||
assertEquals(arrayList.size(), 1); | ||
assertEquals(arrayList.get(0), new TodoTask("Wash Clothes", 1)); | ||
} | ||
|
||
// Test data/duke.txt if it doesn't exist in test/data/duke.txt | ||
@Test | ||
public void TestLoadEmptyDirectory() throws DukeException { | ||
assertEquals(new Storage("data/dukeEmpty.txt").load(), new ArrayList<>()); | ||
} | ||
|
||
|
||
@Test | ||
public void TestReadLine() throws DukeException { | ||
assertEquals(new Storage("").readLine("D | 0 | tasking | 2020-02-02T18:00"), | ||
new DeadlineTask("tasking", LocalDateTime.of(2020,2,2,18,0))); | ||
} | ||
|
||
@Test | ||
public void TestSaveTask() throws DukeException { | ||
Storage testStorage = new Storage("data/saveTask.txt"); | ||
testStorage.load(); | ||
TaskList taskList = new TaskList(); | ||
|
||
taskList.addTask(new TodoTask("Wash Clothes", 1)); | ||
taskList.addTask(new TodoTask("Do tutorial", 0)); | ||
|
||
testStorage.saveTasks(taskList); | ||
|
||
List<Task> arrayList = testStorage.load(); | ||
assertEquals(arrayList.size(), 2); | ||
assertEquals(arrayList.get(0), new TodoTask("Wash Clothes", 1)); | ||
assertEquals(arrayList.get(1), new TodoTask("Do tutorial", 0)); | ||
|
||
|
||
} | ||
|
||
} |