-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for #equals(Object) implementations
- Loading branch information
Showing
5 changed files
with
104 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,4 +65,24 @@ public void isValidEmail() { | |
assertTrue(Email.isValidEmail("[email protected]")); // long local part | ||
assertTrue(Email.isValidEmail("[email protected]")); // more than one period in domain | ||
} | ||
|
||
@Test | ||
public void equals() { | ||
Email email = new Email("valid@email"); | ||
|
||
// same values -> returns true | ||
assertTrue(email.equals(new Email("valid@email"))); | ||
|
||
// same object -> returns true | ||
assertTrue(email.equals(email)); | ||
|
||
// null -> returns false | ||
assertFalse(email.equals(null)); | ||
|
||
// different types -> returns false | ||
assertFalse(email.equals(5.0f)); | ||
|
||
// different values -> returns false | ||
assertFalse(email.equals(new Email("other.valid@email"))); | ||
} | ||
} |
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