forked from AY2425S1-CS2103T-F15-2/tp
-
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.
Merge branch 'master' into fix-alpha-bugs
- Loading branch information
Showing
4 changed files
with
108 additions
and
3 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
67 changes: 67 additions & 0 deletions
67
src/test/java/seedu/address/model/person/ModuleContainsKeywordsPredicateTest.java
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,67 @@ | ||
package seedu.address.model.person; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.testutil.PersonBuilder; | ||
|
||
public class ModuleContainsKeywordsPredicateTest { | ||
|
||
@Test | ||
public void equals() { | ||
String firstPredicateKeyword = "CS1010"; | ||
String secondPredicateKeyword = "CS2030"; | ||
|
||
ModuleContainsKeywordsPredicate firstPredicate = | ||
new ModuleContainsKeywordsPredicate(firstPredicateKeyword); | ||
ModuleContainsKeywordsPredicate secondPredicate = | ||
new ModuleContainsKeywordsPredicate(secondPredicateKeyword); | ||
|
||
// same object -> returns true | ||
assertTrue(firstPredicate.equals(firstPredicate)); | ||
|
||
// same values -> returns true | ||
ModuleContainsKeywordsPredicate firstPredicateCopy = | ||
new ModuleContainsKeywordsPredicate(firstPredicateKeyword); | ||
assertTrue(firstPredicate.equals(firstPredicateCopy)); | ||
|
||
// different types -> returns false | ||
assertFalse(firstPredicate.equals(1)); | ||
|
||
// null -> returns false | ||
assertFalse(firstPredicate.equals(null)); | ||
|
||
// different predicate -> returns false | ||
assertFalse(firstPredicate.equals(secondPredicate)); | ||
} | ||
|
||
@Test | ||
public void test_moduleContainsKeyword_returnsTrue() { | ||
ModuleContainsKeywordsPredicate predicate = new ModuleContainsKeywordsPredicate("CS1010"); | ||
assertTrue(predicate.test(new PersonBuilder().addUngradedModule("CS1010").build())); | ||
|
||
predicate = new ModuleContainsKeywordsPredicate("cs1010"); | ||
assertTrue(predicate.test(new PersonBuilder().addUngradedModule("CS1010").build())); | ||
|
||
predicate = new ModuleContainsKeywordsPredicate("1010"); | ||
assertTrue(predicate.test(new PersonBuilder().addUngradedModule("CS1010").build())); | ||
} | ||
|
||
@Test | ||
public void test_moduleDoesNotContainKeyword_returnsFalse() { | ||
ModuleContainsKeywordsPredicate predicate = new ModuleContainsKeywordsPredicate("CS9999"); | ||
assertFalse(predicate.test(new PersonBuilder().addUngradedModule("CS2030").build())); | ||
} | ||
|
||
@Test | ||
public void toStringMethod() { | ||
String keyword = "CS1010"; | ||
ModuleContainsKeywordsPredicate predicate = new ModuleContainsKeywordsPredicate(keyword); | ||
|
||
String expected = ModuleContainsKeywordsPredicate.class.getCanonicalName() + "{keywords=" + keyword + "}"; | ||
assertEquals(expected, predicate.toString()); | ||
} | ||
} |