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())); } }