Skip to content

Commit 7ea5790

Browse files
authored
Merge pull request #15 from JuliaString/spj/usedef
Use default
2 parents eda34bd + 561d9f3 commit 7ea5790

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

deps/build.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function process_line(vec::Vector{T}) where {T<:AbstractString}
1818
num = vec[1]
1919
str = vec[2]
2020
alias = vec[11]
21-
ch = parse(UInt32, num, 16)
21+
ch = parse_hex(UInt32, num)
2222
str[1] == '<' &&
2323
return str == "<control>" ? (alias != "", ch, _empty_string, alias) : _empty_val
2424
# Don't save names that simply contain hex representation

test/runtests.jl

+21-27
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
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

1610
const datapath = joinpath(Pkg.dir(), "Unicode_Entities", "data")
1711
const 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") == "\x03" # \3
82-
@test ue_lookupname("TIBETAN LETTER -A") == "\u0f60"
83-
@test ue_lookupname("LESS-THAN OR SLANTED EQUAL TO") == "\u2a7d"
84-
@test ue_lookupname("REVERSED HAND WITH MIDDLE FINGER EXTENDED") == "\U1f595"
73+
@test lookupname(def, "foobar") == ""
74+
@test lookupname(def, SubString("My name is Spock", 12)) == ""
75+
@test lookupname(def, "end of text") == "\x03" # \3
76+
@test lookupname(def, "TIBETAN LETTER -A") == "\u0f60"
77+
@test lookupname(def, "LESS-THAN OR SLANTED EQUAL TO") == "\u2a7d"
78+
@test lookupname(def, "REVERSED HAND WITH MIDDLE FINGER EXTENDED") == "\U1f595"
8579
end
8680

8781
@testset "matches" begin
88-
@test isempty(ue_matches(""))
89-
@test isempty(ue_matches("\uf900"))
90-
@test isempty(ue_matches(SubString("This is \uf900", 9)))
82+
@test isempty(matches(def, ""))
83+
@test isempty(matches(def, "\uf900"))
84+
@test isempty(matches(def, SubString("This is \uf900", 9)))
9185
for (chrs, exp) in (("\U1f596", ["RAISED HAND WITH PART BETWEEN MIDDLE AND RING FINGERS"]),
9286
("\u0f4a", ["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
9892
end
9993

10094
@testset "longestmatches" begin
101-
@test isempty(ue_longestmatches("\uf900 abcd"))
102-
@test isempty(ue_longestmatches(SubString("This is \uf900 abcd", 9)))
95+
@test isempty(longestmatches(def, "\uf900 abcd"))
96+
@test isempty(longestmatches(def, SubString("This is \uf900 abcd", 9)))
10397
for (chrs, exp) in (("\U1f596 abcd", ["RAISED HAND WITH PART BETWEEN MIDDLE AND RING FINGERS"]),
10498
(".abcd", ["FULL STOP", "PERIOD"]),
10599
("\u0f4a#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
110104
end
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

Comments
 (0)