Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed May 21, 2024
1 parent 32c6671 commit 526461d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.common.options.OptionsParser.ConstructionException;
import java.lang.reflect.Constructor;
import java.util.Arrays;
Expand Down Expand Up @@ -160,7 +161,7 @@ public OptionDefinition getOptionDefinitionFromName(String name) {
* appear ordered first by their options class (the order in which they were passed to {@link
* #from(Collection, boolean)}, and then in alphabetic order within each options class.
*/
public Collection<Map.Entry<String, OptionDefinition>> getAllOptionDefinitions() {
public ImmutableSet<Map.Entry<String, OptionDefinition>> getAllOptionDefinitions() {
return nameToField.entrySet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public void usageWithCustomConverter() {
}

@Test
public void unknownBooleanOption() {
public void unknownBooleanOptionNegativeForm() {
OptionsParsingException e =
assertThrows(
OptionsParsingException.class,
Expand All @@ -445,6 +445,28 @@ public void unknownBooleanOption() {
.isEqualTo("Unrecognized option: --no-debug (did you mean '--nodebug'?)");
}

@Test
public void unknownOption() {
OptionsParsingException e =
assertThrows(
OptionsParsingException.class,
() -> Options.parse(HttpOptions.class, new String[] {"--pert"}));
assertThat(e)
.hasMessageThat()
.isEqualTo("Unrecognized option: --pert (did you mean '--port'?)");
}

@Test
public void unknownBooleanOptionPositiveForm() {
OptionsParsingException e =
assertThrows(
OptionsParsingException.class,
() -> Options.parse(HttpOptions.class, new String[] {"--dbg"}));
assertThat(e)
.hasMessageThat()
.isEqualTo("Unrecognized option: --dbg (did you mean '--debug'?)");
}

public static class J extends OptionsBase {
@Option(
name = "j",
Expand Down

0 comments on commit 526461d

Please sign in to comment.