1
1
using StrTables, Unicode_Entities
2
2
3
- @static VERSION < v " 0.7.0-DEV " ? ( using Base . Test) : ( using Test)
3
+ 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
8
const def = Unicode_Entities. default
9
9
10
- const datapath = " ../ data"
10
+ const datapath = joinpath ( pathof (Unicode_Entities), " data" )
11
11
const dpath = " ftp://ftp.unicode.org/Public/UNIDATA/"
12
12
const fname = " UnicodeData.txt"
13
13
@@ -17,7 +17,15 @@ const symval = Vector{Char}()
17
17
""" Load up all names and characters from original data file"""
18
18
function load_unicode_data ()
19
19
lname = joinpath (datapath, fname)
20
- isfile (lname) || download (string (dpath, fname), lname)
20
+ if ! isfile (lname)
21
+ try
22
+ lname = download (string (dpath, fname), lname)
23
+ catch ex
24
+ println (" Error loading \" $(string (dpath, fname)) \" and saving in \" $lname \" " )
25
+ println (sprint (showerror, ex, catch_backtrace ()))
26
+ return false
27
+ end
28
+ end
21
29
aliasnam = Vector {String} ()
22
30
aliasval = Vector {Char} ()
23
31
open (lname, " r" ) do f
@@ -48,13 +56,11 @@ function load_unicode_data()
48
56
push! (symval, ch)
49
57
end
50
58
end
59
+ true
51
60
end
52
61
53
- load_unicode_data ()
54
-
55
62
@testset " Unicode_Entities" begin
56
-
57
- @testset " matches data file" begin
63
+ if load_unicode_data () @testset " matches data file" begin
58
64
for (i, ch) in enumerate (symval)
59
65
list = matchchar (def, ch)
60
66
if ! isempty (list)
@@ -68,6 +74,7 @@ load_unicode_data()
68
74
end
69
75
end
70
76
end
77
+ end
71
78
72
79
@testset " lookupname" begin
73
80
@test lookupname (def, " foobar" ) == " "
0 commit comments