ADTF  v2.14.3
testmacros.h File Reference

Test macros. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 adtf_util
 The adtf_util defines the namespace for all functionality that is provided by the definitions and the default implementations within the library adtfutilXXX.a/ adtfutilXXX.lib.
 

Macros

#define __a_utils_test_assert(_msg, _expr)   _assert((_expr), __FILE__, __LINE__)
 This macro creates an assertion if the expression fails using the given message. More...
 
#define __a_utils_test_report(_msg)   _assert(false, __FILE__, __LINE__)
 This macro creates an assertion using the given message. More...
 
#define __a_utils_test_log(_msg)   printf("%s(%d) %s\n", __FILE__, __LINE__, A_UTILS_NS::cString(_msg).GetPtr())
 This macro logs the given message to the standard output. More...
 
#define __a_utils_log_test_fail(_msg, _expr, _umsg)
 Logs a failed test and trows an exception. More...
 
#define __a_utils_log_test_succ(_msg, _expr, _umsg)
 Logs a successful test. More...
 
#define __a_utils_log_test(_msg, _expr)
 This macro. More...
 
#define __a_utils_log_test_ext(_msg, _expr, _umsg)
 This macro. More...
 
#define __a_utils_test(_expr)   __a_utils_log_test("test failed: (" #_expr ")", (_expr))
 This macro checks if the return value of the expression is true (bool) More...
 
#define __a_utils_test_err(_expr)   __a_utils_log_test("bad case test failed: (" #_expr ")", (!(_expr)))
 This macro checks if the return value of the expression is false (bool). More...
 
#define __a_utils_test_result(_expr)
 This macro checks the return value of the expression for equality to ERR_NOERROR (tResult) To report the result the __a_utils_log_test macro is used. More...
 
#define __a_utils_test_err_result(_expr)   __a_utils_log_test("bad case test failed: IS_FAILED(" #_expr ")", (IS_FAILED(_expr)))
 This macro checks the return value of the expression for inequality to ERR_NOERROR (tResult) To report the result the __a_utils_log_test macro is used. More...
 
#define __a_utils_test_pointer(_ptr)   __a_utils_log_test("test failed: (" #_ptr " != NULL)", ((_ptr)!=NULL))
 This macro checks the pointer to inequality to NULL To report the result the __a_utils_log_test macro is used. More...
 
#define __a_utils_test_pointer_null(_ptr)   __a_utils_log_test("bad case test failed: (" #_ptr " != NULL)", ((_ptr)==NULL))
 This macro checks the pointer to equality to NULL To report the result the __a_utils_log_test macro is used. More...
 
#define __a_utils_test_ext(_expr, _msg)   __a_utils_log_test_ext("test failed: (" #_expr ")", (_expr), (_msg))
 The same as __a_utils_test with an additional message To report the result the __a_utils_log_test_ext macro is used. More...
 
#define __a_utils_test_err_ext(_expr, _msg)   __a_utils_log_test_ext("bad case test failed: (" #_expr ")", (!(_expr)), (_msg))
 The same as __a_utils_test_err with an additional message. More...
 
#define __a_utils_test_result_ext(_expr, _msg)
 The same as __a_utils_test_result with an additional message. More...
 
#define __a_utils_test_err_result_ext(_expr, _msg)   __a_utils_log_test_ext("bad case test failed: IS_FAILED(" #_expr ")", (IS_FAILED(_expr)), (_msg))
 The same as __a_utils_test_err_result with an additional message. More...
 
#define __a_utils_test_pointer_ext(_ptr, _msg)   __a_utils_log_test_ext("test failed: (" #_ptr " != NULL)", ((_ptr)!=NULL), (_msg))
 The same as __a_utils_test_pointer with an additional message. More...
 
#define __a_utils_test_pointer_null_ext(_ptr, _msg)   __a_utils_log_test_ext("bad case test failed: (" #_ptr " != NULL)", ((_ptr)==NULL), (_msg))
 The same as __a_utils_test_pointer_null with an additional message. More...
 
#define __a_utils_test_file_exists(_filename)   __a_utils_test_ext(A_UTILS_NS::cFileSystem::Exists(_filename) == tTrue, _filename + A_UTILS_NS::cString(" does not exist"));
 The macro checks if the given file with the filename does exist. More...
 
#define DECLARE_TESTER_FRIEND(_tester, _whitebox)
 This macro declares a new class base on class /a _whitebox which is friend of class /a _tester. More...
 
#define __a_utils_test_friend(_whitebox)   _testable_##_whitebox
 This macro defines the name of the whitebox test class based on class /a _whitebox.
 
