diff --git a/src/test/java/kevin/parser/FileParserTest.java b/src/test/java/kevin/parser/FileParserTest.java new file mode 100644 index 0000000000..cea56e562a --- /dev/null +++ b/src/test/java/kevin/parser/FileParserTest.java @@ -0,0 +1,52 @@ +package kevin.parser; + +import kevin.exception.KevinException; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class FileParserTest { + @Test + public void parseLine_invalidCommand_exceptionThrown() { + String input = "invalidCommand"; + try { + FileParser fileParser = new FileParser(); + fileParser.parseLine(input); + } catch (Exception ex) { + assertTrue(ex instanceof KevinException); + } + } + + @Test + public void parseLine_invalidToDoInput_exceptionThrown() { + String input = "Todo - "; + try { + FileParser fileParser = new FileParser(); + fileParser.parseLine(input); + } catch (Exception ex) { + assertTrue(ex instanceof KevinException); + } + } + + @Test + public void parseLine_invalidDeadlineInput_exceptionThrown() { + String input = "Deadline - cs2103 - today"; + try { + FileParser fileParser = new FileParser(); + fileParser.parseLine(input); + } catch (Exception ex) { + assertTrue(ex instanceof KevinException); + } + } + + @Test + public void parseLine_invalidEventInput_exceptionThrown() { + String input = "Event - lecture - 2pm"; + try { + FileParser fileParser = new FileParser(); + fileParser.parseLine(input); + } catch (Exception ex) { + assertTrue(ex instanceof KevinException); + } + } +} diff --git a/src/test/java/kevin/parser/ParserTest.java b/src/test/java/kevin/parser/ParserTest.java new file mode 100644 index 0000000000..4775f04ed4 --- /dev/null +++ b/src/test/java/kevin/parser/ParserTest.java @@ -0,0 +1,52 @@ +package kevin.parser; + +import kevin.exception.KevinException; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class ParserTest { + @Test + public void prepareArguments_invalidCommand_exceptionThrown() { + String input = "invalidCommand"; + try { + Parser parser = new Parser(); + parser.prepareArguments(input); + } catch (Exception ex) { + assertTrue(ex instanceof KevinException); + } + } + + @Test + public void prepareArguments_invalidToDoInput_exceptionThrown() { + String input = "todo "; + try { + Parser parser = new Parser(); + parser.prepareArguments(input); + } catch (Exception ex) { + assertTrue(ex instanceof KevinException); + } + } + + @Test + public void prepareArguments_invalidDeadlineInput_exceptionThrown() { + String input = "deadline cs2103 by today"; + try { + Parser parser = new Parser(); + parser.prepareArguments(input); + } catch (Exception ex) { + assertTrue(ex instanceof KevinException); + } + } + + @Test + public void prepareArguments_invalidEventInput_exceptionThrown() { + String input = "event lecture /from 2pm"; + try { + Parser parser = new Parser(); + parser.prepareArguments(input); + } catch (Exception ex) { + assertTrue(ex instanceof KevinException); + } + } +}