From 9e900f28c9cb9513ca39acd7992dfce9a93f00f6 Mon Sep 17 00:00:00 2001 From: WooKyoung Noh Date: Sun, 24 Dec 2023 17:37:45 +0900 Subject: [PATCH] test_json3_parse_jsonlines --- Project.toml | 2 +- test/json/parse.jl | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4a9cbef..781e7a7 100644 --- a/Project.toml +++ b/Project.toml @@ -15,7 +15,7 @@ URIParser = "30578b45-9adc-5946-b283-645ec420af67" [compat] Documenter = "0.24, 0.25, 0.26, 0.27" -HTTP = "0.8, 0.9, 1.0" +HTTP = "0.8, 0.9, 1.0, 1.10" MbedTLS = "0.7, 1.0" URIParser = "0.4" JSON = "0.21" diff --git a/test/json/parse.jl b/test/json/parse.jl index c595eee..8d31479 100644 --- a/test/json/parse.jl +++ b/test/json/parse.jl @@ -68,3 +68,27 @@ json_encode = JSON3.write @test (json_encode ∘ json_decode)("[1.0]") == "[1]" # end # module test_json3_parse + + +module test_json3_parse_jsonlines + +using Test +using JSON3 + +json_decode(json) = JSON3.read(json, jsonlines=true) # +json_encode = JSON3.write + +@test_throws ArgumentError json_decode(IOBuffer()) +@test json_decode(IOBuffer("1")) == [1] # +@test json_decode(String(take!(IOBuffer("1")))) == [1] # +@test json_decode(read(IOBuffer("1"), String)) == [1] # +@test (json_encode ∘ json_decode)(IOBuffer("[1]")) == "[[1]]" # +@test (json_encode ∘ json_decode)(IOBuffer("[1.0]")) == "[[1]]" # + +@test_throws ArgumentError json_decode("") +@test json_decode("1") isa JSON3.Array # +@test json_decode("1.0") isa JSON3.Array # +@test (json_encode ∘ json_decode)("[1]") == "[[1]]" # +@test (json_encode ∘ json_decode)("[1.0]") == "[[1]]" # + +end # module test_json3_parse_jsonlines