Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Macros
vtkAddonTestingMacros.h File Reference
#include <vtkAddonTestingUtilities.h>
#include "vtkNew.h"
#include "vtkTestingOutputWindow.h"
Include dependency graph for vtkAddonTestingMacros.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CHECK_BOOL(actual, expected)
 Verifies if actual bool value is the same as expected. More...
 
#define CHECK_DOUBLE(actual, expected)
 Verifies if actual double value is the same as expected. More...
 
#define CHECK_DOUBLE_TOLERANCE(actual, expected, tolerance)
 Verifies if actual double value is the same as expected, within the specified tolerance. More...
 
#define CHECK_EXIT_SUCCESS(actual)
 
#define CHECK_INT(actual, expected)
 Verifies if actual int value is the same as expected. More...
 
#define CHECK_INT_ADD_REPORT(actual, expected, methodToCallOnFailure)
 
#define CHECK_NOT_NULL(pointer)
 Verifies that pointer is not NULL. More...
 
#define CHECK_NOT_NULL_ADD_REPORT(pointer, methodToCallOnFailure)
 
#define CHECK_NULL(pointer)
 Verifies that pointer is NULL. More...
 
#define CHECK_POINTER(actual, expected)
 Verifies if actual pointer value is the same as expected. More...
 
#define CHECK_POINTER_DIFFERENT(actual, expected)
 Verifies if actual pointer value is the same as expected. More...
 
#define CHECK_STD_STRING(actual, expected)
 
#define CHECK_STD_STRING_DIFFERENT(actual, expected)
 
#define CHECK_STRING(actual, expected)
 
#define CHECK_STRING_ADD_REPORT(actual, expected, methodToCallOnFailure)
 
#define CHECK_STRING_DIFFERENT(actual, expected)
 

Macro Definition Documentation

◆ CHECK_BOOL