#define RETURN_TEST_NOERROR   /* */
 This macro returns value if test is OK. More...
 
#define RETURN_TEST_ERROR(_code)   /* */
 This macro returns _code if test failes. More...
 
#define DECLARE_TESTER_CLASS(_classname)   class _classname : public ITester
 This macro has to be used to declare a new tester class. More...
 
#define BEGIN_TESTER_MAP(_classname)
 This macro creates the tester map. More...
 
#define DECLARE_TESTER_FUNCTION(_func)
 This macro defines a test that will be executed. More...
 
#define END_TESTER_MAP()
 This macro closes the tester map. More...
 
#define DECLARE_TESTER_CLASS(_classname)   class _classname : public ITester
 This macro has to be used to declare a new tester class. More...
 
#define IMPLEMENT_TESTER_CLASS(_classname, _id, _title, _desc, _req)
 This macro implements a conrete test class / test group. More...
 

Detailed Description

Test macros.

Copyright © Audi Electronics Venture GmbH. All rights reserved

Author
ENACJEN
Date
2014-10-23 17:15:03 +0200 (Do, 23 Okt 2014)
Revision
1121
Remarks

Definition in file testmacros.h.

Macro Definition Documentation

#define __a_utils_log_test (   _msg,
  _expr 
)
Value:
if (!(_expr)) \
{ \
__a_utils_log_test_fail(_msg, _expr, NULL) \
} \
else \
{ \
__a_utils_log_test_succ(_msg, _expr, NULL) \
}

This macro.

Parameters
[in]_msgAdditional information which will be logged
[in]_exprThe expression which will be executed

Definition at line 341 of file testmacros.h.

#define __a_utils_log_test_ext (   _msg,
  _expr,
  _umsg 
)
Value:
if (!(_expr)) \
{ \
__a_utils_log_test_fail(_msg, _expr, _umsg) \
} \
else \
{ \
__a_utils_log_test_succ(_msg, _expr, _umsg) \
}

This macro.

Parameters
[in]_msgAdditional information which will be logged
[in]_exprThe expression which will be executed
[in]_umsgUser defined message

Definition at line 359 of file testmacros.h.

#define __a_utils_log_test_fail (   _msg,
  _expr,
  _umsg 
)
Value:
{ \
__get_testbench()->Log(ITestBench::TEST_LOG_FAILED, _msg, #_expr, __FILE__, __LINE__, __FUNCTION__, _umsg); \
throw "test failed"; \
}
log when failed
Definition: testbench.h:189

Logs a failed test and trows an exception.

Parameters
[in]_msgAdditional information which will be logged
[in]_exprThe expression which failed
[in]_umsgAdditional message that is logged (can be NULL)

Definition at line 317 of file testmacros.h.

#define __a_utils_log_test_succ (   _msg,
  _expr,
  _umsg 
)
Value:
{ \
__get_testbench()->Log(ITestBench::TEST_LOG_PASSED, _msg, #_expr, __FILE__, __LINE__, __FUNCTION__, _umsg); \
}
log when passed
Definition: testbench.h:188

Logs a successful test.

Parameters
[in]_msgAdditional information which will be logged
[in]_exprThe expression which failed
[in]_umsgAdditional message that is logged (can be NULL)

Definition at line 329 of file testmacros.h.

#define __a_utils_test (   _expr)    __a_utils_log_test("test failed: (" #_expr ")", (_expr))

This macro checks if the return value of the expression is true (bool)

Parameters
[in]_exprThe expression which will be executed

Definition at line 376 of file testmacros.h.

#define __a_utils_test_assert (   _msg,
  _expr 
)    _assert((_expr), __FILE__, __LINE__)

This macro creates an assertion if the expression fails using the given message.

Parameters
[in]_msgAdditional information which will be logged
[in]_exprThe expression which will be executed

Definition at line 74 of file testmacros.h.

#define __a_utils_test_err (   _expr)    __a_utils_log_test("bad case test failed: (" #_expr ")", (!(_expr)))

This macro checks if the return value of the expression is false (bool).

To report the result the __a_utils_log_test macro is used.

Parameters
[in]_exprThe expression which will be executed

Definition at line 387 of file testmacros.h.

