moved here from xpath-dev-sandbox

This commit is contained in:
jez_higgins 2005-08-04 21:23:48 +00:00
parent b18f90ce9e
commit 3b2aea864c
41 changed files with 6730 additions and 0 deletions

View file

@ -0,0 +1,92 @@
#ifndef CPPUNIT_CPPUNITEXCEPTION_H
#define CPPUNIT_CPPUNITEXCEPTION_H
/*
* CppUnitException is an exception that serves
* descriptive strings through its what () method
*
*/
#include <exception>
#include <string>
#define CPPUNIT_UNKNOWNFILENAME "<unknown>"
#define CPPUNIT_UNKNOWNLINENUMBER (-1)
class CppUnitException : public std::exception
{
public:
CppUnitException (std::string message = "",
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
std::string fileName = CPPUNIT_UNKNOWNFILENAME);
CppUnitException (const CppUnitException& other);
virtual ~CppUnitException () throw();
CppUnitException& operator= (const CppUnitException& other);
const char *what() const throw ();
long lineNumber ();
std::string fileName ();
private:
std::string m_message;
long m_lineNumber;
std::string m_fileName;
};
// Construct the exception
inline CppUnitException::CppUnitException (const CppUnitException& other)
: std::exception (other)
{
m_message = other.m_message;
m_lineNumber = other.m_lineNumber;
m_fileName = other.m_fileName;
}
inline CppUnitException::CppUnitException (std::string message, long lineNumber, std::string fileName)
: m_message (message), m_lineNumber (lineNumber), m_fileName (fileName)
{}
// Destruct the exception
inline CppUnitException::~CppUnitException () throw ()
{}
// Perform an assignment
inline CppUnitException& CppUnitException::operator= (const CppUnitException& other)
{
exception::operator=(other);
if (&other != this) {
m_message = other.m_message;
m_lineNumber = other.m_lineNumber;
m_fileName = other.m_fileName;
}
return *this;
}
// Return descriptive message
inline const char *CppUnitException::what() const throw ()
{ return m_message.c_str (); }
// The line on which the error occurred
inline long CppUnitException::lineNumber ()
{ return m_lineNumber; }
// The file in which the error occurred
inline std::string CppUnitException::fileName ()
{ return m_fileName; }
#endif

View file

@ -0,0 +1,12 @@
#ifndef CPPUNIT_GUARDS_H
#define CPPUNIT_GUARDS_H
// Prevent copy construction and assignment for a class
#define REFERENCEOBJECT(className) \
private: \
className (const className& other); \
className& operator= (const className& other);
#endif

View file

@ -0,0 +1,50 @@
#ifndef CPPUNIT_TEST_H
#define CPPUNIT_TEST_H
#include <string>
class TestResult;
/*
* A Test can be run and collect its results.
* See TestResult.
*
*/
class Test
{
public:
virtual ~Test () = 0;
virtual void run (TestResult *result) = 0;
virtual int countTestCases () = 0;
virtual std::string toString () = 0;
};
inline Test::~Test ()
{}
// Runs a test and collects its result in a TestResult instance.
inline void Test::run (TestResult *result)
{}
// Counts the number of test cases that will be run by this test.
inline int Test::countTestCases ()
{ return 0; }
// Returns the name of the test instance.
inline std::string Test::toString ()
{ return ""; }
#endif

View file

@ -0,0 +1,75 @@
#ifndef CPPUNIT_TESTCALLER_H
#define CPPUNIT_TESTCALLER_H
#ifndef CPPUNIT_GUARDS_H
#include "Guards.h"
#endif
#ifndef CPPUNIT_TESTCASE_H
#include "TestCase.h"
#endif
/*
* A test caller provides access to a test case method
* on a test case class. Test callers are useful when
* you want to run an individual test or add it to a
* suite.
*
* Here is an example:
*
* class MathTest : public TestCase {
* ...
* public:
* void setUp ();
* void tearDown ();
*
* void testAdd ();
* void testSubtract ();
* };
*
* Test *MathTest::suite () {
* TestSuite *suite = new TestSuite;
*
* suite->addTest (new TestCaller<MathTest> ("testAdd", testAdd));
* return suite;
* }
*
* You can use a TestCaller to bind any test method on a TestCase
* class, as long as it returns accepts void and returns void.
*
* See TestCase
*/
template <class Fixture> class TestCaller : public TestCase
{
REFERENCEOBJECT (TestCaller)
typedef void (Fixture::*TestMethod)();
public:
TestCaller (std::string name, TestMethod test)
: TestCase (name), m_fixture (new Fixture (name)), m_test (test)
{}
protected:
void runTest ()
{ (m_fixture.get ()->*m_test)(); }
void setUp ()
{ m_fixture.get ()->setUp (); }
void tearDown ()
{ m_fixture.get ()->tearDown (); }
private:
std::auto_ptr<Fixture> m_fixture;
TestMethod m_test;
};
#endif

View file

@ -0,0 +1,129 @@
#include <exception>
#include <stdexcept>
#include <cmath>
#include "TestCase.h"
#include "TestResult.h"
#include "estring.h"
// Create a default TestResult
TestResult *TestCase::defaultResult ()
{ return new TestResult; }
// Check for a failed general assertion
void TestCase::assertImplementation (bool condition,
std::string conditionExpression,
long lineNumber,
std::string fileName)
{
if (!condition)
throw CppUnitException (conditionExpression, lineNumber, fileName);
}
// Check for a failed equality assertion
void TestCase::assertEquals (std::string expected,
std::string actual,
long lineNumber,
std::string fileName)
{
if (expected != actual)
assertImplementation (false, notEqualsMessage(expected, actual), lineNumber, fileName);
}
// Check for a failed equality assertion
void TestCase::assertEquals (long expected,
long actual,
long lineNumber,
std::string fileName)
{
if (expected != actual)
assertImplementation (false, notEqualsMessage(expected, actual), lineNumber, fileName);
}
// Check for a failed equality assertion
void TestCase::assertEquals (double expected,
double actual,
double delta,
long lineNumber,
std::string fileName)
{
if (fabs (expected - actual) > delta)
assertImplementation (false, notEqualsMessage(expected, actual), lineNumber, fileName);
}
// Run the test and catch any exceptions that are triggered by it
void TestCase::run (TestResult *result)
{
result->startTest (this);
setUp ();
try {
runTest ();
}
catch (const CppUnitException& e) {
CppUnitException *copy = new CppUnitException (e);
result->addFailure (this, copy);
}
catch (const std::exception& e) {
result->addError (this, new CppUnitException (e.what ()));
}
catch (...) {
CppUnitException *e = new CppUnitException ("unknown exception");
result->addError (this, e);
}
tearDown ();
result->endTest (this);
}
// A default run method
TestResult *TestCase::run ()
{
TestResult *result = defaultResult ();
run (result);
return result;
}
// All the work for runTest is deferred to subclasses
void TestCase::runTest ()
{
}
// Build a message about a failed equality check
std::string TestCase::notEqualsMessage (long expected, long actual)
{
return "expected: " + estring (expected) + " but was: " + estring (actual);
}
// Build a message about a failed equality check
std::string TestCase::notEqualsMessage (double expected, double actual)
{
return "expected: " + estring (expected) + " but was: " + estring (actual);
}
std::string TestCase::notEqualsMessage (std::string expected, std::string actual)
{
return "expected: " + expected + " but was: " + actual;
}

View file

