CUnit(3)
π CUnit β A unit testing framework for C
okay bestie, welcome to the CUnit Programmer's Manual (that's section CUnit(3) for all you manpage girlies tracking the reference). This is the glow-up guide to writing, running, and totally slaying your C unit tests. Let's get into it β¨
π SYNOPSIS
#include <CUnit/CUnit.h> ASSERT definitions, test management.
#include <CUnit/Automated.h> Automated interface with xml output.
#include <CUnit/Basic.h> Basic interface with console output.
#include <CUnit/Console.h> Interactive console interface.
#include <CUnit/CUCurses.h> Interactive curses interface.
Like, pick your interface, bestie. They're all giving different vibes π
πΈ DESCRIPTION
CUnit is a whole system for writing, administering, and running unit tests in C. It uses a simple framework for building test structures (so easy, honestly) and provides a rich set of assertions for testing common data types. CUnit is built as a static library which is linked with the user's testing code β periodt. π₯
π¦ STRUCTURE & GENERAL USAGE π«Ά
So, CUnit is a combo of a platform-independent framework plus a bunch of different user interfaces. The core framework provides basic support for managing a test registry, suites, and test cases. The user interfaces help you interact with the framework to run tests and view results. The way that it all fits together? Iconic. π
The basic hierarchical organization of CUnit is depicted here:
Test Registry
|
-----------------------------
| |
Suite '1' . . . . Suite 'N'
| |
--------------- ---------------
| | | |
Test '11' ... Test '1M' Test 'N1' ... Test 'NM'
Individual test cases are packaged into suites, which are registered with the active test registry. Suites can have setup and teardown functions which are automatically called before and after running the suite's tests (she works hard but she doesn't have to do it manually π ). All suites/tests in the registry may be run using a single function call, or selected suites or tests can be run. Your choice, your era.
The typical usage of CUnit is, like, a whole ritual:
- Write functions for tests (and suite init/cleanup if necessary).
- Initialize the test registry using
CU_initialize_registry() - Add test suites to the registry using
CU_add_suite() - Add test cases to the suites using
CU_add_test() - Run tests using the desired interface, e.g.
CU_console_run_tests()to use the interactive console. - Cleanup the test registry using
CU_cleanup_registry()
All public names in CUnit are prefixed with CU_ β this helps minimize clashes with names in user code, which is honestly so thoughtful of them π. Note that earlier versions of CUnit used different names without this prefix. The older API names are deprecated but still supported. To use the older names, user code must now be compiled with USE_DEPRECATED_CUNIT_NAMES defined. (iykyk, don't @ me about legacy code π)
βοΈ WRITING TEST FUNCTIONS π§
A "test" is a C function having the signature: void test_func(void). There are no restrictions on the content of a test function, except that it should not modify the CUnit framework (like, no adding suites or tests, no modifying the test registry, no initiating a test run β girl, stay in your lane π). A test function may call other functions (which also may not modify the framework). Registering a test will cause its function to be run when the test is run.
CUnit provides a set of assertions for testing logical conditions. The success or failure of these assertions is tracked by the framework, and can be viewed when a test run is complete. Each assertion tests a single logical condition, and fails if the condition evaluates to CU_FALSE. Upon failure, the test continues unless the user chooses the xxx_FATAL version of an assertion. In that case, the test function returns immediately.
CUnit provides a set of assertions for testing logical conditions. The success or failure of these assertions is tracked by the framework, and can be viewed when a test run is complete.
Each assertion tests a single logical condition, and fails if the condition evaluates to CU_FALSE. Upon failure, the test function continues unless the user chooses the xxx_FATAL version of an assertion. In that case, the test function is aborted and returns immediately.
β οΈ FATAL versions of assertions should be used with caution! There is no opportunity for the test function to clean up after itself once a FATAL assertion fails. The normal suite cleanup function is not affected, however. So like, you're not totally doomed π
There are also special "assertions" for registering a pass or fail with the framework without performing a logical test. These are useful for testing flow of control or other conditions not requiring a logical test β the drama-free option π
Other functions called by a registered test function may use the CUnit assertions freely. These assertions will be counted for the calling function. They may also use FATAL versions of assertions β failure will abort the original test function and its entire call chain. No survivors. π
The assertions defined by CUnit are:
#include <CUnit/CUnit.h>
CU_ASSERT(int expression)β asserts thatexpressionisCU_TRUE(non-zero).CU_ASSERT_FATAL(int expression)β same, but if it fails, the test function returns immediately.CU_TEST(int expression)β asserts thatexpressionisCU_TRUE(non-zero).CU_TEST_FATAL(int expression)β same, but fatally.CU_ASSERT_TRUE(value)β asserts thatvalueisCU_TRUE(non-zero).CU_ASSERT_TRUE_FATAL(value)β the fatal version, naturally.CU_ASSERT_FALSE(value)β asserts thatvalueisCU_FALSE(zero).CU_ASSERT_FALSE_FATAL(value)β fatal flop-detection.CU_ASSERT_EQUAL(actual, expected)β asserts thatactual == expected.CU_ASSERT_EQUAL_FATAL(actual, expected)β same, but no second chances.CU_ASSERT_NOT_EQUAL(actual, expected)β asserts thatactual != expected.CU_ASSERT_NOT_EQUAL_FATAL(actual, expected)β the fatal mismatch check.CU_ASSERT_PTR_EQUAL(actual, expected)β asserts that pointersactual == expected.CU_ASSERT_PTR_EQUAL_FATAL(actual, expected)β pointer equality, but make it dramatic.CU_ASSERT_PTR_NOT_EQUAL(actual, expected)β asserts that pointersactual != expected.CU_ASSERT_PTR_NOT_EQUAL_FATAL(actual, expected)β the fatal version of "these are not the same."CU_ASSERT_PTR_NULL(value)β asserts that pointervalue == NULL.CU_ASSERT_PTR_NULL_FATAL(value)β NULL check, zero chill.CU_ASSERT_PTR_NOT_NULL(value)β asserts that pointervalue != NULL.CU_ASSERT_PTR_NOT_NULL_FATAL(value)β the fatal glow-up check.CU_ASSERT_STRING_EQUAL(actual, expected)β asserts that stringsactualandexpectedare equivalent.CU_ASSERT_STRING_EQUAL_FATAL(actual, expected)β string twin flame check, fatally.CU_ASSERT_STRING_NOT_EQUAL(actual, expected)β asserts that stringsactualandexpecteddiffer.CU_ASSERT_STRING_NOT_EQUAL_FATAL(actual, expected)β the fatal "you two are not the same."CU_ASSERT_NSTRING_EQUAL(actual, expected, count)β asserts that the 1stcountchars ofactualandexpectedare the same.CU_ASSERT_NSTRING_EQUAL_FATAL(actual, expected, count)β same vibe, fatal energy.CU_ASSERT_NSTRING_NOT_EQUAL(actual, expected, count)β asserts that the 1stcountchars ofactualandexpecteddiffer.CU_ASSERT_NSTRING_NOT_EQUAL_FATAL(actual, expected, count)β fatal first-count-chars mismatch.CU_ASSERT_DOUBLE_EQUAL(actual, expected, granularity)β asserts that|actual - expected| <= |granularity|. Math library must be linked in for this assertion. πCU_ASSERT_DOUBLE_NOT_EQUAL(actual, expected, granularity)β asserts that|actual - expected| > |granularity|. Math library must be linked in for this assertion.CU_PASS(message)β registers a success without performing a logical test.CU_FAIL(message)β registers a failure without performing a logical test.CU_FAIL_FATAL(message)β registers a failure without a logical test, and aborts.
π THE TEST REGISTRY π
The test registry is the repository for suites and associated tests. Normally you only need to initialize the registry before use and clean up afterwards β lowkey simple. But other functions are provided to manipulate the registry when necessary, because sometimes you need main character energy. β¨
The main functions needed by clients are:
#include <CUnit/TestDB.h> (included automatically by <CUnit/CUnit.h>)
CU_ErrorCode CU_initialize_registry(void)β Initializes the framework. This function should be called before any other CUnit functions. Failure to do so will likely result in a crash (no cap, it's giving consequences π). An error status code is returned:CUE_SUCCESSβ if initialization is successful.CUE_NOMEMORYβ if memory allocation failed.
CU_BOOL CU_registry_initialized(void)β Checks whether the framework has been initialized. This may be useful if the registry setup is distributed over multiple files that need to make sure the registry is ready for test registration.void CU_cleanup_registry(void)β Cleans up and releases memory used by the framework. No CUnit functions (other thanCU_initialize_registry()) should be called after this function. Failure to callCU_cleanup_registry()will result in memory leaks π. Note also that this function will destroy all suites (and associated tests) in the registry.
Other registry functions are primarily for internal and testing purposes. However, general users may find use for them and should be aware of them. These include:
CU_pTestRegistry CU_get_registry(void)β Retrieve a pointer to the active test registry. The registry is a variable of data typeCU_Testregistry(declared in<CUnit/TestDB.h>). Note that the returned pointer will be invalidated by a call toCU_cleanup_registry()orCU_initialize_registry()(so don't, like, keep it around like an old situationship π).CU_pTestRegistry CU_set_registry(CU_pTestRegistry pTestRegistry)β Replace the active registry with the specified one. A pointer to the previous registry is returned. It is the caller's responsibility to destroy the old registry. This can be accomplished usingCU_destroy_existing_registry()on the returned pointer. Alternatively, the old registry can be set as the active one. A subsequent call toCU_cleanup_registry()will then destroy it automatically.
β οΈ Care should be taken not to explicitly destroy a registry that is set as the active one. This will result in multiple frees of the same memory and a likely crash. Like, do not do that. π
CU_pTestRegistry CU_create_new_registry(void)β Create a new registry and return a pointer to it. The new registry will not contain any suites or tests. It is the caller's responsibility to destroy the new registry by one of the mechanisms described previously.void CU_destroy_existing_registry(CU_pTestRegistry* ppRegistry)β Destroy the specified test registry, including any registered suites.
π¨ This function should not be called for a registry which is set as the active test registry. This will result in a multiple free of the same memory when CU_cleanup_registry() is called.
ppRegistry may not be NULL, but the pointer it points to may be. Note that *ppRegistry will be NULL on return. β¨
π MANAGING TESTS AND SUITES π
Okay bestie, so CUnit is not gonna run a test just because it exists. Nope. For a test to actually get run, it has to be added to a test collection (a suite), and that suite has to be registered with the test registry. It's giving "you can't sit with us unless you're on the list" energy. π«Ά
π Adding Suites to the Registry π
So the first step in setting up your whole test system is creating and registering one or more test collections (suites). Each suite has a name, and that name can be used to reference the suite later. Because of that, it's recommended (but not required) that every registered suite has a unique name. Current implementation tea: it does not support creating suites independent of the test registry. Suites get created and added to the active registry at the same time, like this:
#include <CUnit/TestDB.h> /* included automatically by <CUnit/CUnit.h> */
CU_pSuite CU_add_suite(const char* strName, CU_InitializeFunc pInit,
CU_CleanupFunc pClean)
This creates and registers a new suite with the specified name, initialization function, and cleanup function. You get back a pointer to the new suite so you can use it to add tests to that suite. That pointer will be NULL if a fatal error happens. Also, the framework error status gets set like this:
CUE_SUCCESSβ the suite was successfully created and registered. Slay. β¨CUE_NOREGISTRYβ error: Test Registry is not initialized.CUE_NO_SUITENAMEβ error: Suite name is not specified orNULL.CUE_DUP_SUITEβ warning: the registry already has a suite with this name.CUE_NOMEMORYβ error: memory allocation failed.
The initialization and cleanup functions are optional, bestie. Both are C functions with the signature int func_name(void). They can do setup and teardown stuff that the suite's tests need. They get called before and after the suite's tests are run, even if only 1 of the suite's tests is run. They take no arguments, and should return NULL if they complete successfully (non-NULL otherwise). If you don't need either function for a particular suite, just pass NULL to CU_add_suite(). Easy. π
π¦ Adding Tests to Suites π¦
Tests get created and added to suites. Each test has a name that can be used to reference it later, so it's recommended (but not required) that the name be unique among all tests added to a single suite. Again, current implementation tea: it does not support creating tests independent of registered suites. Tests get created and added to a suite at the same time, like this:
#include <CUnit/TestDB.h> /* included automatically by <CUnit/CUnit.h> */
CU_pTest CU_add_test(CU_pSuite pSuite, const char* strName, CU_TestFunc pTestFunc)
This creates a new test with the specified name and test function, and adds it to the indicated suite. The suite should have been previously created using CU_add_suite(). You get back a pointer to the new test, which will be NULL if a fatal error occurred. Then the framework error status gets set like this:
CUE_SUCCESSβ the test was successfully created and added. Iconic. πCUE_NOREGISTRYβ error: Test Registry is not initialized.CUE_NOSUITEβ error: specified suite isNULLor invalid.CUE_NO_TESTNAMEβ error: test name is not specified orNULL.CUE_NOTESTβ error: test function is not specified orNULL.CUE_DUP_TESTβ warning: the suite already has a test with this name.CUE_NOMEMORYβ error: memory allocation failed.
πΈ Activation of Suites and Tests πΈ
A suite or test has to be active to be executed during a test run. And good news: all suites and tests are active by default when they're created. π The active state is available as pSuite->fActive and pTest->fActive, respectively. That flag will be CU_TRUE when the entity is active, and CU_FALSE otherwise.
Use these functions to selectively deactivate suites and tests so you can choose subsets of tests to run dynamically:
#include <CUnit/TestDB.h> /* included automatically by <CUnit/CUnit.h> */
CU_ErrorCode CU_set_suite_active(CU_pSuite pSuite, CU_BOOL fNewActive)
CU_ErrorCode CU_set_test_active(CU_pTest pTest, CU_BOOL fNewActive)
Pass CU_TRUE to these functions to activate a suite/test, and CU_FALSE to deactivate it. These functions return CUE_NOSUITE and CUE_NOTEST, respectively, if the specified suite or test is NULL.
π¨ Bestie, important caveat: it is a framework error to deactivate a test or suite and then specifically request that it be run. Don't do that. π
π Modifying Other Attributes of Suites and Tests π
Normally the attributes of suites and tests are set at creation time. But sometimes a client may wish to manipulate these to modify the test structure dynamically. The following functions are provided for that purpose, and you should use them instead of directly setting the value of the data structure members. All return CUE_SUCCESS on success, and the indicated error code on failure.
CU_ErrorCode CU_set_suite_name(CU_pSuite pSuite, const char *strNewName)
CU_ErrorCode CU_set_test_name(CU_pTest pTest, const char *strNewName)
These functions change the name of registered suites and tests. The current names are available as the pSuite->pName and data structure members. If the suite or test is NULL, then CUE_NOSUITE or CUE_NOTEST is returned, respectively. If strNewName is NULL, then CUE_NO_SUITENAME or CUE_NO_TESTNAME is returned, respectively.
CU_ErrorCode CU_set_suite_initfunc(CU_pSuite pSuite, CU_InitializeFunc pNewInit)
CU_ErrorCode CU_set_suite_cleanupfunc(CU_pSuite pSuite, CU_CleanupFunc pNewClean)
These functions change the initialization and cleanup functions for a registered suite. The current functions are available as the pSuite->pInitializeFunc and pSuite->pCleanupFunc data structure members. If the suite is NULL, then CUE_NOSUITE is returned.
CU_ErrorCode CU_set_test_func(CU_pTest pTest, CU_TestFunc pNewFunc)
This function changes the test function for a registered test. The current test function is available as the pTest->pTestFunc data structure member. If either pTest or pNewFunc is NULL, then CUE_NOTEST is returned.
β Lookup of Individual Suites and Tests β
In most cases, clients will have references to registered suites and tests as pointers returned from CU_add_suite() and CU_add_test(). Occasionally, a client may need to retrieve a reference to a suite or test. The following functions are provided to help when the client has some information about the entity (name or order of registration). In cases where nothing is known about the suite or test, the client will need to iterate the internal data structures to enumerate the suites and tests. This is not directly supported in the client API.
CU_pSuite CU_get_suite(const char* strName)
CU_pSuite CU_get_suite_at_pos(unsigned int pos)
unsigned int CU_get_suite_pos(CU_pSuite pSuite)
unsigned int CU_get_suite_pos_by_name(const char* strName)
These functions facilitate lookup of suites registered in the active test registry. The first 2 functions allow lookup of the suite by name or position and return NULL if the suite cannot be found. The position is a 1-based index in the range [1 .. CU_get_registry() ->uiNumberOfSuites]. This may be helpful when suites having duplicate names are registered, in which case lookup by name can only retrieve the 1st suite having that name. The second 2 functions help the client identify the position of a registered suite. These return 0 if the suite cannot be found. In addition, all these functions set the CUnit error state to CUE_NOREGISTRY if the registry is not initialized. As appropriate, CUE_NO_SUITENAME is set if strName is NULL, and CUE_NOSUITE is set if pSuite is NULL.
CU_pTest CU_get_test(CU_pSuite pSuite, const char *strName)
CU_pTest CU_get_test_at_pos(CU_pSuite pSuite, unsigned int pos)
unsigned int CU_get_test_pos(CU_pSuite pSuite, CU_pTest pTest)
unsigned int CU_get_test_pos_by_name(CU_pSuite pSuite, const char *strName)
These functions facilitate lookup of tests registered in suites. The first 2 functions allow lookup of the test by name or position and return NULL if the test cannot be found. The position is a 1-based index in the range [1 .. pSuite->uiNumberOfSuites]. This may be helpful when tests having duplicate names are registered, in which case lookup by name can only retrieve the 1st test having that name. The second 2 functions help the client identify the position of a test in a suite. These return 0 if the test cannot be found. In addition, all these functions set the CUnit error state to CUE_NOREGISTRY if the registry is not initialized, and to CUE_NOSUITE if pSuite is NULL. As appropriate, CUE_NO_TESTNAME is set if strName is NULL, and CUE_NOTEST is set if pTest is NULL.
π RUNNING TESTS π
Okay so running tests is lowkey the main character energy of CUnit. CUnit supports running all tests in all registered suites, but individual tests or suites can also be run. During each run, the framework keeps track of the number of suites, tests, and assertions run, passed, and failed.
β οΈ Important vibe check: the previous results are cleared each time a test run is initiated (even if it fails). No cap.
While CUnit provides primitive functions for running suites and tests, most users will want to use one of the user interfaces. These interfaces handle the details of interaction with the framework and provide output of test details and results for the user. For more about the primitive functions, see <CUnit/testRun.h>.
Test Results π
The interfaces present results of test runs, but client code may sometimes need to access the results directly. These results include various run counts, as well as a linked list of failure records holding the failure details. Test results must be retrieved before attempting to run other tests, which resets the result information. Functions for accessing the test results are:
#include <CUnit/TestRun.h> (included automatically by <CUnit/CUnit.h>)
unsigned int CU_get_number_of_suites_run(void)'β Retrieve the number of suites run. Suites having initialization functions which fail are not run. To get the total number of registered suites, useCU_get_registry()->uiNumberOfSuites.unsigned int CU_get_number_of_suites_failed(void)β Retrieve the number of suites which had initialization or cleanup functions which failed (returned non-NULL).unsigned int CU_get_number_of_tests_run(void)β Retrieve the number of tests run. Tests in suites having initialization functions which fail are not run. To get the total number of registered tests, useCU_get_registry()->uiNumberOfTests.unsigned int CU_get_number_of_tests_failed(void)β Retrieve the number of tests which contained at least 1 failed assertion.unsigned int CU_get_number_of_asserts(void)β Retrieve the number of CUnit assertions made during the test run.unsigned int CU_get_number_of_successes(void)β Retrieve the number of assertions which passed.unsigned int CU_get_number_of_failures(void)β Retrieve the number of assertions which failed.const CU_pRunSummary CU_get_run_summary(void)β Retrieve aCU_RunSummarycontaining all the run count information. This data structure is declared in<CUnit/TestRun.h>and includes the (self-explanatory)unsigned intfieldsnSuitesRun,nSuitesFailed,nTestsRun,nTestsFailed,nAsserts, andnAssertsFailed.const CU_pFailureRecord CU_get_failure_list(void)β Retrieve the head of the linked list of failure records for the last run. Each assertion failure or suite init/cleanup function failure is registered in a newCU_FailureRecordin the linked list. This data structure is declared in<CUnit/TestRun.h>and includes the following fields:
unsigned int uiLineNumber
char* strFileName
char* strCondition
CU_pTest pTest
CU_pSuite pSuite
Automated Interface π¦
The automated interface is non-interactive. The current implementation only supports running all registered suites. Results are output to an xml file to be viewed by appropriate external tools. Registered tests can also be listed to an xml file for viewing. The following public functions are available:
#include <CUnit/Automated.h>
void CU_automated_run_tests(void)β Run all tests in all registered (and active) suites. Results are output to a file namedROOT-Results.xml. The filename'ROOT'is set usingCU_set_output_filename(), or else the default'CUnitAutomated'is used. This means that the same filename is used each run (and the results file overwritten) if the user does not explicitly set the'ROOT'for each run.CU_ErrorCode CU_list_tests_to_file(void)β Lists the registered suites and associated tests to file. The listing file is namedROOT-Listing.xml. The filename'ROOT'is set usingCU_set_output_filename(), or else the default'CUnitAutomated'is used. This means that the same filename is used each run (and the listing file overwritten) if the user does not explicitly set the'ROOT'for each run.void CU_set_output_filename(const char* szFilenameRoot)β Set the filename root to use for automated results and listing files.
Basic Interface (non-interactive) π
The basic interface is also non-interactive, with results output to stdout. This interface supports running individual suites or tests, and allows client code to control the type of output displayed during each run. This interface provides the most flexibility to clients desiring simplified access to the CUnit API. The following public functions are provided:
#include <CUnit/Basic.h>
CU_ErrorCode CU_basic_run_tests(void)β Run all tests in all registered suites. Only the active suites are run, and it is not considered an error if inactive suites are encountered and skipped. Returns the 1st error code occurring during the test run. The type of output is controlled by the current run mode, which can be set usingCU_basic_set_mode().CU_ErrorCode CU_basic_run_suite(CU_pSuite pSuite)β Run all tests in single specified suite. Returns the 1st error code occurring during the test run.CU_basic_run_suite()itself generatesCUE_NOSUITEifpSuiteis NULL, andCUE_SUITE_INACTIVEif the requested suite is not active. The type of output is controlled by the current run mode.CU_ErrorCode CU_basic_run_test(CU_pSuite pSuite, CU_pTest pTest)β Run a single test in a specified suite. Returns the 1st error code occurring during the test run.BU_basic_run_test()itself generatesCUE_NOSUITEifpSuiteis NULL;CUE_NOTESTifpTestis NULL;CUE_SUITE_INACTIVEifpSuiteis not active for execution,CUE_TEST_NOT_IN_SUITEifpTestis not a registered member ofpSuite, andCUE_TEST_INACTIVEifpTestis not active for execution. The type of output is controlled by the current run mode.void CU_basic_set_mode(CU_BasicRunMode mode)β Set the basic run mode, which controls the output during the run. Choices are:CU_BRM_NORMALβ Failures and run summary are printed.CU_BRM_SILENTβ No output is printed except error messages.CU_BRM_VERBOSEβ Maximum output of run details.
CU_BasicRunMode CU_basic_get_mode(void)β Retrieve the current basic run mode code.void CU_basic_show_failures(CU_pFailureRecord pFailure)β Prints a summary of all failures to stdout. Does not depend on the run mode.
Interactive Console Interface πΈ
The console interface is interactive. All the client needs to do is initiate the console session, and the user controls the test run interactively. This includes selection & running of suites and tests, and viewing test results.
#include <CUnit/Console.h>
void CU_console_run_tests(void)β Initiate an interactive test run in the console.
Interactive Curses Interface π§
The curses interface is interactive. All the client needs to do is initiate the curses session, and the user controls the test run interactively. This includes selection & running of suites and tests, and viewing test results. Use of this interface requires linking the ncurses library into the application.
#include <CUnit/CUCurses.h>
void CU_curses_run_tests(void)β Initiate an interactive test run in curses.
π¨ ERROR HANDLING π¨
CUnit Error Status Codes π
Many CUnit functions set a framework error code when an exception occurs. The error codes are an enum named CU_ErrorCode declared in header file <CUnit/CUError.h> (included automatically by <CUnit/CUnit.h>). The following functions are provided for retrieving the framework error status:
#include <CUnit/CUError.h> (included automatically by <CUnit/CUnit.h>)
CU_ErrorCode CU_get_error(void)β Returns the framework error status code.const char* CU_get_error_msg(void)β Returns a message for the current error code.
Error Actions π οΈ
By default, CUnit continues running tests when a framework error occurs. In this context, failed assertions are not considered "framework errors". All other error conditions including suite initialization or cleanup failures, inactive suites or tests which are run explicitly, etc. are included. This 'error action' can be changed by the user if desired. The following functions are provided:
#include <CUnit/CUError.h> (included automatically by <CUnit/CUnit.h>)
void CU_set_error_action(CU_ErrorAction action)β Set the framework error action.CU_ErrorAction CU_get_error_action(void)β Retrieve the current error action.
The error actions are defined in enum CU_ErrorAction in header file <CUnit/CUError.h> (included automatically by <CUnit/CUnit.h>) as follows:
CUEA_IGNOREβ Continue test runs on framework errors (default).CUEA_FAILβ Stop test runs on a framework error.CUEA_ABORTβ Exit the application on a framework error.
π AUTHORS π
- Anil Kumar
<anilsaharan@users.sourceforge.net> - Jerry St.Clair
<jds2@users.sourceforge.net>
π WEBSITE π
β¨ and thatβs a wrap on this CUnit(3) page, bestie β source/version CUnit-2.0-1, dated August 2004. obsessed, periodt! ππ
π¦ where this page comes from
- alpine 3.22: cunit-doc 2.1.3-r7 Β· GPL-2.0-or-later
- alpine 3.23: cunit-doc 2.1.3-r7 Β· GPL-2.0-or-later
- alpine 3.24: cunit-doc 2.1.3-r7 Β· GPL-2.0-or-later
- arch rolling: cunit 2.1.3-4 Β· LGPL2.1
- centos-stream 10: CUnit-devel 2.1.3-34.el10 Β· LGPL-2.0-or-later
- centos-stream 9: CUnit-devel 2.1.3-25.el9 Β· LGPLv2+
- centos-stream 9: CUnit-devel 2.1.3-25.el9 Β· LGPLv2+
- fedora 43: CUnit-devel 2.1.3-35.fc43 Β· LGPL-2.0-or-later
- fedora 43: CUnit-devel 2.1.3-35.fc43 Β· LGPL-2.0-or-later
- fedora 44: CUnit-devel 2.1.3-37.fc44 Β· LGPL-2.0-or-later
- fedora 44: CUnit-devel 2.1.3-37.fc44 Β· LGPL-2.0-or-later
- nixos 26.05: CUnit 2.1-3
- nixpkgs unstable: CUnit 2.1-3
- opensuse-leap 16.0: cunit-doc 2.1.3-160000.2.2 Β· LGPL-2.0-only
- opensuse-leap 16.0: cunit-doc 2.1.3-160000.2.2 Β· LGPL-2.0-only
- opensuse-leap 16.0: cunit-doc 2.1.3-160000.2.2 Β· LGPL-2.0-only
- opensuse-leap 16.0: cunit-doc 2.1.3-160000.2.2 Β· LGPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms