14 #include <gtest/gtest.h>
19 const std::string
data =
"Hello world!";
21 unsigned int ttl = 234;
23 const std::string
validDecodeJson =
"{\"data\":\"Hello world!\",\"ttl\":234,\"type\":1}";
24 const std::string
validEncodeJson =
"{\"data\":\"SGVsbG8gd29ybGQh\",\"ttl\":234,\"type\":1}";
30 TEST(JsonMessageCover, serializeJsonMessageCover)
38 ASSERT_TRUE(jsonMessageCover.
serialize(json));
39 ASSERT_FALSE(jsonMessageCover.
isError());
41 ASSERT_TRUE(jsonMessageCover.
getErrorMsg().empty());
42 ASSERT_FALSE(json.empty());
45 TEST(JsonMessageCover, unserializeJsonMessageCover)
49 #if JSON_USE_BASE64 == 1
57 ASSERT_FALSE(jsonMessageCover.
isError());
59 ASSERT_TRUE(jsonMessageCover.
getErrorMsg().empty());
61 ASSERT_EQ(jsonMessageCover.
getType(), HCE::types::MessageType::mtSphinx);
63 ASSERT_EQ(jsonMessageCover.
getTTL(),
ttl);
66 TEST(JsonMessageCover, useOutputStream)
73 std::stringstream json;
74 json << jsonMessageCover;
76 ASSERT_FALSE(jsonMessageCover.isError());
78 ASSERT_TRUE(jsonMessageCover.getErrorMsg().empty());
79 ASSERT_FALSE(json.str().empty());
82 TEST(JsonMessageCover, useInputStream)
84 std::stringstream json;
86 #if JSON_USE_BASE64 == 1
93 json >> jsonMessageCover;
95 ASSERT_FALSE(jsonMessageCover.isError());
97 ASSERT_TRUE(jsonMessageCover.getErrorMsg().empty());
99 ASSERT_EQ(jsonMessageCover.getType(), HCE::types::MessageType::mtSphinx);
100 ASSERT_EQ(jsonMessageCover.getData(),
data);
101 ASSERT_EQ(jsonMessageCover.getTTL(),
ttl);
104 TEST(JsonMessageCover, errorMessageJsonMessageCover)
106 std::stringstream json;
108 #if JSON_USE_BASE64 == 1
115 json >> jsonMessageCover;
117 ASSERT_TRUE(jsonMessageCover.isError());
119 ASSERT_FALSE(jsonMessageCover.getErrorMsg().empty());
122 int main (
int argc,
char** argv)
124 testing::InitGoogleTest(&argc, argv);
125 return RUN_ALL_TESTS();