forked from nus-cs2103-AY2425S1/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
Showing
12 changed files
with
216 additions
and
20 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
package snowy; | ||
|
||
public class SnowyException extends Exception { | ||
public class SnowyException extends RuntimeException { | ||
public SnowyException(String message) { | ||
super(message); | ||
} | ||
} |
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,30 @@ | ||
package snowy; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class DeadlineTest { | ||
|
||
@Test | ||
public void toString_normalName_success() { | ||
assertEquals("[D][ ] Return Book (by September 11, 2024)", | ||
new Deadline("Return Book", "2024-09-11").toString()); | ||
} | ||
|
||
@Test | ||
public void toFileStorage_normalName_success() { | ||
assertEquals("D|0|Return Book|2024-09-11", | ||
new Deadline("Return Book", "2024-09-11").toFileStorage()); | ||
} | ||
|
||
@Test void constructor_invalidDate_exceptionThrown() { | ||
try { | ||
new Deadline("Return book", "12-123-1234"); | ||
fail(); | ||
} catch (SnowyException e) { | ||
assertEquals("Wrong date format", e.getMessage()); | ||
} | ||
} | ||
} |
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,29 @@ | ||
package snowy; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class EventTest { | ||
@Test | ||
public void toString_normalName_success() { | ||
assertEquals("[E][ ] Orientation Camp (from September 11, 2024 to: September 12, 2024)", | ||
new Event("Orientation Camp", "2024-09-11", "2024-09-12").toString()); | ||
} | ||
|
||
@Test | ||
public void toFileStorage_normalName_success() { | ||
assertEquals("[E][ ] Orientation Camp (from September 11, 2024 to: September 12, 2024)", | ||
new Event("Orientation Camp", "2024-09-11", "2024-09-12").toString()); | ||
} | ||
|
||
@Test void constructor_invalidDate_exceptionThrown() { | ||
try { | ||
new Event("Return book", "12-123-1234", "12-123-1234"); | ||
fail(); | ||
} catch (SnowyException e) { | ||
assertEquals("Wrong date format", e.getMessage()); | ||
} | ||
} | ||
} |
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,16 @@ | ||
package snowy; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertArrayEquals; | ||
|
||
public class ParserTest { | ||
@Test | ||
public void parse_allCapitalCommand_returnLowerCase() { | ||
assertArrayEquals(new String[] {"todo", "read book"}, Parser.parse("TODO read book")); | ||
} | ||
|
||
public void parse_capitalDescription_retainCapital() { | ||
assertArrayEquals(new String[] {"todo", "Read Book"}, Parser.parse("todo Read Book")); | ||
} | ||
} |
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,101 @@ | ||
package snowy; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.ArrayList; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class TaskListTest { | ||
|
||
@Test | ||
public void toString_correctInput_success() { | ||
ArrayList<String> lines = new ArrayList<>(); | ||
lines.add("T|1|read book"); | ||
lines.add("D|0|return book|2024-09-05"); | ||
lines.add("E|0|Camp|2024-09-01|2024-09-02"); | ||
TaskList tasks = new TaskList(lines); | ||
|
||
assertEquals("1. [T][X] read book\n" + | ||
"2. [D][ ] return book (by September 5, 2024)\n" + | ||
"3. [E][ ] Camp (from September 1, 2024 to: September 2, 2024)\n" | ||
, tasks.toString()); | ||
} | ||
|
||
@Test | ||
public void toSaveString_correctInput_success() { | ||
ArrayList<String> lines = new ArrayList<>(); | ||
lines.add("T|1|read book"); | ||
lines.add("D|0|return book|2024-09-05"); | ||
lines.add("E|0|Camp|2024-09-01|2024-09-02"); | ||
TaskList tasks = new TaskList(lines); | ||
|
||
assertEquals("T|1|read book\n" + | ||
"D|0|return book|2024-09-05\n" + | ||
"E|0|Camp|2024-09-01|2024-09-02\n" | ||
, tasks.toSaveString()); | ||
} | ||
|
||
@Test | ||
public void addToDo_correctInput_success() { | ||
TaskList tasks = new TaskList(); | ||
tasks.addToDo("Read Book"); | ||
|
||
assertEquals("1. [T][ ] Read Book\n", tasks.toString()); | ||
} | ||
|
||
@Test | ||
public void addToDo_invalidInput_exceptionThrown() { | ||
try { | ||
TaskList tasks = new TaskList(); | ||
tasks.addToDo(""); | ||
fail(); | ||
} catch (SnowyException e) { | ||
assertEquals("Invalid input for Todo", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void addDeadline_correctInput_success() { | ||
TaskList tasks = new TaskList(); | ||
tasks.addDeadline("Return Book /by 2024-09-05"); | ||
|
||
assertEquals("1. [D][ ] Return Book (by September 5, 2024)\n", tasks.toString()); | ||
} | ||
|
||
@Test | ||
public void addDeadline_emptyInput_exceptionThrown() { | ||
try { | ||
TaskList tasks = new TaskList(); | ||
tasks.addDeadline(""); | ||
fail(); | ||
} catch (SnowyException e) { | ||
assertEquals("Invalid input for Deadline", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void addDeadline_missingBy_exceptionThrown() { | ||
try { | ||
TaskList tasks = new TaskList(); | ||
tasks.addDeadline("Return book 2024-09-05"); | ||
fail(); | ||
} catch (SnowyException e) { | ||
assertEquals("Invalid input for Deadline", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void addDeadline_InvalidDate_exceptionThrown() { | ||
try { | ||
TaskList tasks = new TaskList(); | ||
tasks.addDeadline("Return book /by 123-09-05"); | ||
fail(); | ||
} catch (SnowyException e) { | ||
assertEquals("Wrong date format", e.getMessage()); | ||
} | ||
} | ||
|
||
|
||
} |
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,16 @@ | ||
package snowy; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
public class ToDoTest { | ||
@Test | ||
public void toString_normalName_success() { | ||
assertEquals("[T][ ] Read Book",new ToDo("Read Book").toString()); | ||
} | ||
|
||
@Test | ||
public void toFileStorage_normalName_success() { | ||
assertEquals("T|0|Read Book",new ToDo("Read Book").toFileStorage()); | ||
} | ||
} |