1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ void withNoOptions() {
46
46
void withSingleOptionAndNoValue () {
47
47
CommandLineArgs args = parser .parse ("--o1" );
48
48
assertThat (args .containsOption ("o1" )).isTrue ();
49
- assertThat (args .getOptionValues ("o1" )).isEqualTo ( Collections . EMPTY_LIST );
49
+ assertThat (args .getOptionValues ("o1" )).isEmpty ( );
50
50
}
51
51
52
52
@ Test
@@ -56,6 +56,20 @@ void withSingleOptionAndValue() {
56
56
assertThat (args .getOptionValues ("o1" )).containsExactly ("v1" );
57
57
}
58
58
59
+ @ Test
60
+ void withRepeatedOptionAndSameValues () {
61
+ CommandLineArgs args = parser .parse ("--o1=v1" , "--o1=v1" , "--o1=v1" );
62
+ assertThat (args .containsOption ("o1" )).isTrue ();
63
+ assertThat (args .getOptionValues ("o1" )).containsExactly ("v1" , "v1" , "v1" );
64
+ }
65
+
66
+ @ Test
67
+ void withRepeatedOptionAndDifferentValues () {
68
+ CommandLineArgs args = parser .parse ("--o1=v1" , "--o1=v2" , "--o1=v3" );
69
+ assertThat (args .containsOption ("o1" )).isTrue ();
70
+ assertThat (args .getOptionValues ("o1" )).containsExactly ("v1" , "v2" , "v3" );
71
+ }
72
+
59
73
@ Test
60
74
void withMixOfOptionsHavingValueAndOptionsHavingNoValue () {
61
75
CommandLineArgs args = parser .parse ("--o1=v1" , "--o2" );
@@ -95,17 +109,17 @@ void withNonOptionArguments() {
95
109
}
96
110
97
111
@ Test
98
- void assertOptionNamesIsUnmodifiable () {
112
+ void optionNamesSetIsUnmodifiable () {
99
113
CommandLineArgs args = new SimpleCommandLineArgsParser ().parse ();
100
- assertThatExceptionOfType (UnsupportedOperationException .class ). isThrownBy (() ->
101
- args .getOptionNames ().add ("bogus" ));
114
+ assertThatExceptionOfType (UnsupportedOperationException .class )
115
+ . isThrownBy (() -> args .getOptionNames ().add ("bogus" ));
102
116
}
103
117
104
118
@ Test
105
- void assertNonOptionArgsIsUnmodifiable () {
119
+ void nonOptionArgsListIsUnmodifiable () {
106
120
CommandLineArgs args = new SimpleCommandLineArgsParser ().parse ();
107
- assertThatExceptionOfType (UnsupportedOperationException .class ). isThrownBy (() ->
108
- args .getNonOptionArgs ().add ("foo" ));
121
+ assertThatExceptionOfType (UnsupportedOperationException .class )
122
+ . isThrownBy (() -> args .getNonOptionArgs ().add ("foo" ));
109
123
}
110
124
111
125
@ Test
0 commit comments