1- using Unicode_Entities
1+ using StrTables, Unicode_Entities
22
33@static VERSION < v " 0.7.0-DEV" ? (using Base. Test) : (using Test)
44
55# Test the functions lookupname, matches, longestmatches, completions
66# Check that characters from all 3 tables (BMP, non-BMP, 2 character) are tested
77
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
159
1610const datapath = joinpath (Pkg. dir (), " Unicode_Entities" , " data" )
1711const dpath = " ftp://ftp.unicode.org/Public/UNIDATA/"
@@ -31,7 +25,7 @@ function load_unicode_data()
3125 flds = split (l, " ;" )
3226 str = flds[2 ]
3327 alias = flds[11 ]
34- ch = Char (parse (UInt32, flds[1 ], 16 ))
28+ ch = Char (parse_hex (UInt32, flds[1 ]))
3529 if str[1 ] == ' <'
3630 str != " <control>" && continue
3731 str = " "
@@ -62,60 +56,60 @@ load_unicode_data()
6256
6357 @testset " matches data file" begin
6458 for (i, ch) in enumerate (symval)
65- list = ue_matchchar ( ch)
59+ list = matchchar (def, ch)
6660 if ! isempty (list)
6761 @test symnam[i] in list
6862 end
6963 end
7064 for (i, nam) in enumerate (symnam)
71- str = ue_lookupname ( nam)
65+ str = lookupname (def, nam)
7266 if str != " "
7367 @test symval[i] == str[1 ]
7468 end
7569 end
7670 end
7771
7872@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"
8579end
8680
8781@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 )))
9185 for (chrs, exp) in ((" \U 1f596" , [" RAISED HAND WITH PART BETWEEN MIDDLE AND RING FINGERS" ]),
9286 (" \u 0f4a" , [" TIBETAN LETTER REVERSED TA" ]),
9387 (" ." , [" FULL STOP" , " PERIOD" ]))
94- res = ue_matches ( chrs)
88+ res = matches (def, chrs)
9589 @test length (res) >= length (exp)
9690 @test intersect (res, exp) == exp
9791 end
9892end
9993
10094@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 )))
10397 for (chrs, exp) in ((" \U 1f596 abcd" , [" RAISED HAND WITH PART BETWEEN MIDDLE AND RING FINGERS" ]),
10498 (" .abcd" , [" FULL STOP" , " PERIOD" ]),
10599 (" \u 0f4a#123" , [" TIBETAN LETTER REVERSED TA" , " TIBETAN LETTER TTA" ]))
106- res = ue_longestmatches ( chrs)
100+ res = longestmatches (def, chrs)
107101 @test length (res) >= length (exp)
108102 @test intersect (res, exp) == exp
109103 end
110104end
111105
112106@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 )))
115109 for (chrs, exp) in ((" ZERO" , [" ZERO WIDTH JOINER" , " ZERO WIDTH NO-BREAK SPACE" ,
116110 " ZERO WIDTH NON-JOINER" , " ZERO WIDTH SPACE" ]),
117111 (" BACK OF" , [" BACK OF ENVELOPE" ]))
118- res = ue_completions ( chrs)
112+ res = completions (def, chrs)
119113 @test length (res) >= length (exp)
120114 @test intersect (res, exp) == exp
121115 end
0 commit comments