@ -0,0 +1,225 @@
#ifndef CPPUNIT_TESTCASE_H
#define CPPUNIT_TESTCASE_H
#include <string>
#include <typeinfo>
#ifndef CPPUNIT_GUARDS_H
#include "Guards.h"
#endif
#ifndef CPPUNIT_TEST_H
#include "Test.h"
#endif
#ifndef CPPUNIT_CPPUNITEXCEPTION_H
#include "CppUnitException.h"
#endif
class TestResult;
/*
* A test case defines the fixture to run multiple tests. To define a test case
* 1) implement a subclass of TestCase
* 2) define instance variables that store the state of the fixture
* 3) initialize the fixture state by overriding setUp
* 4) clean-up after a test by overriding tearDown.
*
* Each test runs in its own fixture so there
* can be no side effects among test runs.
* Here is an example:
*
* class MathTest : public TestCase {
* protected: int m_value1;
* protected: int m_value2;
*
* public: MathTest (string name)
* : TestCase (name) {
* }
*
* protected: void setUp () {
* m_value1 = 2;
* m_value2 = 3;
* }
* }
*
*
* For each test implement a method which interacts
* with the fixture. Verify the expected results with assertions specified
* by calling assert on the expression you want to test:
*
* protected: void testAdd () {
* int result = value1 + value2;
* assert (result == 5);
* }
*
* Once the methods are defined you can run them. To do this, use
* a TestCaller.
*
* Test *test = new TestCaller<MathTest>("testAdd", MathTest::testAdd);
* test->run ();
*
*
* The tests to be run can be collected into a TestSuite. CppUnit provides
* different test runners which can run a test suite and collect the results.
* The test runners expect a static method suite as the entry
* point to get a test to run.
*
* public: static MathTest::suite () {
* TestSuite *suiteOfTests = new TestSuite;
* suiteOfTests->addTest(new TestCaller<MathTest>("testAdd", testAdd));
* suiteOfTests->addTest(new TestCaller<MathTest>("testDivideByZero", testDivideByZero));
* return suiteOfTests;
* }
*
* Note that the caller of suite assumes lifetime control
* for the returned suite.
*
* see TestResult, TestSuite and TestCaller
*
*/
class TestCase : public Test
{
REFERENCEOBJECT (TestCase)
public:
TestCase (std::string Name);
~TestCase ();
virtual void run (TestResult *result);
virtual TestResult *run ();
virtual int countTestCases ();
std::string name ();
std::string toString ();
virtual void setUp ();
virtual void tearDown ();
protected:
virtual void runTest ();
TestResult *defaultResult ();
void assertImplementation
(bool condition,
std::string conditionExpression = "",
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
std::string fileName = CPPUNIT_UNKNOWNFILENAME);
void assertEquals (long expected,
long actual,
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
std::string fileName = CPPUNIT_UNKNOWNFILENAME);
void assertEquals (double expected,
double actual,
double delta,
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
std::string fileName = CPPUNIT_UNKNOWNFILENAME);
void assertEquals (std::string expected,
std::string actual,
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
std::string fileName = CPPUNIT_UNKNOWNFILENAME);
std::string notEqualsMessage (long expected,
long actual);
std::string notEqualsMessage (double expected,
double actual);
std::string notEqualsMessage (std::string expected,
std::string actual);
private:
const std::string m_name;
};
// Constructs a test case
inline TestCase::TestCase (std::string name)
: m_name (name)
{}
// Destructs a test case
inline TestCase::~TestCase ()
{}
// Returns a count of all the tests executed
inline int TestCase::countTestCases ()
{ return 1; }
// Returns the name of the test case
inline std::string TestCase::name ()
{ return m_name; }
// A hook for fixture set up
inline void TestCase::setUp ()
{}
// A hook for fixture tear down
inline void TestCase::tearDown ()
{}
// Returns the name of the test case instance
inline std::string TestCase::toString ()
{ const std::type_info& thisClass = typeid (*this); return std::string (thisClass.name ()) + "." + name (); }
// A set of macros which allow us to get the line number
// and file name at the point of an error.
// Just goes to show that preprocessors do have some
// redeeming qualities.
#define CPPUNIT_SOURCEANNOTATION
#ifdef CPPUNIT_SOURCEANNOTATION
#undef assert
#define assert(condition)\
(this->assertImplementation ((condition),(#condition),\
__LINE__, __FILE__))
#define assertTrue(condition)\
(this->assertImplementation ((condition),(#condition),\
__LINE__, __FILE__))
#else
#undef assert
#define assert(condition)\
(this->assertImplementation ((condition),"",\
__LINE__, __FILE__))
#endif
// Macros for primitive value comparison
#define assertDoublesEqual(expected,actual,delta)\
(this->assertEquals ((expected),\
(actual),(delta),__LINE__,__FILE__))
#define assertLongsEqual(expected,actual)\
(this->assertEquals ((expected),\
(actual),__LINE__,__FILE__))
#define assertValuesEqual(expected,actual)\
(this->assertEquals ((expected),\
(actual),__LINE__,__FILE__))
#endif

View file

@ -0,0 +1,9 @@
#include "TestFailure.h"
#include "Test.h"
// Returns a short description of the failure.
std::string TestFailure::toString ()
{
return m_failedTest->toString () + ": " + m_thrownException->what ();
}

View file

@ -0,0 +1,72 @@
#ifndef CPPUNIT_TESTFAILURE_H
#define CPPUNIT_TESTFAILURE_H
#ifndef CPPUNIT_GUARDS_H
#include "Guards.h"
#endif
#ifndef CPPUNIT_EXCEPTION_H
#include "CppUnitException.h"
#endif
class Test;
/*
* A TestFailure collects a failed test together with
* the caught exception.
*
* TestFailure assumes lifetime control for any exception
* passed to it. The lifetime of tests is handled by
* their TestSuite (if they have been added to one) or
* whomever creates them.
*
* see TestResult
* see TestSuite
*
*/
class TestFailure
{
REFERENCEOBJECT (TestFailure)
public:
TestFailure (Test *failedTest, CppUnitException *thrownException);
~TestFailure ();
Test *failedTest ();
CppUnitException *thrownException ();
std::string toString ();
protected:
Test *m_failedTest;
CppUnitException *m_thrownException;
};
// Constructs a TestFailure with the given test and exception.
inline TestFailure::TestFailure (Test *failedTest, CppUnitException *thrownException)
: m_failedTest (failedTest), m_thrownException (thrownException)
{}
// Deletes the owned exception.
inline TestFailure::~TestFailure ()
{ delete m_thrownException; }
// Gets the failed test.
inline Test *TestFailure::failedTest ()
{ return m_failedTest; }
// Gets the thrown exception.
inline CppUnitException *TestFailure::thrownException ()
{ return m_thrownException; }
#endif

View file

@ -0,0 +1,17 @@
#include "TestResult.h"
// Destroys a test result
TestResult::~TestResult ()
{
std::vector<TestFailure *>::iterator it;
for (it = m_errors.begin (); it != m_errors.end (); ++it)
delete *it;
for (it = m_failures.begin (); it != m_failures.end (); ++it)
delete *it;
delete m_syncObject;
}

View file

@ -0,0 +1,175 @@
#ifndef CPPUNIT_TESTRESULT_H
#define CPPUNIT_TESTRESULT_H
#include <vector>
#ifndef CPPUNIT_GUARDS_H
#include "Guards.h"
#endif
#ifndef CPPUNIT_TESTFAILURE_H
#include "TestFailure.h"
#endif
class CppUnitException;
class Test;
/*
* A TestResult collects the results of executing a test case. It is an
* instance of the Collecting Parameter pattern.
*
* The test framework distinguishes between failures and errors.
* A failure is anticipated and checked for with assertions. Errors are
* unanticipated problems signified by exceptions that are not generated
* by the framework.
*
* TestResult supplies a template method 'setSynchronizationObject ()'
* so that subclasses can provide mutual exclusion in the face of multiple
* threads. This can be useful when tests execute in one thread and
* they fill a subclass of TestResult which effects change in another
* thread. To have mutual exclusion, override setSynchronizationObject ()
* and make sure that you create an instance of ExclusiveZone at the
* beginning of each method.
*
* see Test
*/
class TestResult
{
REFERENCEOBJECT (TestResult)
public:
TestResult ();
virtual ~TestResult ();
virtual void addError (Test *test, CppUnitException *e);
virtual void addFailure (Test *test, CppUnitException *e);
virtual void startTest (Test *test);
virtual void endTest (Test *test);
virtual int runTests ();
virtual int testErrors ();
virtual int testFailures ();
virtual bool wasSuccessful ();
virtual bool shouldStop ();
virtual void stop ();
virtual std::vector<TestFailure *>& errors ();
virtual std::vector<TestFailure *>& failures ();
class SynchronizationObject
{
public:
SynchronizationObject () {}
virtual ~SynchronizationObject () {}
virtual void lock () {}
virtual void unlock () {}
};
class ExclusiveZone
{
SynchronizationObject *m_syncObject;
public:
ExclusiveZone (SynchronizationObject *syncObject)
: m_syncObject (syncObject)
{ m_syncObject->lock (); }
~ExclusiveZone ()
{ m_syncObject->unlock (); }
};
protected:
virtual void setSynchronizationObject (SynchronizationObject *syncObject);
std::vector<TestFailure *> m_errors;
std::vector<TestFailure *> m_failures;
int m_runTests;
bool m_stop;
SynchronizationObject *m_syncObject;
};
// Construct a TestResult
inline TestResult::TestResult ()
: m_syncObject (new SynchronizationObject ())
{ m_runTests = 0; m_stop = false; }
// Adds an error to the list of errors. The passed in exception
// caused the error
inline void TestResult::addError (Test *test, CppUnitException *e)
{ ExclusiveZone zone (m_syncObject); m_errors.push_back (new TestFailure (test, e)); }
// Adds a failure to the list of failures. The passed in exception
// caused the failure.
inline void TestResult::addFailure (Test *test, CppUnitException *e)
{ ExclusiveZone zone (m_syncObject); m_failures.push_back (new TestFailure (test, e)); }
// Informs the result that a test will be started.
inline void TestResult::startTest (Test *test)
{ ExclusiveZone zone (m_syncObject); m_runTests++; }
// Informs the result that a test was completed.
inline void TestResult::endTest (Test *test)
{ ExclusiveZone zone (m_syncObject); }
// Gets the number of run tests.
inline int TestResult::runTests ()
{ ExclusiveZone zone (m_syncObject); return m_runTests; }
// Gets the number of detected errors.
inline int TestResult::testErrors ()
{ ExclusiveZone zone (m_syncObject); return static_cast<int>(m_errors.size()); }
// Gets the number of detected failures.
inline int TestResult::testFailures ()
{ ExclusiveZone zone (m_syncObject); return static_cast<int>(m_failures.size()); }
// Returns whether the entire test was successful or not.
inline bool TestResult::wasSuccessful ()
{ ExclusiveZone zone (m_syncObject); return m_failures.size () == 0 && m_errors.size () == 0; }
// Returns a vector of the errors.
inline std::vector<TestFailure *>& TestResult::errors ()
{ ExclusiveZone zone (m_syncObject); return m_errors; }
// Returns a vector of the failures.
inline std::vector<TestFailure *>& TestResult::failures ()
{ ExclusiveZone zone (m_syncObject); return m_failures; }
// Returns whether testing should be stopped
inline bool TestResult::shouldStop ()
{ ExclusiveZone zone (m_syncObject); return m_stop; }
// Stop testing
inline void TestResult::stop ()
{ ExclusiveZone zone (m_syncObject); m_stop = true; }
// Accept a new synchronization object for protection of this instance
// TestResult assumes ownership of the object
inline void TestResult::setSynchronizationObject (SynchronizationObject *syncObject)
{ delete m_syncObject; m_syncObject = syncObject; }
#endif

View file

@ -0,0 +1,48 @@
#include "TestSuite.h"
#include "TestResult.h"
// Deletes all tests in the suite.
void TestSuite::deleteContents ()
{
for (std::vector<Test *>::iterator it = m_tests.begin ();
it != m_tests.end ();
++it)
delete *it;
}
// Runs the tests and collects their result in a TestResult.
void TestSuite::run (TestResult *result)
{
for (std::vector<Test *>::iterator it = m_tests.begin ();
it != m_tests.end ();
++it) {
if (result->shouldStop ())
break;
Test *test = *it;
test->run (result);
}
}
// Counts the number of test cases that will be run by this test.
int TestSuite::countTestCases ()
{
int count = 0;
for (std::vector<Test *>::iterator it = m_tests.begin ();
it != m_tests.end ();
++it)
count += (*it)->countTestCases ();
return count;
}

View file

@ -0,0 +1,77 @@
#ifndef CPPUNIT_TESTSUITE_H
#define CPPUNIT_TESTSUITE_H
#include <vector>
#include <string>
#ifndef CPPUNIT_GUARDS_H
#include "Guards.h"
#endif
#ifndef CPPUNIT_TEST_H
#include "Test.h"
#endif
class TestResult;
/*
* A TestSuite is a Composite of Tests.
* It runs a collection of test cases. Here is an example.
*
* TestSuite *suite= new TestSuite();
* suite->addTest(new TestCaller<MathTest> ("testAdd", testAdd));
* suite->addTest(new TestCaller<MathTest> ("testDivideByZero", testDivideByZero));
*
* Note that TestSuites assume lifetime
* control for any tests added to them.
*
* see Test and TestCaller
*/
class TestSuite : public Test
{
REFERENCEOBJECT (TestSuite)
public:
TestSuite (std::string name = "");
~TestSuite ();
void run (TestResult *result);
int countTestCases ();
void addTest (Test *test);
std::string toString ();
virtual void deleteContents ();
private:
std::vector<Test *> m_tests;
const std::string m_name;
};
// Default constructor
inline TestSuite::TestSuite (std::string name)
: m_name (name)
{}
// Destructor
inline TestSuite::~TestSuite ()
{ deleteContents (); }
// Adds a test to the suite.
inline void TestSuite::addTest (Test *test)
{ m_tests.push_back (test); }
// Returns a string representation of the test suite.
inline std::string TestSuite::toString ()
{ return "suite " + m_name; }
#endif

View file

@ -0,0 +1,32 @@
#ifndef CPPUNIT_ESTRING_H
#define CPPUNIT_ESTRING_H
#include <stdio.h>
// Create a string from a const char pointer
inline std::string estring (const char *cstring)
{ return std::string (cstring); }
// Create a string from a string (for uniformities' sake)
inline std::string estring (std::string& expandedString)
{ return expandedString; }
// Create a string from an int
inline std::string estring (int number)
{ char buffer [50]; sprintf (buffer, "%d", number); return std::string (buffer); }
// Create a string from a long
inline std::string estring (long number)
{ char buffer [50]; sprintf (buffer, "%ld", number); return std::string (buffer); }
// Create a string from a double
inline std::string estring (double number)
{ char buffer [50]; sprintf (buffer, "%lf", number); return std::string (buffer); }
#endif

View file

@ -0,0 +1,93 @@
#ifndef CPPUNIT_ORTHODOX_H
#define CPPUNIT_ORTHODOX_H
#ifndef CPPUNIT_TESTCASE_H
#include "TestCase.h"
#endif
/*
* Orthodox performs a simple set of tests on an arbitary
* class to make sure that it supports at least the
* following operations:
*
* default construction - constructor
* equality/inequality - operator== && operator!=
* assignment - operator=
* negation - operator!
* safe passage - copy construction
*
* If operations for each of these are not declared
* the template will not instantiate. If it does
* instantiate, tests are performed to make sure
* that the operations have correct semantics.
*
* Adding an orthodox test to a suite is very
* easy:
*
* public: Test *suite () {
* TestSuite *suiteOfTests = new TestSuite;
* suiteOfTests->addTest (new ComplexNumberTest ("testAdd");
* suiteOfTests->addTest (new TestCaller<Orthodox<Complex> > ());
* return suiteOfTests;
* }
*
* Templated test cases be very useful when you are want to
* make sure that a group of classes have the same form.
*
* see TestSuite
*/
template <class ClassUnderTest> class Orthodox : public TestCase
{
public:
Orthodox () : TestCase ("Orthodox") {}
protected:
ClassUnderTest call (ClassUnderTest object);
void runTest ();
};
// Run an orthodoxy test
template <class ClassUnderTest> void Orthodox<ClassUnderTest>::runTest ()
{
// make sure we have a default constructor
ClassUnderTest a, b, c;
// make sure we have an equality operator
assert (a == b);
// check the inverse
b.operator= (a.operator! ());
assert (a != b);
// double inversion
b = !!a;
assert (a == b);
// invert again
b = !a;
// check calls
c = a;
assert (c == call (a));
c = b;
assert (c == call (b));
}
// Exercise a call
template <class ClassUnderTest> ClassUnderTest Orthodox<ClassUnderTest>::call (ClassUnderTest object)
{
return object;
}
#endif

View file

@ -0,0 +1,62 @@
#ifndef CPPUNIT_REPEATEDTEST_H
#define CPPUNIT_REPEATEDTEST_H
#ifndef CPPUNIT_GUARDS_H
#include "Guards.h"
#endif
#ifndef CPPUNIT_TESTDECORATOR_H
#include "TestDecorator.h"
#endif
class Test;
class TestResult;
/*
* A decorator that runs a test repeatedly.
* Does not assume ownership of the test it decorates
*
*/
class RepeatedTest : public TestDecorator
{
REFERENCEOBJECT (RepeatedTest)
public:
RepeatedTest (Test *test, int timesRepeat)
: TestDecorator (test), m_timesRepeat (timesRepeat) {}
int countTestCases ();
std::string toString ();
void run (TestResult *result);
private:
const int m_timesRepeat;
};
// Counts the number of test cases that will be run by this test.
inline RepeatedTest::countTestCases ()
{ return TestDecorator::countTestCases () * m_timesRepeat; }
// Returns the name of the test instance.
inline std::string RepeatedTest::toString ()
{ return TestDecorator::toString () + " (repeated)"; }
// Runs a repeated test
inline void RepeatedTest::run (TestResult *result)
{
for (int n = 0; n < m_timesRepeat; n++) {
if (result->shouldStop ())
break;
TestDecorator::run (result);
}
}
#endif

View file

@ -0,0 +1,63 @@
#ifndef CPPUNIT_TESTDECORATOR_H
#define CPPUNIT_TESTDECORATOR_H
#ifndef CPPUNIT_GUARDS_H
#include "Guards.h"
#endif
#ifndef CPPUNIT_TEST_H
#include "Test.h"
#endif
class TestResult;
/*
* A Decorator for Tests
*
* Does not assume ownership of the test it decorates
*
*/
class TestDecorator : public Test
{
REFERENCEOBJECT (TestDecorator)
public:
TestDecorator (Test *test);
~TestDecorator ();
int countTestCases ();
void run (TestResult *result);
std::string toString ();
protected:
Test *m_test;
};
inline TestDecorator::TestDecorator (Test *test)
{ m_test = test; }
inline TestDecorator::~TestDecorator ()
{}
inline TestDecorator::countTestCases ()
{ return m_test->countTestCases (); }
inline void TestDecorator::run (TestResult *result)
{ m_test->run (result); }
inline std::string TestDecorator::toString ()
{ return m_test->toString (); }
#endif

View file

@ -0,0 +1,36 @@
#ifndef CPP_UINT_TESTSETUP_H
#define CPP_UINT_TESTSETUP_H
#ifndef CPPUNIT_GUARDS_H
#include "Guards.h"
#endif
#ifndef CPPUNIT_TESTDECORATOR_H
#include "TestDecorator.h"
#endif
class Test;
class TestResult;
class TestSetup : public TestDecorator
{
REFERENCEOBJECT (TestSetup)
public:
TestSetup (Test *test) : TestDecorator (test) {}
run (TestResult *result);
protected:
void setUp () {}
void tearDown () {}
};
inline TestSetup::run (TestResult *result)
{ setUp (); TestDecorator::run (result); tearDown (); }
#endif

View file

@ -0,0 +1,146 @@
/*
* A command line based tool to run tests.
* TestRunner expects as its only argument the name of a TestCase class.
* TestRunner prints out a trace as the tests are executed followed by a
* summary at the end.
*
* You can add to the tests that the TestRunner knows about by
* making additional calls to "addTest (...)" in main.
*
* Here is the synopsis:
*
* TestRunner [-wait] ExampleTestCase
*
*/
#include <iostream>
#include <vector>
#include "TextTestResult.h"
#include "../framework/Test.h"
//#include "ExampleTestCase.h"
using namespace std;
typedef pair<string, Test *> mapping;
typedef vector<pair<string, Test *> > mappings;
class TestRunner
{
protected:
bool m_wait;
vector<pair<string,Test *> > m_mappings;
public:
TestRunner () : m_wait (false) {}
~TestRunner ();
void run (int ac, char **av);
void addTest (string name, Test *test)
{ m_mappings.push_back (mapping (name, test)); }
protected:
void run (Test *test);
void printBanner ();
};
void TestRunner::printBanner ()
{
cout << "Usage: driver [ -wait ] testName, where name is the name of a test case class" << endl;
}
void TestRunner::run (int ac, char **av)
{
string testCase;
int numberOfTests = 0;
for (int i = 1; i < ac; i++) {
if (string (av [i]) == "-wait") {
m_wait = true;
continue;
}
testCase = av [i];
if (testCase == "") {
printBanner ();
return;
}
Test *testToRun = NULL;
for (mappings::iterator it = m_mappings.begin ();
it != m_mappings.end ();
++it) {
if ((*it).first == testCase) {
testToRun = (*it).second;
run (testToRun);
}
}
numberOfTests++;
if (!testToRun) {
cout << "Test " << testCase << " not found." << endl;
return;
}
}
if (numberOfTests == 0) {
printBanner ();
return;
}
if (m_wait) {
cout << "<RETURN> to continue" << endl;
cin.get ();
}
}
TestRunner::~TestRunner ()
{
for (mappings::iterator it = m_mappings.begin ();
it != m_mappings.end ();
++it)
delete it->second;
}
void TestRunner::run (Test *test)
{
TextTestResult result;
test->run (&result);
cout << result << endl;
}
/*
int main (int ac, char **av)
{
TestRunner runner;
runner.addTest ("ExampleTestCase", ExampleTestCase::suite ());
runner.run (ac, av);
return 0;
}
*/

View file

@ -0,0 +1,110 @@
#include "TextTestResult.h"
#include "../framework/CppUnitException.h"
#include "../framework/estring.h"
using namespace std;
void TextTestResult::addError (Test *test, CppUnitException *e)
{
TestResult::addError (test, e);
cerr << "E" << endl;
}
void TextTestResult::addFailure (Test *test, CppUnitException *e)
{
TestResult::addFailure (test, e);
cerr << "F" << endl;
}
void TextTestResult::startTest (Test *test)
{
TestResult::startTest (test);
cerr << ".";
}
void TextTestResult::printErrors (ostream& stream)
{
if (testErrors () != 0) {
if (testErrors () == 1)
stream << "There was " << testErrors () << " error: " << endl;
else
stream << "There were " << testErrors () << " errors: " << endl;
int i = 1;
for (vector<TestFailure *>::iterator it = errors ().begin (); it != errors ().end (); ++it) {
TestFailure *failure = *it;
CppUnitException *e = failure->thrownException ();
stream << i
<< ") "
<< "line: " << (e ? estring (e->lineNumber ()) : "") << " "
<< (e ? e->fileName () : "") << " "
<< "\"" << failure->thrownException ()->what () << "\""
<< endl;
i++;
}
}
}
void TextTestResult::printFailures (ostream& stream)
{
if (testFailures () != 0) {
if (testFailures () == 1)
stream << "There was " << testFailures () << " failure: " << endl;
else
stream << "There were " << testFailures () << " failures: " << endl;
int i = 1;
for (vector<TestFailure *>::iterator it = failures ().begin (); it != failures ().end (); ++it) {
TestFailure *failure = *it;
CppUnitException *e = failure->thrownException ();
stream << i
<< ") "
<< "line: " << (e ? estring (e->lineNumber ()) : "") << " "
<< (e ? e->fileName () : "") << " "
<< "\"" << failure->thrownException ()->what () << "\""
<< endl;
i++;
}
}
}
void TextTestResult::print (ostream& stream)
{
printHeader (stream);
printErrors (stream);
printFailures (stream);
}
void TextTestResult::printHeader (ostream& stream)
{
if (wasSuccessful ())
cout << endl << "OK (" << runTests () << " tests)" << endl;
else
cout << endl
<< "!!!FAILURES!!!" << endl
<< "Test Results:" << endl
<< "Run: "
<< runTests ()
<< " Failures: "
<< testFailures ()
<< " Errors: "
<< testErrors ()
<< endl;
}

View file

@ -0,0 +1,30 @@
#ifndef CPPUNIT_TEXTTESTRESULT_H
#define CPPUNIT_TEXTTESTRESULT_H
#include <iostream>
#include "../framework/TestResult.h"
class TextTestResult : public TestResult
{
public:
virtual void addError (Test *test, CppUnitException *e);
virtual void addFailure (Test *test, CppUnitException *e);
virtual void startTest (Test *test);
virtual void print (std::ostream& stream);
virtual void printErrors (std::ostream& stream);
virtual void printFailures (std::ostream& stream);
virtual void printHeader (std::ostream& stream);
};
/* insertion operator for easy output */
inline std::ostream& operator<< (std::ostream& stream, TextTestResult& result)
{ result.print (stream); return stream; }
#endif

6
test/XPath/.cvsignore Normal file
View file

@ -0,0 +1,6 @@
Debug
*.ncb
*.suo
xml_grammar.hpp
Release

View file

@ -0,0 +1,188 @@
#ifdef _MSC_VER
#pragma warning(disable: 4786 4250 4503 4224)
#endif
#include "../CppUnit/framework/TestCase.h"
#include "../CppUnit/framework/TestSuite.h"
#include "../CppUnit/framework/TestCaller.h"
#include <XPath/XPath.hpp>
using namespace Arabica::XPath;
class ArithmeticTest : public TestCase
{
public:
ArithmeticTest(const std::string& name) : TestCase(name)
{
} // ArithmeticTest
void setUp()
{
} // setUp
void test1()
{
XPathExpression* p1 = new NumericValue(1);
XPathExpression* p2 = new NumericValue(2);
XPathExpressionPtr add(new PlusOperator(p1, p2));
assertEquals(1, add.use_count());
add->evaluate(dummy_);
assertEquals(3.0, add->evaluateAsNumber(dummy_), 0.0);
assertEquals(1, add.use_count());
} // test1
void test2()
{
XPathExpression* p1 = new NumericValue(1);
XPathExpression* p2 = new NumericValue(2);
XPathExpressionPtr minus(new MinusOperator(p1, p2));
assertEquals(-1.0, minus->evaluateAsNumber(dummy_), 0.0);
} // test2
void test3()
{
XPathExpression* p1 = new NumericValue(3);
XPathExpression* p2 = new NumericValue(2);
XPathExpressionPtr mult(new MultiplyOperator(p1, p2));
assertEquals(6, mult->evaluateAsNumber(dummy_), 0.0);
} // test3
void test4()
{
XPathExpression* mult = new MultiplyOperator(new NumericValue(4), new NumericValue(2));
XPathExpressionPtr minus(new MinusOperator(mult, new NumericValue(2)));
assertEquals(8, mult->evaluateAsNumber(dummy_), 0.0);
assertEquals(6, minus->evaluateAsNumber(dummy_), 0.0);
} // test4
void test5()
{
XPathExpression* p1 = new NumericValue(12);
XPathExpression* p2 = new NumericValue(2);
XPathExpressionPtr div(new DivideOperator(p1, p2));
assertEquals(6, div->evaluateAsNumber(dummy_), 0.0);
} // test5
void test6()
{
XPathExpression* p1 = new NumericValue(12);
XPathExpression* p2 = new NumericValue(2);
XPathExpressionPtr mod(new ModOperator(p1, p2));
assertEquals(0, mod->evaluateAsNumber(dummy_), 0.0);
} // test6
void test7()
{
XPathExpression* p1 = new NumericValue(11);
XPathExpression* p2 = new NumericValue(2);
XPathExpressionPtr div(new DivideOperator(p1, p2));
assertEquals(5.5, div->evaluateAsNumber(dummy_), 0.0);
} // test7
void test8()
{
XPathExpression* p1 = new NumericValue(11);
XPathExpression* p2 = new NumericValue(4);
XPathExpressionPtr mod(new ModOperator(p1, p2));
assertEquals(3, mod->evaluateAsNumber(dummy_), 0.0);
} // test8
void test9()
{
XPathExpression* p1 = new NumericValue(5);
XPathExpression* p2 = new NumericValue(2);
XPathExpressionPtr mod(new ModOperator(p1, p2));
assertEquals(1.0, mod->evaluateAsNumber(dummy_), 0.0);
} // test9
void test10()
{
XPathExpression* p1 = new NumericValue(5);
XPathExpression* p2 = new NumericValue(-2);
XPathExpressionPtr mod(new ModOperator(p1, p2));
assertEquals(1.00, mod->evaluateAsNumber(dummy_), 0.0);
} // test10
void test11()
{
XPathExpression* p1 = new NumericValue(-5);
XPathExpression* p2 = new NumericValue(2);
XPathExpressionPtr mod(new ModOperator(p1, p2));
assertEquals(-1.0, mod->evaluateAsNumber(dummy_), 0.0);
} // test11
void test12()
{
XPathExpression* p1 = new NumericValue(-5);
XPathExpression* p2 = new NumericValue(-2);
XPathExpressionPtr mod(new ModOperator(p1, p2));
assertEquals(-1.0, mod->evaluateAsNumber(dummy_), 0.0);
} // test12
void test13()
{
XPathExpression* p1 = new NumericValue(5);
XPathExpressionPtr p2(new UnaryNegative(p1));
assertEquals(-5.0, p2->evaluateAsNumber(dummy_), 0.0);
} // test13
void test14()
{
XPathExpression* p1 = new NumericValue(-5);
XPathExpressionPtr p2(new UnaryNegative(p1));
assertEquals(5.0, p2->evaluateAsNumber(dummy_), 0.0);
} // test14
private:
DOM::Node<std::string> dummy_;
}; // ArithmeticTest
TestSuite* ArithmeticTest_suite()
{
TestSuite *suiteOfTests = new TestSuite;
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test1", &ArithmeticTest::test1));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test2", &ArithmeticTest::test2));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test3", &ArithmeticTest::test3));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test4", &ArithmeticTest::test4));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test5", &ArithmeticTest::test5));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test6", &ArithmeticTest::test6));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test7", &ArithmeticTest::test7));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test8", &ArithmeticTest::test8));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test9", &ArithmeticTest::test9));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test10", &ArithmeticTest::test10));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test11", &ArithmeticTest::test11));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test12", &ArithmeticTest::test12));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test13", &ArithmeticTest::test13));
suiteOfTests->addTest(new TestCaller<ArithmeticTest>("test14", &ArithmeticTest::test14));
return suiteOfTests;
} // ArithmeticTest_suite

