garydgregory commented on code in PR #229: URL: https://github.com/apache/commons-cli/pull/229#discussion_r1491185632
########## src/test/java/org/apache/commons/cli/CommandLineTest.java: ########## @@ -166,7 +179,27 @@ public void testGetParsedOptionValueWithOption() throws Exception { } @Test - public void testNullhOption() throws Exception { + public void testGetParsedOptionValueUsingDefault() throws Exception { + final Options options = new Options(); + final Option optI = Option.builder("i").hasArg().type(Number.class).build(); + final Option optF = Option.builder("f").hasArg().build(); + options.addOption(optI); + options.addOption(optF); + + final CommandLineParser parser = new DefaultParser(); + final CommandLine cmd = parser.parse(options, new String[] {"-i", "123"}); + + assertEquals(123, ((Number) cmd.getParsedOptionValue(optI)).intValue()); + assertEquals("foo", cmd.getParsedOptionValue(optF, "foo")); + assertEquals("foo", cmd.getParsedOptionValue(optF, () -> "foo")); + assertEquals("foo", cmd.getParsedOptionValue("f", "foo")); + assertEquals("foo", cmd.getParsedOptionValue("f", () -> "foo")); + assertEquals("foo", cmd.getParsedOptionValue('f', "foo")); + assertEquals("foo", cmd.getParsedOptionValue('f', () -> "foo")); Review Comment: The above checks are good but are all "happy paths". I think you need assertions calling `getParsedOptionValue()` with a null Supplier and a Supplier that returns null since the runtime now supports this. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org