summaryrefslogtreecommitdiff
path: root/test/gtest/json.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-02-01 11:35:45 -0800
committerGitHub <noreply@github.com>2024-02-01 19:35:45 +0000
commit5526027b87eaf35b692f2a069e1025c0adf6a93b (patch)
tree0705e4d026c7287f57787fba5c63f414c2683212 /test/gtest/json.cpp
parent2b3a2e8c341395e4cb0f76db6ad4f31fb17720cc (diff)
downloadbinaryen-5526027b87eaf35b692f2a069e1025c0adf6a93b.tar.gz
binaryen-5526027b87eaf35b692f2a069e1025c0adf6a93b.tar.bz2
binaryen-5526027b87eaf35b692f2a069e1025c0adf6a93b.zip
JSON: Add simple printing and creation (#6265)
Diffstat (limited to 'test/gtest/json.cpp')
-rw-r--r--test/gtest/json.cpp16
1 files changed, 16 insertions, 0 deletions
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);
+}