diff --git a/test/XPath/main.cpp b/test/XPath/main.cpp index 5693cfac..f6da9bd8 100644 --- a/test/XPath/main.cpp +++ b/test/XPath/main.cpp @@ -44,7 +44,7 @@ int main(int argc, char** argv) TestRunner runner; - runner.addTest("ValueTest", ValueTest_suite()); + runner.addTest("ValueTest", ValueTest_suite >()); runner.addTest("ArithmeticTest", ArithmeticTest_suite()); runner.addTest("RelationalTest", RelationalTest_suite()); runner.addTest("LogicalTest", LogicalTest_suite()); diff --git a/test/XPath/value_test.cpp b/test/XPath/value_test.cpp deleted file mode 100644 index 5370a5cd..00000000 --- a/test/XPath/value_test.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#ifdef _MSC_VER -#pragma warning(disable: 4786 4250 4503 4224 4180) -#endif -#include "../CppUnit/framework/TestCase.h" -#include "../CppUnit/framework/TestSuite.h" -#include "../CppUnit/framework/TestCaller.h" - -#include -#include "value_test.hpp" - -using namespace Arabica::XPath; - -class ValueTest : public TestCase -{ -private: - DOM::Node dummy_; - -public: - ValueTest(std::string name) : TestCase(name) - { - } // ValueTest - - void setUp() - { - } // setUp - - void test1() - { - XPathExpressionPtr b(new BoolValue >(true)); - assertEquals(true, b->evaluateAsBool(dummy_)); - assertEquals(1.0, b->evaluateAsNumber(dummy_), 0.0); - assertEquals("true", b->evaluateAsString(dummy_)); - } - - void test2() - { - XPathExpressionPtr b2(new BoolValue >(false)); - assertEquals(false, b2->evaluateAsBool(dummy_)); - assertEquals(0.0, b2->evaluateAsNumber(dummy_), 0.0); - assertEquals("false", b2->evaluateAsString(dummy_)); - } // test2 - - void test3() - { - XPathExpressionPtr n(new NumericValue >(99.5)); - assertEquals(true, n->evaluateAsBool(dummy_)); - assertEquals(99.5, n->evaluateAsNumber(dummy_), 0.0); - assertEquals("99.5", n->evaluateAsString(dummy_)); - } - - void test4() - { - XPathExpressionPtr n(new NumericValue >(0.0)); - assertEquals(false, n->evaluateAsBool(dummy_)); - assertEquals(0, n->evaluateAsNumber(dummy_), 0); - assertEquals("0", n->evaluateAsString(dummy_)); - } - - void test5() - { - XPathExpressionPtr s(new StringValue >("hello")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertEquals("hello", s->evaluateAsString(dummy_)); - } // test5 - - void test6() - { - XPathExpressionPtr s(new StringValue >("")); - assertEquals(false, s->evaluateAsBool(dummy_)); - } - - void test7() - { - XPathExpressionPtr s(new StringValue >("100")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertEquals(100.0, s->evaluateAsNumber(dummy_), 0.0); - assertEquals("100", s->evaluateAsString(dummy_)); - } // test7 - - void test8() - { - XPathExpressionPtr s(new StringValue >("0")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertEquals(0.0, s->evaluateAsNumber(dummy_), 0.0); - assertEquals("0", s->evaluateAsString(dummy_)); - } // test8 - - void test9() - { - XPathExpressionPtr bt(new BoolValue >(true)); - XPathExpressionPtr st(new StringValue >("true")); - XPathExpressionPtr bf(new BoolValue >(false)); - XPathExpressionPtr sf(new StringValue >("")); - - assertTrue((impl::areEqual >(bt->evaluate(dummy_), (st->evaluate(dummy_))))); - assertTrue((impl::areEqual >(st->evaluate(dummy_), (bt->evaluate(dummy_))))); - - assertTrue((impl::areEqual >(sf->evaluate(dummy_), (bf->evaluate(dummy_))))); - assertTrue((impl::areEqual >(bf->evaluate(dummy_), (sf->evaluate(dummy_))))); - - assertTrue((impl::areEqual >(bt->evaluate(dummy_), (bt->evaluate(dummy_))))); - assertTrue((impl::areEqual >(bf->evaluate(dummy_), (bf->evaluate(dummy_))))); - assertTrue((impl::areEqual >(st->evaluate(dummy_), (st->evaluate(dummy_))))); - assertTrue((impl::areEqual >(sf->evaluate(dummy_), (sf->evaluate(dummy_))))); - } // test9 - - void test10() - { - XPathExpressionPtr bt(new BoolValue >(true)); - XPathExpressionPtr nt(new NumericValue >(1.0)); - XPathExpressionPtr bf(new BoolValue >(false)); - XPathExpressionPtr nf(new NumericValue >(0.0)); - - assertTrue((impl::areEqual >(bt->evaluate(dummy_), (nt->evaluate(dummy_))))); - assertTrue((impl::areEqual >(nt->evaluate(dummy_), (bt->evaluate(dummy_))))); - - assertTrue((impl::areEqual >(bf->evaluate(dummy_), (nf->evaluate(dummy_))))); - assertTrue((impl::areEqual >(nf->evaluate(dummy_), (bf->evaluate(dummy_))))); - } // test10 - - void test11() - { - XPathExpressionPtr nt(new NumericValue >(1.0)); - XPathValuePtr ns = nt->evaluate(dummy_); - - assertTrue((impl::areEqual >(ns, (nt->evaluate(dummy_))))); - } // test11 -}; // ValueTest - -TestSuite* ValueTest_suite() -{ - TestSuite *suiteOfTests = new TestSuite; - - suiteOfTests->addTest(new TestCaller("test1", &ValueTest::test1)); - suiteOfTests->addTest(new TestCaller("test2", &ValueTest::test2)); - suiteOfTests->addTest(new TestCaller("test3", &ValueTest::test3)); - suiteOfTests->addTest(new TestCaller("test4", &ValueTest::test4)); - suiteOfTests->addTest(new TestCaller("test5", &ValueTest::test5)); - suiteOfTests->addTest(new TestCaller("test6", &ValueTest::test6)); - suiteOfTests->addTest(new TestCaller("test7", &ValueTest::test7)); - suiteOfTests->addTest(new TestCaller("test8", &ValueTest::test8)); - suiteOfTests->addTest(new TestCaller("test9", &ValueTest::test9)); - suiteOfTests->addTest(new TestCaller("test10", &ValueTest::test10)); - suiteOfTests->addTest(new TestCaller("test11", &ValueTest::test11)); - - return suiteOfTests; -} // ValueTest_suite diff --git a/test/XPath/value_test.hpp b/test/XPath/value_test.hpp index 1a132a82..ccb068de 100644 --- a/test/XPath/value_test.hpp +++ b/test/XPath/value_test.hpp @@ -1,7 +1,161 @@ #ifndef XPATHIC_VALUE_TEST_H #define XPATHIC_VALUE_TEST_H -TestSuite* ValueTest_suite(); +#include "../CppUnit/framework/TestCase.h" +#include "../CppUnit/framework/TestSuite.h" +#include "../CppUnit/framework/TestCaller.h" + +#include + +template +class ValueTest : public TestCase +{ +private: + DOM::Node dummy_; + typedef string_adaptor SA; + +public: + ValueTest(std::string name) : TestCase(name) + { + } // ValueTest + + void setUp() + { + } // setUp + + void test1() + { + using namespace Arabica::XPath; + XPathExpressionPtr b(new BoolValue(true)); + assertEquals(true, b->evaluateAsBool(dummy_)); + assertEquals(1.0, b->evaluateAsNumber(dummy_), 0.0); + assertTrue(SA::construct_from_utf8("true") == b->evaluateAsString(dummy_)); + } + + void test2() + { + using namespace Arabica::XPath; + XPathExpressionPtr b2(new BoolValue(false)); + assertEquals(false, b2->evaluateAsBool(dummy_)); + assertEquals(0.0, b2->evaluateAsNumber(dummy_), 0.0); + assertTrue(SA::construct_from_utf8("false") == b2->evaluateAsString(dummy_)); + } // test2 + + void test3() + { + using namespace Arabica::XPath; + XPathExpressionPtr n(new NumericValue(99.5)); + assertEquals(true, n->evaluateAsBool(dummy_)); + assertEquals(99.5, n->evaluateAsNumber(dummy_), 0.0); + assertTrue(SA::construct_from_utf8("99.5") == n->evaluateAsString(dummy_)); + } + + void test4() + { + using namespace Arabica::XPath; + XPathExpressionPtr n(new NumericValue(0.0)); + assertEquals(false, n->evaluateAsBool(dummy_)); + assertEquals(0, n->evaluateAsNumber(dummy_), 0); + assertTrue(SA::construct_from_utf8("0") == n->evaluateAsString(dummy_)); + } + + void test5() + { + using namespace Arabica::XPath; + XPathExpressionPtr s(new StringValue("hello")); + assertEquals(true, s->evaluateAsBool(dummy_)); + assertTrue(SA::construct_from_utf8("hello") == s->evaluateAsString(dummy_)); + } // test5 + + void test6() + { + using namespace Arabica::XPath; + XPathExpressionPtr s(new StringValue("")); + assertEquals(false, s->evaluateAsBool(dummy_)); + } + + void test7() + { + using namespace Arabica::XPath; + XPathExpressionPtr s(new StringValue("100")); + assertEquals(true, s->evaluateAsBool(dummy_)); + assertEquals(100.0, s->evaluateAsNumber(dummy_), 0.0); + assertTrue(SA::construct_from_utf8("100") == s->evaluateAsString(dummy_)); + } // test7 + + void test8() + { + using namespace Arabica::XPath; + XPathExpressionPtr s(new StringValue("0")); + assertEquals(true, s->evaluateAsBool(dummy_)); + assertEquals(0.0, s->evaluateAsNumber(dummy_), 0.0); + assertTrue(SA::construct_from_utf8("0") == s->evaluateAsString(dummy_)); + } // test8 + + void test9() + { + using namespace Arabica::XPath; + XPathExpressionPtr bt(new BoolValue(true)); + XPathExpressionPtr st(new StringValue("true")); + XPathExpressionPtr bf(new BoolValue(false)); + XPathExpressionPtr sf(new StringValue("")); + + assertTrue((impl::areEqual(bt->evaluate(dummy_), (st->evaluate(dummy_))))); + assertTrue((impl::areEqual(st->evaluate(dummy_), (bt->evaluate(dummy_))))); + + assertTrue((impl::areEqual(sf->evaluate(dummy_), (bf->evaluate(dummy_))))); + assertTrue((impl::areEqual(bf->evaluate(dummy_), (sf->evaluate(dummy_))))); + + assertTrue((impl::areEqual(bt->evaluate(dummy_), (bt->evaluate(dummy_))))); + assertTrue((impl::areEqual(bf->evaluate(dummy_), (bf->evaluate(dummy_))))); + assertTrue((impl::areEqual(st->evaluate(dummy_), (st->evaluate(dummy_))))); + assertTrue((impl::areEqual(sf->evaluate(dummy_), (sf->evaluate(dummy_))))); + } // test9 + + void test10() + { + using namespace Arabica::XPath; + XPathExpressionPtr bt(new BoolValue(true)); + XPathExpressionPtr nt(new NumericValue(1.0)); + XPathExpressionPtr bf(new BoolValue(false)); + XPathExpressionPtr nf(new NumericValue(0.0)); + + assertTrue((impl::areEqual(bt->evaluate(dummy_), (nt->evaluate(dummy_))))); + assertTrue((impl::areEqual(nt->evaluate(dummy_), (bt->evaluate(dummy_))))); + + assertTrue((impl::areEqual(bf->evaluate(dummy_), (nf->evaluate(dummy_))))); + assertTrue((impl::areEqual(nf->evaluate(dummy_), (bf->evaluate(dummy_))))); + } // test10 + + void test11() + { + using namespace Arabica::XPath; + XPathExpressionPtr nt(new NumericValue(1.0)); + XPathValuePtr ns = nt->evaluate(dummy_); + + assertTrue((impl::areEqual(ns, (nt->evaluate(dummy_))))); + } // test11 +}; // ValueTest + +template +TestSuite* ValueTest_suite() +{ + TestSuite *suiteOfTests = new TestSuite; + + suiteOfTests->addTest(new TestCaller >("test1", &ValueTest::test1)); + suiteOfTests->addTest(new TestCaller >("test2", &ValueTest::test2)); + suiteOfTests->addTest(new TestCaller >("test3", &ValueTest::test3)); + suiteOfTests->addTest(new TestCaller >("test4", &ValueTest::test4)); + suiteOfTests->addTest(new TestCaller >("test5", &ValueTest::test5)); + suiteOfTests->addTest(new TestCaller >("test6", &ValueTest::test6)); + suiteOfTests->addTest(new TestCaller >("test7", &ValueTest::test7)); + suiteOfTests->addTest(new TestCaller >("test8", &ValueTest::test8)); + suiteOfTests->addTest(new TestCaller >("test9", &ValueTest::test9)); + suiteOfTests->addTest(new TestCaller >("test10", &ValueTest::test10)); + suiteOfTests->addTest(new TestCaller >("test11", &ValueTest::test11)); + + return suiteOfTests; +} // ValueTest_suite #endif diff --git a/test/XPath/xpathic.vcproj b/test/XPath/xpathic.vcproj index 9f9f3778..7ef15f3d 100644 --- a/test/XPath/xpathic.vcproj +++ b/test/XPath/xpathic.vcproj @@ -152,9 +152,6 @@ - - class Arabica::default_string_adaptor : public silly_string_adaptor { }; + ///////////////////////////////////////// int main(int argc, char** argv) { @@ -44,7 +49,7 @@ int main(int argc, char** argv) TestRunner runner; - runner.addTest("ValueTest", ValueTest_suite()); + runner.addTest("ValueTest", ValueTest_suite >()); runner.addTest("ArithmeticTest", ArithmeticTest_suite()); runner.addTest("RelationalTest", RelationalTest_suite()); runner.addTest("LogicalTest", LogicalTest_suite()); diff --git a/test/XPath_silly/value_test.cpp b/test/XPath_silly/value_test.cpp deleted file mode 100644 index 34b25e45..00000000 --- a/test/XPath_silly/value_test.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#ifdef _MSC_VER -#pragma warning(disable: 4786 4250 4503 4224 4180) -#endif -#include "../CppUnit/framework/TestCase.h" -#include "../CppUnit/framework/TestSuite.h" -#include "../CppUnit/framework/TestCaller.h" - -#include -#include "value_test.hpp" -#include "../silly_string/silly_string.hpp" - -using namespace Arabica::XPath; -template<> class Arabica::default_string_adaptor : public silly_string_adaptor { }; - -class ValueTest : public TestCase -{ -private: - DOM::Node dummy_; - typedef silly_string_adaptor SA; - -public: - ValueTest(std::string name) : TestCase(name) - { - } // ValueTest - - void setUp() - { - } // setUp - - void test1() - { - XPathExpressionPtr b(new BoolValue >(true)); - assertEquals(true, b->evaluateAsBool(dummy_)); - assertEquals(1.0, b->evaluateAsNumber(dummy_), 0.0); - assertTrue(SA::construct_from_utf8("true") == b->evaluateAsString(dummy_)); - } - - void test2() - { - XPathExpressionPtr b2(new BoolValue >(false)); - assertEquals(false, b2->evaluateAsBool(dummy_)); - assertEquals(0.0, b2->evaluateAsNumber(dummy_), 0.0); - assertTrue(SA::construct_from_utf8("false") == b2->evaluateAsString(dummy_)); - } // test2 - - void test3() - { - XPathExpressionPtr n(new NumericValue >(99.5)); - assertEquals(true, n->evaluateAsBool(dummy_)); - assertEquals(99.5, n->evaluateAsNumber(dummy_), 0.0); - assertTrue(SA::construct_from_utf8("99.5") == n->evaluateAsString(dummy_)); - } - - void test4() - { - XPathExpressionPtr n(new NumericValue >(0.0)); - assertEquals(false, n->evaluateAsBool(dummy_)); - assertEquals(0, n->evaluateAsNumber(dummy_), 0); - assertTrue(SA::construct_from_utf8("0") == n->evaluateAsString(dummy_)); - } - - void test5() - { - XPathExpressionPtr s(new StringValue >("hello")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertTrue(SA::construct_from_utf8("hello") == s->evaluateAsString(dummy_)); - } // test5 - - void test6() - { - XPathExpressionPtr s(new StringValue >("")); - assertEquals(false, s->evaluateAsBool(dummy_)); - } - - void test7() - { - XPathExpressionPtr s(new StringValue >("100")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertEquals(100.0, s->evaluateAsNumber(dummy_), 0.0); - assertTrue(SA::construct_from_utf8("100") == s->evaluateAsString(dummy_)); - } // test7 - - void test8() - { - XPathExpressionPtr s(new StringValue >("0")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertEquals(0.0, s->evaluateAsNumber(dummy_), 0.0); - assertTrue(SA::construct_from_utf8("0") == s->evaluateAsString(dummy_)); - } // test8 - - void test9() - { - XPathExpressionPtr bt(new BoolValue >(true)); - XPathExpressionPtr st(new StringValue >("true")); - XPathExpressionPtr bf(new BoolValue >(false)); - XPathExpressionPtr sf(new StringValue >("")); - - assertTrue((impl::areEqual >(bt->evaluate(dummy_), (st->evaluate(dummy_))))); - assertTrue((impl::areEqual >(st->evaluate(dummy_), (bt->evaluate(dummy_))))); - - assertTrue((impl::areEqual >(sf->evaluate(dummy_), (bf->evaluate(dummy_))))); - assertTrue((impl::areEqual >(bf->evaluate(dummy_), (sf->evaluate(dummy_))))); - - assertTrue((impl::areEqual >(bt->evaluate(dummy_), (bt->evaluate(dummy_))))); - assertTrue((impl::areEqual >(bf->evaluate(dummy_), (bf->evaluate(dummy_))))); - assertTrue((impl::areEqual >(st->evaluate(dummy_), (st->evaluate(dummy_))))); - assertTrue((impl::areEqual >(sf->evaluate(dummy_), (sf->evaluate(dummy_))))); - } // test9 - - void test10() - { - XPathExpressionPtr bt(new BoolValue >(true)); - XPathExpressionPtr nt(new NumericValue >(1.0)); - XPathExpressionPtr bf(new BoolValue >(false)); - XPathExpressionPtr nf(new NumericValue >(0.0)); - - assertTrue((impl::areEqual >(bt->evaluate(dummy_), (nt->evaluate(dummy_))))); - assertTrue((impl::areEqual >(nt->evaluate(dummy_), (bt->evaluate(dummy_))))); - - assertTrue((impl::areEqual >(bf->evaluate(dummy_), (nf->evaluate(dummy_))))); - assertTrue((impl::areEqual >(nf->evaluate(dummy_), (bf->evaluate(dummy_))))); - } // test10 - - void test11() - { - XPathExpressionPtr nt(new NumericValue >(1.0)); - XPathValuePtr ns = nt->evaluate(dummy_); - - assertTrue((impl::areEqual >(ns, (nt->evaluate(dummy_))))); - } // test11 -}; // ValueTest - -TestSuite* ValueTest_suite() -{ - TestSuite *suiteOfTests = new TestSuite; - - suiteOfTests->addTest(new TestCaller("test1", &ValueTest::test1)); - suiteOfTests->addTest(new TestCaller("test2", &ValueTest::test2)); - suiteOfTests->addTest(new TestCaller("test3", &ValueTest::test3)); - suiteOfTests->addTest(new TestCaller("test4", &ValueTest::test4)); - suiteOfTests->addTest(new TestCaller("test5", &ValueTest::test5)); - suiteOfTests->addTest(new TestCaller("test6", &ValueTest::test6)); - suiteOfTests->addTest(new TestCaller("test7", &ValueTest::test7)); - suiteOfTests->addTest(new TestCaller("test8", &ValueTest::test8)); - suiteOfTests->addTest(new TestCaller("test9", &ValueTest::test9)); - suiteOfTests->addTest(new TestCaller("test10", &ValueTest::test10)); - suiteOfTests->addTest(new TestCaller("test11", &ValueTest::test11)); - - return suiteOfTests; -} // ValueTest_suite diff --git a/test/XPath_silly/value_test.hpp b/test/XPath_silly/value_test.hpp deleted file mode 100644 index 1a132a82..00000000 --- a/test/XPath_silly/value_test.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef XPATHIC_VALUE_TEST_H -#define XPATHIC_VALUE_TEST_H - -TestSuite* ValueTest_suite(); - -#endif - diff --git a/test/XPath_silly/xpathic_silly.vcproj b/test/XPath_silly/xpathic_silly.vcproj index f1d2aae9..d085f9c9 100644 --- a/test/XPath_silly/xpathic_silly.vcproj +++ b/test/XPath_silly/xpathic_silly.vcproj @@ -155,9 +155,6 @@ - - + RelativePath="..\XPath\value_test.hpp">