summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gtest/CMakeLists.txt1
-rw-r--r--test/gtest/json.cpp16
2 files changed, 17 insertions, 0 deletions
diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt
index b40130760..303e386c6 100644
--- a/test/gtest/CMakeLists.txt
+++ b/test/gtest/CMakeLists.txt
@@ -4,6 +4,7 @@ include_directories(../../src/wasm)
set(unittest_SOURCES
cfg.cpp
dfa_minimization.cpp
+ json.cpp
lattices.cpp
possible-contents.cpp
printing.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);
+}