Skip to content

Commit cf65828

Browse files
Even more tests
1 parent dbaa10e commit cf65828

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

tests/tests.rs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,36 @@ fn test_canonical_equivalence() {
148148
if line.is_empty() || line.starts_with('#') || line.starts_with('@') {
149149
continue;
150150
}
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();
161164

162165
assert_eq!(
166+
orig.width(),
163167
nfc.width(),
168+
"width of X == {orig:?} differs from toNFC(X) == {nfc:?}"
169+
);
170+
171+
assert_eq!(
172+
orig.width(),
164173
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:?}"
166181
);
167182
}
168183
}

0 commit comments

Comments
 (0)