mapleFU commented on code in PR #1829:
URL: https://github.com/apache/kvrocks/pull/1829#discussion_r1364183253


##########
tests/cppunit/types/json_test.cc:
##########
@@ -119,3 +119,21 @@ TEST_F(RedisJsonTest, Get) {
   ASSERT_TRUE(json_->Get(key_, {"$..x", "$..y", "$..z"}, &json_val_).ok());
   ASSERT_EQ(json_val_.Dump(), 
R"({"$..x":[{"y":1},4],"$..y":[[2,{"z":3}],1],"$..z":[{"a":{"x":4}},3]})");
 }
+
+TEST_F(RedisJsonTest, LegacyPath) {
+  ASSERT_THAT(json_->Set(key_, ".", "invalid").ToString(), 
MatchesRegex(".*syntax_error.*"));
+  ASSERT_THAT(json_->Set(key_, ".", "{").ToString(), 
MatchesRegex(".*Unexpected end of file.*"));
+
+  ASSERT_TRUE(json_->Set(key_, ".", "  \t{\n  }  ").ok());
+  ASSERT_TRUE(json_->Get(key_, {"."}, &json_val_).ok());
+  ASSERT_EQ(json_val_.Dump(), "[{}]");
+
+  auto s = json_->Set(key_, ".", "1");
+  ASSERT_TRUE(s.ok()) << s.ToString();
+  ASSERT_TRUE(json_->Get(key_, {"."}, &json_val_).ok());
+  ASSERT_EQ(json_val_.Dump(), "[1]");
+
+  ASSERT_TRUE(json_->Set(key_, ".", "[1, 2, 3]").ok());
+  ASSERT_TRUE(json_->Get(key_, {"."}, &json_val_).ok());
+  ASSERT_EQ(json_val_.Dump(), "[[1,2,3]]");

Review Comment:
   added, PTAL again



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to