aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2005-07-18 20:19:00 +0000
committerVincent Richard <[email protected]>2005-07-18 20:19:00 +0000
commit6c324d55ec756a8032f005233cd594d371416039 (patch)
treed9b5c0bc8eb1e5c2ee77dcbd299c36ad2dc510e4
parentFixed default 'word' constructor using platform handler before being initiali... (diff)
downloadvmime-6c324d55ec756a8032f005233cd594d371416039.tar.gz
vmime-6c324d55ec756a8032f005233cd594d371416039.zip
Added simple test for STL containers.
-rw-r--r--tests/utility/smartPtrTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/utility/smartPtrTest.cpp b/tests/utility/smartPtrTest.cpp
index 9bb8a49d..0c255cdd 100644
--- a/tests/utility/smartPtrTest.cpp
+++ b/tests/utility/smartPtrTest.cpp
@@ -21,6 +21,7 @@
#include <iostream>
#include <ostream>
+#include <vector>
#include "vmime/vmime.hpp"
#include "vmime/platforms/posix/posixHandler.hpp"
@@ -173,6 +174,45 @@ namespace
assert_true("3", r4.get() == dynamic_cast <A*>(r3.get()));
}
+ void testContainer()
+ {
+ bool o1_alive;
+ vmime::ref <R> r1 = vmime::create <R>(&o1_alive);
+
+ bool o2_alive;
+ vmime::ref <R> r2 = vmime::create <R>(&o2_alive);
+
+ std::vector <vmime::ref <R> > v1;
+ v1.push_back(r1);
+ v1.push_back(r2);
+
+ assert_true("1", o1_alive);
+ assert_eq("2", 2, r1->strongCount());
+ assert_true("3", o2_alive);
+ assert_eq("4", 2, r2->strongCount());
+
+ {
+ std::vector <vmime::ref <R> > v2 = v1;
+
+ assert_true("5", o1_alive);
+ assert_eq("6", 3, r1->strongCount());
+ assert_true("7", o2_alive);
+ assert_eq("8", 3, r2->strongCount());
+
+ v2[1] = NULL;
+
+ assert_true("9", o1_alive);
+ assert_eq("10", 3, r1->strongCount());
+ assert_true("11", o2_alive);
+ assert_eq("12", 2, r2->strongCount());
+ }
+
+ assert_true("13", o1_alive);
+ assert_eq("14", 2, r1->strongCount());
+ assert_true("15", o2_alive);
+ assert_eq("16", 2, r2->strongCount());
+ }
+
public:
smartPtrTest() : suite("vmime::utility::url")
@@ -184,6 +224,7 @@ namespace
add("RefCounting", testcase(this, "TestRefCounting", &smartPtrTest::testRefCounting));
add("WeakRef", testcase(this, "TestWeakRef", &smartPtrTest::testWeakRef));
add("Cast", testcase(this, "TestCast", &smartPtrTest::testCast));
+ add("Container", testcase(this, "TestContainer", &smartPtrTest::testContainer));
suite::main().add("vmime::utility::smartPtr", this);
}