From 2607c6db8263b5f3768384fed3f817c0a20f41cc Mon Sep 17 00:00:00 2001 From: Felix Wang Wei Ze <122252298+Xilef121@users.noreply.github.com> Date: Mon, 15 Apr 2024 04:09:26 +0800 Subject: [PATCH] Create test class for SortType --- .../commons/core/sorttype/SortTypeTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/java/seedu/address/commons/core/sorttype/SortTypeTest.java diff --git a/src/test/java/seedu/address/commons/core/sorttype/SortTypeTest.java b/src/test/java/seedu/address/commons/core/sorttype/SortTypeTest.java new file mode 100644 index 00000000000..b24b65edc28 --- /dev/null +++ b/src/test/java/seedu/address/commons/core/sorttype/SortTypeTest.java @@ -0,0 +1,34 @@ +package seedu.address.commons.core.sorttype; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; + +import org.junit.jupiter.api.Test; + +public class SortTypeTest { + + @Test + public void testGetSortType() { + assertEquals(SortType.ALPHABETICAL_ASCENDING, SortType.getSortType('a')); + assertEquals(SortType.STARTDATE_ASCENDING, SortType.getSortType('s')); + assertEquals(SortType.ENDDATE_ASCENDING, SortType.getSortType('e')); + + // Test invalid preference + assertNull(SortType.getSortType('x')); + } + + @Test + public void testGetPref() { + assertEquals('a', SortType.ALPHABETICAL_ASCENDING.getPref()); + assertEquals('s', SortType.STARTDATE_ASCENDING.getPref()); + assertEquals('e', SortType.ENDDATE_ASCENDING.getPref()); + } + + @Test + public void testEquality() { + assertSame(SortType.ALPHABETICAL_ASCENDING, SortType.ALPHABETICAL_ASCENDING); + assertSame(SortType.STARTDATE_ASCENDING, SortType.STARTDATE_ASCENDING); + assertSame(SortType.ENDDATE_ASCENDING, SortType.ENDDATE_ASCENDING); + } +}