Skip to content

Commit

Permalink
test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jpjones76 committed Sep 23, 2019
1 parent c5e5648 commit db224e9
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 12 deletions.
2 changes: 1 addition & 1 deletion test/CoreUtils/test_typ2code.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ for c = 0x00:0xfe
end
end

@test_throws UndefVarError code2typ(0x02)
@test_throws ErrorException code2typ(0x02)
1 change: 1 addition & 0 deletions test/DataFormats/test_read_meta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ S1 = read_meta("sxml", path*"/SampleFiles/fdsnws-station_2019-09-11T06_26_58Z.xm
S2 = read_meta("resp", path*"/SampleFiles/JRO.resp", units=true)
S3 = read_meta("dataless", path*"/SampleFiles/SEED/CC.dataless", s="2016-01-01T00:00:00", units=true)[56:58]
S4 = read_meta("sacpz", path*"/SampleFiles/JRO.sacpz")
@test_throws ErrorException read_meta("deez", "nutz.sac")

C = Array{Char,2}(undef, 10, 3)
fill!(C, ' ')
Expand Down
5 changes: 5 additions & 0 deletions test/DataFormats/test_uw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ printstyled(" UW\n", color=:light_green)
uwf = joinpath(path, "SampleFiles/[0-9]*W")

S = read_data("uw", uwf)
S1 = SeisData()
uwdf!(S1, joinpath(path, "SampleFiles/00012502123W"))
uwdf!(S1, joinpath(path, "SampleFiles/99011116541W"))
@test S == S1

uwf1 = joinpath(path, "SampleFiles/99011116541")
uwf2 = joinpath(path, "SampleFiles/94100613522o")
uwf3 = joinpath(path, "SampleFiles/02062915175o")
Expand Down
3 changes: 2 additions & 1 deletion test/NativeIO/test_native_io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ redirect_stdout(out) do
@test R[i] == A[i]
end

# add an incompatible type; should throw a warning
# add an incompatible type; should throw a warning, and another when read back in
push!(A, rand(Float64,3))
wseis(savfile1, A...)
R = rseis(savfile1, v=2)
end

printstyled(" test read/write with data compression\n", color=:light_green)
Expand Down
10 changes: 5 additions & 5 deletions test/Processing/test_convert_seis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ redirect_stdout(out) do

# Test on a SeisChannel
C = deepcopy(U[1])
convert_seis!(C, units_out="m")
convert_seis!(C, units_out="m/s")
convert_seis!(C, units_out="m/s2")
convert_seis!(C, units_out="m")
D = convert_seis(C, units_out="m/s2")
convert_seis!(C, units_out="m", v=1)
convert_seis!(C, units_out="m/s", v=1)
convert_seis!(C, units_out="m/s2", v=1)
convert_seis!(C, units_out="m", v=1)
D = convert_seis(C, units_out="m/s2", v=1)
end
29 changes: 28 additions & 1 deletion test/Types/test_InstResp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,37 @@ redirect_stdout(out) do
@test code2resptyp(resptyp2code(R)) == T
@test sizeof(R) == sizeof(R2)
end

nr = 255
R = MultiStageResp(nr)
for f in (:fs, :gain, :fg, :delay, :corr, :fac, :os)
setfield!(R, f, rand(eltype(getfield(R, f)), nr))
end
i = Array{String,1}(undef,nr)
o = Array{String,1}(undef,nr)
o[1] = "m/s"
i[1] = "{counts}"
for j = 2:nr
i[j] = randstring(2^rand(2:6))
o[j] = i[j-1]
end
R.i = i
R.o = o
R.stage[1] = RandSeis.randResp()
for i = 2:nr
R.stage[i] = CoeffResp(b = rand(rand(1:1200)))
end
show(R)
end

printstyled(" resp codes\n", color=:light_green)
for c in (0x00, 0x01, 0x02, 0x03, 0x04, 0xff)
codes = (0x00, 0x01, 0x02, 0x03, 0x04, 0xff)
types = (GenResp, PZResp, PZResp64, CoeffResp, MultiStageResp, Nothing)
for c in codes
T = code2resptyp(c)()
@test c == resptyp2code(T)
end
for (i, T) in enumerate(types)
resp = T()
@test resptyp2code(resp) == codes[i]
end
2 changes: 2 additions & 0 deletions test/Types/test_extended_methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ printstyled(stdout," getindex\n", color=:light_green)
@test findid(T, S) == [0, 0, 4, 5]

printstyled(stdout," getindex + Int on SeisData ==> SeisChannel\n", color=:light_green)
C = S[1]
@test S[firstindex(S)] == C
i_targ = 3
C = S[i_targ]
test_fields_preserved(C,S,i_targ)
Expand Down
3 changes: 0 additions & 3 deletions test/cleanup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ for fpat in ("*.mseed", "*.SAC", "*.geocsv", "FDSNsta.xml", "FDSNevq.log")
println("Attempting to delete ", fpat, " threw error: ", err)
end
end
if !keep_log
rm("runtests.log")
end
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ for d in ["CoreUtils", "Types", "RandSeis", "Utils", "NativeIO", "DataFormats",
end

include("cleanup.jl")

if !keep_log
rm("runtests.log")
end
test_end = Dates.now()
δt = 0.001*(test_end-test_start).value
mm = round(Int, div(δt, 60))
Expand Down
1 change: 1 addition & 0 deletions test/test_helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Dates: DateTime, Hour, now
import DelimitedFiles: readdlm
import Random: rand, randperm, randstring
import SeisIO: BUF, FDSN_sta_xml,
code2typ, typ2code,
bad_chars, checkbuf!, checkbuf_8!, datafields, datareq_summ, endtime,
fillx_i16_le!, fillx_i32_be!, fillx_i32_le!, findhex, formats, get_http_req,
get_http_post, get_views, int2tstr, mean, minreq!,
Expand Down

2 comments on commit db224e9

@jpjones76
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/3778

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.0 -m "<description of version>" db224e96f93582409aa46be9b0df5a440d7c5731
git push origin v0.4.0

Please sign in to comment.