本文整理汇总了C++中KDB::open方法的典型用法代码示例。如果您正苦于以下问题:C++ KDB::open方法的具体用法?C++ KDB::open怎么用?C++ KDB::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDB
的用法示例。
在下文中一共展示了KDB::open方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parentKey
TEST_F (Simple, SetSystemGetAppend2)
{
using namespace kdb;
KDB kdb;
KeySet ks;
Key parentKey (testRoot, KEY_END);
ks.append (Key ("system" + testRoot + "key", KEY_VALUE, "value1", KEY_END));
kdb.get (ks, parentKey);
ASSERT_EQ (ks.size (), 1) << "got keys from freshly mounted backends";
ks.rewind ();
ks.next ();
EXPECT_EQ (ks.current ().getName (), "system/tests/kdb/key") << "name of element in keyset wrong";
EXPECT_EQ (ks.current ().getString (), "value1") << "string of element in keyset wrong";
kdb.set (ks, parentKey);
kdb.close (parentKey);
KeySet ks2;
ks2.append (Key ("system" + testRoot + "key2", KEY_VALUE, "value2", KEY_END));
kdb.open (parentKey);
kdb.get (ks2, parentKey);
ks2.rewind ();
ks2.next ();
ASSERT_EQ (ks2.size (), 1) << "wrong size";
EXPECT_EQ (ks2.current ().getName (), "system/tests/kdb/key") << "name of element in keyset wrong";
EXPECT_EQ (ks2.current ().getString (), "value1") << "string of element in keyset wrong";
}
示例2:
TEST_F (Simple, RemoveFile)
{
using namespace kdb;
KDB kdb;
KeySet ks;
kdb.get (ks, testRoot);
ks.append (Key ("system" + testRoot + "remove", KEY_END));
ASSERT_EQ (ks.size (), 1) << "could not append key\n" << ks;
kdb.set (ks, testRoot);
ASSERT_EQ (ks.size (), 1) << "key gone after kdb.set?\n" << ks;
struct stat buf;
ASSERT_EQ (stat (mp->systemConfigFile.c_str (), &buf), 0) << "found no file";
Key parentKey;
kdb.close (parentKey);
kdb.open (parentKey);
kdb.get (ks, testRoot);
ks.clear ();
ASSERT_EQ (ks.size (), 0) << "keyset should be empty after clearing it\n" << ks;
kdb.set (ks, testRoot);
ASSERT_EQ (stat (mp->systemConfigFile.c_str (), &buf), -1) << "found wrong file";
}