Skip to content

Commit

Permalink
Add test files and fix checkstyle issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jessica2828 committed Oct 16, 2024
1 parent 815731f commit abfd797
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class FilterCommandParserTest {

@Test
public void parse_emptyArg_throwsParseException() {
assertParseFailure(parser, " ", String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE));
assertParseFailure(
parser, " ", String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE));
}

@Test
Expand All @@ -35,4 +36,16 @@ public void parse_validArgs_returnsFilterCommand() {
assertParseSuccess(parser, " \n n/alice \n \t bob \t charlie", expectedFilterCommand);
}

@Test
public void parse_invalidArgs_throwsParseException() {
// invalid inputs
assertParseFailure(parser, "invalid input",
String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE));
assertParseFailure(parser, " n/",
String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE));
assertParseFailure(parser, " n/ ",
String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE));
assertParseFailure(parser, " x/alice",
String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ public void equals() {
List<String> firstPredicateKeywordList = Collections.singletonList("Computer Science");
List<String> secondPredicateKeywordList = Arrays.asList("Computer Science", "Data Science");

CourseContainsKeywordsPredicate firstPredicate = new CourseContainsKeywordsPredicate(firstPredicateKeywordList);
CourseContainsKeywordsPredicate secondPredicate = new CourseContainsKeywordsPredicate(secondPredicateKeywordList);
CourseContainsKeywordsPredicate firstPredicate =
new CourseContainsKeywordsPredicate(firstPredicateKeywordList);
CourseContainsKeywordsPredicate secondPredicate =
new CourseContainsKeywordsPredicate(secondPredicateKeywordList);

// same object -> returns true
assertTrue(firstPredicate.equals(firstPredicate));

// same values -> returns true
CourseContainsKeywordsPredicate firstPredicateCopy = new CourseContainsKeywordsPredicate(firstPredicateKeywordList);
CourseContainsKeywordsPredicate firstPredicateCopy =
new CourseContainsKeywordsPredicate(firstPredicateKeywordList);
assertTrue(firstPredicate.equals(firstPredicateCopy));

// different types -> returns false
Expand All @@ -42,7 +45,8 @@ public void equals() {
@Test
public void test_courseContainsKeywords_returnsTrue() {
// One keyword
CourseContainsKeywordsPredicate predicate = new CourseContainsKeywordsPredicate(Collections.singletonList("Computer Science"));
CourseContainsKeywordsPredicate predicate =
new CourseContainsKeywordsPredicate(Collections.singletonList("Computer Science"));
assertTrue(predicate.test(new PersonBuilder().withCourse("Computer Science").build()));

// Multiple keywords
Expand All @@ -61,7 +65,8 @@ public void test_courseContainsKeywords_returnsTrue() {
@Test
public void test_courseDoesNotContainKeywords_returnsFalse() {
// Zero keywords
CourseContainsKeywordsPredicate predicate = new CourseContainsKeywordsPredicate(Collections.emptyList());
CourseContainsKeywordsPredicate predicate =
new CourseContainsKeywordsPredicate(Collections.emptyList());
assertFalse(predicate.test(new PersonBuilder().withCourse("Computer Science").build()));

// Non-matching keyword
Expand Down

0 comments on commit abfd797

Please sign in to comment.