LANG-1631 - Check if the char to be searched is defined (#682)

This commit is contained in:
Arturo Bernal 2020-12-27 18:05:33 +01:00 committed by GitHub
parent 45bec219d2
commit 9fa1d734f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -109,6 +109,7 @@ public class CharSequenceUtils {
return i;
}
}
return NOT_FOUND;
}
//supplementary characters (LANG1300)
if (searchChar <= Character.MAX_CODE_POINT) {
@ -195,6 +196,7 @@ public class CharSequenceUtils {
return i;
}
}
return NOT_FOUND;
}
//supplementary characters (LANG1300)
//NOTE - we must do a forward traversal for this to avoid duplicating code points
@ -244,7 +246,7 @@ public class CharSequenceUtils {
}
if (start < 0 || len2 < 0 || len2 > len1) {
return -1;
return NOT_FOUND;
}
if (len2 == 0) {
@ -272,7 +274,7 @@ public class CharSequenceUtils {
while (cs.charAt(i) != char0) {
i--;
if (i < 0) {
return -1;
return NOT_FOUND;
}
}
if (checkLaterThan1(cs, searchChar, len2, i)) {
@ -280,7 +282,7 @@ public class CharSequenceUtils {
}
i--;
if (i < 0) {
return -1;
return NOT_FOUND;
}
}
}

View File

@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.CharBuffer;
import java.util.Locale;
import org.hamcrest.core.IsNot;
@ -275,6 +276,7 @@ public class StringUtilsEqualsIndexOfTest {
assertEquals(2, StringUtils.indexOf("aabaabaa", 'b'));
assertEquals(2, StringUtils.indexOf(new StringBuilder("aabaabaa"), 'b'));
assertEquals(StringUtils.INDEX_NOT_FOUND, StringUtils.indexOf(new StringBuilder("aabaabaa"), -1738));
}
@Test
@ -564,6 +566,7 @@ public class StringUtilsEqualsIndexOfTest {
assertEquals(1, StringUtils.lastIndexOf(builder, CODE_POINT, 1 ));
assertEquals(-1, StringUtils.lastIndexOf(builder.toString(), CODE_POINT, 0));
assertEquals(1, StringUtils.lastIndexOf(builder.toString(), CODE_POINT, 1));
assertEquals(StringUtils.INDEX_NOT_FOUND, StringUtils.lastIndexOf(CharBuffer.wrap("[%{.c.0rro"), -1738, 982));
}
@Test