Add a PromotionManager.
[tagua/yd.git] / tests / weak_set / weakset_test.cpp
blobd4ba6b2cc8bc8ad566458a22e28bcf477b77586e
1 #include "weakset_test.h"
2 #include "weakset.h"
4 CPPUNIT_TEST_SUITE_REGISTRATION(WeaksetTest);
6 template <typename T>
7 uint weak_set_size(weak_set<T>& w) {
8 uint c = 0;
9 for (typename weak_set<T>::iterator i = w.begin();
10 i != w.end(); ++i) {
11 ++c;
13 return c;
16 void WeaksetTest::test_insertion() {
17 boost::shared_ptr<int> n(new int(8));
18 boost::shared_ptr<int> m(new int(1));
19 weak_set<int> s;
20 s.insert(n);
21 s.insert(m);
23 CPPUNIT_ASSERT_EQUAL(2U, weak_set_size(s));
26 void WeaksetTest::test_garbage_collection() {
27 weak_set<int> s;
29 boost::shared_ptr<int> u(new int(37));
30 s.insert(u);
33 boost::shared_ptr<int> m(new int(1));
34 s.insert(m);
37 boost::shared_ptr<int> n(new int(8));
38 s.insert(n);
40 CPPUNIT_ASSERT_EQUAL(2U, weak_set_size(s));
43 void WeaksetTest::test_get() {
44 weak_set<int> s;
45 boost::shared_ptr<int> n(new int(42));
47 s.insert(n);
49 CPPUNIT_ASSERT_EQUAL(42, *s.begin());
52 void WeaksetTest::test_empty() {
53 weak_set<int> s;
56 boost::shared_ptr<int> m(new int(37));
57 s.insert(m);
60 CPPUNIT_ASSERT_EQUAL(0U, weak_set_size(s));