le_test.h File Reference
Go to the source code of this file.
Macros | |
#define | LE_TEST_NO_PLAN -1 |
#define | LE_TEST_PLAN(testCount) |
#define | LE_TEST_INIT LE_TEST_PLAN(LE_TEST_NO_PLAN) |
#define | LE_TEST_OK(test, testName, ...) |
#define | LE_TEST(testResult) LE_TEST_OK((testResult), #testResult) |
#define | LE_TEST_FATAL(...) |
#define | LE_TEST_ASSERT(test, testName, ...) |
#define | LE_TEST_INFO(...) LE_TEST_OUTPUT("# " __VA_ARGS__) |
#define | LE_TEST_BEGIN_TODO(cond) |
#define | LE_TEST_END_TODO() |
#define | LE_TEST_BEGIN_SKIP(cond, count) |
#define | LE_TEST_END_SKIP() } while(0) |
#define | LE_TEST_EXIT |
#define | LE_TEST_SUMMARY LE_TEST_EXIT |
DEPRECATED old name for LE_TEST_EXIT. | |
Local definitions that should not be used directly. | |
#define | LE_TEST_OUTPUT(format, ...) LE_INFO("TAP | " format, ##__VA_ARGS__) |
void | _le_test_Init (int testCount) |
void | _le_test_Exit (void) |
bool | _le_test_CheckNeedsPlan (void) |
void | _le_test_Fail (void) |
int | _le_test_NumberTest (void) |
int | _le_test_GetNumTests (void) |
int | _le_test_GetNumFailures (void) |
bool | _le_test_SetTodo (bool todo) |
void | _le_test_Skip (int count) |
bool | _le_test_IsSkipping (void) |
const char * | _le_test_GetTag (void) |
Detailed Description
Legato Unit Testing API include file.
Copyright (C) Sierra Wireless Inc.
Macro Definition Documentation
◆ LE_TEST
#define LE_TEST | ( | testResult | ) | LE_TEST_OK((testResult), #testResult) |
Performs the test.
For new tests, LE_TEST_OK is preferred which gives an option to set the test name.
◆ LE_TEST_ASSERT
#define LE_TEST_ASSERT | ( | test, | |
testName, | |||
... | |||
) |
do { \if (test) \{ \LE_TEST_OUTPUT("ok %d - " testName "%s", \_le_test_NumberTest(), \##__VA_ARGS__, \_le_test_GetTag()); \} \else \{ \LE_TEST_OUTPUT("not ok %d - " testName "%s", \_le_test_NumberTest(), \##__VA_ARGS__, \_le_test_GetTag()); \_le_test_Fail(); \LE_TEST_FATAL(); \} \} while(0)
Perform a test, and bail out if the test fails.
This should only be used if a test suite cannot continue if this test fails. Generally LE_TEST_OK should be used instead.
◆ LE_TEST_BEGIN_SKIP
#define LE_TEST_BEGIN_SKIP | ( | cond, | |
count | |||
) |
do { \if (cond) \{ \_le_test_Skip(count); \break; \}
Mark a test as skipped. Skipped tests will not be run, and will always pass.
Begins a block which must be terminated by LE_TEST_END_SKIP()
◆ LE_TEST_BEGIN_TODO
#define LE_TEST_BEGIN_TODO | ( | cond | ) |
do { \bool _le_test_OldTodo = _le_test_SetTodo(cond); \
Mark a test as not yet implemented. Todo tests will still be run, but are expected to fail.
Begins a block which must be terminated by LE_TEST_END_TODO()
◆ LE_TEST_END_SKIP
#define LE_TEST_END_SKIP | ( | ) | } while(0) |
End a block of tests which may not be implemented yet.
◆ LE_TEST_END_TODO
#define LE_TEST_END_TODO | ( | ) |
_le_test_SetTodo(_le_test_OldTodo); \} while(0)
End a block of tests which may not be implemented yet.
◆ LE_TEST_EXIT
#define LE_TEST_EXIT |
do { \if (_le_test_CheckNeedsPlan()) \{ \LE_TEST_OUTPUT("1..%d", _le_test_GetNumTests()); \} \_le_test_Exit(); \} while(0)
Exits the process and returns the number of failed tests.
◆ LE_TEST_FATAL
#define LE_TEST_FATAL | ( | ... | ) |
do { \LE_TEST_OUTPUT("Bail out! " __VA_ARGS__); \_le_test_Exit(); \} while(0)
Bail out of a test suite early.
Using this instead of LE_FATAL ensures the test harness is notified the test suite is exiting abnormally.
◆ LE_TEST_INFO
#define LE_TEST_INFO | ( | ... | ) | LE_TEST_OUTPUT("# " __VA_ARGS__) |
Ouptut some diagnostic information. In tests this should be used instead of LE_INFO so the output appears in the test results
◆ LE_TEST_INIT
#define LE_TEST_INIT LE_TEST_PLAN(LE_TEST_NO_PLAN) |
Initializes the testing framework. Must be called once before any tests are performed.
Obselete synonym for LE_TEST_PLAN(LE_TEST_NO_PLAN)
◆ LE_TEST_NO_PLAN
#define LE_TEST_NO_PLAN -1 |
Indicate the number of tests is not known in advance.
◆ LE_TEST_OK
#define LE_TEST_OK | ( | test, | |
testName, | |||
... | |||
) |
do { \if (test) \{ \LE_TEST_OUTPUT("ok %d - " testName "%s", \_le_test_NumberTest(), \##__VA_ARGS__, \_le_test_GetTag()); \} \else \{ \LE_TEST_OUTPUT("not ok %d - " testName "%s", \_le_test_NumberTest(), \##__VA_ARGS__, \_le_test_GetTag()); \_le_test_Fail(); \} \} while(0)
Perform the test
◆ LE_TEST_PLAN
#define LE_TEST_PLAN | ( | testCount | ) |
do { \if (testCount >= 0) { LE_TEST_OUTPUT("1..%d", testCount); } \_le_test_Init(testCount); \} while(0)
Initializes a test plan. Must be called once before any tests are performed.
- Parameters
-
testCount Number of tests expected in this test case.