Copilot commented on code in PR #395:
URL: https://github.com/apache/commons-validator/pull/395#discussion_r3408132719


##########
src/test/java/org/apache/commons/validator/routines/RegexValidatorTest.java:
##########
@@ -222,6 +222,19 @@ void testSingle() {
         checkArray("match one", new String[] { "ABC" }, new 
RegexValidator("^([A-Z]*)$").match("ABC"));
     }
 
+    /**
+     * Test that validate() is consistent with isValid() and match() when the 
only
+     * capturing group is optional and does not participate in the match. The 
value
+     * is valid, so validate() must not return null (which signals an invalid 
value).
+     */
+    @Test
+    void testValidateOptionalGroup() {
+        final RegexValidator validator = new RegexValidator("^(abc)?def$");
+        assertTrue(validator.isValid("def"), "isValid()");
+        checkArray("match()", new String[] { null }, validator.match("def"));
+        assertEquals("", validator.validate("def"), "validate()");

Review Comment:
   Test failure messages are currently very generic ("isValid()", "match()", 
"validate()"), which makes it harder to diagnose failures when multiple tests 
assert the same methods. Use more descriptive labels to identify the 
optional-group scenario.



-- 
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]

Reply via email to