diff --git a/src/test/java/seedu/address/AppParametersTest.java b/src/test/java/seedu/address/AppParametersTest.java index 3edf13d6..133cc008 100644 --- a/src/test/java/seedu/address/AppParametersTest.java +++ b/src/test/java/seedu/address/AppParametersTest.java @@ -1,6 +1,8 @@ package seedu.address; 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 java.nio.file.Paths; import java.util.Collections; @@ -44,6 +46,28 @@ public void toStringMethod() { assertEquals(expected, appParameters.toString()); } + @Test + public void equals() { + AppParameters appParameters = new AppParameters(); + + // same values -> returns true + assertTrue(appParameters.equals(new AppParameters())); + + // same object -> returns true + assertTrue(appParameters.equals(appParameters)); + + // null -> returns false + assertFalse(appParameters.equals(null)); + + // different types -> returns false + assertFalse(appParameters.equals(5.0f)); + + // different config path -> returns false + AppParameters otherAppParameters = new AppParameters(); + otherAppParameters.setConfigPath(Paths.get("configPath")); + assertFalse(appParameters.equals(otherAppParameters)); + } + private static class ParametersStub extends Application.Parameters { private Map namedParameters = new HashMap<>(); diff --git a/src/test/java/seedu/address/model/person/AddressTest.java b/src/test/java/seedu/address/model/person/AddressTest.java index dcd3be87..314885ec 100644 --- a/src/test/java/seedu/address/model/person/AddressTest.java +++ b/src/test/java/seedu/address/model/person/AddressTest.java @@ -33,4 +33,24 @@ public void isValidAddress() { assertTrue(Address.isValidAddress("-")); // one character assertTrue(Address.isValidAddress("Leng Inc; 1234 Market St; San Francisco CA 2349879; USA")); // long address } + + @Test + public void equals() { + Address address = new Address("Valid Address"); + + // same values -> returns true + assertTrue(address.equals(new Address("Valid Address"))); + + // same object -> returns true + assertTrue(address.equals(address)); + + // null -> returns false + assertFalse(address.equals(null)); + + // different types -> returns false + assertFalse(address.equals(5.0f)); + + // different values -> returns false + assertFalse(address.equals(new Address("Other Valid Address"))); + } } diff --git a/src/test/java/seedu/address/model/person/EmailTest.java b/src/test/java/seedu/address/model/person/EmailTest.java index bbcc6c8c..f08cdff0 100644 --- a/src/test/java/seedu/address/model/person/EmailTest.java +++ b/src/test/java/seedu/address/model/person/EmailTest.java @@ -65,4 +65,24 @@ public void isValidEmail() { assertTrue(Email.isValidEmail("if.you.dream.it_you.can.do.it@example.com")); // long local part assertTrue(Email.isValidEmail("e1234567@u.nus.edu")); // 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"))); + } } diff --git a/src/test/java/seedu/address/model/person/NameTest.java b/src/test/java/seedu/address/model/person/NameTest.java index c9801392..94e3dd72 100644 --- a/src/test/java/seedu/address/model/person/NameTest.java +++ b/src/test/java/seedu/address/model/person/NameTest.java @@ -37,4 +37,24 @@ public void isValidName() { assertTrue(Name.isValidName("Capital Tan")); // with capital letters assertTrue(Name.isValidName("David Roger Jackson Ray Jr 2nd")); // long names } + + @Test + public void equals() { + Name name = new Name("Valid Name"); + + // same values -> returns true + assertTrue(name.equals(new Name("Valid Name"))); + + // same object -> returns true + assertTrue(name.equals(name)); + + // null -> returns false + assertFalse(name.equals(null)); + + // different types -> returns false + assertFalse(name.equals(5.0f)); + + // different values -> returns false + assertFalse(name.equals(new Name("Other Valid Name"))); + } } diff --git a/src/test/java/seedu/address/model/person/PhoneTest.java b/src/test/java/seedu/address/model/person/PhoneTest.java index 8dd52766..deaaa5ba 100644 --- a/src/test/java/seedu/address/model/person/PhoneTest.java +++ b/src/test/java/seedu/address/model/person/PhoneTest.java @@ -37,4 +37,24 @@ public void isValidPhone() { assertTrue(Phone.isValidPhone("93121534")); assertTrue(Phone.isValidPhone("124293842033123")); // long phone numbers } + + @Test + public void equals() { + Phone phone = new Phone("999"); + + // same values -> returns true + assertTrue(phone.equals(new Phone("999"))); + + // same object -> returns true + assertTrue(phone.equals(phone)); + + // null -> returns false + assertFalse(phone.equals(null)); + + // different types -> returns false + assertFalse(phone.equals(5.0f)); + + // different values -> returns false + assertFalse(phone.equals(new Phone("995"))); + } }