View file

@ -0,0 +1,7 @@
#ifndef XPATHIC_ARITHMETIC_TEST_H
#define XPATHIC_ARITHMETIC_TEST_H
TestSuite* ArithmeticTest_suite();
#endif

View file

@ -0,0 +1,947 @@
#ifdef _MSC_VER
#pragma warning(disable: 4786 4250 4503 4224)
#endif
#include "../CppUnit/framework/TestCase.h"
#include "../CppUnit/framework/TestSuite.h"
#include "../CppUnit/framework/TestCaller.h"
#include <XPath/XPath.hpp>
#include <DOM/Simple/DOMImplementation.h>
using namespace Arabica::XPath;
class AxisEnumeratorTest : public TestCase
{
DOM::DOMImplementation<std::string> factory_;
DOM::Document<std::string> document_;
DOM::Element<std::string> root_;
DOM::Element<std::string> element1_;
DOM::Element<std::string> element2_;
DOM::Element<std::string> element3_;
DOM::Attr<std::string> attr_;
DOM::Text<std::string> text_;
DOM::Comment<std::string> comment_;
DOM::ProcessingInstruction<std::string> processingInstruction_;
public:
AxisEnumeratorTest(const std::string& name) : TestCase(name)
{
} // AxisEnumeratorTest
void setUp()
{
factory_ = SimpleDOM::DOMImplementation<std::string>::getDOMImplementation();
document_ = factory_.createDocument("", "root", 0);
root_ = document_.getDocumentElement();
element1_ = document_.createElement("child1");
element2_ = document_.createElement("child2");
element3_ = document_.createElement("child3");
element1_.setAttribute("one", "1");
element2_.setAttribute("one", "1");
element2_.setAttribute("two", "1");
element2_.setAttribute("three", "1");
element2_.setAttribute("four", "1");
text_ = document_.createTextNode("data");
comment_ = document_.createComment("comment");
processingInstruction_ = document_.createProcessingInstruction("target", "data");
element2_.appendChild(text_);
element2_.appendChild(document_.createElement("spinkle"));
element2_.appendChild(comment_);
element2_.appendChild(processingInstruction_);
attr_ = element1_.getAttributeNode("one");
root_.appendChild(element1_);
root_.appendChild(element2_);
root_.appendChild(element3_);
} // setup
void childTest1()
{
DOM::DocumentFragment<std::string> node;
AxisEnumerator e(node, CHILD);
assertTrue(*e == 0);
assertTrue(e.forward());
} // test1
void childTest2()
{
DOM::Node<std::string> node;
AxisEnumerator e(node, CHILD);
assertTrue(*e == 0);
} // test2
void childTest3()
{
AxisEnumerator e(root_, CHILD);
assertTrue(element1_ == *e);
assertEquals("child1", e->getNodeName());
++e;
assertTrue(element2_ == *e);
assertEquals("child2", e->getNodeName());
++e;
assertTrue(element3_ == *e);
assertEquals("child3", e->getNodeName());
++e;
assertTrue(DOM::Node<std::string>() == *e);
assertTrue(*e == 0);
} // test3
void childTest4()
{
AxisEnumerator e(document_, CHILD);
assertTrue(root_ == *e);
++e;
assertTrue(*e == 0);
} // childTest4
void attributeTest1()
{
DOM::DocumentFragment<std::string> node;
AxisEnumerator e(node, ATTRIBUTE);
assertTrue(*e == 0);
assertTrue(e.forward());
} // attributeTest1
void attributeTest2()
{
DOM::Node<std::string> node;
AxisEnumerator e(node, ATTRIBUTE);
assertTrue(*e == 0);
} // attributeTest2
void attributeTest3()
{
AxisEnumerator e(element1_, ATTRIBUTE);
assertEquals("one", e->getNodeName());
assertEquals("1", e->getNodeValue());
++e;
assertTrue(*e == 0);
} // attributeTest3
void attributeTest4()
{
int count = 0;
AxisEnumerator e(element2_, ATTRIBUTE);
while(*e++ != 0)
++count;
assertEquals(4, count);
} // attributeTest4
void attributeTest5()
{
element2_.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:poop", "poop-uri");
int count = 0;
AxisEnumerator e(element2_, ATTRIBUTE);
while(*e++ != 0)
++count;
assertEquals(4, count);
} // attributeTest5
void attributeTest6()
{
element2_.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:poop", "poop-uri");
element2_.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:qooq", "qooq-uri");
int count = 0;
AxisEnumerator e(element2_, ATTRIBUTE);
while(*e++ != 0)
++count;
assertEquals(4, count);
} // attributeTest6
void followingSiblingTest1()
{
DOM::Node<std::string> node;
AxisEnumerator e(node, FOLLOWING_SIBLING);
assertTrue(*e == 0);
assertTrue(e.forward());
} // followingSiblingTest1
void followingSiblingTest2()
{
AxisEnumerator e(document_, FOLLOWING_SIBLING);
assertTrue(*e == 0);
} // followingSiblingTest2
void followingSiblingTest3()
{
AxisEnumerator e(element1_, FOLLOWING_SIBLING);
assertTrue(*e == element2_);
++e;
assertTrue(*e == element3_);
++e;
assertTrue(*e == 0);
} // followingSiblingTest3
void followingSiblingTest4()
{
AxisEnumerator e(element2_, FOLLOWING_SIBLING);
assertTrue(*e == element3_);
++e;
assertTrue(*e == 0);
} // followingSiblingTest4
void followingSiblingTest5()
{
AxisEnumerator e(element3_, FOLLOWING_SIBLING);
assertTrue(*e == 0);
} // followingSiblingTest5
void followingSiblingTest6()
{
AxisEnumerator e(attr_, FOLLOWING_SIBLING);
assertTrue(*e == 0);
} // followingSiblingTest6
void precedingSiblingTest1()
{
DOM::Node<std::string> node;
AxisEnumerator e(node, PRECEDING_SIBLING);
assertTrue(*e == 0);
assertTrue(e.reverse());
} // precedingSiblingTest1
void precedingSiblingTest2()
{
AxisEnumerator e(document_, PRECEDING_SIBLING);
assertTrue(*e == 0);
} // precedingSiblingTest2
void precedingSiblingTest3()
{
AxisEnumerator e(element3_, PRECEDING_SIBLING);
assertTrue(*e == element2_);
++e;
assertTrue(*e == element1_);
++e;
assertTrue(*e == 0);
} // precedingSiblingTest3
void precedingSiblingTest4()
{
AxisEnumerator e(element2_, PRECEDING_SIBLING);
assertTrue(*e == element1_);
++e;
assertTrue(*e == 0);
} // precedingSiblingTest4
void precedingSiblingTest5()
{
AxisEnumerator e(element1_, PRECEDING_SIBLING);
assertTrue(*e == 0);
} // precedingSiblingTest5
void precedingSiblingTest6()
{
AxisEnumerator e(attr_, PRECEDING_SIBLING);
assertTrue(*e == 0);
} // precedingSiblingTest6
void selfTest1()
{
AxisEnumerator e(document_, SELF);
assertTrue(document_ == *e);
++e;
assertTrue(*e == 0);
assertTrue(e.forward());
} // selfTest1
void selfTest2()
{
AxisEnumerator e(root_, SELF);
assertTrue(root_ == *e);
++e;
assertTrue(*e == 0);
} // selfTest2
void selfTest3()
{
DOM::Node<std::string> node;
AxisEnumerator e(node, SELF);
assertTrue(*e == 0);
} // selfTest3
void parentTest1()
{
AxisEnumerator e(document_, PARENT);
assertTrue(*e == 0);
assertTrue(e.reverse());
} // parentTest1
void parentTest2()
{
AxisEnumerator e(root_, PARENT);
assertTrue(*e == document_);
++e;
assertTrue(*e == 0);
} // parentTest2
void parentTest3()
{
AxisEnumerator e(element2_, PARENT);
assertTrue(*e == root_);
++e;
assertTrue(*e == 0);
} // parentTest3
void parentTest4()
{
AxisEnumerator e(attr_, PARENT);
assertTrue(*e == element1_);
++e;
assertTrue(*e == 0);
} // parentTest4
void ancestorTest1()
{
AxisEnumerator e(document_, ANCESTOR);
assertTrue(*e == 0);
assertTrue(e.reverse());
} // ancestorTest1
void ancestorTest2()
{
AxisEnumerator e(root_, ANCESTOR);
assertTrue(*e == document_);
++e;
assertTrue(*e == 0);
} // ancestorTest2
void ancestorTest3()
{
AxisEnumerator e(element2_, ANCESTOR);
assertTrue(*e == root_);
++e;
assertTrue(*e == document_);
++e;
assertTrue(*e == 0);
} // ancestorTest3
void ancestorTest4()
{
AxisEnumerator e(attr_, ANCESTOR);
assertTrue(*e == element1_);
++e;
assertTrue(*e == root_);
++e;
assertTrue(*e == document_);
++e;
assertTrue(*e == 0);
} // ancestorTest4
void ancestorOrSelfTest1()
{
AxisEnumerator e(document_, ANCESTOR_OR_SELF);
assertTrue(*e == document_);
++e;
assertTrue(*e == 0);
assertTrue(e.reverse());
} // ancestorOrSelfTest1
void ancestorOrSelfTest2()
{
AxisEnumerator e(root_, ANCESTOR_OR_SELF);
assertTrue(*e == root_);
++e;
assertTrue(*e == document_);
++e;
assertTrue(*e == 0);
} // ancestorOrSelfTest2
void ancestorOrSelfTest3()
{
AxisEnumerator e(element2_, ANCESTOR_OR_SELF);
assertTrue(*e == element2_);
++e;
assertTrue(*e == root_);
++e;
assertTrue(*e == document_);
++e;
assertTrue(*e == 0);
} // ancestorOrSelfTest3
void ancestorOrSelfTest4()
{
AxisEnumerator e(attr_, ANCESTOR_OR_SELF);
assertTrue(*e == attr_);
++e;
assertTrue(*e == element1_);
++e;
assertTrue(*e == root_);
++e;
assertTrue(*e == document_);
++e;
assertTrue(*e == 0);
} // ancestorOrSelfTest4
void descendantTest1()
{
AxisEnumerator e(root_, DESCENDANT);
assertTrue(*e == element1_);
++e;
assertTrue(*e == element2_);
++e;
assertTrue(*e == text_);
++e;
++e; // spinkle
assertTrue(*e == comment_);
++e;
assertTrue(*e == processingInstruction_);
++e;
assertTrue(*e == element3_);
++e;
assertTrue(*e == 0);
assertTrue(e.forward());
} // descendantTest1
void descendantTest2()
{
AxisEnumerator e(element1_, DESCENDANT);
assertTrue(*e == 0);
} // descendantTest2
void descendantTest3()
{
AxisEnumerator e(element2_, DESCENDANT);
assertTrue(*e == text_);
++e;
++e; // spinkle
assertTrue(*e == comment_);
++e;
assertTrue(*e == processingInstruction_);
++e;
assertTrue(*e == 0);
} // descendantTest3
void descendantTest4()
{
AxisEnumerator e(comment_, DESCENDANT);
assertTrue(*e == 0);
} // descendantTest4
void descendantTest5()
{
AxisEnumerator e(processingInstruction_, DESCENDANT);
assertTrue(*e == 0);
} // descendantTest5
void descendantTest6()
{
AxisEnumerator e(text_, DESCENDANT);
assertTrue(*e == 0);
} // descendantTest6
void descendantTest7()
{
AxisEnumerator e(attr_, DESCENDANT);
assertTrue(*e == 0);
} // descendantTest7
void descendantOrSelfTest1()
{
AxisEnumerator e(root_, DESCENDANT_OR_SELF);
assertTrue(e.forward());
assertTrue(*e == root_);
++e;
assertTrue(*e == element1_);
++e;
assertTrue(*e == element2_);
++e;
assertTrue(*e == text_);
++e;
++e; // spinkle
assertTrue(*e == comment_);
++e;
assertTrue(*e == processingInstruction_);
++e;
assertTrue(*e == element3_);
++e;
assertTrue(*e == 0);
} // descendantOrSelfTest1
void descendantOrSelfTest2()
{
AxisEnumerator e(element1_, DESCENDANT_OR_SELF);
assertTrue(*e == element1_);
++e;
assertTrue(*e == 0);
} // descendantOrSelfTest2
void descendantOrSelfTest3()
{
AxisEnumerator e(element2_, DESCENDANT_OR_SELF);
assertTrue(*e == element2_);
++e;
assertTrue(*e == text_);
++e;
++e; // spinkle
assertTrue(*e == comment_);
++e;
assertTrue(*e == processingInstruction_);
++e;
assertTrue(*e == 0);
} // descendantOrSelfTest3
void descendantOrSelfTest4()
{
AxisEnumerator e(comment_, DESCENDANT_OR_SELF);
assertTrue(*e == comment_);
++e;
assertTrue(*e == 0);
} // descendantOrSelfTest4
void descendantOrSelfTest5()
{
AxisEnumerator e(processingInstruction_, DESCENDANT_OR_SELF);
assertTrue(*e == processingInstruction_);
++e;
assertTrue(*e == 0);
} // descendantOrSelfTest5
void descendantOrSelfTest6()
{
AxisEnumerator e(text_, DESCENDANT_OR_SELF);
assertTrue(*e == text_);
++e;
assertTrue(*e == 0);
} // descendantOrSelfTest6
void descendantOrSelfTest7()
{
AxisEnumerator e(attr_, DESCENDANT_OR_SELF);
assertTrue(*e == attr_);
++e;
assertTrue(*e == 0);
} // descendantOrSelfTest7
void followingTest1()
{
AxisEnumerator e(root_, FOLLOWING);
assertTrue(*e == 0);
assertTrue(e.forward());
} // followingTest1
void followingTest2()
{
AxisEnumerator e(element1_, FOLLOWING);
assertTrue(*e == element2_);
++e;
assertTrue(*e == text_);
++e;
++e; // spinkle
assertTrue(*e == comment_);
++e;
assertTrue(*e == processingInstruction_);
++e;
assertTrue(*e == element3_);
++e;
assertTrue(*e == 0);
} // followingTest2
void followingTest3()
{
AxisEnumerator e(element2_, FOLLOWING);
assertTrue(*e == element3_);
++e;
assertTrue(*e == 0);
} // followingTest3
void followingTest4()
{
AxisEnumerator e(comment_, FOLLOWING);
assertTrue(*e == processingInstruction_);
++e;
assertTrue(*e == element3_);
++e;
assertTrue(*e == 0);
} // followingTest4
void followingTest5()
{
AxisEnumerator e(processingInstruction_, FOLLOWING);
assertTrue(*e == element3_);
++e;
assertTrue(*e == 0);
} // followingTest5
void followingTest6()
{
AxisEnumerator e(text_, FOLLOWING);
++e; // spinkle
assertTrue(*e == comment_);
++e;
assertTrue(*e == processingInstruction_);
++e;
assertTrue(*e == element3_);
++e;
assertTrue(*e == 0);
} // followingTest6
void followingTest7()
{
AxisEnumerator e(attr_, FOLLOWING);
assertTrue(*e == 0);
} // followingTest7
void precedingTest1()
{
AxisEnumerator e(root_, PRECEDING);
assertTrue(*e == 0);
} // precedingTest1
void precedingTest2()
{
AxisEnumerator e(element1_, PRECEDING);
assertTrue(*e == 0);
} // precedingTest2
void precedingTest3()
{
AxisEnumerator e(element2_, PRECEDING);
assertTrue(*e == element1_);
++e;
assertTrue(*e == 0);
} // precedingTest3
void precedingTest4()
{
AxisEnumerator e(comment_, PRECEDING);
assertTrue(e.reverse());
++e; // spinkle
assertTrue(*e == text_);
++e;
assertTrue(*e == element1_);
++e;
assertTrue(*e == 0);
} // precedingTest4();
void precedingTest5()
{
AxisEnumerator e(processingInstruction_, PRECEDING);
assertTrue(*e == comment_);
++e;
++e; // spinkle
assertTrue(*e == text_);
++e;
assertTrue(*e == element1_);
++e;
assertTrue(*e == 0);
} // precedingTest5
void precedingTest6()
{
AxisEnumerator e(text_, PRECEDING);
assertTrue(*e == element1_);
++e;
assertTrue(*e == 0);
} // precedingTest6
void precedingTest7()
{
AxisEnumerator e(element3_, PRECEDING);
assertTrue(*e == processingInstruction_);
++e;
assertTrue(*e == comment_);
++e;
++e; // spinkle;
assertTrue(*e == text_);
++e;
assertTrue(*e == element2_);
++e;
assertTrue(*e == element1_);
++e;
assertTrue(*e == 0);
} // precedingTest7
void namespaceNodeTest1()
{
DOM::Node<std::string> node(new NamespaceNodeImpl<std::string>("p", "test-uri"));
DOM::Node<std::string> node2;
node2 = node;
} // namespaceNodeTest1
void namespaceNodeTest2()
{
DOM::Node<std::string> node;
{
DOM::Node<std::string> node2(new NamespaceNodeImpl<std::string>("p", "test-uri"));
node = node2;
}
} // namespaceNodeTest2
void namespaceNodeTest3()
{
DOM::Node<std::string> node;
{
DOM::Node<std::string> node2(new NamespaceNodeImpl<std::string>("p", "test-uri"));
node = node2;
}
node = 0;
} // namespaceNodeTest3
void namespaceNodeTest4()
{
DOM::Node<std::string> node(new NamespaceNodeImpl<std::string>("p", "test-uri"));
assertValuesEqual("p", node.getLocalName());
assertValuesEqual("test-uri", node.getNodeValue());
assertValuesEqual("", node.getNamespaceURI());
assertValuesEqual("p", node.getNodeName());
} // namespaceNodeTest4
void namespaceAxisTest1()
{
AxisEnumerator e(root_, NAMESPACE);
assertTrue(*e == 0);
} // namespaceAxisTest1()
void namespaceAxisTest2()
{
root_.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:poop", "urn:test");
AxisEnumerator e(root_, NAMESPACE);
assertTrue(*e != 0);
DOM::Node<std::string> ns = *e;
assertValuesEqual("poop", ns.getLocalName());
assertValuesEqual("urn:test", ns.getNodeValue());
++e;
assertTrue(*e == 0);
} // namespaceAxisTest2
void namespaceAxisTest3()
{
root_.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:poop", "urn:test");
element2_.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:test", "urn:another-test");
AxisEnumerator e(element2_, NAMESPACE);
assertTrue(*e != 0);
++e;
assertTrue(*e != 0);
++e;
assertTrue(*e == 0);
} // namespaceAxisTest3
}; // AxisEnumeratorTest
TestSuite* AncestorTest_suite()
{
TestSuite* suiteOfTests = new TestSuite;
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("ancestorTest1", &AxisEnumeratorTest::ancestorTest1));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("ancestorTest2", &AxisEnumeratorTest::ancestorTest2));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("ancestorTest3", &AxisEnumeratorTest::ancestorTest3));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("ancestorTest4", &AxisEnumeratorTest::ancestorTest4));
return suiteOfTests;
} // AncestorTest_suite
TestSuite* AncestorOrSelfTest_suite()
{
TestSuite* suiteOfTests = new TestSuite;
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("ancestorOrSelfTest1", &AxisEnumeratorTest::ancestorOrSelfTest1));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("ancestorOrSelfTest2", &AxisEnumeratorTest::ancestorOrSelfTest2));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("ancestorOrSelfTest3", &AxisEnumeratorTest::ancestorOrSelfTest3));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("ancestorOrSelfTest4", &AxisEnumeratorTest::ancestorOrSelfTest4));
return suiteOfTests;
} // AncestorOrSelfTest_suite
TestSuite* ChildTest_suite()
{
TestSuite* suiteOfTests = new TestSuite;
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("childTest1", &AxisEnumeratorTest::childTest1));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("childTest2", &AxisEnumeratorTest::childTest2));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("childTest3", &AxisEnumeratorTest::childTest3));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("childTest4", &AxisEnumeratorTest::childTest4));
return suiteOfTests;
} // ChildTest_suite
TestSuite* AttributeTest_suite()
{
TestSuite* suiteOfTests = new TestSuite;
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("attributeTest1", &AxisEnumeratorTest::attributeTest1));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("attributeTest2", &AxisEnumeratorTest::attributeTest2));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("attributeTest3", &AxisEnumeratorTest::attributeTest3));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("attributeTest4", &AxisEnumeratorTest::attributeTest4));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("attributeTest5", &AxisEnumeratorTest::attributeTest5));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("attributeTest6", &AxisEnumeratorTest::attributeTest6));
return suiteOfTests;
} // AttributeTest_suite
TestSuite* FollowingSibling_suite()
{
TestSuite* suite = new TestSuite;
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingSiblingTest1", &AxisEnumeratorTest::followingSiblingTest1));
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingSiblingTest2", &AxisEnumeratorTest::followingSiblingTest2));
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingSiblingTest3", &AxisEnumeratorTest::followingSiblingTest3));
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingSiblingTest4", &AxisEnumeratorTest::followingSiblingTest4));
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingSiblingTest5", &AxisEnumeratorTest::followingSiblingTest5));
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingSiblingTest6", &AxisEnumeratorTest::followingSiblingTest6));
return suite;
} // FollowingSibling_suite
TestSuite* PrecedingSibling_suite()
{
TestSuite* suite = new TestSuite;
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingSiblingTest1", &AxisEnumeratorTest::precedingSiblingTest1));
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingSiblingTest2", &AxisEnumeratorTest::precedingSiblingTest2));
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingSiblingTest3", &AxisEnumeratorTest::precedingSiblingTest3));
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingSiblingTest4", &AxisEnumeratorTest::precedingSiblingTest4));
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingSiblingTest5", &AxisEnumeratorTest::precedingSiblingTest5));
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingSiblingTest6", &AxisEnumeratorTest::precedingSiblingTest6));
return suite;
} // PrecedingSibling_suite
TestSuite* SelfTest_suite()
{
TestSuite* suiteOfTests = new TestSuite;
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("selfTest1", &AxisEnumeratorTest::selfTest1));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("selfTest2", &AxisEnumeratorTest::selfTest2));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("selfTest3", &AxisEnumeratorTest::selfTest3));
return suiteOfTests;
} // SelfTest_suite
TestSuite* ParentTest_suite()
{
TestSuite* suiteOfTests = new TestSuite;
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("parentTest1", &AxisEnumeratorTest::parentTest1));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("parentTest2", &AxisEnumeratorTest::parentTest2));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("parentTest3", &AxisEnumeratorTest::parentTest3));
suiteOfTests->addTest(new TestCaller<AxisEnumeratorTest>("parentTest4", &AxisEnumeratorTest::parentTest4));
return suiteOfTests;
} // ParentTest_suite
TestSuite* DescendantTest_suite()
{
TestSuite* suite = new TestSuite;
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantTest1", &AxisEnumeratorTest::descendantTest1));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantTest2", &AxisEnumeratorTest::descendantTest2));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantTest3", &AxisEnumeratorTest::descendantTest3));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantTest4", &AxisEnumeratorTest::descendantTest4));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantTest5", &AxisEnumeratorTest::descendantTest5));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantTest6", &AxisEnumeratorTest::descendantTest6));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantTest7", &AxisEnumeratorTest::descendantTest7));
return suite;
} // DescendantTest_suite
TestSuite* DescendantOrSelfTest_suite()
{
TestSuite* suite = new TestSuite;
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantOrSelfTest1", &AxisEnumeratorTest::descendantOrSelfTest1));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantOrSelfTest2", &AxisEnumeratorTest::descendantOrSelfTest2));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantOrSelfTest3", &AxisEnumeratorTest::descendantOrSelfTest3));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantOrSelfTest4", &AxisEnumeratorTest::descendantOrSelfTest4));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantOrSelfTest5", &AxisEnumeratorTest::descendantOrSelfTest5));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantOrSelfTest6", &AxisEnumeratorTest::descendantOrSelfTest6));
suite->addTest(new TestCaller<AxisEnumeratorTest>("descendantOrSelfTest7", &AxisEnumeratorTest::descendantOrSelfTest7));
return suite;
} // DescendantOrSelfTest_suite
TestSuite* FollowingTest_suite()
{
TestSuite* suite = new TestSuite;
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingTest1", &AxisEnumeratorTest::followingTest1));
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingTest2", &AxisEnumeratorTest::followingTest2));
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingTest3", &AxisEnumeratorTest::followingTest3));
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingTest4", &AxisEnumeratorTest::followingTest4));
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingTest5", &AxisEnumeratorTest::followingTest5));
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingTest6", &AxisEnumeratorTest::followingTest6));
suite->addTest(new TestCaller<AxisEnumeratorTest>("followingTest7", &AxisEnumeratorTest::followingTest7));
return suite;
} // FollowingTest_suite
TestSuite* PrecedingTest_suite()
{
TestSuite* suite = new TestSuite;
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingTest1", &AxisEnumeratorTest::precedingTest1));
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingTest2", &AxisEnumeratorTest::precedingTest2));
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingTest3", &AxisEnumeratorTest::precedingTest3));
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingTest4", &AxisEnumeratorTest::precedingTest4));
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingTest5", &AxisEnumeratorTest::precedingTest5));
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingTest6", &AxisEnumeratorTest::precedingTest6));
suite->addTest(new TestCaller<AxisEnumeratorTest>("precedingTest7", &AxisEnumeratorTest::precedingTest7));
return suite;
} // PrecedingTest_suite
TestSuite* NamespaceNodeTest_suite()
{
TestSuite* suite = new TestSuite;
suite->addTest(new TestCaller<AxisEnumeratorTest>("namespaceNodeTest1", &AxisEnumeratorTest::namespaceNodeTest1));
suite->addTest(new TestCaller<AxisEnumeratorTest>("namespaceNodeTest2", &AxisEnumeratorTest::namespaceNodeTest2));
suite->addTest(new TestCaller<AxisEnumeratorTest>("namespaceNodeTest3", &AxisEnumeratorTest::namespaceNodeTest3));
suite->addTest(new TestCaller<AxisEnumeratorTest>("namespaceNodeTest4", &AxisEnumeratorTest::namespaceNodeTest4));
return suite;
} // NamespaceNodeTest_suite
TestSuite* NamespaceAxisTest_suite()
{
TestSuite* suite = new TestSuite;
suite->addTest(new TestCaller<AxisEnumeratorTest>("namespaceAxisTest1", &AxisEnumeratorTest::namespaceAxisTest1));
suite->addTest(new TestCaller<AxisEnumeratorTest>("namespaceAxisTest2", &AxisEnumeratorTest::namespaceAxisTest2));
suite->addTest(new TestCaller<AxisEnumeratorTest>("namespaceAxisTest3", &AxisEnumeratorTest::namespaceAxisTest3));
return suite;
} // NamespaceAxisTest_suite
TestSuite* AxisEnumeratorTest_suite()
{
TestSuite* suiteOfTests = new TestSuite;
suiteOfTests->addTest(AncestorTest_suite());
suiteOfTests->addTest(AncestorOrSelfTest_suite());
suiteOfTests->addTest(AttributeTest_suite());
suiteOfTests->addTest(ChildTest_suite());
suiteOfTests->addTest(FollowingSibling_suite());
suiteOfTests->addTest(PrecedingSibling_suite());
suiteOfTests->addTest(SelfTest_suite());
suiteOfTests->addTest(ParentTest_suite());
suiteOfTests->addTest(DescendantTest_suite());
suiteOfTests->addTest(DescendantOrSelfTest_suite());
suiteOfTests->addTest(FollowingTest_suite());
suiteOfTests->addTest(PrecedingTest_suite());
suiteOfTests->addTest(NamespaceNodeTest_suite());
suiteOfTests->addTest(NamespaceAxisTest_suite());
return suiteOfTests;
} // AxisEnumeratorTest_suite

