1 //#define WEAK_SET_DEBUG
2 #include "../src/weakset.h"
3 #include <boost/test/unit_test.hpp>
4 using boost::unit_test::test_suite
;
7 uint
weak_set_size(weak_set
<T
>& w
) {
9 for (typename weak_set
<T
>::iterator i
= w
.begin();
16 void test_insertion() {
17 boost::shared_ptr
<int> n(new int(8));
18 boost::shared_ptr
<int> m(new int(1));
23 BOOST_CHECK_EQUAL(2, weak_set_size(s
));
26 void test_garbage_collection() {
28 cout
<< "\n\ntesting garbage collection\n\n" << endl
;
29 #endif // WEAK_SET_DEBUG
33 boost::shared_ptr
<int> u(new int(37));
37 boost::shared_ptr
<int> m(new int(1));
41 boost::shared_ptr
<int> n(new int(8));
44 BOOST_CHECK_EQUAL(2, weak_set_size(s
));
49 boost::shared_ptr
<int> n(new int(42));
53 BOOST_CHECK_EQUAL(42, *s
.begin());
57 init_unit_test_suite(int, char*[]) {
58 test_suite
* test
= BOOST_TEST_SUITE( "Weak set test suite" );
60 test
->add(BOOST_TEST_CASE(&test_insertion
), 0);
61 test
->add(BOOST_TEST_CASE(&test_garbage_collection
), 0);
62 test
->add(BOOST_TEST_CASE(&test_get
), 0);