Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Moelf committed Oct 16, 2024
1 parent fb6c633 commit 9bd2f17
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 19 deletions.
40 changes: 40 additions & 0 deletions test/RNTupleWriting/lowlevel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,22 @@ write("/tmp/mine.root", mio)
@test mio == REFERENCE_BYTES
end


@testset "RNTuple Writing - triple jagged vector" begin
newtable = (;
one_vuint = [[0xcececece, 0xcdcdcdcd], [0xabababab]],
two_uint = [0xabababab, 0xcdcdcdcd],
three_v_vuint = [[[0xcececece], [0xcdcdcdcd]], [[0xabababab]]]
)
frs, crs = UnROOT.schema_to_field_column_records(newtable)

parent_field_ids = getproperty.(frs, :parent_field_id)
field_ids = getproperty.(crs, :field_id)

@test parent_field_ids == [0,0,2,3,3,4]
@test field_ids == [0,1,2,3,4,5]
end

@testset "RNTuple Writing - Single colunm round trips" begin
for _ = 1:10, T in [Float64, Float32, Float16, Int64, Int32, Int16, Int8, UInt64, UInt32, UInt16]
newtable = Dict(randstring(rand(2:10)) => rand(T, rand(1:100)))
Expand Down Expand Up @@ -266,3 +282,27 @@ end
@test all(getproperty(t, i) .== newtable[String(i)])
end
end

@testset "RNTuple Writing - Vector colunms" begin
Ts = rand([Float64, Float32, Float16, Int64, Int32, Int16, Int8, UInt64, UInt32, UInt16], 15)
inner_Nitems = [3,4,0,0,1,2]
newtable = Dict(randstring(rand(2:10)) => [rand(T, Nitems) for Nitems in inner_Nitems] for T in Ts)
newio = IOBuffer()
UnROOT.write_rntuple(newio, newtable)
nio = take!(newio)

if isfile("a.root")
rm("a.root")
end

open("a.root", "w") do f
write(f, nio)
end

rntuple_name = "myntuple"
t = LazyTree("a.root", rntuple_name)
@test sort(names(t)) == sort(collect(keys(newtable)))
for i in propertynames(t)
@test all(getproperty(t, i) .== newtable[String(i)])
end
end
38 changes: 19 additions & 19 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ nthreads = UnROOT._maxthreadid()
nthreads == 1 && @warn "Running on a single thread. Please re-run the test suite with at least two threads (`julia --threads 2 ...`)"

@testset "UnROOT tests" verbose = true begin
include("Aqua.jl")
include("bootstrapping.jl")
include("compressions.jl")
include("jagged.jl")
include("lazy.jl")
include("histograms.jl")
include("views.jl")
include("multithreading.jl")
include("remote.jl")
include("displays.jl")
include("type_stability.jl")
include("utils.jl")
include("misc.jl")
# include("Aqua.jl")
# include("bootstrapping.jl")
# include("compressions.jl")
# include("jagged.jl")
# include("lazy.jl")
# include("histograms.jl")
# include("views.jl")
# include("multithreading.jl")
# include("remote.jl")
# include("displays.jl")
# include("type_stability.jl")
# include("utils.jl")
# include("misc.jl")

include("type_support.jl")
include("custom_bootstrapping.jl")
include("lorentzvectors.jl")
include("NanoAOD.jl")
# include("type_support.jl")
# include("custom_bootstrapping.jl")
# include("lorentzvectors.jl")
# include("NanoAOD.jl")

include("issues.jl")
# include("issues.jl")

if VERSION >= v"1.9"
include("rntuple.jl")
# include("rntuple.jl")
include("./RNTupleWriting/lowlevel.jl")
end
end

0 comments on commit 9bd2f17

Please sign in to comment.