use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.
the class FlagParserTest method listFlag_setMultipleTimesWithSpace_throws.
@Test
public void listFlag_setMultipleTimesWithSpace_throws() throws Exception {
ParsedFlags fp = new FlagParser().parse("command", "--flag1", "v1", "--flag1", "v2");
FlagParseException e = assertThrows(FlagParseException.class, () -> Flag.stringList("flag1").getRequiredValue(fp));
assertThat(e).hasMessageThat().contains("Flag --flag1 has been set more than once");
}
use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.
the class FlagParserTest method duplicateSimpleFlag_throws.
@Test
public void duplicateSimpleFlag_throws() throws Exception {
FlagParseException e = assertThrows(FlagParseException.class, () -> new FlagParser().parse("command", "--flag=v1", "--flag=v2").getFlagValue("flag"));
assertThat(e).hasMessageThat().contains("flag");
}
use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.
the class FlagParserTest method booleanFlag_nonTrueFalse_throws.
@Test
public void booleanFlag_nonTrueFalse_throws() throws Exception {
ParsedFlags fp = new FlagParser().parse("command", "--boolFlag=no");
FlagParseException exception = assertThrows(FlagParseException.class, () -> Flag.booleanFlag("boolFlag").getRequiredValue(fp));
assertThat(exception).hasMessageThat().contains("Error while parsing the boolean flag");
}
use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.
the class FlagParserTest method listFlag_multipleValuesWithSpaceInValue_throws.
@Test
public void listFlag_multipleValuesWithSpaceInValue_throws() throws Exception {
FlagParseException e = assertThrows(FlagParseException.class, () -> new FlagParser().parse("command", "--flag1", "v1", "v2", "v3"));
assertThat(e).hasMessageThat().contains("Syntax error: flags should start with -- (v2)");
}
use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.
the class FlagTest method positiveIntegerFlag_negative_throws.
@Test
public void positiveIntegerFlag_negative_throws() throws Exception {
Flag<Integer> flag = Flag.positiveInteger("testFlag");
ParsedFlags parsedFlags = new FlagParser().parse("--testFlag=-1");
FlagParseException exception = assertThrows(FlagParseException.class, () -> flag.getValue(parsedFlags));
assertThat(exception).hasMessageThat().contains("has illegal value");
}
Aggregations