#pragma warning(push, 0) #include #include #include #pragma warning(pop) namespace { struct SplitIntervalMapFixture { struct TestEntry : boost::equality_comparable , boost::additive { static size_t createCount; static size_t addCount; static size_t subCount; TestEntry() { ++createCount; } TestEntry& operator+=(TestEntry const& other) { ++addCount; return *this; } TestEntry& operator-=(TestEntry const& other) { ++subCount; return *this; } }; typedef boost::icl::split_interval_map TestContainer; typedef TestContainer::interval_type TestInterval; TestContainer container; TestEntry entry; }; size_t SplitIntervalMapFixture::TestEntry::createCount; size_t SplitIntervalMapFixture::TestEntry::addCount; size_t SplitIntervalMapFixture::TestEntry::subCount; bool operator==(SplitIntervalMapFixture::TestEntry const& fst, SplitIntervalMapFixture::TestEntry const& snd) { return false; } } BOOST_FIXTURE_TEST_SUITE(SplitIntervalMap_Tests, SplitIntervalMapFixture) BOOST_AUTO_TEST_CASE(add_noHint_Test) { TestEntry::createCount = 0; TestEntry::addCount = 0; TestEntry::subCount = 0; add(container, std::make_pair(TestInterval::right_open(10, 20), entry)); BOOST_CHECK_EQUAL(TestEntry::createCount, 1); // for the absorption test BOOST_CHECK_EQUAL(TestEntry::addCount, 0); BOOST_CHECK_EQUAL(TestEntry::subCount, 0); } BOOST_AUTO_TEST_CASE(add_hint_Test) { TestEntry::createCount = 0; TestEntry::addCount = 0; TestEntry::subCount = 0; container.add(container.begin(), std::make_pair(TestInterval::right_open(10, 20), entry)); BOOST_CHECK_EQUAL(TestEntry::createCount, 1); // but is 5 BOOST_CHECK_EQUAL(TestEntry::addCount, 0); // but is 1 BOOST_CHECK_EQUAL(TestEntry::subCount, 0); } BOOST_AUTO_TEST_SUITE_END()