View file

@ -0,0 +1,7 @@
#ifndef AXIS_ENUMERATOR_TEST_H
#define AXIS_ENUMERATOR_TEST_H
TestSuite* AxisEnumeratorTest_suite();
#endif

2374
test/XPath/execute_test.cpp Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
#ifndef XPATHIC_EXECUTE_TEST_HPP
#define XPATHIC_EXECUTE_TEST_HPP
TestSuite* ExecuteTest_suite();
#endif

View file

@ -0,0 +1,89 @@
#ifdef _MSC_VER
#pragma warning(disable: 4786 4250 4503 4224)
#endif
#include "../CppUnit/framework/TestCase.h"
#include "../CppUnit/framework/TestSuite.h"
#include "../CppUnit/framework/TestCaller.h"
#include <XPath/XPath.hpp>
using namespace Arabica::XPath;
class LogicalTest : public TestCase
{
public:
LogicalTest(const std::string& name) : TestCase(name)
{
} // LogicalTest
void setUp()
{
} // setUp
void test1()
{
XPathExpressionPtr orTest(new OrOperator(new BoolValue(false), new BoolValue(false)));
assertEquals(false, orTest->evaluateAsBool(dummy_));
} // test1
void test2()
{
XPathExpressionPtr orTest(new OrOperator(new BoolValue(false), new BoolValue(true)));
assertEquals(true, orTest->evaluateAsBool(dummy_));
} // test2
void test3()
{
XPathExpressionPtr orTest(new OrOperator(new BoolValue(true), new BoolValue(false)));
assertEquals(true, orTest->evaluateAsBool(dummy_));
} // test3
void test4()
{
XPathExpressionPtr orTest(new OrOperator(new BoolValue(true), new BoolValue(true)));
assertEquals(true, orTest->evaluateAsBool(dummy_));
} // test4
void test5()
{
XPathExpressionPtr andTest(new AndOperator(new BoolValue(false), new BoolValue(false)));
assertEquals(false, andTest->evaluateAsBool(dummy_));
} // test5
void test6()
{
XPathExpressionPtr andTest(new AndOperator(new BoolValue(false), new BoolValue(true)));
assertEquals(false, andTest->evaluateAsBool(dummy_));
} // test6
void test7()
{
XPathExpressionPtr andTest(new AndOperator(new BoolValue(true), new BoolValue(false)));
assertEquals(false, andTest->evaluateAsBool(dummy_));
} // test7
void test8()
{
XPathExpressionPtr andTest(new AndOperator(new BoolValue(true), new BoolValue(true)));
assertEquals(true, andTest->evaluateAsBool(dummy_));
} // test8
private:
DOM::Node<std::string> dummy_;
}; // class LogicalTest
TestSuite* LogicalTest_suite()
{
TestSuite* tests = new TestSuite;
tests->addTest(new TestCaller<LogicalTest>("test1", &LogicalTest::test1));
tests->addTest(new TestCaller<LogicalTest>("test2", &LogicalTest::test2));
tests->addTest(new TestCaller<LogicalTest>("test3", &LogicalTest::test3));
tests->addTest(new TestCaller<LogicalTest>("test4", &LogicalTest::test4));
tests->addTest(new TestCaller<LogicalTest>("test5", &LogicalTest::test5));
tests->addTest(new TestCaller<LogicalTest>("test6", &LogicalTest::test6));
tests->addTest(new TestCaller<LogicalTest>("test7", &LogicalTest::test7));
tests->addTest(new TestCaller<LogicalTest>("test8", &LogicalTest::test8));
return tests;
} // LogicalTest_suite

