TestEvents.h File Reference

#include <string>
#include "TestToolBox/IEventReceiver.h"
#include "TestToolBox/CommonSources/ObjectLock.h"
Include dependency graph for TestEvents.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TestToolBox::EventPosition
class  TestToolBox::TestEvents
 This class stores the test events as they occure during test execution. When verifying the test results only the first error within a test case is reported. Further errors are ignored. More...
struct  TestToolBox::TestEvents::FirstError
 Information about the first error which was detected. More...

Namespaces

namespace  TestToolBox::CheckType
 

Mode of checking recorded events.


Defines

Macros to call a method and log info about the call to test protocol

Depending on the number of arguments given to the called method you have to use TTB_CMD1, TTB_CMD2, TTB_CMD3, ...

#define TTB_CMD(method)
 Base macro.
#define TTB_CMD1(method, p1)
#define TTB_CMD2(method, p1, p2)
#define TTB_CMD3(method, p1, p2, p3)
#define TTB_CMD4(method, p1, p2, p3, p4)
#define TTB_CMD5(method, p1, p2, p3, p4, p5)
#define TTB_CMD6(method, p1, p2, p3, p4, p5, p6)
#define TTB_CMD7(method, p1, p2, p3, p4, p5, p6, p7)
#define TTB_CMD8(method, p1, p2, p3, p4, p5, p6, p7, p8)
#define TTB_CMD9(method, p1, p2, p3, p4, p5, p6, p7, p8, p9)
#define TTB_CMD10(method, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
#define TTB_CMD11(method, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)
#define TTB_CMD12(method, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)
Macro to log the occurance of a relevant test event in stream syntax


Example TTB_ACT_S("Event occured: x=" << x << " y=" << y);

#define TTB_ACT_S(expression)
Macros to check the recorded test events

There are macros of several types from which you have to choose depending on the kind of checks you want to perform. The general syntax is TTB_EXP<checkType>, where checkType is

  • "empty" (e.g. TTB_EXP). To be used when checking for strict sequences for all events, the checkmode for these type of macros can also be changed via TestEvents::SetCheckType.
  • "_SEQ" (e.g. TTB_EXP_SEQ). To be used when checking for a sequence of events which may be overlayed with other events between.
  • "_VAR" (e.g. TTB_EXP_VAR). To be used when sequence does not matter at all.

In the simplest case the argument for a macro is the expected event string containing all formatted arguments (e.g. "Recorded value=3.14"). For this simple task use one of the macros TTB_EXP, TTB_EXP_SEQ or TTB_EXP_VAR.

You can also specify some arguments to build the final string analogous to printf syntax. Depending on the number of arguments given to the called method you have to use TTB_EXP<checkType>1, TTB_EXP<checkType>2, TTB_EXP_<checkType>3, ...
Example: TTB_EXP_SEQ2("Recorded x=%.2f y=%.2f", x,y);

For using stream syntax with manipulators to format the final event string use macros of the form TTB_EXP<checkType>_S.
Example TTB_EXP_S("Recorded x=" << x << " y=" << y);

#define TTB_EXP_S(expression)
#define TTB_EXP(stringValue)   TestToolBox::TestEvents::Get()->ExpectResult (__FILE__,__LINE__,stringValue)
 Base macro.
