@@ -2355,6 +2355,18 @@ void testSplitByCharacterType() {
23552355
23562356 assertTrue (Objects .deepEquals (new String []{"ASFR" , "ules" },
23572357 StringUtils .splitByCharacterType ("ASFRules" )));
2358+
2359+ // Supplementary code points are classified by their own type, not split apart as surrogates.
2360+ // U+1D400 MATHEMATICAL BOLD CAPITAL A is an upper-case letter, like ASCII 'A'.
2361+ final String boldA = new String (Character .toChars (0x1D400 ));
2362+ // U+1D7D3 MATHEMATICAL BOLD DIGIT FIVE is a decimal digit, like ASCII '5'.
2363+ final String boldFive = new String (Character .toChars (0x1D7D3 ));
2364+ assertTrue (Objects .deepEquals (new String []{"A" + boldA },
2365+ StringUtils .splitByCharacterType ("A" + boldA )));
2366+ assertTrue (Objects .deepEquals (new String []{"5" + boldFive },
2367+ StringUtils .splitByCharacterType ("5" + boldFive )));
2368+ assertTrue (Objects .deepEquals (new String []{boldA , "5" + boldFive , "z" },
2369+ StringUtils .splitByCharacterType (boldA + "5" + boldFive + "z" )));
23582370 }
23592371
23602372 @ Test
@@ -2382,6 +2394,16 @@ void testSplitByCharacterTypeCamelCase() {
23822394
23832395 assertTrue (Objects .deepEquals (new String []{"ASF" , "Rules" },
23842396 StringUtils .splitByCharacterTypeCamelCase ("ASFRules" )));
2397+
2398+ // A supplementary upper-case letter immediately before a lower-case run joins the following token,
2399+ // exactly as a BMP upper-case letter does. U+1D400 MATHEMATICAL BOLD CAPITAL A is an upper-case letter.
2400+ final String boldA = new String (Character .toChars (0x1D400 ));
2401+ assertTrue (Objects .deepEquals (new String []{boldA + "bc" },
2402+ StringUtils .splitByCharacterTypeCamelCase (boldA + "bc" )));
2403+ assertTrue (Objects .deepEquals (new String []{"AB" , boldA + "cd" },
2404+ StringUtils .splitByCharacterTypeCamelCase ("AB" + boldA + "cd" )));
2405+ assertTrue (Objects .deepEquals (new String []{"foo" , boldA + "bar" },
2406+ StringUtils .splitByCharacterTypeCamelCase ("foo" + boldA + "bar" )));
23852407 }
23862408
23872409 @ Test
0 commit comments