View file

@ -0,0 +1,6 @@
#ifndef XPATHIC_LOGICAL_TEST_H
#define XPATHIC_LOGICAL_TEST_H
TestSuite* LogicalTest_suite();
#endif

167
test/XPath/main.cpp Normal file
View file

@ -0,0 +1,167 @@
#pragma warning(disable:4224 4267)
#include <iostream>
#include "../CppUnit/textui/TextTestResult.h"
#include "../CppUnit/framework/Test.h"
#include "../CppUnit/framework/TestSuite.h"
#include "parse_test.hpp"
#include "value_test.hpp"
#include "arithmetic_test.hpp"
#include "relational_test.hpp"
#include "logical_test.hpp"
#include "axis_enumerator_test.hpp"
#include "node_test_test.hpp"
#include "step_test.hpp"
#include "execute_test.hpp"
class TestRunner
{
protected:
bool m_wait;
std::vector<std::pair<std::string,Test *> > m_mappings;
public:
TestRunner() : m_wait(false) {}
~TestRunner();
void run(int ac, char **av);
void addTest(std::string name, Test *test)
{ m_mappings.push_back(std::make_pair(name, test)); }
protected:
void run(Test *test);
void printBanner();
}; // TestRunner;
/////////////////////////////////////////
int main(int argc, char** argv)
{
std::cout << "Hello" << std::endl;
TestRunner runner;
runner.addTest("ValueTest", ValueTest_suite());
runner.addTest("ArithmeticTest", ArithmeticTest_suite());
runner.addTest("RelationalTest", RelationalTest_suite());
runner.addTest("LogicalTest", LogicalTest_suite());
runner.addTest("AxisEnumeratorTest", AxisEnumeratorTest_suite());
runner.addTest("NodeTestTest", NodeTestTest_suite());
runner.addTest("StepTest", StepTest_suite());
runner.addTest("ParseTest", ParseTest_suite());
runner.addTest("ExecuteTest", ExecuteTest_suite());
runner.run(argc, argv);
} // main
//////////////////////////////////////////
/*
* A command line based tool to run tests.
* TestRunner expects as its only argument the name of a TestCase class.
* TestRunner prints out a trace as the tests are executed followed by a
* summary at the end.
*
* You can add to the tests that the TestRunner knows about by
* making additional calls to "addTest (...)" in main.
*
* Here is the synopsis:
*
* TestRunner [-wait] ExampleTestCase
*
*/
using namespace std;
typedef pair<string, Test *> mapping;
typedef vector<pair<string, Test *> > mappings;
void TestRunner::printBanner ()
{
cout << "Usage: driver [ -wait ] testName, where name is the name of a test case class" << endl;
} // printBanner
void TestRunner::run(int ac, char **av)
{
string testCase;
int numberOfTests = 0;
for(int i = 1; i < ac; i++)
{
if(string(av[i]) == "-wait")
{
m_wait = true;
continue;
}
testCase = av[i];
if(testCase == "")
{
printBanner ();
return;
}
Test *testToRun = NULL;
for(mappings::iterator it = m_mappings.begin();
it != m_mappings.end();
++it)
{
if((*it).first == testCase)
{
cout << (*it).first << std::endl;
testToRun = (*it).second;
run(testToRun);
}
}
numberOfTests++;
if(!testToRun)
{
cout << "Test " << testCase << " not found." << endl;
return;
}
} // for ...
if(ac == 1)
{
// run everything
for(mappings::iterator it = m_mappings.begin(); it != m_mappings.end(); ++it)
{
cout << (*it).first << std::endl;
run((*it).second);
}
return;
}
if(numberOfTests == 0)
{
printBanner ();
return;
}
if(m_wait)
{
cout << "<RETURN> to continue" << endl;
cin.get ();
}
} // run
TestRunner::~TestRunner ()
{
for(mappings::iterator it = m_mappings.begin ();
it != m_mappings.end ();
++it)
delete it->second;
} // ~TestRunner
void TestRunner::run(Test *test)
{
TextTestResult result;
test->run (&result);
cout << result << endl;
} // run

