forked from jtauber/pyuca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
full_test.py
36 lines (28 loc) · 927 Bytes
/
full_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
from pyuca import Collator
from pyuca.utils import format_sort_key
c = Collator()
prev_sort_key = None
success = 0
failure = 0
with open("CollationTest/CollationTest_NON_IGNORABLE.txt") as f:
for line in f.readlines():
points = line.split("#")[0].split(";")[0].strip().split()
if points:
test_string = "".join(
chr(int(point, 16)) for point in points
)
test_string_sort_key = c.sort_key(test_string)
x = format_sort_key(test_string_sort_key)
if prev_sort_key:
if prev_sort_key > test_string_sort_key:
failure += 1
print(line)
print(x)
else:
success += 1
prev_sort_key = test_string_sort_key
print()
print("{} success; {} failure".format(success, failure))
if failure > 0:
sys.exit(1)