File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -346,6 +346,22 @@ fn test_slice_fail() {
346
346
& "中华Việt Nam" [ 0 ..2 ] ;
347
347
}
348
348
349
+
350
+ #[ test]
351
+ fn test_is_char_boundary ( ) {
352
+ let s = "ศไทย中华Việt Nam β-release 🐱123" ;
353
+ assert ! ( s. is_char_boundary( 0 ) ) ;
354
+ assert ! ( s. is_char_boundary( s. len( ) ) ) ;
355
+ assert ! ( !s. is_char_boundary( s. len( ) + 1 ) ) ;
356
+ for ( i, ch) in s. char_indices ( ) {
357
+ // ensure character locations are boundaries and continuation bytes are not
358
+ assert ! ( s. is_char_boundary( i) , "{} is a char boundary in {:?}" , i, s) ;
359
+ for j in 1 ..ch. len_utf8 ( ) {
360
+ assert ! ( !s. is_char_boundary( i + j) ,
361
+ "{} should not be a char boundary in {:?}" , i + j, s) ;
362
+ }
363
+ }
364
+ }
349
365
const LOREM_PARAGRAPH : & ' static str = "\
350
366
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse quis lorem sit amet dolor \
351
367
ultricies condimentum. Praesent iaculis purus elit, ac malesuada quam malesuada in. Duis sed orci \
You can’t perform that action at this time.
0 commit comments