1 # To fully test this module, we would need a copy of the stringprep tables.
2 # Since we don't have them, this test checks only a few codepoints.
4 from test
.test_support
import verify
, vereq
8 from stringprep
import *
10 verify(in_table_a1(u
"\u0221"))
11 verify(not in_table_a1(u
"\u0222"))
13 verify(in_table_b1(u
"\u00ad"))
14 verify(not in_table_b1(u
"\u00ae"))
16 verify(map_table_b2(u
"\u0041"), u
"\u0061")
17 verify(map_table_b2(u
"\u0061"), u
"\u0061")
19 verify(map_table_b3(u
"\u0041"), u
"\u0061")
20 verify(map_table_b3(u
"\u0061"), u
"\u0061")
22 verify(in_table_c11(u
"\u0020"))
23 verify(not in_table_c11(u
"\u0021"))
25 verify(in_table_c12(u
"\u00a0"))
26 verify(not in_table_c12(u
"\u00a1"))
28 verify(in_table_c12(u
"\u00a0"))
29 verify(not in_table_c12(u
"\u00a1"))
31 verify(in_table_c11_c12(u
"\u00a0"))
32 verify(not in_table_c11_c12(u
"\u00a1"))
34 verify(in_table_c21(u
"\u001f"))
35 verify(not in_table_c21(u
"\u0020"))
37 verify(in_table_c22(u
"\u009f"))
38 verify(not in_table_c22(u
"\u00a0"))
40 verify(in_table_c21_c22(u
"\u009f"))
41 verify(not in_table_c21_c22(u
"\u00a0"))
43 verify(in_table_c3(u
"\ue000"))
44 verify(not in_table_c3(u
"\uf900"))
46 verify(in_table_c4(u
"\uffff"))
47 verify(not in_table_c4(u
"\u0000"))
49 verify(in_table_c5(u
"\ud800"))
50 verify(not in_table_c5(u
"\ud7ff"))
52 verify(in_table_c6(u
"\ufff9"))
53 verify(not in_table_c6(u
"\ufffe"))
55 verify(in_table_c7(u
"\u2ff0"))
56 verify(not in_table_c7(u
"\u2ffc"))
58 verify(in_table_c8(u
"\u0340"))
59 verify(not in_table_c8(u
"\u0342"))
61 # C.9 is not in the bmp
62 # verify(in_table_c9(u"\U000E0001"))
63 # verify(not in_table_c8(u"\U000E0002"))
65 verify(in_table_d1(u
"\u05be"))
66 verify(not in_table_d1(u
"\u05bf"))
68 verify(in_table_d2(u
"\u0041"))
69 verify(not in_table_d2(u
"\u0040"))
71 # This would generate a hash of all predicates. However, running
72 # it is quite expensive, and only serves to detect changes in the
73 # unicode database. Instead, stringprep.py asserts the version of
76 # predicates = [k for k in dir(stringprep) if k.startswith("in_table")]
78 # for p in predicates:
79 # f = getattr(stringprep, p)
80 # # Collect all BMP code points
81 # data = ["0"] * 0x10000
82 # for i in range(0x10000):
85 # data = "".join(data)
88 # print p,h.hexdigest()