gnodet-bot commented on code in PR #2356:
URL: https://github.com/apache/maven-resolver/pull/2356#discussion_r4730434343
##########
maven-resolver-util/src/test/java/org/eclipse/aether/util/version/GenericVersionTest.java:
##########
@@ -36,9 +38,20 @@ protected Version newVersion(String version) {
return new GenericVersion(version);
}
- @Test
- void testEmptyVersion() {
- assertOrder(X_EQ_Y, "0", "");
+ @ParameterizedTest(name = "{0}: {1} {2} {3}")
+ @CsvFileSource(resources = "/version-comparison.csv", encoding = "UTF-8",
numLinesToSkip = 1)
+ void testVersionComparisons(String testCase, String left, String operator,
String right) {
+ int expected;
+ if ("LT".equals(operator)) {
+ expected = X_LT_Y;
+ } else if ("GT".equals(operator)) {
+ expected = X_GT_Y;
+ } else if ("EQ".equals(operator)) {
+ expected = X_EQ_Y;
+ } else {
Review Comment:
💡 **[Low] Defensive operator validation:** The `else` branch silently treats
any unrecognized operator as `EQ`. A CSV typo like `"LTT"` or `"Eq"` would
produce a passing test with wrong semantics instead of failing loudly.
```suggestion
int expected;
if ("LT".equals(operator)) {
expected = X_LT_Y;
} else if ("GT".equals(operator)) {
expected = X_GT_Y;
} else if ("EQ".equals(operator)) {
expected = X_EQ_Y;
} else {
throw new IllegalArgumentException("Unknown operator: " +
operator);
}
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]