File: tools.hpp

package info (click to toggle)
xmlrpc-c 1.60.05-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,132 kB
  • sloc: ansic: 55,332; cpp: 13,541; sh: 3,321; makefile: 2,556; perl: 593; xml: 134
file content (85 lines) | stat: -rw-r--r-- 2,340 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef TEST_HPP_INCLUDED
#define TEST_HPP_INCLUDED

#ifdef _WIN32
#  include <winsock2.h>  /* For XMLRPC_SOCKET (= SOCKET) */
#  include <ws2tcpip.h>
#else
#include <netinet/in.h>
#endif

#include <string>

#include "xmlrpc-c/girerr.hpp"
using girerr::error;

class testSuite {
/*----------------------------------------------------------------------------
   This is a base class for a test suite.  Give the suite a name
   (to be used in messages about it) and some test code via
   virtual methods suiteName() and runtests(), respectively.

   runtests() should throw either an 'error' object or an 'XmlRpcFault'
   object if the test fails.  It should throw something else if the
   test can't run.  It should throw nothing if the tests pass.

   You don't normally keep an object of this class around.  You don't
   even give it a name.  You simply refer to a literal object, like so:

     myTestSuite().run(0)
-----------------------------------------------------------------------------*/
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