/** * test the difference methods */ void ScopeSetTest::testDifference() { ScopeSet scopes1("one,two,three"); ScopeSet scopes2("two,three"); ScopeSet scopes3("one,four"); ScopeSet scopes4("four,five,six"); ScopeSet difference = scopes1.Difference(scopes2); OLA_ASSERT_EQ(1u, difference.size()); OLA_ASSERT_EQ(string("one"), difference.ToString()); difference = scopes2.Difference(scopes1); OLA_ASSERT_TRUE(difference.empty()); OLA_ASSERT_EQ(0u, difference.size()); OLA_ASSERT_EQ(string(""), difference.ToString()); // difference update ScopeSet removed = scopes4.DifferenceUpdate(scopes3); OLA_ASSERT_FALSE(removed.empty()); OLA_ASSERT_EQ(1u, removed.size()); OLA_ASSERT_EQ(string("four"), removed.ToString()); OLA_ASSERT_FALSE(scopes4.empty()); OLA_ASSERT_EQ(2u, scopes4.size()); OLA_ASSERT_EQ(string("five,six"), scopes4.ToString()); }
/** * Test that the intersection methods works */ void ScopeSetTest::testIntersection() { ScopeSet scopes1("one,two"); ScopeSet scopes2("two,three"); ScopeSet scopes3("three,four"); // test Intersects OLA_ASSERT_TRUE(scopes1.Intersects(scopes2)); OLA_ASSERT_TRUE(scopes2.Intersects(scopes3)); OLA_ASSERT_FALSE(scopes1.Intersects(scopes3)); // test Intersection ScopeSet intersection = scopes1.Intersection(scopes2); OLA_ASSERT_EQ(1u, intersection.size()); OLA_ASSERT_EQ(string("two"), intersection.ToString()); intersection = scopes2.Intersection(scopes3); OLA_ASSERT_EQ(1u, intersection.size()); OLA_ASSERT_EQ(string("three"), intersection.ToString()); intersection = scopes1.Intersection(scopes3); OLA_ASSERT_TRUE(intersection.empty()); // test IntersectionCount OLA_ASSERT_EQ(1u, scopes1.IntersectionCount(scopes2)); OLA_ASSERT_EQ(1u, scopes2.IntersectionCount(scopes3)); OLA_ASSERT_EQ(0u, scopes1.IntersectionCount(scopes3)); }