Skip to content

Commit 498a7fe

Browse files
committed
Update tests, badges
1 parent de43cde commit 498a7fe

File tree

4 files changed

+23
-28
lines changed

4 files changed

+23
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://travis-ci.org/JuliaString/HTML_Entities.jl.svg?branch=master)](https://travis-ci.org/JuliaString/HTML_Entities.jl)
44

5-
[![Coverage Status](https://coveralls.io/repos/JuliaString/HTML_Entities.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/JuliaString/HTML_Entities.jl?branch=master)
5+
[![Coverage Status](https://coveralls.io/repos/github/JuliaString/HTML_Entities.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaString/HTML_Entities.jl?branch=master)
66

77
[![codecov.io](http://codecov.io/github/JuliaString/HTML_Entities.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaString/HTML_Entities.jl?branch=master)
88

src/HTML_Entities.jl

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,23 @@ __precompile__()
1010
module HTML_Entities
1111
using StrTables
1212

13-
include("html_table.jl")
13+
VER = UInt32(1)
14+
15+
immutable HTML_Table{T} <: AbstractEntityTable
16+
ver::UInt32
17+
tim::String
18+
inf::String
19+
base32::UInt32
20+
base2c::UInt32
21+
nam::StrTable{T}
22+
ind::Vector{UInt16}
23+
val16::Vector{UInt16}
24+
ind16::Vector{UInt16}
25+
val32::Vector{UInt16}
26+
ind32::Vector{UInt16}
27+
val2c::Vector{UInt32}
28+
ind2c::Vector{UInt16}
29+
end
1430

1531
function __init__()
1632
const global _tab =
@@ -34,20 +50,16 @@ function _get_strings{T}(val::T, tab::Vector{T}, ind::Vector{UInt16})
3450
_tab.nam[ind[rng]]
3551
end
3652

37-
"""Given a HTML name, return the string it represents, or an empty string if not found"""
3853
function lookupname(str::AbstractString)
3954
rng = searchsorted(_tab.nam, str)
4055
isempty(rng) ? _empty_str : _get_str(_tab.ind[rng.start])
4156
end
4257

43-
"""Given a character, return all exact matches to the character as a vector"""
4458
matchchar(ch::Char) =
4559
(ch <= '\uffff'
4660
? _get_strings(ch%UInt16, _tab.val16, _tab.ind16)
4761
: (ch <= '\U1ffff' ? _get_strings(ch%UInt16, _tab.val32, _tab.ind32) : _empty_str_vec))
4862

49-
"""Given a string, return all exact matches to the string as a vector"""
50-
function matches end
5163
matches(str::AbstractString) = matches(convert(Vector{Char}, str))
5264
function matches(vec::Vector{Char})
5365
if length(vec) == 1
@@ -59,8 +71,6 @@ function matches(vec::Vector{Char})
5971
end
6072
end
6173

62-
"""Given a string, return all of the longest matches to the beginning of the string as a vector"""
63-
function longestmatches end
6474
longestmatches(str::AbstractString) = longestmatches(convert(Vector{Char}, str))
6575
function longestmatches(vec::Vector{Char})
6676
isempty(vec) && return _empty_str_vec
@@ -72,9 +82,6 @@ function longestmatches(vec::Vector{Char})
7282
matchchar(vec[1])
7383
end
7484

75-
76-
"""Given a string, return all of the HTML entity names that start with that string, if any"""
77-
function completions end
7885
completions(str::AbstractString) = completions(convert(String, str))
7986
completions(str::String) = StrTables.matchfirst(_tab.nam, str)
8087

src/html_table.jl

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ HE = HTML_Entities
88

99
@testset "HTML_Entities" begin
1010
@testset "lookupname" begin
11+
@test HE.lookupname(SubString("My name is Spock", 12)) == ""
1112
@test HE.lookupname("foobar") == ""
1213
@test HE.lookupname("nle") == "\u2270"
1314
@test HE.lookupname("Pscr") == "\U1d4ab"
1415
@test HE.lookupname("lvnE") == "\u2268\ufe00"
1516
end
1617

1718
@testset "matches" begin
19+
@test isempty(HE.matches(""))
1820
@test isempty(HE.matches("\u201f"))
21+
@test isempty(EE.matches(SubString("This is \u201f", 9)))
1922
for (chrs, exp) in (("\u2270", ["nle", "nleq"]),
2023
("\U1d4ab", ["Pscr"]),
2124
("\U1d51e", ["afr"]),
@@ -28,6 +31,7 @@ end
2831

2932
@testset "longestmatches" begin
3033
@test isempty(HE.longestmatches("\u201f abcd"))
34+
@test isempty(EE.longestmatches(SubString("This is \U201f abcd", 9)))
3135
for (chrs, exp) in (("\u2270 abcd", ["nle", "nleq"]),
3236
("\U1d4ab abcd", ["Pscr"]),
3337
("\u2268\ufe00 silly", ["lvertneqq", "lvnE"]))
@@ -39,6 +43,7 @@ end
3943

4044
@testset "completions" begin
4145
@test isempty(HE.completions("ScottPaulJones"))
46+
@test isempty(EE.completions(SubString("My name is Scott", 12)))
4247
for (chrs, exp) in (("and", ["and", "andand", "andd", "andslope", "andv"]),
4348
("um", ["umacr", "uml"]))
4449
res = HE.completions(chrs)

0 commit comments

Comments
 (0)