forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
ed42a00
commit 1e00dcb
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/test/java/seedu/address/model/person/NricMatchesPredicateTest.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,60 @@ | ||
package seedu.address.model.person; | ||
|
||
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 NricMatchesPredicateTest { | ||
|
||
@Test | ||
public void equals() { | ||
String firstNric = "S1234567A"; | ||
String secondNric = "S7654321Z"; | ||
|
||
NricMatchesPredicate firstPredicate = new NricMatchesPredicate(firstNric); | ||
NricMatchesPredicate secondPredicate = new NricMatchesPredicate(secondNric); | ||
|
||
// Same object -> returns true | ||
assertTrue(firstPredicate.equals(firstPredicate)); | ||
|
||
// Same NRIC -> returns true | ||
NricMatchesPredicate firstPredicateCopy = new NricMatchesPredicate(firstNric); | ||
assertTrue(firstPredicate.equals(firstPredicateCopy)); | ||
|
||
// Different types -> returns false | ||
assertFalse(firstPredicate.equals(1)); | ||
|
||
// Null -> returns false | ||
assertFalse(firstPredicate.equals(null)); | ||
|
||
// Different NRIC -> returns false | ||
assertFalse(firstPredicate.equals(secondPredicate)); | ||
} | ||
|
||
@Test | ||
public void test_nricMatches_returnsTrue() { | ||
NricMatchesPredicate predicate = new NricMatchesPredicate("S1234567A"); | ||
Person person = new PersonBuilder().withNric("S1234567A").build(); | ||
|
||
assertTrue(predicate.test(person)); | ||
} | ||
|
||
@Test | ||
public void test_nricMatches_caseInsensitive_returnsTrue() { | ||
NricMatchesPredicate predicate = new NricMatchesPredicate("s1234567a"); | ||
Person person = new PersonBuilder().withNric("S1234567A").build(); | ||
|
||
assertTrue(predicate.test(person)); | ||
} | ||
|
||
@Test | ||
public void test_nricDoesNotMatch_returnsFalse() { | ||
NricMatchesPredicate predicate = new NricMatchesPredicate("S0000000X"); | ||
Person person = new PersonBuilder().withNric("S1234567A").build(); | ||
|
||
assertFalse(predicate.test(person)); | ||
} | ||
} |