Frobby  0.9.5
Classes | Namespaces | Macros | Functions
asserts.h File Reference
#include <stdexcept>
#include <sstream>
#include <vector>
#include <ostream>

Go to the source code of this file.

Classes

class  AssertException
 
struct  TestInternal::StdData
 

Namespaces

 TestInternal
 

Macros

#define STD_DATA   TestInternal::StdData(__LINE__, __FILE__, __nameOfTest, __printDots)
 
#define SILENT(X)    {bool ___printDots = __printDots; __printDots = false; X; __printDots = ___printDots;}
 
#define ASSERT_EXCEPTION(CODE, EXCEPTION_TYPE)
 
#define ASSERT_TRUE(VALUE)    {if(VALUE)assertOK(STD_DATA);else assertFail(#VALUE,"true",STD_DATA);}
 
#define ASSERT_TRUE_SILENT(VALUE)   SILENT(ASSERT_TRUE(VALUE))
 
#define ASSERT_TRUE1(VALUE, X)    {if(VALUE)assertOK(STD_DATA);else assertFail1(#VALUE,"true",STD_DATA,#X,TestInternal::toStr(X));}
 
#define ASSERT_FALSE1(VALUE, X)    {if(!VALUE)assertOK(STD_DATA);else assertFail1(#VALUE,"false",STD_DATA,#X,TestInternal::toStr(X));}
 
#define ASSERT_TRUE2(VALUE, X, Y)    {if(VALUE)assertOK(STD_DATA);else assertFail2(#VALUE,"true",STD_DATA,#X,TestInternal::toStr(X),#Y,TestInternal::toStr(Y));}
 
#define ASSERT_FALSE2(VALUE, X, Y)    {if(!VALUE)assertOK(STD_DATA);else assertFail2(#VALUE,"false",STD_DATA,#X,TestInternal::toStr(X),#Y,TestInternal::toStr(Y));}
 
#define ASSERT_TRUE2_SILENT(VALUE, A, B)
 
#define ASSERT_FALSE(VALUE)    TestInternal::assertFalse(VALUE, #VALUE, __nameOfTest, __FILE__, __LINE__, __printDots)
 
#define ASSERT_FALSE_SILENT(VALUE)    TestInternal::assertFalse(VALUE, #VALUE, __nameOfTest, __FILE__, __LINE__, false)
 
#define ASSERT_EQ(A, B)    TestInternal::assertEqual(A, B, #A, #B, __nameOfTest, __FILE__, __LINE__, __printDots)
 
#define ASSERT_EQ_SILENT(A, B)    TestInternal::assertEqual(A, B, #A, #B, __nameOfTest, __FILE__, __LINE__, false)
 
#define ASSERT_NEQ(A, B)    TestInternal::assertNotEqual(A, B, #A, #B, __nameOfTest, __FILE__, __LINE__, __printDots)
 
#define ASSERT_NEQ_SILENT(A, B)    TestInternal::assertNotEqual(A, B, #A, #B, __nameOfTest, __FILE__, __LINE__, false)
 

Functions

template<class T >
string TestInternal::toStr (const T &t)
 
void TestInternal::assertOK (const StdData &data)
 
void TestInternal::assertFail (const char *cond, const char *expected, const StdData &data)
 
void TestInternal::assertFail1 (const char *cond, const char *expected, const StdData &data, const char *exp1, string exp1Value)
 
void TestInternal::assertFail2 (const char *cond, const char *expected, const StdData &data, const char *exp1, string exp1Value, const char *exp2, string exp2Value)
 
void TestInternal::assertSucceeded (bool printDot)
 
void TestInternal::assertFailed (const char *errorMsg, const char *testName, const char *file, size_t line)
 
void TestInternal::assertTrue (bool value, const char *valueString, const char *testName, const char *file, size_t line, bool printDot)
 
void TestInternal::assertTrue2Failed (const char *valueString, const char *testName, const char *file, size_t line, const char *expression1, const char *expression1Value, const char *expression2, const char *expression2Value)
 
template<class A , class B >
void TestInternal::assertTrue2 (bool value, const char *valueString, const char *testName, const char *file, size_t line, const char *expression1, const A &a, const char *expression2, const B &b, bool printDot)
 
void TestInternal::assertFalse (bool value, const char *valueString, const char *testName, const char *file, size_t line, bool printDot)
 
void TestInternal::assertEqualFailed (const char *a, const char *b, const char *aString, const char *bString, const char *testName, const char *file, size_t line)
 
template<class T1 , class T2 >
void TestInternal::assertEqual (const T1 &a, const T2 &b, const char *aString, const char *bString, const char *testName, const char *file, size_t line, bool printDot)
 
void TestInternal::assertNotEqualFailed (const char *a, const char *b, const char *aString, const char *bString, const char *testName, const char *file, size_t line)
 
template<class T1 , class T2 >
void TestInternal::assertNotEqual (const T1 &a, const T2 &b, const char *aString, const char *bString, const char *testName, const char *file, size_t line, bool printDot)
 