#define TTB_EXP1(formatString, p1)   TestToolBox::TestEvents::Get()->ExpectResult (__FILE__,__LINE__,formatString,p1)
#define TTB_EXP2(formatString, p1, p2)   TestToolBox::TestEvents::Get()->ExpectResult (__FILE__,__LINE__,formatString,p1,p2)
#define TTB_EXP3(formatString, p1, p2, p3)   TestToolBox::TestEvents::Get()->ExpectResult (__FILE__,__LINE__,formatString,p1,p2,p3)
#define TTB_EXP4(formatString, p1, p2, p3, p4)   TestToolBox::TestEvents::Get()->ExpectResult (__FILE__,__LINE__,formatString,p1,p2,p3,p4)
#define TTB_EXP5(formatString, p1, p2, p3, p4, p5)   TestToolBox::TestEvents::Get()->ExpectResult (__FILE__,__LINE__,formatString,p1,p2,p3,p4,p5)
#define TTB_EXP6(formatString, p1, p2, p3, p4, p5, p6)   TestToolBox::TestEvents::Get()->ExpectResult (__FILE__,__LINE__,formatString,p1,p2,p3,p4,p5,p6)
#define TTB_EXP7(formatString, p1, p2, p3, p4, p5, p6, p7)   TestToolBox::TestEvents::Get()->ExpectResult (__FILE__,__LINE__,formatString,p1,p2,p3,p4,p5,p6,p7)
#define TTB_EXP_SEQ_S(expression)
 Verify that the specified event value can be found at the current position or behind. The current position will be set to the position one afterwards of the found event position. Using this macro instead of TTB_EXP you explicitly allow a variable sequence of test events. You can use printf-syntax and specify additional arguments by using macros TTB_EXP_VAR1, TTB_EXP_VAR2.
#define TTB_EXP_SEQ(stringValue)   TestToolBox::TestEvents::Get()->ExpectResultSequential (__FILE__,__LINE__,stringValue)
#define TTB_EXP_SEQ1(formatString, p1)   TestToolBox::TestEvents::Get()->ExpectResultSequential (__FILE__,__LINE__,formatString,p1)
#define TTB_EXP_SEQ2(formatString, p1, p2)   TestToolBox::TestEvents::Get()->ExpectResultSequential (__FILE__,__LINE__,formatString,p1,p2)
#define TTB_EXP_SEQ3(formatString, p1, p2, p3)   TestToolBox::TestEvents::Get()->ExpectResultSequential (__FILE__,__LINE__,formatString,p1,p2,p3)
#define TTB_EXP_SEQ4(formatString, p1, p2, p3, p4)   TestToolBox::TestEvents::Get()->ExpectResultSequential (__FILE__,__LINE__,formatString,p1,p2,p3,p4)
#define TTB_EXP_SEQ5(formatString, p1, p2, p3, p4, p5)   TestToolBox::TestEvents::Get()->ExpectResultSequential (__FILE__,__LINE__,formatString,p1,p2,p3,p4,p5)
#define TTB_EXP_SEQ6(formatString, p1, p2, p3, p4, p5, p6)   TestToolBox::TestEvents::Get()->ExpectResultSequential (__FILE__,__LINE__,formatString,p1,p2,p3,p4,p5,p6)
#define TTB_EXP_SEQ7(formatString, p1, p2, p3, p4, p5, p6, p7)   TestToolBox::TestEvents::Get()->ExpectResultSequential (__FILE__,__LINE__,formatString,p1,p2,p3,p4,p5,p6,p7)
#define TTB_EXP_VAR_S(expression)
 Verify that one of the entries stored anywhere within TestEvents has the specified value. The current position will only be adjusted if the element is found at the current position. Using this macro instead of TTB_EXP you explicitly allow a variable sequence of test events. You can use printf-syntax and specify additional arguments by using macros TTB_EXP_VAR1, TTB_EXP_VAR2.
