mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-29 08:36:45 +01:00
XPath and XPath_silly now use the same ValueTest
This commit is contained in:
parent
37e114a49d
commit
88ffdaa214
8 changed files with 164 additions and 315 deletions
|
@ -44,7 +44,7 @@ int main(int argc, char** argv)
|
|||
|
||||
TestRunner runner;
|
||||
|
||||
runner.addTest("ValueTest", ValueTest_suite());
|
||||
runner.addTest("ValueTest", ValueTest_suite<std::string, Arabica::default_string_adaptor<std::string> >());
|
||||
runner.addTest("ArithmeticTest", ArithmeticTest_suite());
|
||||
runner.addTest("RelationalTest", RelationalTest_suite());
|
||||
runner.addTest("LogicalTest", LogicalTest_suite());
|
||||
|
|
|
@ -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 <XPath/XPath.hpp>
|
||||
#include "value_test.hpp"
|
||||
|
||||
using namespace Arabica::XPath;
|
||||
|
||||
class ValueTest : public TestCase
|
||||
{
|
||||
private:
|
||||
DOM::Node<std::string> dummy_;
|
||||
|
||||
public:
|
||||
ValueTest(std::string name) : TestCase(name)
|
||||
{
|
||||
} // ValueTest
|
||||
|
||||
void setUp()
|
||||
{
|
||||
} // setUp
|
||||
|
||||
void test1()
|
||||
{
|
||||
XPathExpressionPtr<std::string> b(new BoolValue<std::string, Arabica::default_string_adaptor<std::string> >(true));
|
||||
assertEquals(true, b->evaluateAsBool(dummy_));
|
||||
assertEquals(1.0, b->evaluateAsNumber(dummy_), 0.0);
|
||||
assertEquals("true", b->evaluateAsString(dummy_));
|
||||
}
|
||||
|
||||
void test2()
|
||||
{
|
||||
XPathExpressionPtr<std::string> b2(new BoolValue<std::string, Arabica::default_string_adaptor<std::string> >(false));
|
||||
assertEquals(false, b2->evaluateAsBool(dummy_));
|
||||
assertEquals(0.0, b2->evaluateAsNumber(dummy_), 0.0);
|
||||
assertEquals("false", b2->evaluateAsString(dummy_));
|
||||
} // test2
|
||||
|
||||
void test3()
|
||||
{
|
||||
XPathExpressionPtr<std::string> n(new NumericValue<std::string, Arabica::default_string_adaptor<std::string> >(99.5));
|
||||
assertEquals(true, n->evaluateAsBool(dummy_));
|
||||
assertEquals(99.5, n->evaluateAsNumber(dummy_), 0.0);
|
||||
assertEquals("99.5", n->evaluateAsString(dummy_));
|
||||
}
|
||||
|
||||
void test4()
|
||||
{
|
||||
XPathExpressionPtr<std::string> n(new NumericValue<std::string, Arabica::default_string_adaptor<std::string> >(0.0));
|
||||
assertEquals(false, n->evaluateAsBool(dummy_));
|
||||
assertEquals(0, n->evaluateAsNumber(dummy_), 0);
|
||||
assertEquals("0", n->evaluateAsString(dummy_));
|
||||
}
|
||||
|
||||
void test5()
|
||||
{
|
||||
XPathExpressionPtr<std::string> s(new StringValue<std::string, Arabica::default_string_adaptor<std::string> >("hello"));
|
||||
assertEquals(true, s->evaluateAsBool(dummy_));
|
||||
assertEquals("hello", s->evaluateAsString(dummy_));
|
||||
} // test5
|
||||
|
||||
void test6()
|
||||
{
|
||||
XPathExpressionPtr<std::string> s(new StringValue<std::string, Arabica::default_string_adaptor<std::string> >(""));
|
||||
assertEquals(false, s->evaluateAsBool(dummy_));
|
||||
}
|
||||
|
||||
void test7()
|
||||
{
|
||||
XPathExpressionPtr<std::string> s(new StringValue<std::string, Arabica::default_string_adaptor<std::string> >("100"));
|
||||
assertEquals(true, s->evaluateAsBool(dummy_));
|
||||
assertEquals(100.0, s->evaluateAsNumber(dummy_), 0.0);
|
||||
assertEquals("100", s->evaluateAsString(dummy_));
|
||||
} // test7
|
||||
|
||||
void test8()
|
||||
{
|
||||
XPathExpressionPtr<std::string> s(new StringValue<std::string, Arabica::default_string_adaptor<std::string> >("0"));
|
||||
assertEquals(true, s->evaluateAsBool(dummy_));
|
||||
assertEquals(0.0, s->evaluateAsNumber(dummy_), 0.0);
|
||||
assertEquals("0", s->evaluateAsString(dummy_));
|
||||
} // test8
|
||||
|
||||
void test9()
|
||||
{
|
||||
XPathExpressionPtr<std::string> bt(new BoolValue<std::string, Arabica::default_string_adaptor<std::string> >(true));
|
||||
XPathExpressionPtr<std::string> st(new StringValue<std::string, Arabica::default_string_adaptor<std::string> >("true"));
|
||||
XPathExpressionPtr<std::string> bf(new BoolValue<std::string, Arabica::default_string_adaptor<std::string> >(false));
|
||||
XPathExpressionPtr<std::string> sf(new StringValue<std::string, Arabica::default_string_adaptor<std::string> >(""));
|
||||
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(bt->evaluate(dummy_), (st->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(st->evaluate(dummy_), (bt->evaluate(dummy_)))));
|
||||
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(sf->evaluate(dummy_), (bf->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(bf->evaluate(dummy_), (sf->evaluate(dummy_)))));
|
||||
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(bt->evaluate(dummy_), (bt->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(bf->evaluate(dummy_), (bf->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(st->evaluate(dummy_), (st->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(sf->evaluate(dummy_), (sf->evaluate(dummy_)))));
|
||||
} // test9
|
||||
|
||||
void test10()
|
||||
{
|
||||
XPathExpressionPtr<std::string> bt(new BoolValue<std::string, Arabica::default_string_adaptor<std::string> >(true));
|
||||
XPathExpressionPtr<std::string> nt(new NumericValue<std::string, Arabica::default_string_adaptor<std::string> >(1.0));
|
||||
XPathExpressionPtr<std::string> bf(new BoolValue<std::string, Arabica::default_string_adaptor<std::string> >(false));
|
||||
XPathExpressionPtr<std::string> nf(new NumericValue<std::string, Arabica::default_string_adaptor<std::string> >(0.0));
|
||||
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(bt->evaluate(dummy_), (nt->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(nt->evaluate(dummy_), (bt->evaluate(dummy_)))));
|
||||
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(bf->evaluate(dummy_), (nf->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(nf->evaluate(dummy_), (bf->evaluate(dummy_)))));
|
||||
} // test10
|
||||
|
||||
void test11()
|
||||
{
|
||||
XPathExpressionPtr<std::string> nt(new NumericValue<std::string, Arabica::default_string_adaptor<std::string> >(1.0));
|
||||
XPathValuePtr<std::string> ns = nt->evaluate(dummy_);
|
||||
|
||||
assertTrue((impl::areEqual<std::string, Arabica::default_string_adaptor<std::string> >(ns, (nt->evaluate(dummy_)))));
|
||||
} // test11
|
||||
}; // ValueTest
|
||||
|
||||
TestSuite* ValueTest_suite()
|
||||
{
|
||||
TestSuite *suiteOfTests = new TestSuite;
|
||||
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test1", &ValueTest::test1));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test2", &ValueTest::test2));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test3", &ValueTest::test3));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test4", &ValueTest::test4));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test5", &ValueTest::test5));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test6", &ValueTest::test6));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test7", &ValueTest::test7));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test8", &ValueTest::test8));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test9", &ValueTest::test9));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test10", &ValueTest::test10));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test11", &ValueTest::test11));
|
||||
|
||||
return suiteOfTests;
|
||||
} // ValueTest_suite
|
|
@ -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 <XPath/XPath.hpp>
|
||||
|
||||
template<class string_type, class string_adaptor>
|
||||
class ValueTest : public TestCase
|
||||
{
|
||||
private:
|
||||
DOM::Node<string_type> dummy_;
|
||||
typedef string_adaptor SA;
|
||||
|
||||
public:
|
||||
ValueTest(std::string name) : TestCase(name)
|
||||
{
|
||||
} // ValueTest
|
||||
|
||||
void setUp()
|
||||
{
|
||||
} // setUp
|
||||
|
||||
void test1()
|
||||
{
|
||||
using namespace Arabica::XPath;
|
||||
XPathExpressionPtr<string_type> b(new BoolValue<string_type, string_adaptor>(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<string_type> b2(new BoolValue<string_type, string_adaptor>(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<string_type> n(new NumericValue<string_type, string_adaptor>(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<string_type> n(new NumericValue<string_type, string_adaptor>(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<string_type> s(new StringValue<string_type, string_adaptor>("hello"));
|
||||
assertEquals(true, s->evaluateAsBool(dummy_));
|
||||
assertTrue(SA::construct_from_utf8("hello") == s->evaluateAsString(dummy_));
|
||||
} // test5
|
||||
|
||||
void test6()
|
||||
{
|
||||
using namespace Arabica::XPath;
|
||||
XPathExpressionPtr<string_type> s(new StringValue<string_type, string_adaptor>(""));
|
||||
assertEquals(false, s->evaluateAsBool(dummy_));
|
||||
}
|
||||
|
||||
void test7()
|
||||
{
|
||||
using namespace Arabica::XPath;
|
||||
XPathExpressionPtr<string_type> s(new StringValue<string_type, string_adaptor>("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<string_type> s(new StringValue<string_type, string_adaptor>("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<string_type> bt(new BoolValue<string_type, string_adaptor>(true));
|
||||
XPathExpressionPtr<string_type> st(new StringValue<string_type, string_adaptor>("true"));
|
||||
XPathExpressionPtr<string_type> bf(new BoolValue<string_type, string_adaptor>(false));
|
||||
XPathExpressionPtr<string_type> sf(new StringValue<string_type, string_adaptor>(""));
|
||||
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(bt->evaluate(dummy_), (st->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(st->evaluate(dummy_), (bt->evaluate(dummy_)))));
|
||||
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(sf->evaluate(dummy_), (bf->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(bf->evaluate(dummy_), (sf->evaluate(dummy_)))));
|
||||
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(bt->evaluate(dummy_), (bt->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(bf->evaluate(dummy_), (bf->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(st->evaluate(dummy_), (st->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(sf->evaluate(dummy_), (sf->evaluate(dummy_)))));
|
||||
} // test9
|
||||
|
||||
void test10()
|
||||
{
|
||||
using namespace Arabica::XPath;
|
||||
XPathExpressionPtr<string_type> bt(new BoolValue<string_type, string_adaptor>(true));
|
||||
XPathExpressionPtr<string_type> nt(new NumericValue<string_type, string_adaptor>(1.0));
|
||||
XPathExpressionPtr<string_type> bf(new BoolValue<string_type, string_adaptor>(false));
|
||||
XPathExpressionPtr<string_type> nf(new NumericValue<string_type, string_adaptor>(0.0));
|
||||
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(bt->evaluate(dummy_), (nt->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(nt->evaluate(dummy_), (bt->evaluate(dummy_)))));
|
||||
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(bf->evaluate(dummy_), (nf->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(nf->evaluate(dummy_), (bf->evaluate(dummy_)))));
|
||||
} // test10
|
||||
|
||||
void test11()
|
||||
{
|
||||
using namespace Arabica::XPath;
|
||||
XPathExpressionPtr<string_type> nt(new NumericValue<string_type, string_adaptor>(1.0));
|
||||
XPathValuePtr<string_type> ns = nt->evaluate(dummy_);
|
||||
|
||||
assertTrue((impl::areEqual<string_type, string_adaptor>(ns, (nt->evaluate(dummy_)))));
|
||||
} // test11
|
||||
}; // ValueTest
|
||||
|
||||
template<class string_type, class string_adaptor>
|
||||
TestSuite* ValueTest_suite()
|
||||
{
|
||||
TestSuite *suiteOfTests = new TestSuite;
|
||||
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest<string_type, string_adaptor> >("test1", &ValueTest<string_type, string_adaptor>::test1));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest<string_type, string_adaptor> >("test2", &ValueTest<string_type, string_adaptor>::test2));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest<string_type, string_adaptor> >("test3", &ValueTest<string_type, string_adaptor>::test3));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest<string_type, string_adaptor> >("test4", &ValueTest<string_type, string_adaptor>::test4));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest<string_type, string_adaptor> >("test5", &ValueTest<string_type, string_adaptor>::test5));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest<string_type, string_adaptor> >("test6", &ValueTest<string_type, string_adaptor>::test6));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest<string_type, string_adaptor> >("test7", &ValueTest<string_type, string_adaptor>::test7));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest<string_type, string_adaptor> >("test8", &ValueTest<string_type, string_adaptor>::test8));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest<string_type, string_adaptor> >("test9", &ValueTest<string_type, string_adaptor>::test9));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest<string_type, string_adaptor> >("test10", &ValueTest<string_type, string_adaptor>::test10));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest<string_type, string_adaptor> >("test11", &ValueTest<string_type, string_adaptor>::test11));
|
||||
|
||||
return suiteOfTests;
|
||||
} // ValueTest_suite
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -152,9 +152,6 @@
|
|||
<File
|
||||
RelativePath=".\step_test.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\value_test.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "../CppUnit/framework/TestSuite.h"
|
||||
|
||||
#include "parse_test.hpp"
|
||||
#include "value_test.hpp"
|
||||
#include "../XPath/value_test.hpp"
|
||||
#include "arithmetic_test.hpp"
|
||||
#include "relational_test.hpp"
|
||||
#include "logical_test.hpp"
|
||||
|
@ -37,6 +37,11 @@ protected:
|
|||
void printBanner();
|
||||
}; // TestRunner;
|
||||
|
||||
|
||||
#include "../silly_string/silly_string.hpp"
|
||||
|
||||
template<> class Arabica::default_string_adaptor<silly_string> : 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<silly_string, Arabica::default_string_adaptor<silly_string> >());
|
||||
runner.addTest("ArithmeticTest", ArithmeticTest_suite());
|
||||
runner.addTest("RelationalTest", RelationalTest_suite());
|
||||
runner.addTest("LogicalTest", LogicalTest_suite());
|
||||
|
|
|
@ -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 <XPath/XPath.hpp>
|
||||
#include "value_test.hpp"
|
||||
#include "../silly_string/silly_string.hpp"
|
||||
|
||||
using namespace Arabica::XPath;
|
||||
template<> class Arabica::default_string_adaptor<silly_string> : public silly_string_adaptor { };
|
||||
|
||||
class ValueTest : public TestCase
|
||||
{
|
||||
private:
|
||||
DOM::Node<silly_string> dummy_;
|
||||
typedef silly_string_adaptor SA;
|
||||
|
||||
public:
|
||||
ValueTest(std::string name) : TestCase(name)
|
||||
{
|
||||
} // ValueTest
|
||||
|
||||
void setUp()
|
||||
{
|
||||
} // setUp
|
||||
|
||||
void test1()
|
||||
{
|
||||
XPathExpressionPtr<silly_string> b(new BoolValue<silly_string, Arabica::default_string_adaptor<silly_string> >(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<silly_string> b2(new BoolValue<silly_string, Arabica::default_string_adaptor<silly_string> >(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<silly_string> n(new NumericValue<silly_string, Arabica::default_string_adaptor<silly_string> >(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<silly_string> n(new NumericValue<silly_string, Arabica::default_string_adaptor<silly_string> >(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<silly_string> s(new StringValue<silly_string, Arabica::default_string_adaptor<silly_string> >("hello"));
|
||||
assertEquals(true, s->evaluateAsBool(dummy_));
|
||||
assertTrue(SA::construct_from_utf8("hello") == s->evaluateAsString(dummy_));
|
||||
} // test5
|
||||
|
||||
void test6()
|
||||
{
|
||||
XPathExpressionPtr<silly_string> s(new StringValue<silly_string, Arabica::default_string_adaptor<silly_string> >(""));
|
||||
assertEquals(false, s->evaluateAsBool(dummy_));
|
||||
}
|
||||
|
||||
void test7()
|
||||
{
|
||||
XPathExpressionPtr<silly_string> s(new StringValue<silly_string, Arabica::default_string_adaptor<silly_string> >("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<silly_string> s(new StringValue<silly_string, Arabica::default_string_adaptor<silly_string> >("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<silly_string> bt(new BoolValue<silly_string, Arabica::default_string_adaptor<silly_string> >(true));
|
||||
XPathExpressionPtr<silly_string> st(new StringValue<silly_string, Arabica::default_string_adaptor<silly_string> >("true"));
|
||||
XPathExpressionPtr<silly_string> bf(new BoolValue<silly_string, Arabica::default_string_adaptor<silly_string> >(false));
|
||||
XPathExpressionPtr<silly_string> sf(new StringValue<silly_string, Arabica::default_string_adaptor<silly_string> >(""));
|
||||
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(bt->evaluate(dummy_), (st->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(st->evaluate(dummy_), (bt->evaluate(dummy_)))));
|
||||
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(sf->evaluate(dummy_), (bf->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(bf->evaluate(dummy_), (sf->evaluate(dummy_)))));
|
||||
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(bt->evaluate(dummy_), (bt->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(bf->evaluate(dummy_), (bf->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(st->evaluate(dummy_), (st->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(sf->evaluate(dummy_), (sf->evaluate(dummy_)))));
|
||||
} // test9
|
||||
|
||||
void test10()
|
||||
{
|
||||
XPathExpressionPtr<silly_string> bt(new BoolValue<silly_string, Arabica::default_string_adaptor<silly_string> >(true));
|
||||
XPathExpressionPtr<silly_string> nt(new NumericValue<silly_string, Arabica::default_string_adaptor<silly_string> >(1.0));
|
||||
XPathExpressionPtr<silly_string> bf(new BoolValue<silly_string, Arabica::default_string_adaptor<silly_string> >(false));
|
||||
XPathExpressionPtr<silly_string> nf(new NumericValue<silly_string, Arabica::default_string_adaptor<silly_string> >(0.0));
|
||||
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(bt->evaluate(dummy_), (nt->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(nt->evaluate(dummy_), (bt->evaluate(dummy_)))));
|
||||
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(bf->evaluate(dummy_), (nf->evaluate(dummy_)))));
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(nf->evaluate(dummy_), (bf->evaluate(dummy_)))));
|
||||
} // test10
|
||||
|
||||
void test11()
|
||||
{
|
||||
XPathExpressionPtr<silly_string> nt(new NumericValue<silly_string, Arabica::default_string_adaptor<silly_string> >(1.0));
|
||||
XPathValuePtr<silly_string> ns = nt->evaluate(dummy_);
|
||||
|
||||
assertTrue((impl::areEqual<silly_string, Arabica::default_string_adaptor<silly_string> >(ns, (nt->evaluate(dummy_)))));
|
||||
} // test11
|
||||
}; // ValueTest
|
||||
|
||||
TestSuite* ValueTest_suite()
|
||||
{
|
||||
TestSuite *suiteOfTests = new TestSuite;
|
||||
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test1", &ValueTest::test1));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test2", &ValueTest::test2));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test3", &ValueTest::test3));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test4", &ValueTest::test4));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test5", &ValueTest::test5));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test6", &ValueTest::test6));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test7", &ValueTest::test7));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test8", &ValueTest::test8));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test9", &ValueTest::test9));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test10", &ValueTest::test10));
|
||||
suiteOfTests->addTest(new TestCaller<ValueTest>("test11", &ValueTest::test11));
|
||||
|
||||
return suiteOfTests;
|
||||
} // ValueTest_suite
|
|
@ -1,7 +0,0 @@
|
|||
#ifndef XPATHIC_VALUE_TEST_H
|
||||
#define XPATHIC_VALUE_TEST_H
|
||||
|
||||
TestSuite* ValueTest_suite();
|
||||
|
||||
#endif
|
||||
|
|
@ -155,9 +155,6 @@
|
|||
<File
|
||||
RelativePath=".\step_test.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\value_test.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
|
@ -191,7 +188,7 @@
|
|||
RelativePath=".\step_test.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\value_test.hpp">
|
||||
RelativePath="..\XPath\value_test.hpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
|
Loading…
Add table
Reference in a new issue