#define CHECK_BOOL (   actual,
  expected 
)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckInt(__LINE__,#actual " != " #expected, (actual)?1:0, (expected)?1:0)) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckInt(int line, const std::string &description, int current, int expected)

Verifies if actual bool value is the same as expected.

Definition at line 147 of file vtkAddonTestingMacros.h.

◆ CHECK_DOUBLE

#define CHECK_DOUBLE (   actual,
  expected 
)
Value:
{ \
if (!vtkAddonTestingUtilities::Check<double>(__LINE__,#actual " != " #expected, (actual), (expected), "CheckDouble")) \
{ \
return EXIT_FAILURE; \
} \
}

Verifies if actual double value is the same as expected.

Definition at line 91 of file vtkAddonTestingMacros.h.

◆ CHECK_DOUBLE_TOLERANCE

#define CHECK_DOUBLE_TOLERANCE (   actual,
  expected,
  tolerance 
)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckDoubleTolerance(__LINE__,#actual " != " #expected " (tolerance: " #tolerance ")", (actual), (expected), (tolerance))) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckDoubleTolerance(int line, const std::string &description, double current, double expected, double tolerance)

Verifies if actual double value is the same as expected, within the specified tolerance.

Definition at line 100 of file vtkAddonTestingMacros.h.

◆ CHECK_EXIT_SUCCESS

#define CHECK_EXIT_SUCCESS (   actual)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckInt(__LINE__,#actual " != EXIT_SUCCESS", (actual), EXIT_SUCCESS)) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckInt(int line, const std::string &description, int current, int expected)

Definition at line 82 of file vtkAddonTestingMacros.h.

◆ CHECK_INT

#define CHECK_INT (   actual,
  expected 
)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckInt(__LINE__,#actual " != " #expected, (actual), (expected))) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckInt(int line, const std::string &description, int current, int expected)

Verifies if actual int value is the same as expected.

Definition at line 109 of file vtkAddonTestingMacros.h.

◆ CHECK_INT_ADD_REPORT

#define CHECK_INT_ADD_REPORT (   actual,
  expected,
  methodToCallOnFailure 
)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckInt(__LINE__,#actual " != " #expected, (actual), (expected))) \
{ \
methodToCallOnFailure; \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckInt(int line, const std::string &description, int current, int expected)

Verifies if actual int value is the same as expected, if check fails then it calls methodToCallOnFailure before returning with failure

Definition at line 119 of file vtkAddonTestingMacros.h.

◆ CHECK_NOT_NULL

#define CHECK_NOT_NULL (   pointer)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckNotNull(__LINE__,#pointer " is NULL", (pointer))) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckNotNull(int line, const std::string &description, const void *pointer)

Verifies that pointer is not NULL.

Definition at line 63 of file vtkAddonTestingMacros.h.

◆ CHECK_NOT_NULL_ADD_REPORT

#define CHECK_NOT_NULL_ADD_REPORT (   pointer,
  methodToCallOnFailure 
)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckNotNull(__LINE__,#pointer " is NULL", (pointer))) \
{ \
methodToCallOnFailure; \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckNotNull(int line, const std::string &description, const void *pointer)

Verifies that pointer is NULL, if check fails then it calls methodToCallOnFailure before returning with failure

Definition at line 73 of file vtkAddonTestingMacros.h.

◆ CHECK_NULL

#define CHECK_NULL (   pointer)
Value:
{ \
const void* pointerValue = (pointer); \
if (!vtkAddonTestingUtilities::CheckNull(__LINE__,#pointer " is not NULL", pointerValue)) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckNull(int line, const std::string &description, const void *pointer)

Verifies that pointer is NULL.

Convenience macros for unit tests.

The macro returns from the current method with EXIT_FAILURE if the check fails. Expressions can be passed as arguments, they are guaranteed to be executed only once.

Example:

int testedFunction(int a, int b) { return a+b; }
int MyTest1(int , char * [])
{
int current = 40 + 2;
int expected = 42;
CHECK_INT(current, expected);
CHECK_INT(testedFunction(40,2), 42);
CHECK_INT(testedFunction(35,5), 40);
return EXIT_SUCCESS;
}

Definition at line 53 of file vtkAddonTestingMacros.h.

◆ CHECK_POINTER

#define CHECK_POINTER (   actual,
  expected 
)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckPointer(__LINE__,#actual " != " #expected, (actual), (expected))) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckPointer(int line, const std::string &description, void *current, void *expected, bool errorIfDifferent=true)

Verifies if actual pointer value is the same as expected.

Definition at line 129 of file vtkAddonTestingMacros.h.

◆ CHECK_POINTER_DIFFERENT

#define CHECK_POINTER_DIFFERENT (   actual,
  expected 
)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckPointer(__LINE__,#actual " == " #expected, (actual), (expected), false)) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckPointer(int line, const std::string &description, void *current, void *expected, bool errorIfDifferent=true)

Verifies if actual pointer value is the same as expected.

Definition at line 138 of file vtkAddonTestingMacros.h.

◆ CHECK_STD_STRING

#define CHECK_STD_STRING (   actual,
  expected 
)
Value:
{ \
std::string a = (actual); \
std::string e = (expected); \
if (!vtkAddonTestingUtilities::CheckString(__LINE__,#actual " != " #expected, a.c_str(), e.c_str())) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckString(int line, const std::string &description, const char *current, const char *expected, bool errorIfDifferent=true)

Verifies if actual std::string value is the same as expected. It is safe to use for comparing std::string values. It cannot handle NULL pointer inputs.

Definition at line 168 of file vtkAddonTestingMacros.h.

◆ CHECK_STD_STRING_DIFFERENT

#define CHECK_STD_STRING_DIFFERENT (   actual,
  expected 
)
Value:
{ \
std::string a = (actual); \
std::string e = (expected); \
if (!vtkAddonTestingUtilities::CheckString(__LINE__,#actual " != " #expected, a.c_str(), e.c_str(), false)) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckString(int line, const std::string &description, const char *current, const char *expected, bool errorIfDifferent=true)

Verifies if actual std::string value is not the same as expected. It is safe to use for comparing std::string values. It cannot handle NULL pointer inputs.

Definition at line 203 of file vtkAddonTestingMacros.h.

◆ CHECK_STRING

#define CHECK_STRING (   actual,
  expected 
)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckString(__LINE__,#actual " != " #expected, (actual), (expected))) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckString(int line, const std::string &description, const char *current, const char *expected, bool errorIfDifferent=true)

Verifies if actual const char* value is the same as expected. It can handle NULL pointer inputs.

Definition at line 157 of file vtkAddonTestingMacros.h.

◆ CHECK_STRING_ADD_REPORT

#define CHECK_STRING_ADD_REPORT (   actual,
  expected,
  methodToCallOnFailure 
)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckString(__LINE__,#actual " != " #expected, (actual), (expected))) \
{ \
methodToCallOnFailure; \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckString(int line, const std::string &description, const char *current, const char *expected, bool errorIfDifferent=true)

Verifies if actual const char* value is the same as expected, if check fails then it calls methodToCallOnFailure before returning with failure It can handle NULL pointer inputs.

Definition at line 181 of file vtkAddonTestingMacros.h.

◆ CHECK_STRING_DIFFERENT

#define CHECK_STRING_DIFFERENT (   actual,
  expected 
)
Value:
{ \
if (!vtkAddonTestingUtilities::CheckString(__LINE__,#actual " != " #expected, (actual), (expected), false)) \
{ \
return EXIT_FAILURE; \
} \
}
VTK_ADDON_EXPORT bool CheckString(int line, const std::string &description, const char *current, const char *expected, bool errorIfDifferent=true)

Verifies if actual const char* value is not the same as expected. It can handle NULL pointer inputs.

Definition at line 192 of file vtkAddonTestingMacros.h.