diff options
author | Daniel Burrows <dburrows@debian.org> | 2010-05-09 20:13:13 -0700 |
---|---|---|
committer | Daniel Burrows <dburrows@debian.org> | 2010-05-09 20:13:13 -0700 |
commit | b9bc1287d810412fef93951bf891f9ebabbcb6f0 (patch) | |
tree | 378d54a3ad463ffe0f5a88cb41b1fe3b94053897 /tests | |
parent | b8cd277d1d613c2b4aaccdd6cd5f9c6b27e944b3 (diff) | |
download | aptitude-b9bc1287d810412fef93951bf891f9ebabbcb6f0.tar.gz |
Write the first (trivial) test of the set union class.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_dynamic_set.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/test_dynamic_set.cc b/tests/test_dynamic_set.cc index cf416103..6ad3c9b5 100644 --- a/tests/test_dynamic_set.cc +++ b/tests/test_dynamic_set.cc @@ -495,3 +495,56 @@ BOOST_FIXTURE_TEST_CASE(dynamicSetRemoveTwice, set_test) FINISH_SET_TEST(); } + + + +struct set_union_test +{ + shared_ptr<writable_dynamic_set<int> > set1, set2, set3; + shared_ptr<dynamic_set_union<int> > valuesPtr; + dynamic_set_union<int> &values; + dynamic_set_signals<int> signals, expected_signals; + + std::vector<int> expected; + + typedef inserted_call<int> ins; + typedef removed_call<int> rem; + + set_union_test() + : set1(dynamic_set_impl<int>::create()), + set2(dynamic_set_impl<int>::create()), + set3(dynamic_set_impl<int>::create()), + valuesPtr(dynamic_set_union<int>::create()), + values(*valuesPtr) + { + signals.attach(values); + } + + // Adds the sets in order (set1, then set2, then set3) + void addSets() + { + values.insert_set(set1); + values.insert_set(set2); + values.insert_set(set3); + } + + std::vector<int> as_vector() const + { + std::vector<int> rval; + + for(shared_ptr<enumerator<int> > e = values.enumerate(); + e->advance(); ) + { + rval.push_back(e->get_current()); + } + + return rval; + } +}; + +BOOST_FIXTURE_TEST_CASE(dynamicSetUnionInsertEmptySets, set_union_test) +{ + addSets(); + + FINISH_SET_TEST(); +} |