|
|
#ifndef TEST_HPP_INCLUDED |
|
|
#define TEST_HPP_INCLUDED |
|
|
|
|
|
#ifdef _WIN32 |
|
|
# include <winsock2.h> |
|
|
# include <ws2tcpip.h> |
|
|
#else |
|
|
#include <netinet/in.h> |
|
|
#endif |
|
|
|
|
|
#include <string> |
|
|
|
|
|
#include "xmlrpc-c/girerr.hpp" |
|
|
using girerr::error; |
|
|
|
|
|
class testSuite { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
virtual ~testSuite(); |
|
|
|
|
|
void run(unsigned int const indentation); |
|
|
|
|
|
virtual void runtests(unsigned int const) { |
|
|
throw(error("test suite does not have a runtests() method")); |
|
|
}; |
|
|
virtual std::string suiteName() { |
|
|
return "unnamed test suite"; |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
logFailedTest(const char * const fileName, |
|
|
unsigned int const lineNum, |
|
|
const char * const statement); |
|
|
|
|
|
error |
|
|
fileLineError(std::string const filename, |
|
|
unsigned int const lineNumber, |
|
|
std::string const description); |
|
|
|
|
|
struct in_addr |
|
|
test_ipAddrFromDecimal(unsigned int const byte0, |
|
|
unsigned int const byte1, |
|
|
unsigned int const byte2, |
|
|
unsigned int const byte3); |
|
|
|
|
|
#define TEST(statement) \ |
|
|
do { \ |
|
|
if (!(statement)) \ |
|
|
logFailedTest(__FILE__, __LINE__, #statement); \ |
|
|
} while (0) |
|
|
|
|
|
|
|
|
#define TEST_PASSED() \ |
|
|
do { } while (0) |
|
|
|
|
|
#define TEST_FAILED(reason) \ |
|
|
do { \ |
|
|
logFailedTest(__FILE__, __LINE__, (reason)); \ |
|
|
} while (0) |
|
|
|
|
|
#define EXPECT_ERROR(statement) \ |
|
|
do { try { statement } catch (error const&) {break;} \ |
|
|
throw(fileLineError(__FILE__, __LINE__, "Expected error; didn't get one")); \ |
|
|
} while (0) |
|
|
|
|
|
#define trickToStraightenOutEmacsIndentation \ |
|
|
; |
|
|
|
|
|
#endif |
|
|
|