Unit Test Framework Modern C++ API Reference
C++ Utilities

A set of definitions to help writing unit tests for Modern C++ code. More...

Macros

#define RTI_TEST_WAIT(max_seconds__)
 Sleep for a given number of seconds. More...
 
#define RTI_TEST_WAIT_FOR(expression__, max_seconds__)
 Wait for an expression to become true. Otherwise, throw a TestFailure exception. More...
 
#define RTI_TEST_WAIT_FOR_EQUALS(expected__, actual__, max_seconds__)
 Wait for two values to become equal. Otherwise, throw a TestFailure exception. More...
 
#define RTI_TEST_WAIT_FOR_GREATER_OR_EQUALS(actual__, limit__, max_seconds__)
 Wait for a value to become equal to or greater than another one. Otherwise, throw a TestFailure exception. More...
 
#define RTI_TEST_WAIT_FOR_GREATER_OR_EQUALS_INT    RTI_TEST_WAIT_FOR_GREATER_OR_EQUALS
 Wait for an integer to become equal to or greater than another one. Otherwise, throw a TestFailure exception. More...
 
#define RTI_TEST_WAIT_FOR_EQUALS_INT   RTI_TEST_WAIT_FOR_EQUALS
 Wait for two given integers to become equal. More...
 

Detailed Description

A set of definitions to help writing unit tests for Modern C++ code.

Macro Definition Documentation

◆ RTI_TEST_WAIT

#define RTI_TEST_WAIT (   max_seconds__)
Value:
{ \
const struct RTITestTime sleepTime__ = { 0, 429496730 }; \
int sleeps__ = 0; \
while (sleeps__ < max_seconds__ * 10) { \
RTITest_sleep(&sleepTime__); \
++sleeps__; \
} \
}

Sleep for a given number of seconds.

Parameters
max_seconds__In. The number of seconds to sleep.

◆ RTI_TEST_WAIT_FOR

#define RTI_TEST_WAIT_FOR (   expression__,
  max_seconds__ 
)
Value:
{ \
/* 100ms */ \
const struct RTITestTime sleepTime__ = { 0, 429496730 }; \
int sleeps__ = 0; \
bool result__ = (expression__); \
while (!result__ && sleeps__ < max_seconds__ * 10) { \
RTITest_sleep(&sleepTime__); \
++sleeps__; \
result__ = (expression__); \
} \
if (!result__) { \
"" __FILE__, \
"" RTI_TEST_TOSTRING(__LINE__), \
"wait for condition failed: " #expression__); \
} \
}
Represents a test failure exception.
Definition: TestAssertion.hpp:42

Wait for an expression to become true. Otherwise, throw a TestFailure exception.

Parameters
expression__In. The expression to be evaluated.
max_seconds__In. The maximum number of seconds to wait for.

◆ RTI_TEST_WAIT_FOR_EQUALS

#define RTI_TEST_WAIT_FOR_EQUALS (   expected__,
  actual__,
  max_seconds__ 
)
Value:
{ \
try { \
RTI_TEST_WAIT_FOR((expected__) == (actual__), (max_seconds__)); \
} catch (const rti::test::TestFailure&) { \
print_assert_equals_failure(expected__, actual__); \
throw; \
} \
}

Wait for two values to become equal. Otherwise, throw a TestFailure exception.

Parameters
expected__In. The expected value.
actual__In. The actual value.
max_seconds__In. The maximum number of seconds to wait for.

◆ RTI_TEST_WAIT_FOR_GREATER_OR_EQUALS

#define RTI_TEST_WAIT_FOR_GREATER_OR_EQUALS (   actual__,
  limit__,
  max_seconds__ 
)
Value:
{ \
try { \
RTI_TEST_WAIT_FOR((actual__) >= (limit__), (max_seconds__)); \
} catch (const rti::test::TestFailure&) { \
print_assert_equals_failure(limit__, actual__); \
throw; \
} \
}

Wait for a value to become equal to or greater than another one. Otherwise, throw a TestFailure exception.

Parameters
actual__In. The actual value.
limit__In. The limit value.
max_seconds__In. The maximum number of seconds to wait for.

◆ RTI_TEST_WAIT_FOR_GREATER_OR_EQUALS_INT

#define RTI_TEST_WAIT_FOR_GREATER_OR_EQUALS_INT    RTI_TEST_WAIT_FOR_GREATER_OR_EQUALS

Wait for an integer to become equal to or greater than another one. Otherwise, throw a TestFailure exception.

Parameters
actual__In. The actual value.
limit__In. The limit value.
max_seconds__In. The maximum number of seconds to wait for.

◆ RTI_TEST_WAIT_FOR_EQUALS_INT

#define RTI_TEST_WAIT_FOR_EQUALS_INT   RTI_TEST_WAIT_FOR_EQUALS

Wait for two given integers to become equal.

Parameters
expected__In. The expected value.
actual__In. The actual value.
max_seconds__In. The maximum number of seconds to wait for.