BibTeX.jl/test/runtests.jl

50 lines
1.4 KiB
Julia

using BibTeX, Base.Test
import Documenter
Documenter.makedocs(
modules = [BibTeX],
format = :html,
sitename = "BibTeX.jl",
root = joinpath(dirname(dirname(@__FILE__)), "docs"),
pages = Any["Home" => "index.md"],
strict = true,
linkcheck = true,
checkdocs = :exports,
authors = "Brandon Taylor"
)
@testset "examples.bib" begin
b = open(Bibliography, joinpath("..", "example", "examples.bib"), "r")
@test length(b) == 92
@test (b["angenendt"]::Citation{:article})["date"] == "2002"
end
@testset "small bib" begin
b = Bibliography("""
@article{foo, bar=baz}
@book{bar, foobar=1}
""")
@test get(b, "foobar", nothing) === nothing
@test get(b["foo"], "blah", nothing) === nothing
@test string(b["foo"]) == "Citation{:article}(1 entries)"
Base.rehash!(b)
b2 = copy(b)
@test length(b2) == length(b)
@test isempty(sizehint!(empty!(b2),10))
@test isempty(similar(b))
b2["x"] = Citation{:foo}()
b2["x"]["bar"] = "blah"
@test length(b2) == length(b2["x"]) == 1
@test b2["x"]["bar"] == "blah"
@test get(b2["x"], "foo", nothing) === nothing
@test collect(b2)[1][2] == b2["x"]
@test collect(b2["x"])[1] == ("bar"=>"blah")
Base.rehash!(b2["x"])
x2 = copy(b2["x"])::Citation{:foo}
@test length(x2) == 1
@test isempty(similar(x2))
@test isempty(sizehint!(empty!(x2),10))
end