Skip to content

Commit

Permalink
Merge pull request #242 from yucongkoo/branch-prefix-enhancement
Browse files Browse the repository at this point in the history
Add test case
  • Loading branch information
LamJiuFong authored Nov 3, 2023
2 parents 4dba78e + effccfc commit 9b68aca
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public JsonSerializableAddressBook(ReadOnlyAddressBook source) {
public AddressBook toModelType() throws IllegalValueException {
AddressBook addressBook = new AddressBook();
for (JsonAdaptedPerson jsonAdaptedPerson : persons) {
if (jsonAdaptedPerson == null) {
continue;
}
Person person = jsonAdaptedPerson.toModelType();
if (addressBook.hasPerson(person)) {
throw new IllegalValueException(MESSAGE_DUPLICATE_PERSON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
public class ArgumentTokenizerTest {

private final Prefix unknownPrefix = new Prefix("--u", "--u");
private final Prefix pSlash = new Prefix("p/", "p/");
private final Prefix dashT = new Prefix("-t", "-t");
private final Prefix hatQ = new Prefix("^Q", "^Q");
private final Prefix pSlash = new Prefix("p/", "ppp/");
private final Prefix dashT = new Prefix("-t", "-ttt");
private final Prefix hatQ = new Prefix("^Q", "^QQQ");

@Test
public void tokenize_emptyArgsString_noValues() {
Expand Down Expand Up @@ -71,12 +71,21 @@ public void tokenize_oneArgument() {
assertPreamblePresent(argMultimap, "Some preamble string");
assertArgumentPresent(argMultimap, pSlash, "Argument value");

argsString = " Some preamble string ppp/ Argument value ";
argMultimap = ArgumentTokenizer.tokenize(argsString, pSlash);
assertPreamblePresent(argMultimap, "Some preamble string");
assertArgumentPresent(argMultimap, pSlash, "Argument value");

// No preamble
argsString = " p/ Argument value ";
argMultimap = ArgumentTokenizer.tokenize(argsString, pSlash);
assertPreambleEmpty(argMultimap);
assertArgumentPresent(argMultimap, pSlash, "Argument value");

argsString = " ppp/ Argument value ";
argMultimap = ArgumentTokenizer.tokenize(argsString, pSlash);
assertPreambleEmpty(argMultimap);
assertArgumentPresent(argMultimap, pSlash, "Argument value");
}

@Test
Expand Down Expand Up @@ -136,6 +145,16 @@ public void tokenize_multipleArgumentsJoined() {
assertArgumentAbsent(argMultimap, hatQ);
}

@Test
public void tokenize_multipleArgumentsWithSecondaryPrefix_success() {
String argsString = "Some Preamble String ppp/value 1 pPp/value2 p/value3 P/value4 PPP/value5 -tdashvalue -ttt";
ArgumentMultimap argumentMultimap = ArgumentTokenizer.tokenize(argsString, pSlash, dashT, hatQ);
assertPreamblePresent(argumentMultimap, "Some Preamble String");
assertArgumentPresent(argumentMultimap, pSlash, "value 1", "value2", "value3", "value4", "value5");
assertArgumentPresent(argumentMultimap, dashT, "dashvalue", "");
assertArgumentAbsent(argumentMultimap, hatQ);
}


@Test
public void equalsMethod() {
Expand Down

0 comments on commit 9b68aca

Please sign in to comment.