Skip to content

Commit

Permalink
switch test read wrapper to default to strict=true
Browse files Browse the repository at this point in the history
  • Loading branch information
jpjones76 committed Feb 29, 2020
1 parent 661eddf commit 1328565
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions test/DataFormats/test_ah.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ printstyled(" v1\n", color=:light_green)
redirect_stdout(out) do
S = verified_read_data("ah1", ah1_file, v=3)
S = verified_read_data("ah1", ah1_file, full=true)
S = verified_read_data("ah1", ah1_fstr, full=true, v=3)
S = verified_read_data("ah1", ah1_fstr, full=true, v=3, strict=false)
@test S.n == 3

S = read_data("ah1", ah1_fstr, full=true, v=3, strict=true)
Expand Down Expand Up @@ -79,7 +79,7 @@ printstyled(" v2\n", color=:light_green)
redirect_stdout(out) do
S = verified_read_data("ah2", ah2_file, v=3)
S = verified_read_data("ah2", ah2_file, v=3, full=true)
S = verified_read_data("ah2", ah2_fstr, v=3, full=true, vl=true)
S = verified_read_data("ah2", ah2_fstr, v=3, full=true, vl=true, strict=false)
@test S.n == 1

S = read_data("ah2", ah2_fstr, v=3, full=true, strict=true, vl=true)
Expand Down
10 changes: 5 additions & 5 deletions test/DataFormats/test_mseed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mseed_vals_file = string(path, "/SampleFiles/SEED/test_mseed_vals.txt")

@test_throws ErrorException verified_read_data("mseed", test_sac_file)

S = verified_read_data("mseed", test_mseed_file, v=0)
S = verified_read_data("mseed", test_mseed_file, v=0, strict=false)
@test isequal(S.id[1], "NL.HGN.00.BHZ")
@test (S.fs[1], 40.0)
@test (S.gain[1], 1.0)
Expand All @@ -23,9 +23,9 @@ Sm = read_data("mseed", test_mseed_file, v=0, memmap=true)
@test Sm == S

# Test breaks if memory-resident SeisIOBuf structure SEED is not reset
S1 = verified_read_data("mseed", test_mseed_file, v=0)
S1 = verified_read_data("mseed", test_mseed_file, v=0, strict=false)
if Sys.iswindows() == false
S2 = verified_read_data("mseed", test_mseed_pat, v=0)
S2 = verified_read_data("mseed", test_mseed_pat, v=0, strict=false)
@test S2.src[1] == abspath(test_mseed_pat)
S2.src = S1.src
@test S == S1 == S2
Expand All @@ -49,9 +49,9 @@ if safe_isdir(path*"/SampleFiles/Restricted")
S = SeisData()
ae = any([occursin(i, f) for i in ("blkt2000", "detection.record", "text-encoded", "timing.500s")])
if ae
verified_read_data!(S, "mseed", f, v=3, allow_empty=true)
verified_read_data!(S, "mseed", f, v=3, allow_empty=true, strict=false)
else
verified_read_data!(S, "mseed", f, v=2)
verified_read_data!(S, "mseed", f, v=2, strict=false)
end

# Test that our encoders return the expected values
Expand Down
4 changes: 4 additions & 0 deletions test/TestHelpers/verified_read_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ function verified_read_data!(S::GphysData, fmt::String, fpat::Union{String, Arra
jst ::Bool = true, # are sample times JST (UTC+9)?
nx_add ::Int64 = KW.nx_add, # append nx_add to overfull channels
nx_new ::Int64 = KW.nx_new, # new channel samples
strict ::Bool = true,
swap ::Bool = false, # do byte swap?
v ::Int64 = KW.v, # verbosity level
vl ::Bool = false, # verbose logging
Expand All @@ -16,6 +17,7 @@ function verified_read_data!(S::GphysData, fmt::String, fpat::Union{String, Arra
jst = jst,
nx_add = nx_add,
nx_new = nx_new,
strict = strict,
swap = swap,
v = v,
vl = vl
Expand All @@ -31,6 +33,7 @@ function verified_read_data(fmt::String, fpat::Union{String, Array{String,1}};
jst ::Bool = true, # are sample times JST (UTC+9)?
nx_add ::Int64 = KW.nx_add, # append nx_add to overfull channels
nx_new ::Int64 = KW.nx_new, # new channel samples
strict ::Bool = true,
swap ::Bool = false, # do byte swap?
v ::Int64 = KW.v, # verbosity level
vl ::Bool = false, # verbose logging
Expand All @@ -43,6 +46,7 @@ function verified_read_data(fmt::String, fpat::Union{String, Array{String,1}};
jst = jst,
nx_add = nx_add,
nx_new = nx_new,
strict = strict,
swap = swap,
v = v,
vl = vl
Expand Down

0 comments on commit 1328565

Please sign in to comment.