template<class T >
ostream & TestInternal::operator<< (ostream &out, const vector< T > &v)
 Prints out a vector. More...
 

Macro Definition Documentation

◆ ASSERT_EQ

#define ASSERT_EQ (   A,
 
)     TestInternal::assertEqual(A, B, #A, #B, __nameOfTest, __FILE__, __LINE__, __printDots)

Definition at line 147 of file asserts.h.

◆ ASSERT_EQ_SILENT

#define ASSERT_EQ_SILENT (   A,
 
)     TestInternal::assertEqual(A, B, #A, #B, __nameOfTest, __FILE__, __LINE__, false)

Definition at line 149 of file asserts.h.

◆ ASSERT_EXCEPTION

#define ASSERT_EXCEPTION (   CODE,
  EXCEPTION_TYPE 
)
Value:
{bool _frobby_sawException = false; \
try {CODE;} catch (EXCEPTION_TYPE) {_frobby_sawException = true;} \
if (_frobby_sawException)assertOK(STD_DATA); \
else assertFail(#CODE,"throw exception of type " #EXCEPTION_TYPE,STD_DATA);}
#define STD_DATA
Definition: asserts.h:42
void assertOK(const StdData &data)
Definition: asserts.cpp:31
void assertFail(const char *cond, const char *expected, const StdData &data)
Definition: asserts.cpp:38

Definition at line 66 of file asserts.h.

◆ ASSERT_FALSE

#define ASSERT_FALSE (   VALUE)     TestInternal::assertFalse(VALUE, #VALUE, __nameOfTest, __FILE__, __LINE__, __printDots)

Definition at line 119 of file asserts.h.

◆ ASSERT_FALSE1

#define ASSERT_FALSE1 (   VALUE,
 
)     {if(!VALUE)assertOK(STD_DATA);else assertFail1(#VALUE,"false",STD_DATA,#X,TestInternal::toStr(X));}

Definition at line 78 of file asserts.h.

◆ ASSERT_FALSE2

#define ASSERT_FALSE2 (   VALUE,
  X,
 
)     {if(!VALUE)assertOK(STD_DATA);else assertFail2(#VALUE,"false",STD_DATA,#X,TestInternal::toStr(X),#Y,TestInternal::toStr(Y));}

Definition at line 83 of file asserts.h.

◆ ASSERT_FALSE_SILENT

#define ASSERT_FALSE_SILENT (   VALUE)     TestInternal::assertFalse(VALUE, #VALUE, __nameOfTest, __FILE__, __LINE__, false)

Definition at line 121 of file asserts.h.

◆ ASSERT_NEQ

#define ASSERT_NEQ (   A,
 
)     TestInternal::assertNotEqual(A, B, #A, #B, __nameOfTest, __FILE__, __LINE__, __printDots)

Definition at line 175 of file asserts.h.

◆ ASSERT_NEQ_SILENT

#define ASSERT_NEQ_SILENT (   A,
 
)     TestInternal::assertNotEqual(A, B, #A, #B, __nameOfTest, __FILE__, __LINE__, false)

Definition at line 177 of file asserts.h.

◆ ASSERT_TRUE

#define ASSERT_TRUE (   VALUE)     {if(VALUE)assertOK(STD_DATA);else assertFail(#VALUE,"true",STD_DATA);}

Definition at line 72 of file asserts.h.

◆ ASSERT_TRUE1

#define ASSERT_TRUE1 (   VALUE,
 
)     {if(VALUE)assertOK(STD_DATA);else assertFail1(#VALUE,"true",STD_DATA,#X,TestInternal::toStr(X));}

Definition at line 76 of file asserts.h.

◆ ASSERT_TRUE2

#define ASSERT_TRUE2 (   VALUE,
  X,
 
)     {if(VALUE)assertOK(STD_DATA);else assertFail2(#VALUE,"true",STD_DATA,#X,TestInternal::toStr(X),#Y,TestInternal::toStr(Y));}

Definition at line 81 of file asserts.h.

◆ ASSERT_TRUE2_SILENT

#define ASSERT_TRUE2_SILENT (   VALUE,
  A,
 
)
Value:
TestInternal::assertTrue2(VALUE, #VALUE, __nameOfTest, __FILE__, __LINE__, \
#A,A,#B,B, false);
void assertTrue2(bool value, const char *valueString, const char *testName, const char *file, size_t line, const char *expression1, const A &a, const char *expression2, const B &b, bool printDot)
Definition: asserts.h:91

Definition at line 111 of file asserts.h.

◆ ASSERT_TRUE_SILENT

#define ASSERT_TRUE_SILENT (   VALUE)    SILENT(ASSERT_TRUE(VALUE))

Definition at line 74 of file asserts.h.

◆ SILENT

#define SILENT (   X)     {bool ___printDots = __printDots; __printDots = false; X; __printDots = ___printDots;}

Definition at line 43 of file asserts.h.

◆ STD_DATA

#define STD_DATA   TestInternal::StdData(__LINE__, __FILE__, __nameOfTest, __printDots)

Definition at line 42 of file asserts.h.