Skip to content

Commit

Permalink
Merge pull request #153 from AjayArvind2207/branch-AddTestsForTag
Browse files Browse the repository at this point in the history
Add tests for equality in Tag.java
  • Loading branch information
Xilef121 authored Apr 14, 2024
2 parents aa2a1a7 + b5fe5d9 commit f9a3be5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/test/java/seedu/address/model/company/PhoneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ public void isValidPhone() {

@Test
public void isPhonePresent() {
Phone default_phone = Phone.getDefaultPhone();
Phone defaultPhone = Phone.getDefaultPhone();
Phone phone = new Phone("995");
assertTrue(phone.isPhonePresent());
assertFalse(default_phone.isPhonePresent());
assertFalse(defaultPhone.isPhonePresent());
}

@Test
public void equals() {
Phone phone = new Phone("999");
Phone default_phone = Phone.getDefaultPhone();
Phone defaultPhone = Phone.getDefaultPhone();
// same values -> returns true
assertTrue(phone.equals(new Phone("999")));

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

//two phones with default values -> return true
assertTrue(default_phone.equals(Phone.getDefaultPhone()));
assertTrue(defaultPhone.equals(Phone.getDefaultPhone()));

// null -> returns false
assertFalse(phone.equals(null));
Expand All @@ -74,13 +74,13 @@ public void equals() {
assertFalse(phone.equals(new Phone("995")));

//one default phone, one non default phone -> returns false
assertFalse(default_phone.equals(new Phone("995")));
assertFalse(defaultPhone.equals(new Phone("995")));
}

@Test
public void testToString() {
Phone default_phone = Phone.getDefaultPhone();
assertTrue(default_phone.toString().equals("No phone number"));
Phone defaultPhone = Phone.getDefaultPhone();
assertTrue(defaultPhone.toString().equals("No phone number"));
Phone phone = new Phone("995");
assertTrue(phone.toString().equals("995"));
}
Expand Down
27 changes: 25 additions & 2 deletions src/test/java/seedu/address/model/tag/TagTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package seedu.address.model.tag;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.testutil.Assert.assertThrows;

import org.junit.jupiter.api.Test;


public class TagTest {

@Test
Expand All @@ -26,11 +29,31 @@ public void isValidTagName() {
@Test
public void capitaliseTest() {
Tag tag = new Tag("software engineer");
assert(tag.capitalise().equals("Software Engineer"));
assertTrue(tag.capitalise().equals("Software Engineer"));

tag = new Tag("softWare EnginEEr");
assert(tag.capitalise().equals("Software Engineer"));
assertTrue(tag.capitalise().equals("Software Engineer"));

}

@Test
public void equals() {
Tag tag = new Tag("Valid Tag");

// same values -> returns true
assertTrue(tag.equals(new Tag("Valid Tag")));

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

// null -> returns false
assertFalse(tag.equals(null));

// different types -> returns false
assertFalse(tag.equals(5.0f));

// different values -> returns false
assertFalse(tag.equals(new Tag("Other Valid Tag")));
}

}

0 comments on commit f9a3be5

Please sign in to comment.