Skip to content

Commit

Permalink
Merge pull request #225 from EugeneChanJiajun/master
Browse files Browse the repository at this point in the history
Update Junit tests
  • Loading branch information
ChinYanXu committed Apr 12, 2024
2 parents 0c649c7 + afaac8a commit 19fa341
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/test/java/seedu/omnitravel/OmniTravelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import java.io.IOException;
import java.time.DateTimeException;
import java.util.NoSuchElementException;

class OmniTravelTest {


Expand Down Expand Up @@ -580,11 +586,17 @@ public void testAddExceptions() throws OmniException {
@Test
public void testContainsWords() throws OmniException {
CheckParameters.containsWords("2 days");
assertThrows(OmniException.class, () -> {
CheckParameters.containsWords("£$%");
});
}

@Test
public void testIsValidExpense() throws OmniException {
assertTrue(CheckParameters.isValidExpense("50"));
assertThrows(OmniException.class, () -> {
CheckParameters.isValidExpense("-0");
});
}

@Test
Expand All @@ -595,12 +607,39 @@ public void testCheckCurrencyParameters() throws OmniException {

@Test
public void testHandleException() {
CheckParameters.handleException(new OmniException("Test OmniException"));
OmniException omniException = new OmniException("Test OmniException");
NoSuchElementException noSuchElementException = new NoSuchElementException("Test NoSuchElementException");
NumberFormatException numberFormatException = new NumberFormatException("Test NumberFormatException");
DateTimeException dateTimeException = new DateTimeException("Test DateTimeException");
IOException ioException = new IOException("Test IOException");
InterruptedException interruptedException = new InterruptedException("Test InterruptedException");

assertDoesNotThrow(() -> {
CheckParameters.handleException(omniException);
});
assertDoesNotThrow(() -> {
CheckParameters.handleException(noSuchElementException);
});
assertDoesNotThrow(() -> {
CheckParameters.handleException(numberFormatException);
});
assertDoesNotThrow(() -> {
CheckParameters.handleException(dateTimeException);
});
assertDoesNotThrow(() -> {
CheckParameters.handleException(ioException);
});
assertDoesNotThrow(() -> {
CheckParameters.handleException(interruptedException);
});
}

@Test
public void testAsciiCheck() throws OmniException {
CheckParameters.asciiCheck("Valid input");
assertThrows(OmniException.class, () -> {
CheckParameters.asciiCheck(" ©, ®, €, £, µ, ¥,");
});
}

@Test
Expand Down

0 comments on commit 19fa341

Please sign in to comment.