summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2016-11-28 19:03:36 +0100
committerWillem Jan Palenstijn <wjp@usecode.org>2016-11-28 19:17:44 +0100
commitbba67ebac5f05aed001d8e205e0e2220004252d9 (patch)
tree8d937c0a8cb38ccbb8b4c51dfd4d58a693cd09fe /tests
parent7300a49309f13aee9d21e39bf0e2638a461b21fc (diff)
downloadastra-bba67ebac5f05aed001d8e205e0e2220004252d9.tar.gz
astra-bba67ebac5f05aed001d8e205e0e2220004252d9.tar.bz2
astra-bba67ebac5f05aed001d8e205e0e2220004252d9.tar.xz
astra-bba67ebac5f05aed001d8e205e0e2220004252d9.zip
Fix AstraObjectManager test
Diffstat (limited to 'tests')
-rw-r--r--tests/test_AstraObjectManager.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/tests/test_AstraObjectManager.cpp b/tests/test_AstraObjectManager.cpp
index da641ba..39652f1 100644
--- a/tests/test_AstraObjectManager.cpp
+++ b/tests/test_AstraObjectManager.cpp
@@ -31,19 +31,35 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#include "astra/AstraObjectManager.h"
+struct TestT {
+ TestT(int _x) : x(_x) { }
+ bool operator==(int _x) const { return x == _x; }
+
+ int x;
+ bool isInitialized() const { return true; }
+ std::string description() const { return ""; }
+};
+
namespace astra {
-DEFINE_SINGLETON(CAstraObjectManager<int>);
+
+class CTestManager : public Singleton<CTestManager>, public CAstraObjectManager<TestT>
+{
+ virtual std::string getType() const { return "test"; }
+};
+
+DEFINE_SINGLETON(CTestManager);
+
}
BOOST_AUTO_TEST_CASE( testAstraObjectManager )
{
- astra::CAstraObjectManager<int> man;
+ astra::CTestManager &man = astra::CTestManager::getSingleton();
- int i1 = man.store(new int(1));
+ int i1 = man.store(new TestT(1));
BOOST_REQUIRE(man.hasIndex(i1));
BOOST_CHECK(*(man.get(i1)) == 1);
- int i2 = man.store(new int(2));
+ int i2 = man.store(new TestT(2));
BOOST_REQUIRE(man.hasIndex(i2));
BOOST_CHECK(*(man.get(i1)) == 1);
BOOST_CHECK(*(man.get(i2)) == 2);
@@ -53,12 +69,12 @@ BOOST_AUTO_TEST_CASE( testAstraObjectManager )
BOOST_CHECK(!man.hasIndex(i1));
BOOST_REQUIRE(man.hasIndex(i2));
- int i3 = man.store(new int(3));
+ int i3 = man.store(new TestT(3));
BOOST_REQUIRE(man.hasIndex(i3));
BOOST_CHECK(*(man.get(i2)) == 2);
BOOST_CHECK(*(man.get(i3)) == 3);
- int* pi4 = new int(4);
+ TestT* pi4 = new TestT(4);
int i4 = man.store(pi4);
BOOST_REQUIRE(man.hasIndex(i4));
BOOST_CHECK(*(man.get(i2)) == 2);