view julia/JSONStructs/test/runtests.jl @ 39:8a21e7a32029

Initial commit on JSONStructs
author Lewin Bormann <lbo@spheniscida.de>
date Sat, 25 Mar 2023 21:39:20 +0100
parents
children 5e3662b65004
line wrap: on
line source

# Some basic tests.

using JSONStructs

@json_parseable struct TestStruct1
    a::Int
    b::Float64
    c::Vector{String}
end

function test_parse_1()
    json = "{\"a\": 33, \"b\": 55.55, \"c\": [\"xyz\", \"abc\"]}"
    have = parse_struct(TestStruct1, json)
    want = TestStruct1(33, 55.55, ["xyz", "abc"])
    @assert string(have) == string(want) "$have == $want"
end


test_parse_1()