TEST_F(ConcurrentContainersTest, concurrentSetTest) { ConcurrentSet<uint32_t> set; run_on_samples([&set](const std::vector<uint32_t>& sample) { for (size_t i = 0; i < sample.size(); ++i) { set.insert(sample[i]); EXPECT_EQ(1, set.count(sample[i])); } }); EXPECT_EQ(m_data_set.size(), set.size()); for (uint32_t x : m_data) { EXPECT_EQ(1, set.count(x)); EXPECT_NE(set.end(), set.find(x)); } run_on_subset_samples([&set](const std::vector<uint32_t>& sample) { for (size_t i = 0; i < sample.size(); ++i) { set.erase(sample[i]); } }); for (uint32_t x : m_subset_data) { EXPECT_EQ(0, set.count(x)); EXPECT_EQ(set.end(), set.find(x)); } run_on_samples([&set](const std::vector<uint32_t>& sample) { for (size_t i = 0; i < sample.size(); ++i) { set.erase(sample[i]); } }); EXPECT_EQ(0, set.size()); for (uint32_t x : m_data) { EXPECT_EQ(0, set.count(x)); EXPECT_EQ(set.end(), set.find(x)); } set.insert({1, 2, 3}); EXPECT_EQ(3, set.size()); set.clear(); EXPECT_EQ(0, set.size()); }
void RemoveUnreachablePass::write_out_removed_symbols( const std::string filepath, const ConcurrentSet<std::string>& removed_symbols) { std::fstream out(filepath, std::ios_base::app); if (!out.is_open()) { fprintf(stderr, "Unable to write the removed symbols into file %s\n", filepath.c_str()); return; } TRACE(RMU, 4, "Writing %d removed symbols to %s", removed_symbols.size(), filepath.c_str()); for (const auto& obj : removed_symbols) { out << obj << std::endl; } }