File tree Expand file tree Collapse file tree 1 file changed +26
-11
lines changed Expand file tree Collapse file tree 1 file changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -148,21 +148,36 @@ fn test_canonical_equivalence() {
148
148
if line. is_empty ( ) || line. starts_with ( '#' ) || line. starts_with ( '@' ) {
149
149
continue ;
150
150
}
151
- let ( nfc, postnfc) = line. split_once ( ';' ) . unwrap ( ) ;
152
- let ( nfd, _) = postnfc. split_once ( ';' ) . unwrap ( ) ;
153
- let nfc: String = nfc
154
- . split ( ' ' )
155
- . map ( |s| char:: try_from ( u32:: from_str_radix ( s, 16 ) . unwrap ( ) ) . unwrap ( ) )
156
- . collect ( ) ;
157
- let nfd: String = nfd
158
- . split ( ' ' )
159
- . map ( |s| char:: try_from ( u32:: from_str_radix ( s, 16 ) . unwrap ( ) ) . unwrap ( ) )
160
- . collect ( ) ;
151
+
152
+ let mut forms_iter = line. split ( ';' ) . map ( |substr| -> String {
153
+ substr
154
+ . split ( ' ' )
155
+ . map ( |s| char:: try_from ( u32:: from_str_radix ( s, 16 ) . unwrap ( ) ) . unwrap ( ) )
156
+ . collect ( )
157
+ } ) ;
158
+
159
+ let orig = forms_iter. next ( ) . unwrap ( ) ;
160
+ let nfc = forms_iter. next ( ) . unwrap ( ) ;
161
+ let nfd = forms_iter. next ( ) . unwrap ( ) ;
162
+ let nfkc = forms_iter. next ( ) . unwrap ( ) ;
163
+ let nfkd = forms_iter. next ( ) . unwrap ( ) ;
161
164
162
165
assert_eq ! (
166
+ orig. width( ) ,
163
167
nfc. width( ) ,
168
+ "width of X == {orig:?} differs from toNFC(X) == {nfc:?}"
169
+ ) ;
170
+
171
+ assert_eq ! (
172
+ orig. width( ) ,
164
173
nfd. width( ) ,
165
- "width of {nfc:?} differs from {nfd:?}"
174
+ "width of X == {orig:?} differs from toNFD(X) == {nfd:?}"
175
+ ) ;
176
+
177
+ assert_eq ! (
178
+ nfkc. width( ) ,
179
+ nfkd. width( ) ,
180
+ "width of toNFKC(X) == {nfkc:?} differs from toNFKD(X) == {nfkd:?}"
166
181
) ;
167
182
}
168
183
}
You can’t perform that action at this time.
0 commit comments