View file

@ -0,0 +1,263 @@
#ifdef _MSC_VER
#pragma warning(disable: 4786 4250 4503 4224)
#endif
#include "../CppUnit/framework/TestCase.h"
#include "../CppUnit/framework/TestSuite.h"
#include "../CppUnit/framework/TestCaller.h"
#include <XPath/XPath.hpp>
#include <DOM/Simple/DOMImplementation.h>
using namespace Arabica::XPath;
class NodeTestTest : public TestCase
{
DOM::DOMImplementation<std::string> factory_;
DOM::Document<std::string> document_;
DOM::Element<std::string> root_;
DOM::Element<std::string> element1_;
DOM::Element<std::string> element2_;
DOM::Element<std::string> element3_;
DOM::Attr<std::string> attr_;
DOM::Text<std::string> text_;
DOM::Comment<std::string> comment_;
DOM::ProcessingInstruction<std::string> processingInstruction_;
public:
NodeTestTest(const std::string& name) : TestCase(name)
{
} // NodeTestTest
void setUp()
{
factory_ = SimpleDOM::DOMImplementation<std::string>::getDOMImplementation();
document_ = factory_.createDocument("", "root", 0);
root_ = document_.getDocumentElement();
element1_ = document_.createElement("child1");
element2_ = document_.createElement("child2");
element3_ = document_.createElement("child3");
element1_.setAttribute("one", "1");
element2_.setAttribute("one", "1");
element2_.setAttribute("two", "1");
element2_.setAttribute("three", "1");
element2_.setAttribute("four", "1");
text_ = document_.createTextNode("data");
comment_ = document_.createComment("comment");
processingInstruction_ = document_.createProcessingInstruction("target", "data");
element2_.appendChild(text_);
element2_.appendChild(document_.createElement("spinkle"));
element2_.appendChild(comment_);
element2_.appendChild(processingInstruction_);
attr_ = element1_.getAttributeNode("one");
root_.appendChild(element1_);
root_.appendChild(element2_);
root_.appendChild(element3_);
} // setUp
void test1()
{
AnyNodeTest test;
assertTrue(test(element1_));
assertTrue(test(element2_));
assertTrue(test(root_));
assertTrue(test(attr_));
assertTrue(test(document_));
assertTrue(test(text_));
assertTrue(test(comment_));
assertTrue(test(processingInstruction_));
} // test1
void test2()
{
NameNodeTest test("child1");
assertTrue(test(element1_));
assertTrue(!test(element2_));
assertTrue(!test(root_));
assertTrue(!test(attr_));
assertTrue(!test(document_));
assertTrue(!test(text_));
assertTrue(!test(comment_));
assertTrue(!test(processingInstruction_));
} // test2
void test3()
{
NameNodeTest test("one");
assertTrue(!test(element1_));
assertTrue(!test(element2_));
assertTrue(!test(root_));
assertTrue(test(attr_));
assertTrue(!test(document_));
assertTrue(!test(text_));
assertTrue(!test(comment_));
assertTrue(!test(processingInstruction_));
} // test3
void test4()
{
TextNodeTest test;
assertTrue(!test(element1_));
assertTrue(!test(root_));
assertTrue(!test(attr_));
assertTrue(!test(document_));
assertTrue(test(text_));
assertTrue(!test(comment_));
assertTrue(!test(processingInstruction_));
} // test4
void test5()
{
CommentNodeTest test;
assertTrue(!test(element1_));
assertTrue(!test(root_));
assertTrue(!test(attr_));
assertTrue(!test(document_));
assertTrue(!test(text_));
assertTrue(test(comment_));
assertTrue(!test(processingInstruction_));
} // test5
void test6()
{
ProcessingInstructionNodeTest test;
assertTrue(!test(element1_));
assertTrue(!test(root_));
assertTrue(!test(attr_));
assertTrue(!test(document_));
assertTrue(!test(text_));
assertTrue(!test(comment_));
assertTrue(test(processingInstruction_));
} // test6
void test7()
{
ProcessingInstructionNodeTest test("fruity");
assertTrue(!test(element1_));
assertTrue(!test(root_));
assertTrue(!test(attr_));
assertTrue(!test(document_));
assertTrue(!test(text_));
assertTrue(!test(comment_));
assertTrue(!test(processingInstruction_));
} // test7
void test8()
{
ProcessingInstructionNodeTest test("target");
assertTrue(!test(element1_));
assertTrue(!test(root_));
assertTrue(!test(attr_));
assertTrue(!test(document_));
assertTrue(!test(text_));
assertTrue(!test(comment_));
assertTrue(test(processingInstruction_));
} // test8
void test9()
{
StarNodeTest test;
AxisEnumerator e(element2_, CHILD);
assertTrue(!test(*e));
++e;
assertTrue(test(*e));
++e;
assertTrue(!test(*e));
++e;
assertTrue(!test(*e));
} // test9
void test10()
{
QNameNodeTest test("http://example.com/test", "one");
assertTrue(!test(element1_));
assertTrue(!test(element2_));
assertTrue(!test(root_));
assertTrue(!test(attr_));
assertTrue(!test(document_));
assertTrue(!test(text_));
assertTrue(!test(comment_));
assertTrue(!test(processingInstruction_));
} // test10
void test11()
{
QNameNodeTest test("http://example.com/test", "one");
DOM::Element<std::string> e1_ = document_.createElementNS("http://example.com/test", "ns:one");
DOM::Element<std::string> e2_ = document_.createElementNS("http://example.com/test", "ttt:one");
DOM::Element<std::string> e3_ = document_.createElementNS("http://example.com/test", "ns:two");
DOM::Element<std::string> e4_ = document_.createElementNS("http://example.com/test", "ttt:two");
DOM::Element<std::string> e5_ = document_.createElementNS("http://example.com/ssss", "ns:one");
DOM::Element<std::string> e6_ = document_.createElementNS("http://example.com/eeee", "ttt:one");
assertTrue(test(e1_));
assertTrue(test(e2_));
assertTrue(!test(e3_));
assertTrue(!test(e4_));
assertTrue(!test(e5_));
assertTrue(!test(e6_));
} // test11
void test12()
{
QStarNodeTest test("http://example.com/test");
DOM::Element<std::string> e1_ = document_.createElementNS("http://example.com/test", "ns:one");
DOM::Element<std::string> e2_ = document_.createElementNS("http://example.com/test", "ttt:one");
DOM::Element<std::string> e3_ = document_.createElementNS("http://example.com/test", "ns:two");
DOM::Element<std::string> e4_ = document_.createElementNS("http://example.com/test", "ttt:two");
DOM::Element<std::string> e5_ = document_.createElementNS("http://example.com/ssss", "ns:one");
DOM::Element<std::string> e6_ = document_.createElementNS("http://example.com/eeee", "ttt:one");
assertTrue(test(e1_));
assertTrue(test(e2_));
assertTrue(test(e3_));
assertTrue(test(e4_));
assertTrue(!test(e5_));
assertTrue(!test(e6_));
} // test12
}; // class NodeTestTest
TestSuite* NodeTestTest_suite()
{
TestSuite* suiteOfTests = new TestSuite;
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test1", &NodeTestTest::test1));
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test2", &NodeTestTest::test2));
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test3", &NodeTestTest::test3));
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test4", &NodeTestTest::test4));
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test5", &NodeTestTest::test5));
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test6", &NodeTestTest::test6));
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test7", &NodeTestTest::test7));
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test8", &NodeTestTest::test8));
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test9", &NodeTestTest::test9));
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test10", &NodeTestTest::test10));
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test11", &NodeTestTest::test11));
suiteOfTests->addTest(new TestCaller<NodeTestTest>("test12", &NodeTestTest::test12));
return suiteOfTests;
} // NodeTestTest_suite

View file

@ -0,0 +1,6 @@
#ifndef NODE_TEST_TEST_H
#define NODE_TEST_TEST_H
TestSuite* NodeTestTest_suite();
#endif

394
test/XPath/parse_test.cpp Normal file
View file