#define TTB_EXP_VAR(stringValue)   TestToolBox::TestEvents::Get()->ExpectResultVariable (__FILE__,__LINE__,stringValue)
#define TTB_EXP_VAR1(formatString, p1)   TestToolBox::TestEvents::Get()->ExpectResultVariable (__FILE__,__LINE__,formatString,p1)
#define TTB_EXP_VAR2(formatString, p1, p2)   TestToolBox::TestEvents::Get()->ExpectResultVariable (__FILE__,__LINE__,formatString,p1,p2)
#define TTB_EXP_VAR3(formatString, p1, p2, p3)   TestToolBox::TestEvents::Get()->ExpectResultVariable (__FILE__,__LINE__,formatString,p1,p2,p3)
#define TTB_EXP_VAR4(formatString, p1, p2, p3, p4)   TestToolBox::TestEvents::Get()->ExpectResultVariable (__FILE__,__LINE__,formatString,p1,p2,p3,p4)
#define TTB_EXP_VAR5(formatString, p1, p2, p3, p4, p5)   TestToolBox::TestEvents::Get()->ExpectResultVariable (__FILE__,__LINE__,formatString,p1,p2,p3,p4,p5)
#define TTB_EXP_VAR6(formatString, p1, p2, p3, p4, p5, p6)   TestToolBox::TestEvents::Get()->ExpectResultVariable (__FILE__,__LINE__,formatString,p1,p2,p3,p4,p5,p6)
#define TTB_EXP_VAR7(formatString, p1, p2, p3, p4, p5, p6, p7)   TestToolBox::TestEvents::Get()->ExpectResultVariable (__FILE__,__LINE__,formatString,p1,p2,p3,p4,p5,p6,p7)
Macros for comparing expressions and values

#define TTB_CHECK_COND(expression)   TestToolBox::TestEvents::Get()->CheckCondition( __FILE__,__LINE__, #expression, expression);
#define TTB_CHECK_EQUAL(left, right)   TestToolBox::TestEvents::Get()->CheckEqual( __FILE__,__LINE__, #left, left, #right, right);
#define TTB_CHECK(left, op, right)   TestToolBox::TestEvents::Get()->Check(__FILE__,__LINE__,#left,left,#op,op,#right,right);
General macros

#define TTB_INFO(message)   TestToolBox::TestEvents::Get()->Info (message)
 Write a (possibly longer) textual message to test protocol.
#define TTB_SECTION(sectionName)   TestToolBox::TestEvents::Get()->Section (sectionName)
 Writes a (short) textual message to test protocol and adds horizontal lines before and after it.
#define TTB_LIST_ALL_STORED_EVENTS()   TestToolBox::TestEvents::Get()->ListAllStoredEvents (__FILE__,__LINE__)
 Write an informational message about the stored test events to test protcol.
#define TTB_CHECK_FOR_UNEXPECTED_EVENTS()   TestToolBox::TestEvents::Get()->CheckForUnexpectedEvents ("explicit check", __FILE__,__LINE__)
 Explicitly chek in unexpected evetns have been recorded.
#define TTB_CHECK_DEFINED_SEQUENCES()   TestToolBox::TestEvents::Get()->CheckDefinedSequences (__FILE__,__LINE__)
 Check if the event sequences defined by DefineSequence() and subsequent calls to TTB_EXP() match with the sequence of recorded events.

Enumerations

enum  TestToolBox::CheckType::Enum {
  TestToolBox::CheckType::eNOT_SET, TestToolBox::CheckType::eSTRICT, TestToolBox::CheckType::eSEQUENTIAL, TestToolBox::CheckType::eMULTIPLE_SEQUENCES,
  TestToolBox::CheckType::eVARIABLE
}

Functions

static TestEvents * TestToolBox::TheTestEvents (void)
 Free function to get access to the singleton instance of class TestEvents.

Detailed Description

Author:
Gerald Fahrnholz

Define Documentation

#define TTB_CMD ( method   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method); \
    method ();

Base macro.

#define TTB_CMD1 ( method,
p1   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1); \
    method ( p1 );
#define TTB_CMD2 ( method,
p1,
p2   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1 " " #p2); \
    method ( p1, p2 );
#define TTB_CMD3 ( method,
p1,
p2,
p3   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1 " " #p2 " " #p3); \
    method ( p1, p2, p3 );
#define TTB_CMD4 ( method,
p1,
p2,
p3,
p4   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1 " " #p2 " " #p3 " " #p4); \
    method ( p1, p2, p3, p4 );
#define TTB_CMD5 ( method,
p1,
p2,
p3,
p4,
p5   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1 " " #p2 " " #p3 " " #p4 " " #p5); \
    method ( p1, p2, p3, p4, p5 );
