本文整理汇总了C++中RepoBSON::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ RepoBSON::toString方法的具体用法?C++ RepoBSON::toString怎么用?C++ RepoBSON::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RepoBSON
的用法示例。
在下文中一共展示了RepoBSON::toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testDiff_org
TEST(RepoBSONTest, Swap)
{
RepoBSON test = testBson;
//Test with bigfile mapping
std::vector < uint8_t > in;
in.resize(100);
std::unordered_map<std::string, std::pair<std::string, std::vector<uint8_t>>> map, mapout;
map["testingfile"] = std::pair<std::string, std::vector<uint8_t>>("blah", in);
RepoBSON testDiff_org(BSON("entirely" << "different"), map);
RepoBSON testDiff = testDiff_org;
EXPECT_TRUE(testDiff_org.toString() == testDiff.toString());
EXPECT_TRUE(testDiff_org.getFilesMapping().size() == testDiff.getFilesMapping().size());
test.swap(testDiff);
EXPECT_EQ(testDiff_org.toString(), test.toString());
mapout = test.getFilesMapping();
ASSERT_EQ(map.size(), mapout.size());
auto mapIt = map.begin();
auto mapoutIt = mapout.begin();
for (; mapIt != map.end(); ++mapIt, ++mapoutIt)
{
EXPECT_EQ(mapIt->first, mapIt->first);
EXPECT_EQ(mapIt->second.first, mapIt->second.first);
std::vector<uint8_t> dataOut = mapoutIt->second.second;
std::vector<uint8_t> dataIn = mapIt->second.second;
EXPECT_EQ(dataIn.size(), dataOut.size());
if (dataIn.size()>0)
EXPECT_EQ(0, strncmp((char*)dataOut.data(), (char*)dataIn.data(), dataIn.size()));
}
}
示例2: strncmp
TEST(RepoBSONTest, AssignOperator)
{
RepoBSON test = testBson;
EXPECT_TRUE(test.toString() == testBson.toString());
EXPECT_EQ(test.getFilesMapping().size(), testBson.getFilesMapping().size());
//Test with bigfile mapping
std::vector < uint8_t > in;
in.resize(100);
std::unordered_map<std::string, std::pair<std::string, std::vector<uint8_t>>> map, mapout;
map["testingfile"] = std::pair<std::string, std::vector<uint8_t>>( "field", in);
RepoBSON test2(testBson, map);
mapout = test2.getFilesMapping();
ASSERT_EQ(mapout.size(), map.size());
auto mapIt = map.begin();
auto mapoutIt = mapout.begin();
for (; mapIt != map.end(); ++mapIt, ++mapoutIt)
{
EXPECT_EQ(mapIt->first, mapIt->first);
EXPECT_EQ(mapIt->second.first, mapIt->second.first);
std::vector<uint8_t> dataOut = mapoutIt->second.second;
std::vector<uint8_t> dataIn = mapIt->second.second;
EXPECT_EQ(dataOut.size(), dataIn.size());
if (dataIn.size()>0)
EXPECT_EQ(0, strncmp((char*)&dataOut[0], (char*)&dataIn[0], dataIn.size()));
}
}
示例3: BSON
TEST(RepoBSONFactoryTest, MakeMetaDataNodeTest)
{
RepoBSON data = BSON("something" << "Something else" << "something2" << "somethingelse2");
std::string mimeType = "application/x-mswrite";
std::string name = "MetaTest";
MetadataNode metaNode = RepoBSONFactory::makeMetaDataNode(data, mimeType, name);
EXPECT_FALSE(metaNode.isEmpty());
EXPECT_EQ(name, metaNode.getName());
EXPECT_EQ(metaNode.getTypeAsEnum(), NodeType::METADATA);
EXPECT_EQ(mimeType, metaNode.getStringField(REPO_LABEL_MEDIA_TYPE));
EXPECT_EQ(data.toString(), metaNode.getObjectField(REPO_NODE_LABEL_METADATA).toString());
}