#define __a_utils_test_err_ext (   _expr,
  _msg 
)    __a_utils_log_test_ext("bad case test failed: (" #_expr ")", (!(_expr)), (_msg))

The same as __a_utils_test_err with an additional message.

Parameters
[in]_exprThe expression which will be executed
[in]_msgAdditional information which will be logged

Definition at line 465 of file testmacros.h.

#define __a_utils_test_err_result (   _expr)    __a_utils_log_test("bad case test failed: IS_FAILED(" #_expr ")", (IS_FAILED(_expr)))

This macro checks the return value of the expression for inequality to ERR_NOERROR (tResult) To report the result the __a_utils_log_test macro is used.

Parameters
[in]_exprThe expression which will be executed

Definition at line 420 of file testmacros.h.

#define __a_utils_test_err_result_ext (   _expr,
  _msg 
)    __a_utils_log_test_ext("bad case test failed: IS_FAILED(" #_expr ")", (IS_FAILED(_expr)), (_msg))

The same as __a_utils_test_err_result with an additional message.

Parameters
[in]_exprThe expression which will be executed
[in]_msgAdditional information which will be logged

Definition at line 498 of file testmacros.h.

#define __a_utils_test_ext (   _expr,
  _msg 
)    __a_utils_log_test_ext("test failed: (" #_expr ")", (_expr), (_msg))

The same as __a_utils_test with an additional message To report the result the __a_utils_log_test_ext macro is used.

Parameters
[in]_exprThe expression which will be executed
[in]_msgAdditional information which will be logged

Definition at line 454 of file testmacros.h.

#define __a_utils_test_file_exists (   _filename)    __a_utils_test_ext(A_UTILS_NS::cFileSystem::Exists(_filename) == tTrue, _filename + A_UTILS_NS::cString(" does not exist"));

The macro checks if the given file with the filename does exist.

To report the result the __a_utils_test_ext macro is used.

Parameters
[in]_filenameThe filename which will be checked

Definition at line 531 of file testmacros.h.

#define __a_utils_test_log (   _msg)    printf("%s(%d) %s\n", __FILE__, __LINE__, A_UTILS_NS::cString(_msg).GetPtr())

This macro logs the given message to the standard output.

Parameters
[in]_msgAdditional information which will be logged

Definition at line 94 of file testmacros.h.

#define __a_utils_test_pointer (   _ptr)    __a_utils_log_test("test failed: (" #_ptr " != NULL)", ((_ptr)!=NULL))

This macro checks the pointer to inequality to NULL To report the result the __a_utils_log_test macro is used.

Parameters
[in]_ptrThe pointer which will be checked

Definition at line 431 of file testmacros.h.

#define __a_utils_test_pointer_ext (   _ptr,
  _msg 
)    __a_utils_log_test_ext("test failed: (" #_ptr " != NULL)", ((_ptr)!=NULL), (_msg))

The same as __a_utils_test_pointer with an additional message.

Parameters
[in]_ptrThe pointer which will be checked
[in]_msgAdditional information which will be logged

Definition at line 509 of file testmacros.h.

#define __a_utils_test_pointer_null (   _ptr)    __a_utils_log_test("bad case test failed: (" #_ptr " != NULL)", ((_ptr)==NULL))

This macro checks the pointer to equality to NULL To report the result the __a_utils_log_test macro is used.

Parameters
[in]_ptrThe pointer which will be checked

Definition at line 442 of file testmacros.h.

#define __a_utils_test_pointer_null_ext (   _ptr,
  _msg 
)    __a_utils_log_test_ext("bad case test failed: (" #_ptr " != NULL)", ((_ptr)==NULL), (_msg))

The same as __a_utils_test_pointer_null with an additional message.

Parameters
[in]_ptrThe pointer which will be checked
[in]_msgAdditional information which will be logged

Definition at line 520 of file testmacros.h.

#define __a_utils_test_report (   _msg)    _assert(false, __FILE__, __LINE__)

This macro creates an assertion using the given message.

Parameters
[in]_msgAdditional information which will be logged

Definition at line 84 of file testmacros.h.

#define __a_utils_test_result (   _expr)
Value:
{\
tResult __nHelperResult = _expr; \
if (IS_FAILED(__nHelperResult)) \
{\
__a_utils_test_log(A_UTILS_NS::cString::Format(#_expr " returned error code: %d", __nHelperResult));\
__a_utils_log_test_fail("test failed: IS_OK(" #_expr ")", IS_OK(_expr), NULL);\
}\
else \
{ \
__a_utils_log_test_succ("test failed: IS_OK(" #_expr ")", IS_OK(_expr), NULL);\
} \
}
#define IS_FAILED(s)
Check if result is failed.
Definition: error.h:41
#define IS_OK(s)
Check if result is OK.
Definition: error.h:38

This macro checks the return value of the expression for equality to ERR_NOERROR (tResult) To report the result the __a_utils_log_test macro is used.

Parameters
[in]_exprThe expression which will be executed

Definition at line 398 of file testmacros.h.

#define __a_utils_test_result_ext (   _expr,
  _msg 
)
Value:
{\
tResult __nHelperResult = _expr; \
if (IS_FAILED(__nHelperResult)) \
{\
__a_utils_test_log(A_UTILS_NS::cString::Format(#_expr " returned error code: %d", __nHelperResult));\
__a_utils_log_test_fail("test failed: IS_OK(" #_expr ")", IS_OK(_expr), (_msg));\
}\
else \
{ \
__a_utils_log_test_succ("test failed: IS_OK(" #_expr ")", IS_OK(_expr), (_msg));\
} \
}
#define IS_FAILED(s)
Check if result is failed.
Definition: error.h:41
#define IS_OK(s)
Check if result is OK.
Definition: error.h:38

The same as __a_utils_test_result with an additional message.

Parameters
[in]_exprThe expression which will be executed
[in]_msgAdditional information which will be logged

Definition at line 476 of file testmacros.h.

#define BEGIN_TESTER_MAP (   _classname)
Value:
public: \
_classname(); \
const char* getClassName(); \
virtual void run() {
tResult run(int argc, const char *argv[])
Processing loop of the program.
Definition: console_app.cpp:33

This macro creates the tester map.

all tests that will be executed are inserted between BEGIN_TESTER_MAP and END_TESTER_MAP

Parameters
[in]_classnamename of the test implementation class

Definition at line 592 of file testmacros.h.

#define DECLARE_TESTER_CLASS (   _classname)    class _classname : public ITester

This macro has to be used to declare a new tester class.

This macro creates the basic testclass implementation.

This has to be done at least once for a test.

Parameters
[in]_classnameThe class name i.e. cTesterAlsaPlayback
[in]_classnameThe class which includes the test cases (functions)

Definition at line 641 of file testmacros.h.

#define DECLARE_TESTER_CLASS (   _classname)    class _classname : public ITester

This macro has to be used to declare a new tester class.

This macro creates the basic testclass implementation.

This has to be done at least once for a test.

Parameters
[in]_classnameThe class name i.e. cTesterAlsaPlayback
[in]_classnameThe class which includes the test cases (functions)

Definition at line 641 of file testmacros.h.

#define DECLARE_TESTER_FRIEND (   _tester,
  _whitebox 
)
Value:
class _testable_##_whitebox : public _whitebox \
{ friend class _tester; };

This macro declares a new class base on class /a _whitebox which is friend of class /a _tester.

Definition at line 544 of file testmacros.h.

#define DECLARE_TESTER_FUNCTION (   _func)
Value:
extern tTestDoc sFunctionDoc_##_func; \
__get_testbench()->LogStartFunction(&sFunctionDoc_##_func); \
if (sFunctionDoc_##_func.bActive) \
{ \
try \
{ \
setUp(); \
_func(); \
} \
catch (const char*) { } \
try \
{ \
tearDown(); \
} \
catch (const char*) { } \
} \
__get_testbench()->LogStopFunction(&sFunctionDoc_##_func); \
This structure defines a test case.
Definition: testbench.h:23

This macro defines a test that will be executed.

Parameters
[in]_funcThe name of the test function

Definition at line 605 of file testmacros.h.

#define END_TESTER_MAP ( )
Value:
} \
tTestGroupDoc* getDoc();

This macro closes the tester map.

See also
BEGIN_TESTER_MAP

Definition at line 630 of file testmacros.h.

#define IMPLEMENT_TESTER_CLASS (   _classname,
  _id,
  _title,
  _desc,
  _req 
)
Value:
static _classname _instance_##_classname; \
_classname::_classname() \
const char* _classname::getClassName() \
{ return #_classname; } \
tTestGroupDoc* _classname::getDoc() \
{ \
static tTestGroupDoc sDoc= { _id, _title, _desc, _req }; \
return &sDoc; \
}
ITestBench * __get_testbench()
This function will return the pointer to the currently active test bench.
virtual void RegisterTester(ITester *pTester)=0
Registers a new tester at the test bench.
This structure defines a group of test cases.
Definition: testbench.h:40

This macro implements a conrete test class / test group.

Parameters
[in]_classnameName of the testclass
[in]_idIdentifier of the group
[in]_titleTitle of the group
[in]_descProvides a short description
[in]_reqLinks to the related requirements

Definition at line 740 of file testmacros.h.

#define RETURN_TEST_ERROR (   _code)    /* */

This macro returns _code if test failes.

Parameters
[in]_codereturn code

Definition at line 571 of file testmacros.h.

#define RETURN_TEST_NOERROR   /* */

This macro returns value if test is OK.

Definition at line 562 of file testmacros.h.


Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Fri Mar 22 2019 by doxygen 1.8.10)