本文整理汇总了C++中dynamic::at方法的典型用法代码示例。如果您正苦于以下问题:C++ dynamic::at方法的具体用法?C++ dynamic::at怎么用?C++ dynamic::at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dynamic
的用法示例。
在下文中一共展示了dynamic::at方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkItemParseError
void checkItemParseError(
// real_k can differ from err_k, which is typically coerced to string
dynamic d, Fn fn, dynamic real_k, dynamic err_k, std::string re) {
DynamicParser p(DynamicParser::OnError::RECORD, &d);
fn(p);
auto errors = p.releaseErrors();
auto error = errors.at("nested").at(err_k);
EXPECT_EQ(d.at(real_k), error.at("value"));
EXPECT_PCRE_MATCH(re, error.at("error").getString());
EXPECT_EQ(dynamic(dynamic::object("nested", dynamic::object(
err_k, dynamic::object("value", d.at(real_k))("error", error.at("error"))
))), errors);
}
示例2: ds
TEST(Dynamic, At) {
const dynamic cd = dynamic::object("key1", make_long_string());
dynamic dd = dynamic::object("key1", make_long_string());
dynamic md = dynamic::object("key1", make_long_string());
dynamic ds(make_long_string());
EXPECT_EQ(ds, cd.at("key1"));
EXPECT_EQ(ds, cd.at("key1"));
dd.at("key1").getString() += " hello";
EXPECT_EQ(dynamic(make_long_string() + " hello"), dd.at("key1"));
EXPECT_EQ(dynamic(make_long_string() + " hello"), dd.at("key1"));
EXPECT_EQ(ds, std::move(md).at("key1"));
EXPECT_NE(ds, md.at("key1"));
}
示例3: ds
TEST(Dynamic, At) {
const dynamic cd = dynamic::object("key1", make_long_string());
dynamic dd = dynamic::object("key1", make_long_string());
dynamic md = dynamic::object("key1", make_long_string());
dynamic ds(make_long_string());
EXPECT_EQ(ds, cd.at("key1"));
EXPECT_EQ(ds, cd.at("key1"));
dd.at("key1").getString() += " hello";
EXPECT_EQ(dynamic(make_long_string() + " hello"), dd.at("key1"));
EXPECT_EQ(dynamic(make_long_string() + " hello"), dd.at("key1"));
EXPECT_EQ(ds, std::move(md).at("key1")); // move available, but not performed
EXPECT_EQ(ds, md.at("key1"));
dynamic moved = std::move(md).at("key1"); // move performed
EXPECT_EQ(ds, moved);
EXPECT_NE(ds, md.at("key1"));
}