def test_1(self): from pyuca.utils import format_sort_key self.assertEqual( format_sort_key(self.c.sort_key("\u1DF6\u0334")), "| 004A 0033 | 0002 0002 |", )
def test_2(self): from pyuca.utils import format_sort_key self.assertEqual( format_sort_key(self.c.sort_key("\u9FEA\u0062")), "FB41 9FEA 1CC6 | 0020 0020 | 0002 0002 |", )
def test_3(self): from pyuca.utils import format_sort_key self.assertEqual( format_sort_key(self.c.sort_key("\U0002B81E\u0062")), "FBC5 B81E 1BDB | 0020 0020 | 0002 0002 |", )
def test_4(self): from pyuca.utils import format_sort_key self.assertEqual( format_sort_key(self.c.sort_key("\U0002CEA2\u0021")), "FBC5 CEA2 025F | 0020 0020 | 0002 0002 |", )
def test_1(self): from pyuca.utils import format_sort_key self.assertEqual( format_sort_key(self.c.sort_key("\u9FD5\u0062")), "FB41 9FD5 1BDB | 0020 0020 | 0002 0002 |", )
def test_2(self): from pyuca.utils import format_sort_key self.assertEqual( format_sort_key(self.c.sort_key("\U0002CEA1\u0062")), "FB85 CEA1 1BDB | 0020 0020 | 0002 0002 |", )
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)
with open(path) as f: for i, line in enumerate(f.readlines()): points = line.split("#", 1)[0].split(";", 1)[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) if prev_sort_key: if prev_sort_key > test_string_sort_key: failure += 1 print("-------") print("failed on line {0}:".format(i + 1)) print(line.rstrip("\n")) print("PREV: {0}".format( format_sort_key(prev_sort_key))) print("THIS: {0}".format( format_sort_key(test_string_sort_key))) print("-------") else: success += 1 prev_sort_key = test_string_sort_key print("") print("{0} success; {1} failure (UCA version {2})".format( success, failure, c.UCA_VERSION)) total_failures += failure if total_failures > 0: sys.exit(1)
def test_format_sort_key(self): from pyuca.utils import format_sort_key self.assertEqual( format_sort_key([0, 1, 65535]), "| 0001 FFFF" )
def test_format_sort_key(self): from pyuca.utils import format_sort_key self.assertEqual(format_sort_key([0, 1, 65535]), "| 0001 FFFF")
with open(path) as f: for i, line in enumerate(f.readlines()): points = line.split("#", 1)[0].split(";", 1)[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) if prev_sort_key: if prev_sort_key > test_string_sort_key: failure += 1 print('-------') print("failed on line {0}:".format(i+1)) print(line.rstrip('\n')) print("PREV: {0}".format(format_sort_key(prev_sort_key))) print("THIS: {0}".format( format_sort_key(test_string_sort_key))) print('-------') else: success += 1 prev_sort_key = test_string_sort_key print("") print("{0} success; {1} failure (UCA version {2})".format( success, failure, c.UCA_VERSION)) if failure > 0: sys.exit(1)