mirror of
https://github.com/jezhiggins/arabica
synced 2024-11-17 07:48:50 +01:00
74 lines
2.9 KiB
C++
74 lines
2.9 KiB
C++
#ifndef test_DOMImplementation_H
|
|
#define test_DOMImplementation_H
|
|
|
|
#include "../CppUnit/framework/TestCase.h"
|
|
#include "../CppUnit/framework/TestSuite.h"
|
|
#include "../CppUnit/framework/TestCaller.h"
|
|
|
|
#include <DOM/Simple/DOMImplementation.h>
|
|
|
|
template<class string_type, class string_adaptor>
|
|
class DOMImplementationTest : public TestCase
|
|
{
|
|
typedef string_adaptor SA;
|
|
public:
|
|
DOMImplementationTest(std::string name) :
|
|
TestCase(name)
|
|
{
|
|
} // DOMImplementationTest
|
|
|
|
void setUp()
|
|
{
|
|
} // setUp
|
|
|
|
void testNull()
|
|
{
|
|
DOM::DOMImplementation<string_type> di;
|
|
assert(di == 0);
|
|
assert(!di);
|
|
|
|
DOM::DOMImplementation<string_type> di2 = SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
|
|
assert(di2 != 0);
|
|
assert(di2);
|
|
|
|
assert(di != di2);
|
|
assert(di2 != di);
|
|
|
|
di = di2;
|
|
assert(di == di2);
|
|
assert(di2 == di);
|
|
} // testNull
|
|
|
|
void testFeatures()
|
|
{
|
|
DOM::DOMImplementation<string_type> di = SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
|
|
|
|
assert(di.hasFeature(SA::construct_from_utf8("Core"), SA::construct_from_utf8("")) == true);
|
|
assert(di.hasFeature(SA::construct_from_utf8("Core"), SA::construct_from_utf8("1.0")) == true);
|
|
assert(di.hasFeature(SA::construct_from_utf8("Core"), SA::construct_from_utf8("2.0")) == true);
|
|
assert(di.hasFeature(SA::construct_from_utf8("Core"), SA::construct_from_utf8("trousers")) == false);
|
|
// assert(di.hasFeature("cOrE", "1.0") == true);
|
|
// assert(di.hasFeature("CorE", "2.0") == true);
|
|
|
|
assert(di.hasFeature(SA::construct_from_utf8("XML"), SA::construct_from_utf8("")) == true);
|
|
assert(di.hasFeature(SA::construct_from_utf8("XML"), SA::construct_from_utf8("1.0")) == true);
|
|
assert(di.hasFeature(SA::construct_from_utf8("XML"), SA::construct_from_utf8("2.0")) == true);
|
|
assert(di.hasFeature(SA::construct_from_utf8("xml"), SA::construct_from_utf8("")) == true);
|
|
assert(di.hasFeature(SA::construct_from_utf8("xml"), SA::construct_from_utf8("1.0")) == true);
|
|
assert(di.hasFeature(SA::construct_from_utf8("xml"), SA::construct_from_utf8("2.0")) == true);
|
|
|
|
assert(di.hasFeature(SA::construct_from_utf8("barleymow"), SA::construct_from_utf8("")) == false);
|
|
} // testDeatures
|
|
};
|
|
|
|
template<class string_type, class string_adaptor>
|
|
TestSuite* DOMImplementationTest_suite()
|
|
{
|
|
TestSuite *suiteOfTests = new TestSuite;
|
|
suiteOfTests->addTest(new TestCaller<DOMImplementationTest<string_type, string_adaptor> >("testNill", &DOMImplementationTest<string_type, string_adaptor>::testNull));
|
|
suiteOfTests->addTest(new TestCaller<DOMImplementationTest<string_type, string_adaptor> >("testFeatures", &DOMImplementationTest<string_type, string_adaptor>::testFeatures));
|
|
return suiteOfTests;
|
|
} // DOMImplementationTest_suite
|
|
|
|
#endif
|
|
|