node/convert: support conversion for std::string_view (#1148)

This commit is contained in:
Kefu Chai
2023-07-25 03:51:05 +08:00
committed by GitHub
parent b8882652fc
commit 35b4498026
2 changed files with 27 additions and 0 deletions

View File

@@ -356,6 +356,15 @@ TEST(NodeTest, ConstInteratorOnSequence) {
EXPECT_EQ(3, count);
}
#if __cplusplus >= 201703L
TEST(NodeTest, StdStringViewAsKey) {
Node node;
std::string_view key = "username";
node[key] = "monkey";
EXPECT_EQ("monkey", node[key].as<std::string>());
}
#endif
TEST(NodeTest, SimpleSubkeys) {
Node node;
node["device"]["udid"] = "12345";