gnodet-bot commented on code in PR #29851:
URL: https://github.com/apache/camel/pull/29851#discussion_r4563995412
##########
core/camel-util/src/test/java/org/apache/camel/util/StringHelperTest.java:
##########
@@ -693,6 +693,27 @@ public void testSplitOnCharacter() {
assertEquals("99", list[99]);
}
+ @Test
+ public void testSplitOnCharacterMultiChar() {
+ String[] list = splitOnCharacter("foo::bar", "::", 2);
+ assertEquals(2, list.length);
+ assertEquals("foo", list[0]);
+ assertEquals("bar", list[1]);
+
+ list = splitOnCharacter("foo::bar::baz", "::", 3);
+ assertEquals(3, list.length);
+ assertEquals("foo", list[0]);
+ assertEquals("bar", list[1]);
+ assertEquals("baz", list[2]);
+
+ // the separator characters must not leak into the following value
+ list = splitOnCharacter("a=>b=>c", "=>", 3);
+ assertEquals(3, list.length);
+ assertEquals("a", list[0]);
+ assertEquals("b", list[1]);
+ assertEquals("c", list[2]);
+ }
Review Comment:
The new test covers the basic split cases well, but misses the documented
trailing-`null` behaviour. Consider adding:
```suggestion
list = splitOnCharacter("foo::bar", "::", 3);
assertEquals(3, list.length);
assertEquals("foo", list[0]);
assertEquals("bar", list[1]);
assertNull(list[2]);
}
```
--
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]