From 1fad1b04d505288ac8fcc8a4c4ec1502306a0e12 Mon Sep 17 00:00:00 2001
From: stewartamiles
Cmockery unit test cases are functions with the signature
void function(void **state). Cmockery test applications initialize a
table with test case function pointers using unit_test*() macros. This
@@ -93,14 +93,14 @@ int main(int argc, char* argv[]) {
}
-Exception Handling
+Exception Handling
Before a test function is executed by run_tests(), exception / signal handlers are overridden with a handler that simply displays an error and exits a test function if an exception occurs. If an exception occurs outside of a test function, for example in Cmockery itself, the application aborts execution and returns an error code.
-If a failure occurs during a test function that's executed via run_tests(), the test function is aborted and the application's execution resumes with the next test function. @@ -111,13 +111,13 @@ failure...
Runtime assert macros like the standard C library's assert() should be redefined in modules being tested to use Cmockery's mock_assert() function. Normally mock_assert() signals a -test failure. If a function is called using +test failure. If a function is called using the expect_assert_failure() macro, any calls to mock_assert() within the function will result in the execution of the test. If no calls to mock_assert() occur during the function called via @@ -192,7 +192,7 @@ int main(int argc, char *argv[]) { } -
Cmockery provides an assortment of assert macros that tests applications
should use use in preference to the C standard library's assert macro. On an
@@ -264,14 +264,14 @@ int main(int argc, char *argv[]) {
}
-Dynamic Memory Allocation
+Dynamic Memory Allocation
To test for memory leaks, buffer overflows and underflows a module being tested by Cmockery should replace calls to malloc(), calloc() and free() to test_malloc(), test_calloc() and test_free() respectively. Each time a block is deallocated using test_free() it is checked for corruption, if a corrupt block is found -a test failure is signalled. All blocks +a test failure is signalled. All blocks allocated using the test_*() allocation functions are tracked by the Cmockery library. When a test completes if any allocated blocks (memory leaks) remain they are reported and a test failure is signalled.
@@ -349,7 +349,7 @@ int main(int argc, char* argv[]) { } -A unit test should ideally isolate the function or module being tested from any external dependencies. This can be performed using mock functions @@ -359,7 +359,7 @@ references external functions. Dynamic linking is simply the process of setting a function pointer in a table used by the tested module to reference a mock function defined in the unit test.
-In order to simplify the implementation of mock functions Cmockery provides
functionality which stores return values for mock functions in each test
@@ -492,7 +492,7 @@ int main(int argc, char* argv[]) {
}
-Checking Parameters
+Checking Parameters
In addition to storing the return values of mock functions, Cmockery
provides functionality to store expected values for mock function parameters
using the expect_*() functions provided. A mock function parameter can then
@@ -569,7 +569,7 @@ int main(int argc, char* argv[]) {
}
-Test State
+Test State
Cmockery allows the specification of multiple setup and tear down functions for each test case. Setup functions, specified by the unit_test_setup() @@ -702,5 +702,5 @@ are provided as an example of Cmockery's features discussed in this document.