use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.
the class FlagTest method positiveIntegerFlag_zero_throws.
@Test
public void positiveIntegerFlag_zero_throws() throws Exception {
Flag<Integer> flag = Flag.positiveInteger("testFlag");
ParsedFlags parsedFlags = new FlagParser().parse("--testFlag=0");
FlagParseException exception = assertThrows(FlagParseException.class, () -> flag.getValue(parsedFlags));
assertThat(exception).hasMessageThat().contains("has illegal value");
}
use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.
the class FlagTest method positiveIntegerFlag_notANumber_throws.
@Test
public void positiveIntegerFlag_notANumber_throws() throws Exception {
Flag<Integer> flag = Flag.positiveInteger("testFlag");
ParsedFlags parsedFlags = new FlagParser().parse("--testFlag=blah");
FlagParseException exception = assertThrows(FlagParseException.class, () -> flag.getValue(parsedFlags));
assertThat(exception).hasMessageThat().contains("Error while parsing");
}
use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.
the class FlagTest method nonNegativeIntegerFlag_notANumber_throws.
@Test
public void nonNegativeIntegerFlag_notANumber_throws() throws Exception {
Flag<Integer> flag = Flag.nonNegativeInteger("testFlag");
ParsedFlags parsedFlags = new FlagParser().parse("--testFlag=blah");
FlagParseException exception = assertThrows(FlagParseException.class, () -> flag.getValue(parsedFlags));
assertThat(exception).hasMessageThat().contains("Error while parsing");
}
use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.
the class BuildSdkApksCommandTest method nonPositiveMaxThreads_throws.
@Test
public void nonPositiveMaxThreads_throws() throws Exception {
FlagParseException zeroException = assertThrows(FlagParseException.class, () -> BuildSdkApksCommand.fromFlags(getDefaultFlagsWithAdditionalFlags("--max-threads=0")));
assertThat(zeroException).hasMessageThat().contains("flag --max-threads has illegal value");
FlagParseException negativeException = assertThrows(FlagParseException.class, () -> BuildSdkApksCommand.fromFlags(getDefaultFlagsWithAdditionalFlags("--max-threads=-3")));
assertThat(negativeException).hasMessageThat().contains("flag --max-threads has illegal value");
}
use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.
the class FlagTest method keyValueFlag_missingKeyValueDelimiter_throws.
@Test
public void keyValueFlag_missingKeyValueDelimiter_throws() throws Exception {
Flag<Map.Entry<String, String>> flag = Flag.keyValue("testFlag", String.class, String.class);
ParsedFlags parsedFlags = new FlagParser().parse("--testFlag=key=value");
FlagParseException exception = assertThrows(FlagParseException.class, () -> flag.getRequiredValue(parsedFlags));
assertThat(exception).hasMessageThat().contains("must contain ':'");
}
Aggregations