mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-14 03:37:16 +01:00
4a6bfc086c
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
115 lines
2.7 KiB
C++
115 lines
2.7 KiB
C++
//
|
|
// ManifestTest.cpp
|
|
//
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#include "ManifestTest.h"
|
|
#include "CppUnit/TestCaller.h"
|
|
#include "CppUnit/TestSuite.h"
|
|
#include "Poco/Manifest.h"
|
|
#include "Poco/MetaObject.h"
|
|
#include <set>
|
|
|
|
|
|
using Poco::Manifest;
|
|
using Poco::MetaObject;
|
|
|
|
|
|
class MfTestBase
|
|
{
|
|
};
|
|
|
|
|
|
class MfTestObject: public MfTestBase
|
|
{
|
|
};
|
|
|
|
|
|
ManifestTest::ManifestTest(const std::string& name): CppUnit::TestCase(name)
|
|
{
|
|
}
|
|
|
|
|
|
ManifestTest::~ManifestTest()
|
|
{
|
|
}
|
|
|
|
|
|
void ManifestTest::testManifest()
|
|
{
|
|
Manifest<MfTestBase> manifest;
|
|
assertTrue (manifest.empty());
|
|
assertTrue (manifest.size() == 0);
|
|
assertTrue (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject1")));
|
|
assertTrue (!manifest.empty());
|
|
assertTrue (manifest.size() == 1);
|
|
assertTrue (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject2")));
|
|
MetaObject<MfTestObject, MfTestBase>* pMeta = new MetaObject<MfTestObject, MfTestBase>("MfTestObject2");
|
|
assertTrue (!manifest.insert(pMeta));
|
|
delete pMeta;
|
|
assertTrue (!manifest.empty());
|
|
assertTrue (manifest.size() == 2);
|
|
assertTrue (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject3")));
|
|
assertTrue (manifest.size() == 3);
|
|
|
|
assertTrue (manifest.find("MfTestObject1") != manifest.end());
|
|
assertTrue (manifest.find("MfTestObject2") != manifest.end());
|
|
assertTrue (manifest.find("MfTestObject3") != manifest.end());
|
|
assertTrue (manifest.find("MfTestObject4") == manifest.end());
|
|
|
|
std::set<std::string> classes;
|
|
|
|
Manifest<MfTestBase>::Iterator it = manifest.begin();
|
|
assertTrue (it != manifest.end());
|
|
classes.insert(it->name());
|
|
++it;
|
|
assertTrue (it != manifest.end());
|
|
classes.insert(it->name());
|
|
++it;
|
|
assertTrue (it != manifest.end());
|
|
classes.insert(it->name());
|
|
it++;
|
|
assertTrue (it == manifest.end());
|
|
|
|
assertTrue (classes.find("MfTestObject1") != classes.end());
|
|
assertTrue (classes.find("MfTestObject2") != classes.end());
|
|
assertTrue (classes.find("MfTestObject3") != classes.end());
|
|
|
|
manifest.clear();
|
|
assertTrue (manifest.empty());
|
|
assertTrue (manifest.size() == 0);
|
|
assertTrue (manifest.insert(new MetaObject<MfTestObject, MfTestBase>("MfTestObject4")));
|
|
assertTrue (!manifest.empty());
|
|
assertTrue (manifest.size() == 1);
|
|
it = manifest.begin();
|
|
assertTrue (it != manifest.end());
|
|
assertTrue (std::string(it->name()) == "MfTestObject4");
|
|
++it;
|
|
assertTrue (it == manifest.end());
|
|
}
|
|
|
|
|
|
void ManifestTest::setUp()
|
|
{
|
|
}
|
|
|
|
|
|
void ManifestTest::tearDown()
|
|
{
|
|
}
|
|
|
|
|
|
CppUnit::Test* ManifestTest::suite()
|
|
{
|
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ManifestTest");
|
|
|
|
CppUnit_addTest(pSuite, ManifestTest, testManifest);
|
|
|
|
return pSuite;
|
|
}
|