Skip to content

Commit

Permalink
Add JUnit test case
Browse files Browse the repository at this point in the history
  • Loading branch information
aliciamichellew committed Aug 31, 2023
1 parent 9fb8c90 commit dfa0814
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/test/java/kevin/parser/FileParserTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
52 changes: 52 additions & 0 deletions src/test/java/kevin/parser/ParserTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

0 comments on commit dfa0814

Please sign in to comment.