Keep only null as stripChar in the Apache Commons example

This commit is contained in:
Cavero Barca 2020-03-10 14:17:19 +01:00
parent aaabfa4ab2
commit 804b4c42aa
2 changed files with 4 additions and 14 deletions

View File

@ -114,11 +114,8 @@ public class LTrimRTrim {
// Apache Commons StringUtils containsIgnoreCase // Apache Commons StringUtils containsIgnoreCase
@Benchmark @Benchmark
public boolean apacheCommonsStringUtils() { public boolean apacheCommonsStringUtils() {
String ltrim = org.apache.commons.lang3.StringUtils.stripStart(src, " "); String ltrim = org.apache.commons.lang3.StringUtils.stripStart(src, null);
String rtrim = org.apache.commons.lang3.StringUtils.stripEnd(src, " "); String rtrim = org.apache.commons.lang3.StringUtils.stripEnd(src, null);
ltrim = org.apache.commons.lang3.StringUtils.stripStart(src, null);
rtrim = org.apache.commons.lang3.StringUtils.stripEnd(src, null);
return checkStrings(ltrim, rtrim); return checkStrings(ltrim, rtrim);
} }

View File

@ -67,15 +67,8 @@ public class LTrimRTrimUnitTest {
@Test @Test
public void givenString_whenCallingStringUtilsStripStartEnd_thenReturnsTrue() { public void givenString_whenCallingStringUtilsStripStartEnd_thenReturnsTrue() {
// Use StringUtils containsIgnoreCase to avoid case insensitive issues // Use StringUtils containsIgnoreCase to avoid case insensitive issues
String ltrim = org.apache.commons.lang3.StringUtils.stripStart(src, " "); String ltrim = org.apache.commons.lang3.StringUtils.stripStart(src, null);
String rtrim = org.apache.commons.lang3.StringUtils.stripEnd(src, " "); String rtrim = org.apache.commons.lang3.StringUtils.stripEnd(src, null);
// Compare the Strings obtained and the expected
Assert.assertTrue(ltrimResult.equalsIgnoreCase(ltrim));
Assert.assertTrue(rtrimResult.equalsIgnoreCase(rtrim));
ltrim = org.apache.commons.lang3.StringUtils.stripStart(src, null);
rtrim = org.apache.commons.lang3.StringUtils.stripEnd(src, null);
// Compare the Strings obtained and the expected // Compare the Strings obtained and the expected
Assert.assertTrue(ltrimResult.equalsIgnoreCase(ltrim)); Assert.assertTrue(ltrimResult.equalsIgnoreCase(ltrim));