1
- using Unicode_Entities
1
+ using StrTables, Unicode_Entities
2
2
3
3
@static VERSION < v " 0.7.0-DEV" ? (using Base. Test) : (using Test)
4
4
5
5
# Test the functions lookupname, matches, longestmatches, completions
6
6
# Check that characters from all 3 tables (BMP, non-BMP, 2 character) are tested
7
7
8
- UE = Unicode_Entities
9
-
10
- ue_matchchar (ch) = UE. matchchar (UE. default, ch)
11
- ue_lookupname (nam) = UE. lookupname (UE. default, nam)
12
- ue_longestmatches (str) = UE. longestmatches (UE. default, str)
13
- ue_matches (str) = UE. matches (UE. default, str)
14
- ue_completions (str) = UE. completions (UE. default, str)
8
+ const def = Unicode_Entities. default
15
9
16
10
const datapath = joinpath (Pkg. dir (), " Unicode_Entities" , " data" )
17
11
const dpath = " ftp://ftp.unicode.org/Public/UNIDATA/"
@@ -31,7 +25,7 @@ function load_unicode_data()
31
25
flds = split (l, " ;" )
32
26
str = flds[2 ]
33
27
alias = flds[11 ]
34
- ch = Char (parse (UInt32, flds[1 ], 16 ))
28
+ ch = Char (parse_hex (UInt32, flds[1 ]))
35
29
if str[1 ] == ' <'
36
30
str != " <control>" && continue
37
31
str = " "
@@ -62,60 +56,60 @@ load_unicode_data()
62
56
63
57
@testset " matches data file" begin
64
58
for (i, ch) in enumerate (symval)
65
- list = ue_matchchar ( ch)
59
+ list = matchchar (def, ch)
66
60
if ! isempty (list)
67
61
@test symnam[i] in list
68
62
end
69
63
end
70
64
for (i, nam) in enumerate (symnam)
71
- str = ue_lookupname ( nam)
65
+ str = lookupname (def, nam)
72
66
if str != " "
73
67
@test symval[i] == str[1 ]
74
68
end
75
69
end
76
70
end
77
71
78
72
@testset " lookupname" begin
79
- @test ue_lookupname ( " foobar" ) == " "
80
- @test ue_lookupname ( SubString (" My name is Spock" , 12 )) == " "
81
- @test ue_lookupname ( " end of text" ) == " \x 03" # \3
82
- @test ue_lookupname ( " TIBETAN LETTER -A" ) == " \u 0f60"
83
- @test ue_lookupname ( " LESS-THAN OR SLANTED EQUAL TO" ) == " \u 2a7d"
84
- @test ue_lookupname ( " REVERSED HAND WITH MIDDLE FINGER EXTENDED" ) == " \U 1f595"
73
+ @test lookupname (def, " foobar" ) == " "
74
+ @test lookupname (def, SubString (" My name is Spock" , 12 )) == " "
75
+ @test lookupname (def, " end of text" ) == " \x 03" # \3
76
+ @test lookupname (def, " TIBETAN LETTER -A" ) == " \u 0f60"
77
+ @test lookupname (def, " LESS-THAN OR SLANTED EQUAL TO" ) == " \u 2a7d"
78
+ @test lookupname (def, " REVERSED HAND WITH MIDDLE FINGER EXTENDED" ) == " \U 1f595"
85
79
end
86
80
87
81
@testset " matches" begin
88
- @test isempty (ue_matches ( " " ))
89
- @test isempty (ue_matches ( " \u f900" ))
90
- @test isempty (ue_matches ( SubString (" This is \u f900" , 9 )))
82
+ @test isempty (matches (def, " " ))
83
+ @test isempty (matches (def, " \u f900" ))
84
+ @test isempty (matches (def, SubString (" This is \u f900" , 9 )))
91
85
for (chrs, exp) in ((" \U 1f596" , [" RAISED HAND WITH PART BETWEEN MIDDLE AND RING FINGERS" ]),
92
86
(" \u 0f4a" , [" TIBETAN LETTER REVERSED TA" ]),
93
87
(" ." , [" FULL STOP" , " PERIOD" ]))
94
- res = ue_matches ( chrs)
88
+ res = matches (def, chrs)
95
89
@test length (res) >= length (exp)
96
90
@test intersect (res, exp) == exp
97
91
end
98
92
end
99
93
100
94
@testset " longestmatches" begin
101
- @test isempty (ue_longestmatches ( " \u f900 abcd" ))
102
- @test isempty (ue_longestmatches ( SubString (" This is \u f900 abcd" , 9 )))
95
+ @test isempty (longestmatches (def, " \u f900 abcd" ))
96
+ @test isempty (longestmatches (def, SubString (" This is \u f900 abcd" , 9 )))
103
97
for (chrs, exp) in ((" \U 1f596 abcd" , [" RAISED HAND WITH PART BETWEEN MIDDLE AND RING FINGERS" ]),
104
98
(" .abcd" , [" FULL STOP" , " PERIOD" ]),
105
99
(" \u 0f4a#123" , [" TIBETAN LETTER REVERSED TA" , " TIBETAN LETTER TTA" ]))
106
- res = ue_longestmatches ( chrs)
100
+ res = longestmatches (def, chrs)
107
101
@test length (res) >= length (exp)
108
102
@test intersect (res, exp) == exp
109
103
end
110
104
end
111
105
112
106
@testset " completions" begin
113
- @test isempty (ue_completions ( " ScottPaulJones" ))
114
- @test isempty (ue_completions ( SubString (" My name is Scott" , 12 )))
107
+ @test isempty (completions (def, " ScottPaulJones" ))
108
+ @test isempty (completions (def, SubString (" My name is Scott" , 12 )))
115
109
for (chrs, exp) in ((" ZERO" , [" ZERO WIDTH JOINER" , " ZERO WIDTH NO-BREAK SPACE" ,
116
110
" ZERO WIDTH NON-JOINER" , " ZERO WIDTH SPACE" ]),
117
111
(" BACK OF" , [" BACK OF ENVELOPE" ]))
118
- res = ue_completions ( chrs)
112
+ res = completions (def, chrs)
119
113
@test length (res) >= length (exp)
120
114
@test intersect (res, exp) == exp
121
115
end
0 commit comments