@@ -30,40 +30,30 @@ fn test_graphemes() {
30
30
& [ "\u{600} " , "\u{20} " , "\u{20} " ] ) ,
31
31
] ;
32
32
33
- for & ( s, g) in TEST_SAME {
33
+ pub const EXTRA_SAME : & ' static [ ( & ' static str , & ' static [ & ' static str ] ) ] = & [
34
+ // family emoji (more than two emoji joined by ZWJ)
35
+ ( "\u{1f468} \u{200d} \u{1f467} \u{200d} \u{1f466} " ,
36
+ & [ "\u{1f468} \u{200d} \u{1f467} \u{200d} \u{1f466} " ] ) ,
37
+ ] ;
38
+
39
+ for & ( s, g) in TEST_SAME . iter ( ) . chain ( EXTRA_SAME ) {
34
40
// test forward iterator
35
- assert ! ( UnicodeSegmentation :: graphemes( s, true )
36
- . zip( g. iter( ) . cloned( ) )
37
- . all( |( a, b) | a == b) ) ;
38
- assert ! ( UnicodeSegmentation :: graphemes( s, false )
39
- . zip( g. iter( ) . cloned( ) )
40
- . all( |( a, b) | a == b) ) ;
41
+ assert ! ( UnicodeSegmentation :: graphemes( s, true ) . eq( g. iter( ) . cloned( ) ) ) ;
42
+ assert ! ( UnicodeSegmentation :: graphemes( s, false ) . eq( g. iter( ) . cloned( ) ) ) ;
41
43
42
44
// test reverse iterator
43
- assert ! ( UnicodeSegmentation :: graphemes( s, true ) . rev( )
44
- . zip( g. iter( ) . rev( ) . cloned( ) )
45
- . all( |( a, b) | a == b) ) ;
46
- assert ! ( UnicodeSegmentation :: graphemes( s, false ) . rev( )
47
- . zip( g. iter( ) . rev( ) . cloned( ) )
48
- . all( |( a, b) | a == b) ) ;
45
+ assert ! ( UnicodeSegmentation :: graphemes( s, true ) . rev( ) . eq( g. iter( ) . rev( ) . cloned( ) ) ) ;
46
+ assert ! ( UnicodeSegmentation :: graphemes( s, false ) . rev( ) . eq( g. iter( ) . rev( ) . cloned( ) ) ) ;
49
47
}
50
48
51
49
for & ( s, gt, gf) in TEST_DIFF . iter ( ) . chain ( EXTRA_DIFF ) {
52
50
// test forward iterator
53
- assert ! ( UnicodeSegmentation :: graphemes( s, true )
54
- . zip( gt. iter( ) . cloned( ) )
55
- . all( |( a, b) | a == b) , "{:?}" , s) ;
56
- assert ! ( UnicodeSegmentation :: graphemes( s, false )
57
- . zip( gf. iter( ) . cloned( ) )
58
- . all( |( a, b) | a == b) ) ;
51
+ assert ! ( UnicodeSegmentation :: graphemes( s, true ) . eq( gt. iter( ) . cloned( ) ) ) ;
52
+ assert ! ( UnicodeSegmentation :: graphemes( s, false ) . eq( gf. iter( ) . cloned( ) ) ) ;
59
53
60
54
// test reverse iterator
61
- assert ! ( UnicodeSegmentation :: graphemes( s, true ) . rev( )
62
- . zip( gt. iter( ) . rev( ) . cloned( ) )
63
- . all( |( a, b) | a == b) ) ;
64
- assert ! ( UnicodeSegmentation :: graphemes( s, false ) . rev( )
65
- . zip( gf. iter( ) . rev( ) . cloned( ) )
66
- . all( |( a, b) | a == b) ) ;
55
+ assert ! ( UnicodeSegmentation :: graphemes( s, true ) . rev( ) . eq( gt. iter( ) . rev( ) . cloned( ) ) ) ;
56
+ assert ! ( UnicodeSegmentation :: graphemes( s, false ) . rev( ) . eq( gf. iter( ) . rev( ) . cloned( ) ) ) ;
67
57
}
68
58
69
59
// test the indices iterators
0 commit comments