Skip to content

Commit

Permalink
Merge pull request #212 from nixonwidjaja/fix-claim
Browse files Browse the repository at this point in the history
Fix claim bug
  • Loading branch information
nixonwidjaja committed Nov 13, 2023
2 parents 0365e10 + cd56924 commit 496d716
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.StringUtil;
import seedu.address.logic.Messages;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Birthday;
Expand Down Expand Up @@ -157,6 +158,9 @@ public static Birthday parseDob(String dob) throws ParseException {
public static Claim parseClaim(String claimAmount) throws ParseException {
requireNonNull(claimAmount);
String trimmed = claimAmount.trim();
if (trimmed.length() > 14) {
throw new ParseException(Messages.TOO_LARGE_A_NUMBER);
}
if (!Claim.comtainsSymbol(trimmed)) {
throw new ParseException(Claim.NO_SYMBOLS_ERROR);
} else if (!Claim.isCorrectAmountType(trimmed)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.junit.jupiter.api.Test;

import seedu.address.logic.Messages;
import seedu.address.logic.commands.ClaimCommand;

public class ClaimCommandParserTest {
Expand All @@ -35,6 +36,12 @@ public void parse_withEmptyIndex_returnsFailure() {
assertParseFailure(parser, userInput, CLAIM_EMPTY_INDEX);
}

@Test
public void parse_claimTooLarge_returnsFailure() {
String userInput = "1 $/+100000000000000000000000000000000";
assertParseFailure(parser, userInput, Messages.TOO_LARGE_A_NUMBER);
}

@Test
public void parse_withEmptyAmount_returnsFailure() {
String userInput = String.valueOf(INDEX_FIRST_PERSON.getOneBased());
Expand Down

0 comments on commit 496d716

Please sign in to comment.