Skip to content

Commit

Permalink
add parsing tests for structs
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed May 2, 2024
1 parent bda3e9f commit a511d96
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -565,4 +565,33 @@ end
@test Stipple.Layout.THEMES[][end] == my_css
remove_css(my_css, byname = true)
@test findfirst(==(my_css), Stipple.Layout.THEMES[]) === nothing
end

@testset "parsing" begin
struct T1
c::Int
d::Int
end

struct T2
a::Int
b::T1
end

t2 = T2(1, T1(2, 3))
t2_dict = JSON3.read(json(t2), Dict)

Base.@kwdef struct T3
c::Int = 1
d::Int = 3
end

Base.@kwdef struct T4
a::Int = 1
b::T3 = T3()
end

@test Stipple.stipple_parse(T2, t2_dict) == T2(1, T1(2, 3))
@test Stipple.stipple_parse(T3, Dict()) == T3(1, 3)
@test Stipple.stipple_parse(T4, Dict()) == T4(1, T3(1, 3))
end

0 comments on commit a511d96

Please sign in to comment.