arabica/tests/DOM/test_DOMImplementation.hpp

75 lines
3 KiB
C++
Raw Permalink Normal View History

2002-06-21 13:16:28 +02:00
#ifndef test_DOMImplementation_H
#define test_DOMImplementation_H
2005-10-24 23:59:44 +02:00
#include "../CppUnit/framework/TestCase.h"
#include "../CppUnit/framework/TestSuite.h"
#include "../CppUnit/framework/TestCaller.h"
2007-09-05 00:55:47 +02:00
#include <DOM/Simple/DOMImplementation.hpp>
2005-10-24 23:59:44 +02:00
template<class string_type, class string_adaptor>
class DOMImplementationTest : public TestCase
{
2005-10-27 23:50:10 +02:00
typedef string_adaptor SA;
2005-10-24 23:59:44 +02:00
public:
DOMImplementationTest(std::string name) :
TestCase(name)
{
} // DOMImplementationTest
void setUp()
{
} // setUp
void testNull()
{
Arabica::DOM::DOMImplementation<string_type, string_adaptor> di;
2005-10-24 23:59:44 +02:00
assert(di == 0);
2007-01-02 12:33:29 +01:00
assert(!di);
2005-10-24 23:59:44 +02:00
Arabica::DOM::DOMImplementation<string_type, string_adaptor> di2 = Arabica::SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
2005-10-24 23:59:44 +02:00
assert(di2 != 0);
2007-01-02 12:33:29 +01:00
assert(di2);
2005-10-24 23:59:44 +02:00
assert(di != di2);
assert(di2 != di);
di = di2;
assert(di == di2);
assert(di2 == di);
} // testNull
void testFeatures()
{
Arabica::DOM::DOMImplementation<string_type, string_adaptor> di = Arabica::SimpleDOM::DOMImplementation<string_type, string_adaptor>::getDOMImplementation();
2005-10-24 23:59:44 +02:00
2005-10-27 23:50:10 +02:00
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);
2005-10-24 23:59:44 +02:00
// assert(di.hasFeature("cOrE", "1.0") == true);
// assert(di.hasFeature("CorE", "2.0") == true);
2005-10-27 23:50:10 +02:00
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);
2005-10-24 23:59:44 +02:00
2005-10-27 23:50:10 +02:00
assert(di.hasFeature(SA::construct_from_utf8("barleymow"), SA::construct_from_utf8("")) == false);
2005-10-24 23:59:44 +02:00
} // 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
2002-06-21 13:16:28 +02:00
#endif