Debian Codegraph @

tests/test131.pe

raw
1 # test unicode support functions
2
3 if (!IsLower("a") || !IsLower("ā") || IsLower("A") || IsLower("Ā"))
4 Error("IsLower was wrong")
5 endif
6
7 if (!IsUpper("A") || !IsUpper("Ā") || IsUpper("a") || IsUpper("ā"))
8 Error("IsUpper was wrong")
9 endif
10
11 if (ToLower("A") != "a" || ToLower("Ā") != "ā" || ToLower("a") != "a" || ToLower("ā") != "ā")
12 Error("ToLower was wrong")
13 endif
14
15 if (ToUpper("a") != "A" || ToUpper("ā") != "Ā" || ToUpper("A") != "A" || ToUpper("Ā") != "Ā")
16 Error("ToUpper was wrong")
17 endif
18
19 if (ToMirror("(") != ")" || ToMirror(")") != "(" || ToMirror("⦅") != "⦆")
20 Error("ToMirror was wrong")
21 endif
22
23 if (!IsAlNum("A") || !IsAlNum("a") || !IsAlNum("Ā") || !IsAlNum("ā") || !IsAlNum("1") || IsAlNum("$") || IsAlNum(" "))
24 Error("IsAlNum was wrong")
25 endif
26
27 if (!IsAlpha("A") || !IsAlpha("a") || !IsAlpha("Ā") || !IsAlpha("ā") || IsAlpha("1") || IsAlpha("$") || IsAlNum(" "))
28 Error("IsAlpha was wrong")
29 endif
30
31 if (!IsDigit("0") || !IsDigit("1") || IsDigit("a") || IsDigit("A"))
32 Error("IsDigit was wrong")
33 endif
34
35 if (!IsHexDigit("a") || !IsHexDigit("A") || !IsHexDigit("F") || !IsHexDigit("f") || !IsHexDigit("0") || !IsHexDigit("9") || IsHexDigit("G"))
36 Error("IsHexDigit was wrong")
37 endif
38
39 ver = UnicodeNamesListVersion()
40 Print("nameslist version is: ",ver)
41 if (Strlen(ver) <= 0)
42 Error("Bad nameslist version")
43 endif
44
45 if (UnicodeNameFromLib(0x1FBA9) != "BOX DRAWINGS LIGHT DIAGONAL UPPER CENTRE TO MIDDLE RIGHT AND MIDDLE LEFT TO LOWER CENTRE")
46 Error("Unexpected name for U+1FBA9")
47 endif
48
49 annot = UnicodeAnnotationFromLib(0x27)
50 ind = Strstr(annot, "= apostrophe-quote (1.0)")
51 if (ind < 0)
52 Error("Unexpected annotation for U+0027")
53 endif
54 if (Strlen(annot) < 480)
55 Error("Unexpected annotation length for U+0027")
56 endif
57 Print("Strlen for U+0027:", Strlen(annot))
58 Print("Annotation for U+0027:\n", annot)
59
60 cnt = UnicodeBlockCountFromLib()
61 if (cnt <= 0)
62 Error("Unexpected unicode block count")
63 endif
64
65 i = 0
66 while ( i<cnt )
67 start = UnicodeBlockStartFromLib(i)
68 end = UnicodeBlockEndFromLib(i)
69 name = UnicodeBlockNameFromLib(i)
70
71 if (start < 0 || start > end)
72 Error("Bad unicode block at index ", i)
73 endif
74
75 if (Strlen(name) <= 0)
76 Error("Bad unicode block name at index", i)
77 endif
78 ++i;
79 endloop
80
81 s1 = UnicodeNames2FromLib(65)
82 s2 = UnicodeNames2FromLib(0x709)
83 Print("There should be no Names2 for character 65, the value returned is=",s1)
84 Print("There should be a Names2 for character 0x709, the value returned is=",s2)
85 if ( Strlen(s1)>0 || Strlen(s2)<3 )
86 Error("Expected to return a valid Names2 string.")
87 endif
88
89 Print("All Tests done and valid.")
90