diff -r 92e482410453 -r d345541018fa docs/api-2.1/test_8h.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/api-2.1/test_8h.html Sat Feb 06 19:11:44 2021 +0100 @@ -0,0 +1,547 @@ + + +
+ + + + +![]() |
+
+ ucx
+
+ UAP Common Extensions
+ |
+
UCX Test Framework. +More...
+ +Go to the source code of this file.
++Data Structures | |
| struct | UcxTestList |
| Structure for the internal list of test cases. More... | |
| struct | UcxTestSuite |
| A test suite containing multiple test cases. More... | |
+Macros | |
| #define | __FUNCTION__ __func__ |
Alias for the __func__ preprocessor macro. More... | |
| #define | UCX_TEST(name) void name(UcxTestSuite* _suite_,FILE *_output_) |
| Macro for a UcxTest function header. More... | |
| #define | UCX_TEST_BEGIN |
| Marks the begin of a test. More... | |
| #define | UCX_TEST_ASSERT(condition, message) |
| Checks a test assertion. More... | |
| #define | UCX_TEST_SUBROUTINE(name, ...) |
| Macro for a test subroutine function header. More... | |
| #define | UCX_TEST_CALL_SUBROUTINE(name, ...) name(_suite_,_output_,_env_,__VA_ARGS__); |
| Macro for calling a test subroutine. More... | |
| #define | UCX_TEST_END fwrite("success.\n", 1, 9, _output_); _suite_->success++;} |
| Marks the end of a test. More... | |
+Typedefs | |
| typedef struct UcxTestSuite | UcxTestSuite |
| Type for the UcxTestSuite. More... | |
| typedef void(* | UcxTest) (UcxTestSuite *, FILE *) |
| Pointer to a test function. More... | |
| typedef struct UcxTestList | UcxTestList |
| Type for the internal list of test cases. More... | |
+Functions | |
| UcxTestSuite * | ucx_test_suite_new () |
| Creates a new test suite. More... | |
| void | ucx_test_suite_free (UcxTestSuite *suite) |
| Destroys a test suite. More... | |
| int | ucx_test_register (UcxTestSuite *suite, UcxTest test) |
| Registers a test function with the specified test suite. More... | |
| void | ucx_test_run (UcxTestSuite *suite, FILE *outstream) |
| Runs a test suite and writes the test log to the specified stream. More... | |
UCX Test Framework.
+Usage of this test framework:
+**** IN HEADER FILE: ****
++UCX_TEST(function_name); +UCX_TEST_SUBROUTINE(subroutine_name, paramlist); // optional +
**** IN SOURCE FILE: ****
+UCX_TEST_SUBROUTINE(subroutine_name, paramlist) { + // tests with UCX_TEST_ASSERT() +}
UCX_TEST(function_name) { + // memory allocation and other stuff here + UCX_TEST_BEGIN + // tests with UCX_TEST_ASSERT() and/or + // calls with UCX_TEST_CALL_SUBROUTINE() here + UCX_TEST_END + // cleanup of memory here +} +
Note: if a test fails, a longjump is performed back to the UCX_TEST_BEGIN macro!
+Attention: Do not call own functions within a test, that use UCX_TEST_ASSERT() macros and are not defined by using UCX_TEST_SUBROUTINE().
+ +| #define __FUNCTION__ __func__ | +
Alias for the __func__ preprocessor macro.
Some compilers use __func__ and others use FUNCTION. We use FUNCTION so we define it for those compilers which use __func__.
| #define UCX_TEST | +( | ++ | name | ) | +void name(UcxTestSuite* _suite_,FILE *_output_) | +
| #define UCX_TEST_ASSERT | +( | ++ | condition, | +
| + | + | + | message | +
| + | ) | ++ |
Checks a test assertion.
+If the assertion is correct, the test carries on. If the assertion is not correct, the specified message (terminated by a dot and a line break) is written to the test suites output stream.
| condition | the condition to check |
| message | the message that shall be printed out on failure |
| #define UCX_TEST_BEGIN | +
Marks the begin of a test.
+Note: Any UCX_TEST_ASSERT() calls must be performed after UCX_TEST_BEGIN.
+| #define UCX_TEST_CALL_SUBROUTINE | +( | ++ | name, | +
| + | + | + | ... | +
| + | ) | +name(_suite_,_output_,_env_,__VA_ARGS__); | +
Macro for calling a test subroutine.
+Subroutines declared with UCX_TEST_SUBROUTINE() can be called by using this macro.
+Note: You may only call subroutines within a UCX_TEST_BEGIN- UCX_TEST_END-block.
+| name | the name of the subroutine |
| ... | the argument list |
| #define UCX_TEST_END fwrite("success.\n", 1, 9, _output_); _suite_->success++;} | +
Marks the end of a test.
+Note: Any UCX_TEST_ASSERT() calls must be performed before UCX_TEST_END.
+| #define UCX_TEST_SUBROUTINE | +( | ++ | name, | +
| + | + | + | ... | +
| + | ) | ++ |
Macro for a test subroutine function header.
+Use this to declare and/or define a subroutine that can be called by using UCX_TEST_CALL_SUBROUTINE().
+| name | the name of the subroutine |
| ... | the parameter list |
| typedef void(* UcxTest) (UcxTestSuite *, FILE *) | +
Pointer to a test function.
+ +| typedef struct UcxTestList UcxTestList | +
Type for the internal list of test cases.
+ +| typedef struct UcxTestSuite UcxTestSuite | +
Type for the UcxTestSuite.
+ +| int ucx_test_register | +( | +UcxTestSuite * | +suite, | +
| + | + | UcxTest | +test | +
| + | ) | ++ |
Registers a test function with the specified test suite.
+| suite | the suite, the test function shall be added to |
| test | the test function to register |
EXIT_SUCCESS on success or EXIT_FAILURE on failure | void ucx_test_run | +( | +UcxTestSuite * | +suite, | +
| + | + | FILE * | +outstream | +
| + | ) | ++ |
Runs a test suite and writes the test log to the specified stream.
+| suite | the test suite to run |
| outstream | the stream the log shall be written to |
| void ucx_test_suite_free | +( | +UcxTestSuite * | +suite | ) | ++ |
Destroys a test suite.
+| suite | the test suite to destroy |
| UcxTestSuite* ucx_test_suite_new | +( | +) | ++ |
Creates a new test suite.
+
+ 1.8.13
+
+
+