diff options
Diffstat (limited to 'unittest.cpp')
-rw-r--r-- | unittest.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/unittest.cpp b/unittest.cpp index c0a45b7..48798d0 100644 --- a/unittest.cpp +++ b/unittest.cpp @@ -3,6 +3,7 @@ #include "routing.h" #include "utility.h" #include "flask.h" +#include "json.h" using namespace std; using namespace flask; @@ -235,6 +236,19 @@ TEST(multi_server) server2.stop(); } +TEST(json_write) +{ + json::wvalue x; + x["message"] = "hello world"; + ASSERT_EQUAL(R"({"message":"hello world"})", json::encode(x)); + + json::wvalue y; + y["scores"][0] = 1; + y["scores"][1] = "king"; + y["scores"][2] = 3.5; + ASSERT_EQUAL(R"({"scores":[1,"king",3.5]})", json::encode(y)); +} + int testmain() { bool failed = false; |