From 1244f942f14aefe00015cf31cb188e2507a678b5 Mon Sep 17 00:00:00 2001 From: Jarrett Revels Date: Mon, 4 Dec 2023 11:00:00 -0500 Subject: [PATCH] add a test --- test/runtests.jl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 48ca399b..011e0175 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1015,5 +1015,27 @@ end # end + @testset "# 493" begin + # This test stresses the existence of the mechanism + # implemented in https://github.com/apache/arrow-julia/pull/493, + # but doesn't stress the actual use case that motivates + # that mechanism, simply because it'd be more annoying to + # write that test; see the PR for details. + struct Foo493 + x::Int + y::Int + end + Arrow.ArrowTypes.arrowname(::Type{Foo493}) = Symbol("JuliaLang.Foo493") + Arrow.ArrowTypes.JuliaType(::Val{Symbol("JuliaLang.Foo493")}, T) = Foo493 + function Arrow.ArrowTypes.fromarrow(::Type{Foo493}, f::Arrow.StructElement) + return Foo493(f.fields.x + 1, f.fields.y + 1) + end + t = (; f=[Foo493(1, 2), Foo493(3, 4)]) + buf = Arrow.tobuffer(t) + tbl = Arrow.Table(buf) + @test tbl.f[1] === Foo493(2, 3) + @test tbl.f[2] === Foo493(4, 5) + end + end # @testset "misc" end