@ -0,0 +1,394 @@
#ifdef _MSC_VER
#pragma warning(disable: 4786 4250 4503 4224)
#endif
#include "../CppUnit/framework/TestCase.h"
#include "../CppUnit/framework/TestSuite.h"
#include "../CppUnit/framework/TestCaller.h"
#include <XPath/XPath.hpp>
#include <iostream>
class ParseTest : public TestCase
{
Arabica::XPath::XPath parser;
public:
ParseTest(std::string name) : TestCase(name)
{
} // ParseTest
void setUp()
{
} // setUp
void test1()
{
assertTrue(parser.compile("text"));
assertTrue(parser.compile("comment"));
assertTrue(parser.compile("text()"));
assertTrue(parser.compile("text( )"));
assertTrue(parser.compile("text() "));
assertTrue(parser.compile("text ( )"));
assertTrue(parser.compile("comment()"));
assertTrue(parser.compile("following-sibling::comment()"));
assertTrue(parser.compile("descendant::comment()"));
assertTrue(parser.compile("comment()[1]"));
assertTrue(parser.compile("comment()[2]"));
assertTrue(parser.compile("comment()[3]"));
assertTrue(parser.compile("/following-sibling::comment()"));
assertTrue(parser.compile("/descendant::comment()"));
assertTrue(parser.compile("/comment()[1]"));
assertTrue(parser.compile("/comment()[2]"));
assertTrue(parser.compile("/comment()[3]"));
}
void test2()
{
Arabica::XPath::StandardNamespaceContext nsContext;
nsContext.addNamespaceDeclaration("something", "a");
parser.setNamespaceContext(nsContext);
assertTrue(parser.compile("a:b"));
assertTrue(parser.compile(" a:b"));
assertTrue(parser.compile("a:b "));
assertTrue(parser.compile(" a:b "));
parser.resetNamespaceContext();
}
void test3()
{
assertTrue(parser.compile("processing-instruction()"));
assertTrue(parser.compile("processing-instruction( ) "));
assertTrue(parser.compile("processing-instruction('poo')"));
assertTrue(parser.compile("processing-instruction(\"poo\")"));
assertTrue(parser.compile("processing-instruction( \"poo\")"));
assertTrue(parser.compile("processing-instruction( \"poo\" )"));
assertTrue(parser.compile("processing-instruction ( \"poo\" )"));
}
void test4()
{
assertTrue(parser.compile("self::name"));
assertTrue(parser.compile(" self::name"));
assertTrue(parser.compile("self ::name"));
assertTrue(parser.compile("self:: name"));
assertTrue(parser.compile(" self :: name"));
}
void test5()
{
assertTrue(parser.compile("@fruit"));
assertTrue(parser.compile(" @fruit"));
assertTrue(parser.compile("@ fruit"));
assertTrue(parser.compile(" @ fruit"));
}
void test6()
{
assertTrue(parser.compile("one/two"));
assertTrue(parser.compile("one/@fruit"));
assertTrue(parser.compile("one/@fruit[1]"));
assertTrue(parser.compile("one/descendant-or-self::woot[1]"));
assertTrue(parser.compile("one/two/three"));
assertTrue(parser.compile("one/two/three[1]"));
assertTrue(parser.compile("one/two[1]/three"));
assertTrue(parser.compile("one/comment()"));
assertTrue(parser.compile("one/text()"));
assertTrue(parser.compile("one/processing-instruction()"));
assertTrue(parser.compile("one/node()"));
assertTrue(parser.compile("one/*"));
Arabica::XPath::StandardNamespaceContext nsContext;
nsContext.addNamespaceDeclaration("urn:I:made:this:up", "ns");
parser.setNamespaceContext(nsContext);
assertTrue(parser.compile("one/ns:*"));
assertTrue(parser.compile("one/ns:two"));
assertTrue(parser.compile("one/processing-instruction('parp')"));
}
void test7()
{
assertTrue(parser.compile("/"));
assertTrue(parser.compile("/one"));
assertTrue(parser.compile("/one/two"));
assertTrue(parser.compile("/one[1]/two[2]/comment()"));
assertTrue(parser.compile("/one[1]/two[2][1]"));
}
void test8()
{
assertTrue(parser.compile("//one"));
assertTrue(parser.compile("//one/two"));
assertTrue(parser.compile("//one/two//@id"));
assertTrue(parser.compile("//*[@id]"));
assertTrue(parser.compile("one//two"));
}
void test9()
{
assertTrue(parser.compile("."));
assertTrue(parser.compile("./something"));
assertTrue(parser.compile("./something/else"));
assertTrue(parser.compile("./something/./else"));
assertTrue(parser.compile(".."));
assertTrue(parser.compile("../something"));
assertTrue(parser.compile("../../something"));
assertTrue(parser.compile("../../something/../text()"));
}
void test10()
{
assertTrue(parser.compile("/one/*"));
}
void test11()
{
Arabica::XPath::StandardNamespaceContext nsContext;
nsContext.addNamespaceDeclaration("something", "ns");
parser.setNamespaceContext(nsContext);
assertTrue(parser.compile("/ns:one"));
assertTrue(parser.compile("//one/ns:two"));
assertTrue(parser.compile("//ns:one/ns:two//@id"));
assertTrue(parser.compile("//one/ns:*"));
parser.resetNamespaceContext();
}
void test12()
{
assertTrue(parser.compile("one/two/three[@attr]"));
assertTrue(parser.compile("one/two/three[@attr][1]"));
assertTrue(parser.compile("one/two/three[four/@attr]"));
}
void test13()
{
assertTrue(parser.compile("one/two/three[four|@attr]"));
}
void test14()
{
assertTrue(parser.compile("one/two/three[-($a)]"));
assertTrue(parser.compile("one/two/three[--($a)]"));
assertTrue(parser.compile("one/two/three[-$a|$b]"));
assertTrue(parser.compile("one/two/three[2*-$a|$b]"));
assertTrue(parser.compile("one/two/three[2mod-$a|$b]"));
assertTrue(parser.compile("one/two/three[-(@two)=-1]"));
assertTrue(parser.compile("one/two/three[-(@two) =-1]"));
assertTrue(parser.compile("one/two/three[ -(@two)=-1]"));
assertTrue(parser.compile("one/two/three[-(@two) = -1]"));
}
void test15()
{
assertTrue(parser.compile("one/two/three[four]"));
assertTrue(parser.compile("one/two/three[ four]"));
assertTrue(parser.compile("one/two/three[four ]"));
assertTrue(parser.compile("one/two/three[ four ]"));
}
void test16()
{
assertTrue(parser.compile("one/two/three[/four]"));
assertTrue(parser.compile("one/two/three[/four/five]"));
assertTrue(parser.compile("one/two/three[/four/five[1]]"));
assertTrue(parser.compile("one/two/three[/four/five[@id][1]]"));
assertTrue(parser.compile("one/two/three[/four/five[1]/six]"));
assertTrue(parser.compile("one/two/three[/four/five[1]/six[@id][1]]"));
}
void test17()
{
assertTrue(parser.compile("one/two/three[@attr1='nob']"));
assertTrue(parser.compile("one/two/three[$a=$b]"));
assertTrue(parser.compile("one/two/three[$a!=$b]"));
assertTrue(parser.compile("one/two/three[$a=$b=$c]"));
assertTrue(parser.compile("/root/*[child = true()]"));
assertTrue(parser.compile("/root/*[child = 1]"));
assertTrue(parser.compile("/root/*[child = '1']"));
assertTrue(parser.compile("/root/*[1]/trousers"));
assertTrue(parser.compile("/root/*[@* = @two]"));
assertTrue(parser.compile("/root/*[@*]"));
assertTrue(parser.compile("/root/*[*]"));
assertTrue(parser.compile("/root/*[charlie[one]]"));
assertTrue(parser.compile("/root/*[/one]"));
assertTrue(parser.compile("/root/*[charlie[/one]]"));
assertTrue(parser.compile("/root/*[@* = child/@two]"));
assertTrue(parser.compile("/root/*[//root/child/@two = @*]"));
assertTrue(parser.compile("/root/*[/root/child/@two = @*]"));
assertTrue(parser.compile("/root/*[@*=//root/child/@two]"));
assertTrue(parser.compile("/root/*[@* =//root/child/@two]"));
assertTrue(parser.compile("/root/*[@* = //root/child/@two]"));
assertTrue(parser.compile("/root/*[@*= //root/child/@two]"));
assertTrue(parser.compile("/root/*[@*=/root/child/@two]"));
assertTrue(parser.compile("/root/*[@* =/root/child/@two]"));
assertTrue(parser.compile("/root/*[@* = /root/child/@two]"));
assertTrue(parser.compile("/root/*[@*= /root/child/@two]"));
assertTrue(parser.compile("root/*[@*=root/child/@two]"));
assertTrue(parser.compile("root/*[@* =root/child/@two]"));
assertTrue(parser.compile("root/*[@* = root/child/@two]"));
assertTrue(parser.compile("root/*[@*= root/child/@two]"));
assertTrue(parser.compile("one/two/three[$a<$b]"));
assertTrue(parser.compile("one/two/three[$a <$b]"));
assertTrue(parser.compile("one/two/three[$a< $b]"));
assertTrue(parser.compile("one/two/three[$a <$b]"));
assertTrue(parser.compile("one/two/three[$a>$b]"));
assertTrue(parser.compile("one/two/three[$a >$b]"));
assertTrue(parser.compile("one/two/three[$a> $b]"));
assertTrue(parser.compile("one/two/three[$a > $b]"));
assertTrue(parser.compile("one/two/three[$a<$b]"));
assertTrue(parser.compile("one/two/three[$a>=$b]"));
assertTrue(parser.compile("one/two/three[$a<=$b]"));
assertTrue(parser.compile("one/two/three[$a>$b>$c]"));
assertTrue(parser.compile("one/two/three[$a>$b<$c]"));
assertTrue(parser.compile("one/two/three[$a=$b<$c]"));
assertTrue(parser.compile("one/two/three[($a>$b)or($b>$c)]"));
assertTrue(parser.compile("one/two/three[($a>$b)and($b>$c)]"));
assertTrue(parser.compile("/root/*[@* = string('woo')]"));
assertTrue(parser.compile("/root/*[@* = string(//root/child/@two)]"));
assertTrue(parser.compile_expr("$fruit/*[2]"));
assertTrue(parser.compile("/root[$fruit/root = @*]"));
assertTrue(parser.compile("/root/*[$fruit/root/child/@two = @*]"));
assertTrue(parser.compile("/root/*[$fruit/root/child/@two = $fruit/root/child/@two]"));
}
void test18()
{
assertTrue(parser.compile("one/two/three[last()]"));
assertTrue(parser.compile("one/two/three[comment()]"));
assertTrue(parser.compile("one/two/three[string($a)]"));
assertTrue(parser.compile("one/two/three[$var]"));
assertTrue(parser.compile("one/two/three[position()=1]"));
assertTrue(parser.compile("one/two/three[(@attr)or(@id)]"));
assertTrue(parser.compile("one/two/three[$var=1]"));
try {
parser.compile("one/two/three[string($a,$b)]");
assert(false);
}
catch(...) { }
assertTrue(parser.compile("one/two/three[contains($a,string($b))]"));
}
void test19()
{
assertTrue(parser.compile("one/two/three[(1+1)]"));
assertTrue(parser.compile("one/two/three[(1-1)]"));
assertTrue(parser.compile("one/two/three[(1+1-1)]"));
assertTrue(parser.compile("one/two/three[(1+1+1)]"));
assertTrue(parser.compile("one/two/three[(1+1+1+1)]"));
assertTrue(parser.compile("one/two/three[(1*1)]"));
assertTrue(parser.compile("one/two/three[(1*1*1)]"));
assertTrue(parser.compile("one/two/three[(1*1*1*1)]"));
assertTrue(parser.compile("one/two/three[(6div2)]"));
assertTrue(parser.compile("one/two/three[(5mod4)]"));
assertTrue(parser.compile("one/two/three[(2*2)]"));
assertTrue(parser.compile("one[1 + 2 * 3]"));
assertTrue(parser.compile("one[3 * 2 + 1]"));
}
void test20()
{
assertTrue(parser.compile("one/two/three[(1)]"));
assertTrue(parser.compile("one/two/three[(1.1)]"));
assertTrue(parser.compile("one/two/three[(1.)]"));
assertTrue(parser.compile("one/two/three[.1]"));
assertTrue(parser.compile("one/two/three[ .1 ]"));
assertTrue(parser.compile("one/two/three[(12)]"));
assertTrue(parser.compile("one/two/three[(123.456)]"));
assertTrue(parser.compile("one/two/three[(.123456)]"));
}
void test21()
{
assertTrue(parser.compile("one/two/three[$var]"));
assertTrue(parser.compile("one/two/three [$var]"));
assertTrue(parser.compile("one/two/three[$var] "));
assertTrue(parser.compile("one/two/three[$var] /four"));
assertTrue(parser.compile("one/two/three[$var ]"));
assertTrue(parser.compile("one/two/three[$var ]"));
assertTrue(parser.compile("one/two/three[ $var]"));
assertTrue(parser.compile("one/two/three[ $var]"));
assertTrue(parser.compile("one/two/three[ $var ]"));
assertTrue(parser.compile("one/two/three[$var = 1]"));
}
void test22()
{
assertTrue(parser.compile("one/two/three[position() = 1]"));
assertTrue(parser.compile("one/two/three[position( ) = 1]"));
assertTrue(parser.compile("one/two/three[(@attr) or (@id)]"));
assertTrue(parser.compile("one/two/three[@attr or @id]"));
try {
parser.compile("one/two/three[string($a, $b)]");
assert(false);
}
catch(...) { }
assertTrue(parser.compile("one/two/three[contains($a, string($b))]"));
assertTrue(parser.compile("one/two/three[contains( $a, string($b))]"));
assertTrue(parser.compile("one/two/three[contains ($a, string($b) )]"));
} // test22
void test23()
{
assertTrue(parser.compile("/root[count(something)]"));
try {
parser.compile("/root[count()]");
assert(false);
}
catch(...) { }
try {
parser.compile("/root[count(one, two)]");
assert(false);
}
catch(...) { }
try {
parser.compile("/root[count(one,two)]");
assert(false);
}
catch(...) { }
try {
parser.compile("/root/count(one,two)");
assert(false);
}
catch(...) { }
} // test23
}; // class ParseTest
TestSuite* ParseTest_suite()
{
TestSuite *suiteOfTests = new TestSuite;
suiteOfTests->addTest(new TestCaller<ParseTest>("test1", &ParseTest::test1));
suiteOfTests->addTest(new TestCaller<ParseTest>("test2", &ParseTest::test2));
suiteOfTests->addTest(new TestCaller<ParseTest>("test3", &ParseTest::test3));
suiteOfTests->addTest(new TestCaller<ParseTest>("test4", &ParseTest::test4));
suiteOfTests->addTest(new TestCaller<ParseTest>("test5", &ParseTest::test5));
suiteOfTests->addTest(new TestCaller<ParseTest>("test6", &ParseTest::test6));
suiteOfTests->addTest(new TestCaller<ParseTest>("test7", &ParseTest::test7));
suiteOfTests->addTest(new TestCaller<ParseTest>("test8", &ParseTest::test8));
suiteOfTests->addTest(new TestCaller<ParseTest>("test9", &ParseTest::test9));
suiteOfTests->addTest(new TestCaller<ParseTest>("test10", &ParseTest::test10));
suiteOfTests->addTest(new TestCaller<ParseTest>("test11", &ParseTest::test11));
suiteOfTests->addTest(new TestCaller<ParseTest>("test12", &ParseTest::test12));
suiteOfTests->addTest(new TestCaller<ParseTest>("test13", &ParseTest::test13));
suiteOfTests->addTest(new TestCaller<ParseTest>("test14", &ParseTest::test14));
suiteOfTests->addTest(new TestCaller<ParseTest>("test15", &ParseTest::test15));
suiteOfTests->addTest(new TestCaller<ParseTest>("test16", &ParseTest::test16));
suiteOfTests->addTest(new TestCaller<ParseTest>("test17", &ParseTest::test17));
suiteOfTests->addTest(new TestCaller<ParseTest>("test18", &ParseTest::test18));
suiteOfTests->addTest(new TestCaller<ParseTest>("test19", &ParseTest::test19));
suiteOfTests->addTest(new TestCaller<ParseTest>("test20", &ParseTest::test20));
suiteOfTests->addTest(new TestCaller<ParseTest>("test21", &ParseTest::test21));
suiteOfTests->addTest(new TestCaller<ParseTest>("test22", &ParseTest::test22));
suiteOfTests->addTest(new TestCaller<ParseTest>("test23", &ParseTest::test23));
return suiteOfTests;
} // ParseTest_suite

View file

@ -0,0 +1,7 @@
#ifndef XPATHIC_PARSE_TEST_H
#define XPATHIC_PARSE_TEST_H
TestSuite* ParseTest_suite();
#endif

View file

