optimized tests and some code docu

This commit is contained in:
Jan-Peter Klein
2023-06-15 10:54:44 +02:00
parent d680c5812d
commit f054a1af03
2 changed files with 11 additions and 13 deletions

View File

@@ -152,6 +152,14 @@ public class ErrorController implements FxController {
}
}
/**
* Checks if an ErrorDiscussion object is a partial match based on the presence of the error code's method code in its title.
*
* @param errorDiscussion The ErrorDiscussion object to be checked.
* @return A boolean value indicating if the ErrorDiscussion object is a partial match:
* - true if the object's title contains the error code's method code,
* - false otherwise.
*/
public boolean isPartialMatchFilter(ErrorDiscussion errorDiscussion) {
return errorDiscussion.title.contains(" " + errorCode.methodCode());
}

View File

@@ -55,23 +55,13 @@ class ErrorControllerTest {
@CsvSource(textBlock = """
10, 5, -1
8, 15, 1
10, 10, 0
""")
public void testCompareUpvoteCount1(int leftUpvoteCount, int rightUpvoteCount, int expectedResult) {
public void testCompareUpvoteCount(int leftUpvoteCount, int rightUpvoteCount, int expectedResult) {
var left = createErrorDiscussion("", leftUpvoteCount, null);
var right = createErrorDiscussion("", rightUpvoteCount, null);
int result = errorController.compareUpvoteCount(left, right);
Assertions.assertTrue(result*expectedResult>0);
}
@ParameterizedTest
@CsvSource(textBlock = """
10, 10
""")
public void testCompareUpvoteCount2(int leftUpvoteCount, int rightUpvoteCount) {
var left = createErrorDiscussion("", leftUpvoteCount, null);
var right = createErrorDiscussion("", rightUpvoteCount, null);
int result = errorController.compareUpvoteCount(left, right);
Assertions.assertEquals(0,result);
Assertions.assertEquals(expectedResult,Integer.signum(result));
}
@ParameterizedTest