Skip to content

Commit

Permalink
Add tests for UniquePersonList
Browse files Browse the repository at this point in the history
  • Loading branch information
kaajinn committed Oct 28, 2024
1 parent 32c4cf6 commit 34dca7f
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ public void sortById_success() {
VALID_DELIVERY_LIST_ID_UNSORTED.add(VALID_DELIVERY_1);
VALID_DELIVERY_LIST_ID_UNSORTED.sortById();

System.out.println(VALID_DELIVERY_LIST_ID_UNSORTED);

assertArrayEquals(VALID_DELIVERY_LIST_ID_SORTED.asUnmodifiableObservableList().toArray(),
VALID_DELIVERY_LIST_ID_UNSORTED.asUnmodifiableObservableList().toArray());
}
Expand Down
108 changes: 108 additions & 0 deletions src/test/java/seedu/address/model/person/UniquePersonListTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package seedu.address.model.person;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -8,6 +9,8 @@
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.BOB;
import static seedu.address.testutil.TypicalPersons.HOON;
import static seedu.address.testutil.TypicalPersons.IDA;

import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -168,6 +171,111 @@ public void asUnmodifiableObservableList_modifyList_throwsUnsupportedOperationEx
-> uniquePersonList.asUnmodifiableObservableList().remove(0));
}

@Test
public void reversePersonList_success() {
uniquePersonList.add(ALICE);
uniquePersonList.add(HOON);
uniquePersonList.add(IDA);
uniquePersonList.add(BOB);

UniquePersonList expectedUniquePersonList = new UniquePersonList();
expectedUniquePersonList.add(BOB);
expectedUniquePersonList.add(IDA);
expectedUniquePersonList.add(HOON);
expectedUniquePersonList.add(ALICE);
expectedUniquePersonList.reversePersonList();
}

@Test
public void sortByDate_success() {
uniquePersonList.add(ALICE);
uniquePersonList.add(HOON);
uniquePersonList.add(IDA);
uniquePersonList.add(BOB);

UniquePersonList expectedUniquePersonList = new UniquePersonList();
expectedUniquePersonList.add(HOON);
expectedUniquePersonList.add(IDA);
expectedUniquePersonList.add(ALICE);
expectedUniquePersonList.add(BOB);
expectedUniquePersonList.sortByDate();

assertArrayEquals(uniquePersonList.asUnmodifiableObservableList().toArray(),
expectedUniquePersonList.asUnmodifiableObservableList().toArray());
}

@Test
public void sortByEmail_success() {
uniquePersonList.add(ALICE);
uniquePersonList.add(BOB);
uniquePersonList.add(IDA);
uniquePersonList.add(HOON);

UniquePersonList expectedUniquePersonList = new UniquePersonList();
expectedUniquePersonList.add(HOON);
expectedUniquePersonList.add(IDA);
expectedUniquePersonList.add(ALICE);
expectedUniquePersonList.add(BOB);
expectedUniquePersonList.sortByEmail();

assertArrayEquals(uniquePersonList.asUnmodifiableObservableList().toArray(),
expectedUniquePersonList.asUnmodifiableObservableList().toArray());
}

@Test
public void sortByName_success() {
uniquePersonList.add(ALICE);
uniquePersonList.add(BOB);
uniquePersonList.add(HOON);
uniquePersonList.add(IDA);

UniquePersonList expectedUniquePersonList = new UniquePersonList();
expectedUniquePersonList.add(HOON);
expectedUniquePersonList.add(BOB);
expectedUniquePersonList.add(IDA);
expectedUniquePersonList.add(ALICE);
expectedUniquePersonList.sortByName();

assertArrayEquals(uniquePersonList.asUnmodifiableObservableList().toArray(),
expectedUniquePersonList.asUnmodifiableObservableList().toArray());
}

@Test
public void sortByPhone_success() {
uniquePersonList.add(BOB);
uniquePersonList.add(IDA);
uniquePersonList.add(HOON);
uniquePersonList.add(ALICE);

UniquePersonList expectedUniquePersonList = new UniquePersonList();
expectedUniquePersonList.add(HOON);
expectedUniquePersonList.add(BOB);
expectedUniquePersonList.add(IDA);
expectedUniquePersonList.add(ALICE);
expectedUniquePersonList.sortByPhone();

assertArrayEquals(uniquePersonList.asUnmodifiableObservableList().toArray(),
expectedUniquePersonList.asUnmodifiableObservableList().toArray());
}

@Test
public void sortByRole_success() {
uniquePersonList.add(ALICE);
uniquePersonList.add(HOON);
uniquePersonList.add(IDA);
uniquePersonList.add(BOB);

UniquePersonList expectedUniquePersonList = new UniquePersonList();
expectedUniquePersonList.add(ALICE);
expectedUniquePersonList.add(HOON);
expectedUniquePersonList.add(IDA);
expectedUniquePersonList.add(BOB);
expectedUniquePersonList.sortByRole();

assertArrayEquals(uniquePersonList.asUnmodifiableObservableList().toArray(),
expectedUniquePersonList.asUnmodifiableObservableList().toArray());
}

@Test
public void toStringMethod() {
assertEquals(uniquePersonList.asUnmodifiableObservableList().toString(), uniquePersonList.toString());
Expand Down

0 comments on commit 34dca7f

Please sign in to comment.