Skip to content

Commit

Permalink
Fix ThemeCommandParser
Browse files Browse the repository at this point in the history
  • Loading branch information
ruishanteo committed Nov 4, 2023
1 parent cd69484 commit dd1d951
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ public ThemeCommand parse(String args) throws ParseException {
String.format(MESSAGE_INVALID_COMMAND_FORMAT, ThemeCommand.MESSAGE_USAGE));
}

String theme = trimmedArgs.split("\\s+")[0];
String[] splitArgs = trimmedArgs.split("\\s+");
if (splitArgs.length > 1) {
throw new ParseException(
String.format(MESSAGE_UNKNOWN_THEME, ThemeCommand.MESSAGE_USAGE));
}

String theme = splitArgs[0];

switch(theme) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public void parse_unknownTheme_throwsParseException() {
ThemeCommand.MESSAGE_USAGE));
}

@Test
public void parse_twoThemes_throwsParseException() {
assertParseFailure(parser, "blue green", String.format(MESSAGE_UNKNOWN_THEME,
ThemeCommand.MESSAGE_USAGE));
}

@Test
public void parse_validArgs_returnsThemeCommand() {
ThemeCommand expectedThemeCommand1 =
Expand Down

0 comments on commit dd1d951

Please sign in to comment.