@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2024 the original author or authors .
* Copyright 2002 - 2025 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -46,7 +46,7 @@ class SimpleCommandLineArgsParserTests {
@@ -46,7 +46,7 @@ class SimpleCommandLineArgsParserTests {
void withSingleOptionAndNoValue ( ) {
CommandLineArgs args = parser . parse ( "--o1" ) ;
assertThat ( args . containsOption ( "o1" ) ) . isTrue ( ) ;
assertThat ( args . getOptionValues ( "o1" ) ) . isEqualTo ( Collections . EMPTY_LIST ) ;
assertThat ( args . getOptionValues ( "o1" ) ) . isEmpty ( ) ;
}
@Test
@ -56,6 +56,20 @@ class SimpleCommandLineArgsParserTests {
@@ -56,6 +56,20 @@ class SimpleCommandLineArgsParserTests {
assertThat ( args . getOptionValues ( "o1" ) ) . containsExactly ( "v1" ) ;
}
@Test
void withRepeatedOptionAndSameValues ( ) {
CommandLineArgs args = parser . parse ( "--o1=v1" , "--o1=v1" , "--o1=v1" ) ;
assertThat ( args . containsOption ( "o1" ) ) . isTrue ( ) ;
assertThat ( args . getOptionValues ( "o1" ) ) . containsExactly ( "v1" , "v1" , "v1" ) ;
}
@Test
void withRepeatedOptionAndDifferentValues ( ) {
CommandLineArgs args = parser . parse ( "--o1=v1" , "--o1=v2" , "--o1=v3" ) ;
assertThat ( args . containsOption ( "o1" ) ) . isTrue ( ) ;
assertThat ( args . getOptionValues ( "o1" ) ) . containsExactly ( "v1" , "v2" , "v3" ) ;
}
@Test
void withMixOfOptionsHavingValueAndOptionsHavingNoValue ( ) {
CommandLineArgs args = parser . parse ( "--o1=v1" , "--o2" ) ;
@ -95,17 +109,17 @@ class SimpleCommandLineArgsParserTests {
@@ -95,17 +109,17 @@ class SimpleCommandLineArgsParserTests {
}
@Test
void assertOptionNames IsUnmodifiable( ) {
void optionNamesSet IsUnmodifiable( ) {
CommandLineArgs args = new SimpleCommandLineArgsParser ( ) . parse ( ) ;
assertThatExceptionOfType ( UnsupportedOperationException . class ) . isThrownBy ( ( ) - >
args . getOptionNames ( ) . add ( "bogus" ) ) ;
assertThatExceptionOfType ( UnsupportedOperationException . class )
. isThrownBy ( ( ) - > args . getOptionNames ( ) . add ( "bogus" ) ) ;
}
@Test
void assertNonOptionArgs IsUnmodifiable( ) {
void nonOptionArgsList IsUnmodifiable( ) {
CommandLineArgs args = new SimpleCommandLineArgsParser ( ) . parse ( ) ;
assertThatExceptionOfType ( UnsupportedOperationException . class ) . isThrownBy ( ( ) - >
args . getNonOptionArgs ( ) . add ( "foo" ) ) ;
assertThatExceptionOfType ( UnsupportedOperationException . class )
. isThrownBy ( ( ) - > args . getNonOptionArgs ( ) . add ( "foo" ) ) ;
}
@Test