#define TTB_CMD6 ( method,
p1,
p2,
p3,
p4,
p5,
p6   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1 " " #p2 " " #p3 " " #p4 " " #p5 " " #p6); \
    method ( p1, p2, p3, p4, p5, p6 );
#define TTB_CMD7 ( method,
p1,
p2,
p3,
p4,
p5,
p6,
p7   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1 " " #p2 " " #p3 " " #p4 " " #p5 " " #p6 " " #p7); \
    method ( p1, p2, p3, p4, p5, p6, p7 );
#define TTB_CMD8 ( method,
p1,
p2,
p3,
p4,
p5,
p6,
p7,
p8   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1 " " #p2 " " #p3 " " #p4 " " #p5 " " #p6 " " #p7 " " #p8); \
    method ( p1, p2, p3, p4, p5, p6, p7, p8 );
#define TTB_CMD9 ( method,
p1,
p2,
p3,
p4,
p5,
p6,
p7,
p8,
p9   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1 " " #p2 " " #p3 " " #p4 " " #p5 " " #p6 " " #p7 " " #p8 " " #p9); \
    method ( p1, p2, p3, p4, p5, p6, p7, p8, p9 );
#define TTB_CMD10 ( method,
p1,
p2,
p3,
p4,
p5,
p6,
p7,
p8,
p9,
p10   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1 " " #p2 " " #p3 " " #p4 " " #p5 " " #p6 " " #p7 " " #p8 " " #p9 " " #p10); \
    method ( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 );
#define TTB_CMD11 ( method,
p1,
p2,
p3,
p4,
p5,
p6,
p7,
p8,
p9,
p10,
p11   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1 " " #p2 " " #p3 " " #p4 " " #p5 " " #p6 " " #p7 " " #p8 " " #p9 " " #p10 " " #p11); \
    method ( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 );
#define TTB_CMD12 ( method,
p1,
p2,
p3,
p4,
p5,
p6,
p7,
p8,
p9,
p10,
p11,
p12   ) 
Value:
TestToolBox::TestEvents::Get()->Command (#method, #p1 " " #p2 " " #p3 " " #p4 " " #p5 " " #p6 " " #p7 " " #p8 " " #p9 " " #p10 " " #p11 " " #p12); \
    method ( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12);
#define TTB_ACT_S ( expression   ) 
Value:
{\
    std::ostringstream oss; \
    oss << expression; \
    TestToolBox::TestEvents::Get()->Act (oss.str().c_str()); \
}
#define TTB_EXP_S ( expression   ) 
Value:
{\
    std::ostringstream oss; \
    oss << expression; \
    TestToolBox::TestEvents::Get()->ExpectResult  (__FILE__,__LINE__,oss.str().c_str()); \
}
#define TTB_EXP_SEQ_S ( expression   ) 
Value:
{\
    std::ostringstream oss; \
    oss << expression; \
    TestToolBox::TestEvents::Get()->ExpectResultSequential  (__FILE__,__LINE__,oss.str().c_str()); \
}

Verify that the specified event value can be found at the current position or behind. The current position will be set to the position one afterwards of the found event position. Using this macro instead of TTB_EXP you explicitly allow a variable sequence of test events. You can use printf-syntax and specify additional arguments by using macros TTB_EXP_VAR1, TTB_EXP_VAR2.

#define TTB_EXP_VAR_S ( expression   ) 
Value:
{\
    std::ostringstream oss; \
    oss << expression; \
    TestToolBox::TestEvents::Get()->ExpectResultVariable  (__FILE__,__LINE__,oss.str().c_str()); \
}

Verify that one of the entries stored anywhere within TestEvents has the specified value. The current position will only be adjusted if the element is found at the current position. Using this macro instead of TTB_EXP you explicitly allow a variable sequence of test events. You can use printf-syntax and specify additional arguments by using macros TTB_EXP_VAR1, TTB_EXP_VAR2.

Generated on Fri May 27 22:49:22 2011 for TestToolBox by  doxygen 1.6.3