Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / lib / python2.4 / test / test_stringprep.py
CommitLineData
920dae64
AT
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.
3
4from test.test_support import verify, vereq
5import sha
6
7import stringprep
8from stringprep import *
9
10verify(in_table_a1(u"\u0221"))
11verify(not in_table_a1(u"\u0222"))
12
13verify(in_table_b1(u"\u00ad"))
14verify(not in_table_b1(u"\u00ae"))
15
16verify(map_table_b2(u"\u0041"), u"\u0061")
17verify(map_table_b2(u"\u0061"), u"\u0061")
18
19verify(map_table_b3(u"\u0041"), u"\u0061")
20verify(map_table_b3(u"\u0061"), u"\u0061")
21
22verify(in_table_c11(u"\u0020"))
23verify(not in_table_c11(u"\u0021"))
24
25verify(in_table_c12(u"\u00a0"))
26verify(not in_table_c12(u"\u00a1"))
27
28verify(in_table_c12(u"\u00a0"))
29verify(not in_table_c12(u"\u00a1"))
30
31verify(in_table_c11_c12(u"\u00a0"))
32verify(not in_table_c11_c12(u"\u00a1"))
33
34verify(in_table_c21(u"\u001f"))
35verify(not in_table_c21(u"\u0020"))
36
37verify(in_table_c22(u"\u009f"))
38verify(not in_table_c22(u"\u00a0"))
39
40verify(in_table_c21_c22(u"\u009f"))
41verify(not in_table_c21_c22(u"\u00a0"))
42
43verify(in_table_c3(u"\ue000"))
44verify(not in_table_c3(u"\uf900"))
45
46verify(in_table_c4(u"\uffff"))
47verify(not in_table_c4(u"\u0000"))
48
49verify(in_table_c5(u"\ud800"))
50verify(not in_table_c5(u"\ud7ff"))
51
52verify(in_table_c6(u"\ufff9"))
53verify(not in_table_c6(u"\ufffe"))
54
55verify(in_table_c7(u"\u2ff0"))
56verify(not in_table_c7(u"\u2ffc"))
57
58verify(in_table_c8(u"\u0340"))
59verify(not in_table_c8(u"\u0342"))
60
61# C.9 is not in the bmp
62# verify(in_table_c9(u"\U000E0001"))
63# verify(not in_table_c8(u"\U000E0002"))
64
65verify(in_table_d1(u"\u05be"))
66verify(not in_table_d1(u"\u05bf"))
67
68verify(in_table_d2(u"\u0041"))
69verify(not in_table_d2(u"\u0040"))
70
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
74# the database.
75
76# predicates = [k for k in dir(stringprep) if k.startswith("in_table")]
77# predicates.sort()
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):
83# if f(unichr(i)):
84# data[i] = "1"
85# data = "".join(data)
86# h = sha.sha()
87# h.update(data)
88# print p,h.hexdigest()