11using StrTables, Unicode_Entities
22
3- @static VERSION < v " 0.7.0-DEV " ? ( using Base . Test) : ( using Test)
3+ 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
88const def = Unicode_Entities. default
99
10- const datapath = " ../ data"
10+ const datapath = joinpath ( pathof (Unicode_Entities), " data" )
1111const dpath = " ftp://ftp.unicode.org/Public/UNIDATA/"
1212const fname = " UnicodeData.txt"
1313
@@ -17,7 +17,15 @@ const symval = Vector{Char}()
1717""" Load up all names and characters from original data file"""
1818function load_unicode_data ()
1919 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
2129 aliasnam = Vector {String} ()
2230 aliasval = Vector {Char} ()
2331 open (lname, " r" ) do f
@@ -48,13 +56,11 @@ function load_unicode_data()
4856 push! (symval, ch)
4957 end
5058 end
59+ true
5160end
5261
53- load_unicode_data ()
54-
5562@testset " Unicode_Entities" begin
56-
57- @testset " matches data file" begin
63+ if load_unicode_data () @testset " matches data file" begin
5864 for (i, ch) in enumerate (symval)
5965 list = matchchar (def, ch)
6066 if ! isempty (list)
@@ -68,6 +74,7 @@ load_unicode_data()
6874 end
6975 end
7076 end
77+ end
7178
7279@testset " lookupname" begin
7380 @test lookupname (def, " foobar" ) == " "
0 commit comments