test(rdb): Add json dump & restore test (#678)

This commit is contained in:
Vladislav 2023-01-15 12:00:47 +03:00 committed by GitHub
parent cee7a9e67d
commit 7b7e3ea9d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -316,4 +316,22 @@ TEST_F(RdbTest, HMapBugs) {
EXPECT_EQ(2, CheckedInt({"hlen", "hmap1"}));
}
TEST_F(RdbTest, JsonTest) {
string_view data[] = {
R"({"a":1})"sv, //
R"([1,2,3,4,5,6])"sv, //
R"({"a":1.0,"b":[1,2],"c":"value"})"sv, //
R"({"a":{"a":{"a":{"a":1}}}})"sv //
};
for (auto test : data) {
Run({"json.set", "doc", "$", test});
auto dump = Run({"dump", "doc"});
Run({"del", "doc"});
Run({"restore", "doc", "0", facade::ToSV(dump.GetBuf())});
auto res = Run({"json.get", "doc"});
ASSERT_EQ(res, test);
}
}
} // namespace dfly