@ -0,0 +1,189 @@
#ifdef _MSC_VER
#pragma warning(disable: 4786 4250 4503 4224)
#endif
#include "../CppUnit/framework/TestCase.h"
#include "../CppUnit/framework/TestSuite.h"
#include "../CppUnit/framework/TestCaller.h"
#include <XPath/XPath.hpp>
using namespace Arabica::XPath;
class RelationalTest : public TestCase
{
public:
RelationalTest(const std::string& name) : TestCase(name)
{
} // RelationalTest
void setUp()
{
} // setUp
void test1()
{
XPathExpressionPtr equals1(new EqualsOperator(new NumericValue(1), new NumericValue(1)));
XPathExpressionPtr equals2(new EqualsOperator(new NumericValue(1), new NumericValue(1)));
assertEquals(true, equals1->evaluateAsBool(dummy_));
assertEquals(true, equals2->evaluateAsBool(dummy_));
} // test1
void test2()
{
XPathExpressionPtr equals1(new EqualsOperator(new NumericValue(1), new NumericValue(2)));
XPathExpressionPtr equals2(new EqualsOperator(new NumericValue(2), new NumericValue(1)));
assertEquals(false, equals1->evaluateAsBool(dummy_));
assertEquals(false, equals2->evaluateAsBool(dummy_));
} // test2
void test3()
{
XPathExpressionPtr equals1(new EqualsOperator(new NumericValue(1), new NumericValue(1)));
assertEquals(true, equals1->evaluateAsBool(dummy_));
} // test3
void test4()
{
XPathExpression* p1 = new StringValue("charlie");
XPathExpression* p2 = new StringValue("charlie");
XPathExpressionPtr equals1(new EqualsOperator(p1, p2));
assertEquals(true, equals1->evaluateAsBool(dummy_));
} // test4
void test5()
{
XPathExpression* p1 = new StringValue("trousers");
XPathExpression* p2 = new StringValue("charlie");
XPathExpressionPtr equals1(new EqualsOperator(p1, p2));
assertEquals(false, equals1->evaluateAsBool(dummy_));
} // test5
void test6()
{
XPathExpressionPtr equals1(new EqualsOperator(new BoolValue(true), new BoolValue(true)));
XPathExpressionPtr equals2(new EqualsOperator(new BoolValue(false), new BoolValue(false)));
assertEquals(true, equals1->evaluateAsBool(dummy_));
assertEquals(true, equals2->evaluateAsBool(dummy_));
} // test6
void test7()
{
XPathExpressionPtr equals1(new EqualsOperator(new BoolValue(true), new BoolValue(false)));
XPathExpressionPtr equals2(new EqualsOperator(new BoolValue(false), new BoolValue(true)));
assertEquals(false, equals1->evaluateAsBool(dummy_));
assertEquals(false, equals2->evaluateAsBool(dummy_));
} // test7
void testLessThan1()
{
XPathExpressionPtr lessThan1(new LessThanOperator(new BoolValue(true), new BoolValue(true)));
XPathExpressionPtr lessThan2(new LessThanOperator(new BoolValue(false), new BoolValue(false)));
XPathExpressionPtr lessThan3(new LessThanOperator(new BoolValue(true), new BoolValue(false)));
XPathExpressionPtr lessThan4(new LessThanOperator(new BoolValue(false), new BoolValue(true)));
assertEquals(false, lessThan1->evaluateAsBool(dummy_));
assertEquals(false, lessThan2->evaluateAsBool(dummy_));
assertEquals(false, lessThan3->evaluateAsBool(dummy_));
assertEquals(true, lessThan4->evaluateAsBool(dummy_));
} // testLessThan1
void testLessThan2()
{
XPathExpressionPtr lessThan1(new LessThanOperator(new NumericValue(1.0), new NumericValue(1.0)));
XPathExpressionPtr lessThan2(new LessThanOperator(new NumericValue(3.0), new NumericValue(2.0)));
XPathExpressionPtr lessThan3(new LessThanOperator(new NumericValue(2.0), new NumericValue(3.0)));
XPathExpressionPtr lessThan4(new LessThanOperator(new NumericValue(-1), new NumericValue(1)));
assertEquals(false, lessThan1->evaluateAsBool(dummy_));
assertEquals(false, lessThan2->evaluateAsBool(dummy_));
assertEquals(true, lessThan3->evaluateAsBool(dummy_));
assertEquals(true, lessThan4->evaluateAsBool(dummy_));
} // testLessThan2
void testLessThan3()
{
XPathExpressionPtr lessThan1(new LessThanOperator(new StringValue("1.0"), new StringValue("1.0")));
XPathExpressionPtr lessThan2(new LessThanOperator(new StringValue("3.0"), new StringValue("2.0")));
XPathExpressionPtr lessThan3(new LessThanOperator(new StringValue("2.0"), new StringValue("3.0")));
XPathExpressionPtr lessThan4(new LessThanOperator(new StringValue("-1"), new StringValue("1")));
assertEquals(false, lessThan1->evaluateAsBool(dummy_));
assertEquals(false, lessThan2->evaluateAsBool(dummy_));
assertEquals(true, lessThan3->evaluateAsBool(dummy_));
assertEquals(true, lessThan4->evaluateAsBool(dummy_));
} // testLessThan3
void testLessThanEquals1()
{
XPathExpressionPtr lessThanEquals1(new LessThanEqualsOperator(new BoolValue(true), new BoolValue(true)));
XPathExpressionPtr lessThanEquals2(new LessThanEqualsOperator(new BoolValue(false), new BoolValue(false)));
XPathExpressionPtr lessThanEquals3(new LessThanEqualsOperator(new BoolValue(true), new BoolValue(false)));
XPathExpressionPtr lessThanEquals4(new LessThanEqualsOperator(new BoolValue(false), new BoolValue(true)));
assertEquals(true, lessThanEquals1->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals2->evaluateAsBool(dummy_));
assertEquals(false, lessThanEquals3->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals4->evaluateAsBool(dummy_));
} // testLessThanEquals1
void testLessThanEquals2()
{
XPathExpressionPtr lessThanEquals1(new LessThanEqualsOperator(new NumericValue(1.0), new NumericValue(1.0)));
XPathExpressionPtr lessThanEquals2(new LessThanEqualsOperator(new NumericValue(3.0), new NumericValue(2.0)));
XPathExpressionPtr lessThanEquals3(new LessThanEqualsOperator(new NumericValue(2.0), new NumericValue(3.0)));
XPathExpressionPtr lessThanEquals4(new LessThanEqualsOperator(new NumericValue(-1), new NumericValue(1)));
assertEquals(true, lessThanEquals1->evaluateAsBool(dummy_));
assertEquals(false, lessThanEquals2->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals3->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals4->evaluateAsBool(dummy_));
} // testLessThanEquals2
void testLessThanEquals3()
{
XPathExpressionPtr lessThanEquals1(new LessThanEqualsOperator(new StringValue("1.0"), new StringValue("1.0")));
XPathExpressionPtr lessThanEquals2(new LessThanEqualsOperator(new StringValue("3.0"), new StringValue("2.0")));
XPathExpressionPtr lessThanEquals3(new LessThanEqualsOperator(new StringValue("2.0"), new StringValue("3.0")));
XPathExpressionPtr lessThanEquals4(new LessThanEqualsOperator(new StringValue("-1"), new StringValue("1")));
assertEquals(true, lessThanEquals1->evaluateAsBool(dummy_));
assertEquals(false, lessThanEquals2->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals3->evaluateAsBool(dummy_));
assertEquals(true, lessThanEquals4->evaluateAsBool(dummy_));
} // testLessThanEquals3
private:
DOM::Node<std::string> dummy_;
}; // class RelationalTest
TestSuite* RelationalTest_suite()
{
TestSuite* tests = new TestSuite;
tests->addTest(new TestCaller<RelationalTest>("test1", &RelationalTest::test1));
tests->addTest(new TestCaller<RelationalTest>("test2", &RelationalTest::test2));
tests->addTest(new TestCaller<RelationalTest>("test3", &RelationalTest::test3));
tests->addTest(new TestCaller<RelationalTest>("test4", &RelationalTest::test4));
tests->addTest(new TestCaller<RelationalTest>("test5", &RelationalTest::test5));
tests->addTest(new TestCaller<RelationalTest>("test6", &RelationalTest::test6));
tests->addTest(new TestCaller<RelationalTest>("test7", &RelationalTest::test7));
tests->addTest(new TestCaller<RelationalTest>("testLessThan1", &RelationalTest::testLessThan1));
tests->addTest(new TestCaller<RelationalTest>("testLessThan2", &RelationalTest::testLessThan2));
tests->addTest(new TestCaller<RelationalTest>("testLessThan3", &RelationalTest::testLessThan3));
tests->addTest(new TestCaller<RelationalTest>("testLessThanEquals1", &RelationalTest::testLessThanEquals1));
tests->addTest(new TestCaller<RelationalTest>("testLessThanEquals2", &RelationalTest::testLessThanEquals2));
tests->addTest(new TestCaller<RelationalTest>("testLessThanEquals3", &RelationalTest::testLessThanEquals3));
return tests;
} // RelationalTest_suite

View file

@ -0,0 +1,6 @@
#ifndef XPATHIC_RELATIONAL_TEST_H
#define XPATHIC_RELATIONAL_TEST_H
TestSuite* RelationalTest_suite();
#endif

109
test/XPath/step_test.cpp Normal file
View file

@ -0,0 +1,109 @@
#ifdef _MSC_VER
#pragma warning(disable: 4786 4250 4503 4224 4267)
#endif
#include "../CppUnit/framework/TestCase.h"
#include "../CppUnit/framework/TestSuite.h"
#include "../CppUnit/framework/TestCaller.h"
#include <XPath/XPath.hpp>
#include "step_test.hpp"
#include <DOM/Simple/DOMImplementation.h>
using namespace Arabica::XPath;
class StepTest : public TestCase
{
DOM::DOMImplementation<std::string> factory_;
DOM::Document<std::string> document_;
DOM::Element<std::string> root_;
DOM::Element<std::string> element1_;
DOM::Element<std::string> element2_;
DOM::Element<std::string> element3_;
DOM::Attr<std::string> attr_;
public:
StepTest(const std::string& name) : TestCase(name)
{
} // StepTest
void setUp()
{
factory_ = SimpleDOM::DOMImplementation<std::string>::getDOMImplementation();
document_ = factory_.createDocument("", "root", 0);
root_ = document_.getDocumentElement();
element1_ = document_.createElement("child1");
element2_ = document_.createElement("child2");
element3_ = document_.createElement("child3");
element1_.setAttribute("one", "1");
element2_.setAttribute("one", "1");
element2_.setAttribute("two", "1");
element2_.setAttribute("three", "1");
element2_.setAttribute("four", "1");
attr_ = element1_.getAttributeNode("one");
root_.appendChild(element1_);
root_.appendChild(element2_);
root_.appendChild(element3_);
} // setUp
void test1()
{
XPathExpressionPtr step(new TestStepExpression(CHILD, new AnyNodeTest()));
XPathValuePtr value = step->evaluate(root_);
const NodeSet& set = value->asNodeSet();
assertEquals(set.size(), 3);
assertTrue(set[0] == element1_);
assertTrue(set[1] == element2_);
assertTrue(set[2] == element3_);
} // test1
void test2()
{
XPathExpressionPtr step(new TestStepExpression(ATTRIBUTE, new AnyNodeTest()));
NodeSet set = step->evaluateAsNodeSet(element2_);
assertEquals(4, set.size());
DOM::Attr<std::string> attr = static_cast<DOM::Attr<std::string> >(set[0]);
assertEquals(attr.getNodeName(), "one");
attr = static_cast<DOM::Attr<std::string> >(set[1]);
assertEquals(attr.getNodeName(), "two");
attr = static_cast<DOM::Attr<std::string> >(set[2]);
assertEquals(attr.getNodeName(), "three");
attr = static_cast<DOM::Attr<std::string> >(set[3]);
assertEquals(attr.getNodeName(), "four");
} // test2
void test3()
{
XPathExpressionPtr step(new TestStepExpression(CHILD, new NameNodeTest("child2")));
XPathValuePtr value = step->evaluate(root_);
const NodeSet& set = value->asNodeSet();
assertEquals(1, set.size());
assertTrue(set[0] == element2_);
} // test3
}; // class StepTest
TestSuite* StepTest_suite()
{
TestSuite* suiteOfTests = new TestSuite;
suiteOfTests->addTest(new TestCaller<StepTest>("test1", &StepTest::test1));
suiteOfTests->addTest(new TestCaller<StepTest>("test2", &StepTest::test2));
suiteOfTests->addTest(new TestCaller<StepTest>("test3", &StepTest::test3));
return suiteOfTests;
} // StepTest_suite

6
test/XPath/step_test.hpp Normal file
View file

@ -0,0 +1,6 @@
#ifndef STEP_TEST_H
#define STEP_TEST_H
TestSuite* StepTest_suite();
#endif

146
test/XPath/value_test.cpp Normal file
View file

@ -0,0 +1,146 @@
#ifdef _MSC_VER
#pragma warning(disable: 4786 4250 4503 4224)
#endif
#include "../CppUnit/framework/TestCase.h"
#include "../CppUnit/framework/TestSuite.h"
#include "../CppUnit/framework/TestCaller.h"
#include <XPath/XPath.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 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(areEqual(bt->evaluate(dummy_), (st->evaluate(dummy_))));
assertTrue(areEqual(st->evaluate(dummy_), (bt->evaluate(dummy_))));
assertTrue(areEqual(sf->evaluate(dummy_), (bf->evaluate(dummy_))));
assertTrue(areEqual(bf->evaluate(dummy_), (sf->evaluate(dummy_))));
assertTrue(areEqual(bt->evaluate(dummy_), (bt->evaluate(dummy_))));
assertTrue(areEqual(bf->evaluate(dummy_), (bf->evaluate(dummy_))));
assertTrue(areEqual(st->evaluate(dummy_), (st->evaluate(dummy_))));
assertTrue(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(areEqual(bt->evaluate(dummy_), (nt->evaluate(dummy_))));
assertTrue(areEqual(nt->evaluate(dummy_), (bt->evaluate(dummy_))));
assertTrue(areEqual(bf->evaluate(dummy_), (nf->evaluate(dummy_))));
assertTrue(areEqual(nf->evaluate(dummy_), (bf->evaluate(dummy_))));
} // test10
void test11()
{
XPathExpressionPtr nt(new NumericValue(1.0));
XPathValuePtr ns = nt->evaluate(dummy_);
assertTrue(areEqual(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

View file

@ -0,0 +1,7 @@
#ifndef XPATHIC_VALUE_TEST_H
#define XPATHIC_VALUE_TEST_H
TestSuite* ValueTest_suite();
#endif

246
test/XPath/xpathic.vcproj Normal file
View file

@ -0,0 +1,246 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="test_xpath"
ProjectGUID="{B3C75B3A-BB0A-4B23-87F9-FB9CD98FF8CE}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\..\..\bin"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Zm1000 "
Optimization="0"
InlineFunctionExpansion="0"
AdditionalIncludeDirectories="..\.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="FALSE"
BasicRuntimeChecks="0"
RuntimeLibrary="5"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/xpath_test.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/xpathic.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\..\..\Debug"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Zm1000 "
AdditionalIncludeDirectories="..\.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
DisableLanguageExtensions="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/xpath_test.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\arithmetic_test.cpp">
</File>
<File
RelativePath=".\axis_enumerator_test.cpp">
</File>
<File
RelativePath=".\execute_test.cpp">
</File>
<File
RelativePath=".\logical_test.cpp">
</File>
<File
RelativePath=".\main.cpp">
</File>
<File
RelativePath=".\node_test_test.cpp">
</File>
<File
RelativePath=".\parse_test.cpp">
</File>
<File
RelativePath=".\relational_test.cpp">
</File>
<File
RelativePath=".\step_test.cpp">
</File>
<File
RelativePath=".\value_test.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\arithmetic_test.hpp">
</File>
<File
RelativePath=".\axis_enumerator_test.hpp">
</File>
<File
RelativePath=".\execute_test.hpp">
</File>
<File
RelativePath=".\logical_test.hpp">
</File>
<File
RelativePath=".\node_test_test.hpp">
</File>
<File
RelativePath=".\parse_test.hpp">
</File>
<File
RelativePath=".\relational_test.hpp">
</File>
<File
RelativePath=".\step_test.hpp">
</File>
<File
RelativePath=".\value_test.hpp">
</File>
</Filter>
<Filter
Name="CppUnit"
Filter="">
<File
RelativePath="..\CppUnit\framework\CppUnitException.h">
</File>
<File
RelativePath="..\CppUnit\framework\estring.h">
</File>
<File
RelativePath="..\CppUnit\framework\Guards.h">
</File>
<File
RelativePath="..\CppUnit\framework\Test.h">
</File>
<File
RelativePath="..\CppUnit\framework\TestCaller.h">
</File>
<File
RelativePath="..\CppUnit\framework\TestCase.cpp">
</File>
<File
RelativePath="..\CppUnit\framework\TestCase.h">
</File>
<File
RelativePath="..\CppUnit\framework\TestFailure.cpp">
</File>
<File
RelativePath="..\CppUnit\framework\TestFailure.h">
</File>
<File
RelativePath="..\CppUnit\framework\TestResult.cpp">
</File>
<File
RelativePath="..\CppUnit\framework\TestResult.h">
</File>
<File
RelativePath="..\CppUnit\framework\TestSuite.cpp">
</File>
<File
RelativePath="..\CppUnit\framework\TestSuite.h">
</File>
<File
RelativePath="..\CppUnit\textui\TextTestResult.cpp">
</File>
<File
RelativePath="..\CppUnit\textui\TextTestResult.h">
</File>
</Filter>
<File
RelativePath="..\..\lib\Arabica.lib">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>