rootvector2 commented on code in PR #427:
URL: https://github.com/apache/commons-beanutils/pull/427#discussion_r3639489661


##########
src/test/java/org/apache/commons/beanutils2/converters/ArrayConverterTest.java:
##########
@@ -248,6 +248,23 @@ void testTheMatrix() {
         }
     }
 
+    /**
+     * A forward slash is not an allowed character, so it must split like any 
other separator (see {@link #testUnderscore_BEANUTILS_302()}) instead of 
commenting
+     * out the rest of the input and dropping the remaining elements.
+     */
+    @Test
+    void testForwardSlashSeparator() {
+        final String value = "first/value,second/value";
+        final ArrayConverter<String[]> converter = new 
ArrayConverter<>(String[].class, new StringConverter());
+        final String[] result = converter.convert(String[].class, value);
+        assertNotNull(result, "result.null");
+        assertEquals(4, result.length, "result.length");
+        assertEquals("first", result[0], "result[0]");

Review Comment:
   Yes. Any non-allowed char splits and keeps both sides by default, same as 
`_` in `testUnderscore_BEANUTILS_302` (`first_value,second_value` parses to 4 
elements). Before the patch `/` was the only char that instead commented out 
the rest of the input, so `a/b,c` parsed to just `["a"]`. Your asserts hold 
once `/` is in the allowed chars, same as `_`. I extended the test to mirror 
the underscore test: 4 elements by default, `["first/value", "second/value"]` 
after `setAllowedChars(new char[] { '.', '-', '/' })`.



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