From 5526027b87eaf35b692f2a069e1025c0adf6a93b Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 1 Feb 2024 11:35:45 -0800 Subject: JSON: Add simple printing and creation (#6265) --- test/gtest/json.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/gtest/json.cpp (limited to 'test/gtest/json.cpp') diff --git a/test/gtest/json.cpp b/test/gtest/json.cpp new file mode 100644 index 000000000..10417cdb9 --- /dev/null +++ b/test/gtest/json.cpp @@ -0,0 +1,16 @@ +#include "support/json.h" +#include "gtest/gtest.h" + +using JSONTest = ::testing::Test; + +TEST_F(JSONTest, Stringify) { + // TODO: change the API to not require a copy + auto input = "[\"hello\",\"world\"]"; + auto* copy = strdup(input); + json::Value value; + value.parse(copy); + std::stringstream ss; + value.stringify(ss); + EXPECT_EQ(ss.str(), input); + free(copy); +} -- cgit v1.2.3