The C++ framework for developing highly scalable, high performance servers on Windows platforms.

jsontest.h File Reference


Namespaces

namespace  JsonTest

Classes

class  Failure
struct  PredicateContext
 Context used to create the assertion callstack on failure. Must be a POD to allow inline initialisation without stepping into the debugger. More...
class  TestResult
class  TestCase
class  Runner

Defines

#define JSONTEST_ASSERT(expr)
#define JSONTEST_ASSERT_PRED(expr)
#define JSONTEST_ASSERT_EQUAL(expected, actual)
#define JSONTEST_ASSERT_STRING_EQUAL(expected, actual)
#define JSONTEST_ASSERT_THROWS(expr)
#define JSONTEST_FIXTURE(FixtureType, name)
#define JSONTEST_FIXTURE_FACTORY(FixtureType, name)   &Test##FixtureType##name::factory
#define JSONTEST_REGISTER_FIXTURE(runner, FixtureType, name)   (runner).add(JSONTEST_FIXTURE_FACTORY(FixtureType, name))

Typedefs

typedef TestCase *(* TestCaseFactory )()
 Function pointer type for TestCase factory.

Functions

template<typename T, typename U>
TestResult & checkEqual (TestResult &result, T expected, U actual, const char *file, unsigned int line, const char *expr)
TestResult & checkStringEqual (TestResult &result, const std::string &expected, const std::string &actual, const char *file, unsigned int line, const char *expr)


Define Documentation

#define JSONTEST_ASSERT ( expr   ) 

Value:

if (expr) {                                                                  \
  } else                                                                       \
  result_->addFailure(__FILE__, __LINE__, #expr)
Asserts that the given expression is true. JSONTEST_ASSERT( x == y ) << "x=" << x << ", y=" << y; JSONTEST_ASSERT( x == y );

#define JSONTEST_ASSERT_EQUAL ( expected,
actual   ) 

Value:

JsonTest::checkEqual(*result_,                                               \
                       expected,                                               \
                       actual,                                                 \
                       __FILE__,                                               \
                       __LINE__,                                               \
                       #expected " == " #actual)
Asserts that two values are equals.

#define JSONTEST_ASSERT_PRED ( expr   ) 

Value:

{                                                                            \
    JsonTest::PredicateContext _minitest_Context = {                           \
      result_->predicateId_, __FILE__, __LINE__, #expr, NULL, NULL             \
    };                                                                         \
    result_->predicateStackTail_->next_ = &_minitest_Context;                  \
    result_->predicateId_ += 1;                                                \
    result_->predicateStackTail_ = &_minitest_Context;                         \
    (expr);                                                                    \
    result_->popPredicateContext();                                            \
  }
Asserts that the given predicate is true. The predicate may do other assertions and be a member function of the fixture.

#define JSONTEST_ASSERT_STRING_EQUAL ( expected,
actual   ) 

Value:

JsonTest::checkStringEqual(*result_,                                         \
                             std::string(expected),                            \
                             std::string(actual),                              \
                             __FILE__,                                         \
                             __LINE__,                                         \
                             #expected " == " #actual)
Asserts that two values are equals.

#define JSONTEST_ASSERT_THROWS ( expr   ) 

Value:

{                                                                            \
    bool _threw = false;                                                       \
    try {                                                                      \
      expr;                                                                    \
    }                                                                          \
    catch (...) {                                                              \
      _threw = true;                                                           \
    }                                                                          \
    if (!_threw)                                                               \
      result_->addFailure(                                                     \
          __FILE__, __LINE__, "expected exception thrown: " #expr);            \
  }
Asserts that a given expression throws an exception

#define JSONTEST_FIXTURE ( FixtureType,
name   ) 

Value:

class Test##FixtureType##name : public FixtureType {                         \
  public:                                                                      \
    static JsonTest::TestCase* factory() {                                     \
      return new Test##FixtureType##name();                                    \
    }                                                                          \
                                                                               \
  public: /* overidden from TestCase */                                        \
    virtual const char* testName() const { return #FixtureType "/" #name; }    \
    virtual void runTestCase();                                                \
  };                                                                           \
                                                                               \
  void Test##FixtureType##name::runTestCase()
Begin a fixture test case.

#define JSONTEST_FIXTURE_FACTORY ( FixtureType,
name   )     &Test##FixtureType##name::factory

#define JSONTEST_REGISTER_FIXTURE ( runner,
FixtureType,
name   )     (runner).add(JSONTEST_FIXTURE_FACTORY(FixtureType, name))


Generated on Sun Sep 12 19:06:43 2021 for The Server Framework - v7.4 by doxygen 1.5.3