1. Overview
Here is the CUTe’s programmatic API reference manual. If you need an in-depth description of CUTe usage, you should refer to the User guide instead.
2. Build configuration
At Build configuration time, multiple build options are available to customize final CUTe build. From client code, you may eventually refer to the corresponding C macros listed below:
3. Functional domains
3.1. Test definition
Various C preprocessor macros are exposed to define test cases. These are:
See test case definition section of User guide for more informations.
3.2. Fixture operations
Various C preprocessor macros are exposed to attach test fixture functions to tests or suites at definition time. These are:
See fixture operations section of User guide for more informations.
3.3. Timeouts
Various C preprocessor macros are exposed to assign timeouts to tests or suites at definition time. These are:
See timer section of User guide for more informations.
3.4. Group definition
Various C preprocessor macros are exposed to define test groups. These are:
See group definition section of User guide for more informations.
3.5. Suite definition
Various C preprocessor macros are exposed to define test suites. These are:
See suite definition section of User guide for more informations.
3.6. Test assertion
Multiple test assertions are exposed to implement testing logic. These are described in the following sections.
You may also refer to Test assertion section of User guide for more informations.
3.6.1. Basic assertion
cute_check_assert implements a basic versatile test assertion
exposed as a C preprocessor macros.
3.6.2. Booleans
Boolean values may be verified using the cute_check_bool macro.
3.6.3. Signed integers
Signed integer values may be verified using so-called sint definitions :
|
|
3.6.4. Unsigned integers
Unsigned integer values may be verified using so-called uint and / or hex definitions :
|
|
3.6.5. Floating point numbers
Floating point values may be verified using so-called flt definitions :
|
|
3.6.6. Strings
NULL terminated C string contents may be verified using so-called str definitions :
|
|
3.6.7. Pointers
Pointer values may be verified using so-called ptr definitions :
|
|
3.6.8. Memory areas
Use cute_check_mem to verify content of memory areas.
3.7. Mocking
Multiple types of mocking expectations are supported to implement testing logic. These are described in the following sections.
You may also refer to Mocking section of User guide for more informations.
3.7.1. Assertion expectation
Combine cute_expect_assertion() and cute_mock_assert()
to ensure that an assertion failure has been thrown.
3.7.2. Call expectation
Combine cute_expect_call() and cute_mock_call()
to ensure that a function is called according to the expected schedule order.
3.7.3. Parameter expectation
Multiple types of function parameter expectations are supported to implement testing logic. These are described in the following sections.
3.7.3.1. Booleans
Boolean function parameter expectations may be verified using so-called bool definitions :
|
|
3.7.3.2. Signed integers
Signed integer function parameter expectations may be verified using so-called sint definitions :
|
|
3.7.3.3. Unsigned integers
Unsigned integer function parameter expectations may be verified using so-called uint definitions :
|
|
3.7.3.4. Floating point numbers
Floating point number function parameter expectations may be verified using so-called flt definitions :
|
|
3.7.3.5. Strings
String function parameter expectations may be verified using so-called str definitions :
|
|
3.7.3.6. Pointers
Pointer function parameter expectations may be verified using so-called ptr definitions :
|
|
3.7.3.7. Memory areas
Combine cute_expect_mem_parm() and cute_mock_mem_parm()
to verify memory areas content.
3.7.4. Return value expectation
Multiple types of function return value expectations are supported to implement testing logic :
|
|
3.8. Running tests
Use CUTE_MAIN as replacement for main() entry point of a test
runner executable.
This is the most straightforward way to run a test hierarchy. Head to section
main entry point of User guide for more informations.
The following low-level API is exposed for additional flexibility :
|
|
See section Low level runner of User guide for more informations.
4. Reference
4.1. Configuration macros
4.1.1. CONFIG_CUTE_INTERN_ASSERT
-
CONFIG_CUTE_INTERN_ASSERT
Internal assertion.
Build CUTe with internal assertions enabled to check for internal CUTe behavioral consistency.
4.1.2. CONFIG_CUTE_UTEST
-
CONFIG_CUTE_UTEST
Unit tests.
Build CUTe with unit test suite.
4.2. Macros
4.2.1. CUTE_CONFIG_INIT
-
CUTE_CONFIG_INIT
Test run configuration default initializer.
Initialize a cute_config with default values such that a test hierarchy runner behaves as following :
debug mode is off,
CUTE_CONFIG_TERSE_REPORT is enabled,
CUTE_CONFIG_PROBE_TTY is enabled.
4.2.2. CUTE_DFLT_TMOUT
4.2.3. CUTE_FLT_RANGE
-
CUTE_FLT_RANGE(_min, _max)
Define a floating point number range.
Initialize a cute_flt_range variable that defines a range of floating point numbers.
Example
CUTE_TEST(mytest) { const struct cute_flt_range range = CUTE_FLT_RANGE(-5.5f, 20.5f); cute_check_flt_range(0.5f, in, range); cute_check_flt_range(10, not_in, CUTE_FLT_RANGE(-5.5, 5.5)); }
See also
- Parameters:
_min – [in] range’s minimum value (inclusive)
_max – [in] range’s maximum value (inclusive)
4.2.4. CUTE_FLT_SET
-
CUTE_FLT_SET(...)
Define a floating point number set.
Initialize a cute_flt_set variable that defines a set of floating point numbers.
The
...variable argument list is an unordered list of floating point values separated by commas that composes the set.Example
CUTE_TEST(mytest) { const struct cute_flt_set set = CUTE_FLT_SET(-5.5f, 0.5f, 5.5f); cute_check_flt_set(0.5f, in, set); cute_check_flt_set(7, not_in, CUTE_FLT_SET(-10.5, 0.5, 10.0)); }
See also
- Parameters:
... – [in] list of set values
4.2.5. CUTE_GROUP
-
CUTE_GROUP(_name)
Define a test group with default class storage.
Define a test group designated by the
_namevariable that may later be used to define suites. The_nametest group variable is defined with default class storage specifier, i.e., static global file scope.CUTE_GROUP must be immediately followed by an initializer as stated in CUTE_GROUP_DEFN.
Example
CUTE_TEST(sample_test_0) { cute_check_assert(0 == 0); } CUTE_TEST(sample_test_1) { cute_check_assert(1 == 1); } CUTE_GROUP(sample_group) = { CUTE_REF(sample_test_0), CUTE_REF(sample_test_1) }; CUTE_SUITE(sample_suite, sample_group);
- Parameters:
_name – [in] test group name
4.2.6. CUTE_GROUP_DEFN
-
CUTE_GROUP_DEFN(_name)
Define a test group.
Define a test group designated by the
_namevariable that may later be used to define suites.CUTE_GROUP_DEFN must be immediately followed by an initializer. It should define the collection of tests (and / or suites) that composes the
_namegroup thanks to the CUTE_REF macro as shown in the example below.Example
CUTE_TEST(sample_test_0) { cute_check_assert(0 == 0); } CUTE_TEST(sample_test_1) { cute_check_assert(1 == 1); } static CUTE_GROUP_DEFN(sample_group) = { CUTE_REF(sample_test_0), CUTE_REF(sample_test_1) }; CUTE_SUITE(sample_suite, sample_group);
- Parameters:
_name – [in] test group name
4.2.7. CUTE_GROUP_DECL
-
CUTE_GROUP_DECL(_name)
Declare a test group.
Declare a test group designated by the
_namevariable that may later be used to define suites.Use this in combination with CUTE_GROUP_EXTERN or CUTE_GROUP_DEFN to allow referencing defined test group from multiple compilation units.
Example
#ifndef _SAMPLE_TEST_H #define _SAMPLE_TEST_H #include <cute/cute.h> extern CUTE_GROUP_DECL(sample_group); #endif
See also
- Parameters:
_name – [in] test group name
4.2.8. CUTE_GROUP_STATIC
-
CUTE_GROUP_STATIC(_name)
Define a static file scoped test group.
Define a test group designated by the
_namevariable that may later be used to define suites. The_nametest group variable is defined with static global file scope.CUTE_GROUP_STATIC must be immediately followed by an initializer as stated in CUTE_GROUP_DEFN.
Example
CUTE_TEST(sample_test_0) { cute_check_assert(0 == 0); } CUTE_TEST(sample_test_1) { cute_check_assert(1 == 1); } CUTE_GROUP_STATIC(sample_group) = { CUTE_REF(sample_test_0), CUTE_REF(sample_test_1) }; CUTE_SUITE(sample_suite, sample_group);
- Parameters:
_name – [in] test group name
4.2.9. CUTE_GROUP_EXTERN
-
CUTE_GROUP_EXTERN(_name)
Define a test group with external linkage.
Define a test group designated by the
_namevariable that may later be used to define suites. The_nametest group variable is defined with default global file scope, i.e., with external linkage.CUTE_GROUP_EXTERN must be immediately followed by an initializer as stated in CUTE_GROUP_DEFN.
Use CUTE_GROUP_DECL to produce a declaration in a header file so that the created test group may be referenced from other compilation units.
Example definition
CUTE_TEST(sample_test_0) { cute_check_assert(0 == 0); } CUTE_TEST(sample_test_1) { cute_check_assert(1 == 1); } CUTE_GROUP_EXTERN(sample_group) = { CUTE_REF(sample_test_0), CUTE_REF(sample_test_1) };
Example declaration in a sample_test.h header file
#ifndef _SAMPLE_TEST_H #define _SAMPLE_TEST_H #include <cute/cute.h> extern CUTE_GROUP_DECL(sample_group); #endif
- Parameters:
_name – [in] test group name
4.2.10. CUTE_INHR_SETUP
4.2.11. CUTE_INHR_TEARDOWN
4.2.12. CUTE_INHR_TMOUT
-
CUTE_INHR_TMOUT
Inherit timeout from parent suite.
When defining a test case, use this to instruct CUTe to assign a timeout inherited from a parent test suite.
When the test case has no parent suite at running time, CUTE_DFLT_TMOUT is applied instead.
See also
4.2.13. CUTE_MAIN
-
CUTE_MAIN(_root, _package, _version)
Test hierarchy runner main entry point.
Use CUTE_MAIN as the
main()entry point replacement for a test hierarchy runner executable._packageshould be given as a string containing the name of the package for which testing code is written._versionshould hold the version string identifying the_packagepackage revision. Both_packageand_versionare optional and may be specified asNULL.Example
#include <cute/cute.h> CUTE_TEST(my_first_failing_test) { cute_fail(NULL); } CUTE_GROUP(my_first_group) = { CUTE_REF(my_first_failing_test) }; CUTE_SUITE(my_first_suite, my_first_group); CUTE_MAIN(my_first_suite, "My first package", "0.1")
See also
- Parameters:
_root – [in] top-level test hierarchy suite
_package – [in] package name string
_version – [in] package version string
4.2.14. CUTE_NONE_TMOUT
4.2.15. CUTE_NULL_SETUP
4.2.16. CUTE_NULL_TEARDOWN
4.2.17. CUTE_PTR_RANGE
-
CUTE_PTR_RANGE(_min, _max)
Define a pointer range.
Initialize a cute_ptr_range variable that defines a range of pointers.
Example
CUTE_TEST(mytest) { const struct cute_ptr_range range = CUTE_PTR_RANGE((const void *)0xdeadbeef, (const void *)0xdeadc0de); cute_check_ptr_range((const void *)0xdeadc0de, in, range); cute_check_ptr_range((const void *)0x0, not_in, CUTE_PTR_RANGE((const void *)0xbabaface, (const void *)0xdeafbabe)); }
See also
- Parameters:
_min – [in] range’s minimum value (inclusive)
_max – [in] range’s maximum value (inclusive)
4.2.18. CUTE_PTR_SET
-
CUTE_PTR_SET(...)
Define a pointer set.
Initialize a cute_ptr_set variable that defines a set of pointers.
The
...variable argument list is an unordered list of pointer values separated by commas that composes the set.Example
CUTE_TEST(mytest) { const int array[4]; const struct cute_ptr_set set = CUTE_PTR_SET((const void *)&array[0], (const void *)&array[2]); cute_check_ptr_set((const void *)&array[0], in, set); cute_check_ptr_set((const void *)0xdeadbeef, not_in, CUTE_PTR_SET((const void *)&array[0], (const void *)&array[3], (const void *)&array[1]); }
See also
- Parameters:
... – [in] list of set values
4.2.19. CUTE_REF
-
CUTE_REF(_name)
Return a pointer to a test case or suite.
Use CUTE_REF to define collections of test cases or suites when initializing test groups.
Example
CUTE_TEST(sample_subtest) { cute_check_assert(0 == 0); } CUTE_GROUP(sample_subgroup) = { CUTE_REF(sample_subtest) }; CUTE_SUITE(sample_subsuite, sample_subgroup); CUTE_TEST(sample_test) { cute_check_assert(1 == 1); } CUTE_GROUP(sample_group) = { CUTE_REF(sample_subsuite), CUTE_REF(sample_test) }; CUTE_SUITE(sample_suite, sample_group);
- Parameters:
_name – [in] test or suite name
4.2.20. CUTE_SINT_RANGE
-
CUTE_SINT_RANGE(_min, _max)
Define a signed integer range.
Initialize a cute_sint_range variable that defines a range of signed integers.
Example
CUTE_TEST(mytest) { const struct cute_sint_range range = CUTE_SINT_RANGE(-5, 20); cute_check_sint_range(0, in, range); cute_check_sint_range(10, not_in, CUTE_SINT_RANGE(-5, 5)); }
See also
- Parameters:
_min – [in] range’s minimum value (inclusive)
_max – [in] range’s maximum value (inclusive)
4.2.21. CUTE_SINT_SET
-
CUTE_SINT_SET(...)
Define a signed integer set.
Initialize a cute_sint_set variable that defines a set of signed integers.
The
...variable argument list is an unordered list of signed integer values separated by commas that composes the set.Example
CUTE_TEST(mytest) { const struct cute_sint_set set = CUTE_SINT_SET(-5, 0, 5); cute_check_sint_set(0, in, set); cute_check_sint_set(7, not_in, CUTE_SINT_SET(-10, -5, 0, 5, 10)); }
See also
- Parameters:
... – [in] list of set values
4.2.22. CUTE_STR_SET
-
CUTE_STR_SET(...)
Define set of strings.
Initialize a cute_str_set variable that defines a set of strings.
The
...variable argument list is an unordered list ofNULLterminated C strings separated by commas that composes the set.Example
CUTE_TEST(mytest) { const struct cute_str_set set = CUTE_STR_SET("Lorem", "ipsum", "dolor"); cute_check_str_set("ipsum", in, set); cute_check_str_set("Lorem", not_in, CUTE_FLT_SET("amet, ", "consectetur"); }
See also
- Parameters:
... – [in] list of set strings
4.2.23. CUTE_SUITE
-
CUTE_SUITE(_name, _group)
Define a test suite with default class storage.
Define a test suite designated by the
_namevariable with default class storage specifier, i.e. static global file scope._groupis an ordered collection of test cases and / or suites as stated in CUTE_SUITE_DEFN.The test suite is created so that it inherits setup() and teardown() fixture functions from its parent suite when it exists. It is attached dummy / null fixture functions otherwise.
Similarly, it inherits timeout settings from its parent suite when present. CUTE_DFLT_TMOUT default timeout is assigned to it otherwise.
Example
CUTE_TEST(sample_test_0) { cute_check_assert(0 == 0); } CUTE_TEST(sample_test_1) { cute_check_assert(1 == 1); } CUTE_GROUP(sample_group) = { CUTE_REF(sample_test_0), CUTE_REF(sample_test_1) }; CUTE_SUITE(sample_suite, sample_group);
- Parameters:
_name – [in] test suite name
_group – [in] test group
4.2.24. CUTE_SUITE_DEFN
-
CUTE_SUITE_DEFN(_name, _group, _setup, _teardown, _tmout)
Define a test suite with attributes.
Define a test suite designated by the
_namevariable with the specified attributes._groupis an ordered collection of test cases and / or suites defined using one of :_setupis a setup() fixture function that should initialize the runtime context of aggregated sub-tests._teardownis a teardown() fixture function that should release the runtime context established by_setup._tmoutis a timeout expressed in seconds that protects against situations where aggregated sub-tests runs hang.See CUTE_TEST_DEFN for more informations about fixture functions and timeout .
Example
static int value; static void sample_setup(void) { value = 5; } CUTE_TEST(sample_test_0) { cute_check_assert(value > 0); } CUTE_TEST(sample_test_1) { cute_check_assert(value == 5); } CUTE_GROUP(sample_group) = { CUTE_REF(sample_test_0), CUTE_REF(sample_test_1) }; static CUTE_SUITE_DEFN(sample_suite, sample_group, sample_setup, CUTE_NULL_TEARDOWN, CUTE_DFLT_TMOUT);
- Parameters:
_name – [in] test suite name
_group – [in] test group
_setup – [in] setup fixture function
_teardown – [in] teardown fixture function
_tmout – [in] test timeout
4.2.25. CUTE_SUITE_DECL
-
CUTE_SUITE_DECL(_name)
Declare a test suite.
Declare a test suite designated by the
_namevariable.Use this in combination with CUTE_SUITE_EXTERN or CUTE_SUITE_DEFN to allow referencing defined test suite from multiple compilation units.
Example
#ifndef _SAMPLE_TEST_H #define _SAMPLE_TEST_H #include <cute/cute.h> extern CUTE_SUITE_DECL(sample_suite); #endif
See also
- Parameters:
_name – [in] test suite name
4.2.26. CUTE_SUITE_STATIC
-
CUTE_SUITE_STATIC(_name, _group, _setup, _teardown, _tmout)
Define a static file scoped test suite with attributes.
Define a test suite designated by the
_namevariable with static global file scope. The test suite is created with attributes given in argument as explained in CUTE_SUITE_DEFN.Example
CUTE_TEST(sample_test_0) { cute_check_assert(value > 0); } CUTE_TEST(sample_test_1) { cute_check_assert(value == 5); } CUTE_GROUP(sample_group) = { CUTE_REF(sample_test_0), CUTE_REF(sample_test_1) }; CUTE_SUITE_STATIC(sample_suite, sample_group, CUTE_NULL_SETUP, CUTE_NULL_TEARDOWN, CUTE_DFLT_TMOUT);
See also
- Parameters:
_name – [in] test suite name
_group – [in] test group
_setup – [in] setup fixture function
_teardown – [in] teardown fixture function
_tmout – [in] test timeout
4.2.27. CUTE_SUITE_EXTERN
-
CUTE_SUITE_EXTERN(_name, _group, _setup, _teardown, _tmout)
Define a test suite with attributes and external linkage.
Define a test suite designated by the
_namevariable with default global file scope, i.e. with external linkage.The test suite is created with attributes given in argument as explained in CUTE_SUITE_DEFN.
Use CUTE_SUITE_DECL to produce a declaration in a header file so that the created test suite may be referenced from other compilation units.
Example definition
#include "sample_test.h" CUTE_TEST(sample_test_0) { cute_check_assert(value > 0); } CUTE_TEST(sample_test_1) { cute_check_assert(value == 5); } CUTE_GROUP(sample_group) = { CUTE_REF(sample_test_0), CUTE_REF(sample_test_1) }; CUTE_SUITE_EXTERN(sample_suite, sample_group, CUTE_INHR_SETUP, CUTE_INHR_TEARDOWN, CUTE_INHR_TMOUT);
Example declaration in a sample_test.h header file
#ifndef _SAMPLE_TEST_H #define _SAMPLE_TEST_H #include <cute/cute.h> extern CUTE_SUITE_DECL(sample_suite); #endif
- Parameters:
_name – [in] test suite name
_group – [in] test group
_setup – [in] setup fixture function
_teardown – [in] teardown fixture function
_tmout – [in] test timeout
4.2.28. CUTE_TEST
-
CUTE_TEST(_name)
Define a test case with default attributes and class storage.
Define a test case designated by the
_namevariable. CUTE_TEST must be immediately followed by a block of instructions defining the related testing logic as stated in CUTE_TEST_DEFN.The
_nametest case variable is defined with default class storage specifier, i.e. static global file scope.The test case is created so that it inherits setup() and teardown() fixture functions from its parent suite when it exists. It is attached dummy / null fixture functions otherwise.
Similarly, it inherits timeout settings from its parent suite when present. CUTE_DFLT_TMOUT default timeout is assigned to it otherwise.
Example
CUTE_TEST(sample_test) { cute_check_assert(0 == 0); }
- Parameters:
_name – [in] test case name
4.2.29. CUTE_TEST_DECL
-
CUTE_TEST_DECL(_name)
Declare a test case.
Declare a test case designated by the
_namevariable.Use this in combination with CUTE_TEST_EXTERN or CUTE_TEST_DEFN to allow referencing defined test cases from multiple compilation units.
Example
#ifndef _SAMPLE_TEST_H #define _SAMPLE_TEST_H #include <cute/cute.h> extern CUTE_TEST_DECL(sample_test); #endif
See also
- Parameters:
_name – [in] test case name
4.2.30. CUTE_TEST_DEFN
-
CUTE_TEST_DEFN(_name, _exec, _setup, _teardown, _tmout)
Define a test case with attributes.
Define a test case designated by the
_namevariable with the specified attributes._execis a test case function that should implement the testing logic. It should be defined according to the following signature:void test_exec(void)
_setupis a setup() fixture function that should initialize the testing context. It is run before_execfunction and should be defined according to the following signature:void test_setup(void)
Values allowed for
_setupare :or an arbitrary function,
_teardownis a teardown() fixture function that should release the testing context established by_setup. It is run if_setuphas completed and after_execfunction. It should be defined according to the following signature:void test_teardown(void)
Values allowed for
_teardownare :or an arbitrary function,
_tmoutis a timeout expressed in seconds that protects the test run against situations where_setup,_teardownor_execfunctions stall. Values allowed for_tmoutare :or a non-zero unsigned integer.
Example
static int value; static void sample_setup(void) { value = 5; } static void sample_test_exec(void) { cute_check_assert(value == 5); } static CUTE_TEST_DEFN(sample_test, sample_test_exec, sample_setup, CUTE_NULL_TEARDOWN, CUTE_DFLT_TMOUT);
- Parameters:
_name – [in] test case name
_exec – [in] test case function
_setup – [in] setup fixture function
_teardown – [in] teardown fixture function
_tmout – [in] test timeout
4.2.31. CUTE_TEST_EXTERN
-
CUTE_TEST_EXTERN(_name, _setup, _teardown, _tmout)
Define a test case with attributes and external linkage.
Define a test case designated by the
_namevariable with default global file scope, i.e. with external linkage. The test case is created with attributes given in argument as explained below.In addition, CUTE_TEST_EXTERN must be immediately followed by a block of instructions defining the related testing logic as stated in CUTE_TEST_DEFN.
_setupis a setup() fixture function as described in CUTE_TEST_DEFN._teardownis a teardown() fixture function as described in CUTE_TEST_DEFN._tmoutis a timeout expressed in seconds as described in CUTE_TEST_DEFN.Use CUTE_TEST_DECL to produce a declaration in a header file so that the created test case may be referenced from other compilation units.
Example definition
#include "sample_test.h" CUTE_TEST_EXTERN(sample_test, CUTE_NULL_SETUP, CUTE_NULL_TEARDOWN, CUTE_DFLT_TMOUT) { cute_check_assert(0 == 0); }
Example declaration in a sample_test.h header file
#ifndef _SAMPLE_TEST_H #define _SAMPLE_TEST_H #include <cute/cute.h> extern CUTE_TEST_DECL(sample_test); #endif
- Parameters:
_name – [in] test case name
_setup – [in] setup fixture function
_teardown – [in] teardown fixture function
_tmout – [in] test timeout
4.2.32. CUTE_TEST_STATIC
-
CUTE_TEST_STATIC(_name, _setup, _teardown, _tmout)
Define a static file scoped test case with attributes.
Define a test case designated by the
_namevariable with static global file scope. The test case is created with attributes given in argument as explained below.In addition, CUTE_TEST_STATIC must be immediately followed by a block of instructions defining the related testing logic as stated in CUTE_TEST_DEFN.
_setupis a setup() fixture function as described in CUTE_TEST_DEFN._teardownis a teardown() fixture function as described in CUTE_TEST_DEFN._tmoutis a timeout expressed in seconds as described in CUTE_TEST_DEFN.Example
CUTE_TEST_STATIC(sample_test, CUTE_NULL_SETUP, CUTE_NULL_TEARDOWN, CUTE_DFLT_TMOUT) { cute_check_assert(0 == 0); }
See also
- Parameters:
_name – [in] test case name
_setup – [in] setup fixture function
_teardown – [in] teardown fixture function
_tmout – [in] test timeout
4.2.33. CUTE_UINT_RANGE
-
CUTE_UINT_RANGE(_min, _max)
Define a unsigned integer range.
Initialize a cute_uint_range variable that defines a range of unsigned integers.
Example
CUTE_TEST(mytest) { const struct cute_uint_range range = CUTE_UINT_RANGE(-5, 20); cute_check_uint_range(0, in, range); cute_check_uint_range(10, not_in, CUTE_UINT_RANGE(-5, 5)); }
See also
- Parameters:
_min – [in] range’s minimum value (inclusive)
_max – [in] range’s maximum value (inclusive)
4.2.34. CUTE_UINT_SET
-
CUTE_UINT_SET(...)
Define a unsigned integer set.
Initialize a cute_uint_set variable that defines a set of unsigned integers.
The
...variable argument list is an unordered list of unsigned integer values separated by commas that composes the set.Example
CUTE_TEST(mytest) { const struct cute_uint_set set = CUTE_UINT_SET(-5, 0, 5); cute_check_uint_set(0, in, set); cute_check_uint_set(7, not_in, CUTE_UINT_SET(-10, -5, 0, 5, 10)); }
See also
- Parameters:
... – [in] list of set values
4.2.35. cute_check_assert
-
cute_check_assert(_expr)
Check that a test assertion is true.
Abort current test and mark it as failed if
_expris false (i.e., compares equal to zero).This macro may be used from within fixture functions as well as test case functions.
Example
CUTE_TEST(mytest) { cute_check_assert(0 == 0); }
See also
- Parameters:
_expr – [in] expression
4.2.36. cute_check_bool
-
cute_check_bool(_chk, _op, _xpct)
Check a boolean.
Abort current test and mark it as failed if the comparison of
_chkand_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :isto ensure that_chk==_xpct;is_notto ensure that_chk!=_xpct.
Both
_chkand_xpctMUST be booleans, i.e.,boolor an equivalent typedef’ed type.This macro may be used from within fixture functions as well as test case functions.
Ensure that true equals true :
CUTE_TEST(mytest) { cute_check_bool(true, is, true); }
Ensure that true unequals false :
CUTE_TEST(mytest) { cute_check_bool(true, is_not, false); }
See also
- Parameters:
_chk – [in] boolean value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] expected boolean value to perform the check against
4.2.37. cute_check_flt
-
cute_check_flt(_chk, _op, _xpct)
Check a floating point number.
Abort current test and mark it as failed if the comparison of
_chkand_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :equalto ensure that_chk==_xpct;unequalto ensure that_chk!=_xpct;greater, to ensure that_chk>_xpct;greater_equal, to ensure that_chk>=_xpct;lower, to ensure that_chk<_xpct;lower_equal, to ensure that_chk<=_xpct.
Both
_chkand_xpctMUST be floating point numbers, i.e., either :float,double,long double,or an equivalent typedef’ed type.
This macro may be used from within fixture functions as well as test case functions.
Ensure that 0.5 equals 0.5 (single precision) :
CUTE_TEST(mytest) { cute_check_flt(0.5f, equal, 0.5f); }
Ensure that 0.5 unequals 1.5 (single precision) :
CUTE_TEST(mytest) { cute_check_flt(0.5f, unequal, 1.5f); }
Ensure that 1.5 is greater than 0.5 (double precision) :
CUTE_TEST(mytest) { cute_check_flt(1.5, greater, 0.5); }
Ensure that 1 is greater than or equal to 1 (double precision) :
CUTE_TEST(mytest) { cute_check_flt(1.5, greater_equal, 1.5); }
Ensure that 0.5 is lower than 1.5 (extended precision) :
CUTE_TEST(mytest) { cute_check_flt(0.5L, lower, 1.5L); }
Ensure that 1.5 is lower than or equal to 1.5 (extended precision) :
CUTE_TEST(mytest) { cute_check_flt(1.5L, lower_equal, 1.5L); }
See also
- Parameters:
_chk – [in] floating point value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] expected floating point value to perform the check against
Note
Quad-precision floating point numbers (
__float128) are not yet supported.
4.2.38. cute_check_flt_range
-
cute_check_flt_range(_chk, _op, _xpct)
Check a floating point number against a range.
Abort current test and mark it as failed if the comparison of
_chkagainst the_xpctrange using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :in, to ensure that_xpct.min<=_chk<=_xpct.max;not_into ensure that_chk<_xpct.minor_chk>_xpct.max.
_chkMUST be a floating point number, i.e., either :float,double,long double,or an equivalent typedef’ed type.
_xpctMUST be a cute_flt_range floating point number range as defined by the CUTE_FLT_RANGE macro.This macro may be used from within fixture functions as well as test case functions.
Ensure that 0.5 is included within the [-10.5, 10.5] range (single precision) :
CUTE_TEST(mytest) { cute_check_flt_range(0.5f, in, CUTE_FLT_RANGE(-10.5f, 10.5f)); }
Ensure that -10 is not included within the [0.5, 10.5] range (double precision) :
CUTE_TEST(mytest) { const struct cute_flt_range range = CUTE_FLT_RANGE(0.5, 10.5); cute_check_flt_range(-10, not_in, range); }
See also
- Parameters:
_chk – [in] floating point value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] reference floating point range to perform the check against
Note
Quad-precision floating point numbers (
__float128) are not yet supported.
4.2.39. cute_check_flt_set
-
cute_check_flt_set(_chk, _op, _xpct)
Check a floating point number against a set.
Abort current test and mark it as failed if the comparison of
_chkagainst the_xpctset using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :in, to ensure that_chkequals to one the_xpctset values ;not_into ensure that_chkequals to none of the_xpctset values.
_chkMUST be a floating point number, i.e., either :float,double,long double,or an equivalent typedef’ed type.
_xpctMUST be a cute_flt_set floating point number set as defined by the CUTE_FLT_SET macro.This macro may be used from within fixture functions as well as test case functions.
Ensure that 0.5 is included within the {0.5, 1.5, 2.0, 3.5} set (single precision) :
CUTE_TEST(mytest) { cute_check_flt_set(0.5f, in, CUTE_FLT_SET(0.5f, 1.5f, 2.0f, 3.5f)); }
Ensure that 4.5 is not included within the {0.5, 1.5, 2.0, 3.5, 5.5} set (double precision) :
CUTE_TEST(mytest) { const struct cute_flt_set set = CUTE_FLT_SET(0.5, 1.5, 2.0, 3.5, 5.5); cute_check_flt_set(4.5, not_in, set); }
See also
- Parameters:
_chk – [in] floating point value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] reference set of floating point numbers to perform the check against
Note
Quad-precision floating point numbers (
__float128) are not yet supported.
4.2.40. cute_check_hex
-
cute_check_hex(_chk, _op, _xpct)
Check an hexadecimal unsigned integer.
Abort current test and mark it as failed if the comparison of
_chkand_xpctusing the_opcomparison operator results in a failure. It is similar to the cute_check_uint macro with the ability to display values as hexadecimal numbers when producing failure report .Comparison is performed according to the following formula :
Where_chk <_op> _xpct
_opMUST be one of :equalto ensure that_chk==_xpct;unequalto ensure that_chk!=_xpct;greater, to ensure that_chk>_xpct;greater_equal, to ensure that_chk>=_xpct;lower, to ensure that_chk<_xpct;lower_equal, to ensure that_chk<=_xpct.
Both
_chkand_xpctMUST be unsigned integers, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
This macro may be used from within fixture functions as well as test case functions.
Ensure that 0 equals 0 :
CUTE_TEST(mytest) { cute_check_hex(0, equal, 0); }
Ensure that 0 unequals 1 :
CUTE_TEST(mytest) { cute_check_hex(0, unequal, 1); }
Ensure that 1 is greater than 0 :
CUTE_TEST(mytest) { cute_check_hex(1, greater, 0); }
Ensure that 1 is greater than or equal to 1 :
CUTE_TEST(mytest) { cute_check_hex(1, greater_equal, 1); }
Ensure that 0 is lower than 1 :
CUTE_TEST(mytest) { cute_check_hex(0, lower, 1); }
Ensure that 1 is lower than or equal to 1 :
CUTE_TEST(mytest) { cute_check_hex(1, lower_equal, 1); }
See also
- Parameters:
_chk – [in] unsigned integer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] expected unsigned integer value to perform the check against
4.2.41. cute_check_hex_range
-
cute_check_hex_range(_chk, _op, _xpct)
Check an hexadecimal unsigned integer against a range.
Abort current test and mark it as failed if the comparison of
_chkagainst the_xpctrange using the_opcomparison operator results in a failure. It is similar to the cute_check_uint_range macro with the ability to display values as hexadecimal numbers when producing failure report .Comparison is performed according to the following formula :
Where_chk <_op> _xpct
_opMUST be one of :in, to ensure that_xpct.min<=_chk<=_xpct.max;not_into ensure that_chk<_xpct.minor_chk>_xpct.max.
_chkMUST be a unsigned integer, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_uint_range unsigned integer range as defined by the CUTE_UINT_RANGE macro.This macro may be used from within fixture functions as well as test case functions.
Ensure that 0xf is included within the [0x0, 0xff] range :
CUTE_TEST(mytest) { cute_check_hex_range(0xf, in, CUTE_UINT_RANGE(0x0, 0xff)); }
Ensure that 0xffff is not included within the [0x0, 0xff] range :
CUTE_TEST(mytest) { const struct cute_uint_range range = CUTE_UINT_RANGE(0x0, 0xff); cute_check_hex_range(0xffff, not_in, range); }
- Parameters:
_chk – [in] unsigned integer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] reference unsigned integer range to perform the check against
4.2.42. cute_check_hex_set
-
cute_check_hex_set(_chk, _op, _xpct)
Check an hexadecimal unsigned integer against a set.
Abort current test and mark it as failed if the comparison of
_chkagainst the_xpctset using the_opcomparison operator results in a failure. It is similar to the cute_check_uint_set macro with the ability to display values as hexadecimal numbers when producing failure report .Comparison is performed according to the following formula :
Where_chk <_op> _xpct
_opMUST be one of :in, to ensure that_chkequals to one the_xpctset values ;not_into ensure that_chkequals to none of the_xpctset values.
_chkMUST be a unsigned integer, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_uint_set unsigned integer set as defined by the CUTE_UINT_SET macro.This macro may be used from within fixture functions as well as test case functions.
Ensure that 0xbeef is included within the {0xdead, 0xbeef, 0xbabe, 0xcode} set :
CUTE_TEST(mytest) { cute_check_hex_set(0, in, CUTE_UINT_SET(0xdead, 0xbeef, 0xbabe, 0xcode)); }
Ensure that 0xf is not included within the {0xdead, 0xbeef, 0xbabe, 0xcode} set :
CUTE_TEST(mytest) { const struct cute_uint_set set = CUTE_UINT_SET(0xdead, 0xbeef, 0xbabe, 0xcode); cute_check_hex_set(0xf, not_in, set); }
- Parameters:
_chk – [in] unsigned integer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] reference set of unsigned integers to perform the check against
4.2.43. cute_check_mem
-
cute_check_mem(_chk, _op, _xpct, _sz)
Check a memory area.
Abort current test and mark it as failed if the comparison of
_chkand_xpctcontents using the_opcomparison operator results in a failure. Comparison is performed according to the following formula over_szsize bytes :Where_chk <_op> _xpct
_opMUST be one of :equalto ensure that content of_chk==_xpctcontent;unequalto ensure that content of_chk!=_xpctcontent.
Both
_chkand_xpctMUST be pointers, i.e., eithervoid *or an equivalent typedef’ed type.This macro may be used from within fixture functions as well as test case functions.
Ensure that content of 2 memory areas are equal :
CUTE_TEST(mytest) { const int check[] = { 0, 1, 2, 3 }; const int expect[] = { 0, 1, 2, 3 }; cute_check_mem((const void *)check, equal, (const void *)expect, sizeof(expect)); }
Ensure that content of 2 memory areas differ :
CUTE_TEST(mytest) { const int check[] = { 3, 2, 1, 0 }; const int expect[] = { 0, 1, 2, 3 }; cute_check_mem((const void *)check, unequal, (const void *)expect, sizeof(expect)); }
See also
- Parameters:
_chk – [in] memory area to check
_op – [in] constraint operation used to perform the check
_xpct – [in] address of expected memory area to perform the check against
_sz – [in] size of expected memory area to perform the check against
4.2.44. cute_check_ptr
-
cute_check_ptr(_chk, _op, _xpct)
Check a pointer.
Abort current test and mark it as failed if the comparison of
_chkand_xpctusing the_opcomparison operator results in a failure. It is similar to the cute_check_uint macro with the ability to display pointer values as hexadecimal numbers when producing failure report .Comparison is performed according to the following formula :
Where_chk <_op> _xpct
_opMUST be one of :equalto ensure that_chk==_xpct;unequalto ensure that_chk!=_xpct;greater, to ensure that_chk>_xpct;greater_equal, to ensure that_chk>=_xpct;lower, to ensure that_chk<_xpct;lower_equal, to ensure that_chk<=_xpct.
Both
_chkand_xpctMUST be pointers, i.e., eithervoid *or an equivalent typedef’ed type.This macro may be used from within fixture functions as well as test case functions.
Ensure that (void *)0xdeadbeef pointer equals to (void *)0xdeadbeef pointer :
CUTE_TEST(mytest) { cute_check_ptr((const void *)0xdeadbeef, equal, (const void *)0xdeadbeef); }
Ensure that (void *)0xdeadbeef pointer differs from (void *)0xdeafbabe pointer :
CUTE_TEST(mytest) { cute_check_ptr((const void *)0xdeadbeef, unequal, (const void *)0xdeafbabe); }
Ensure that (void *)0xdeafbabe pointer is higher than (void *)0xdeadbeef pointer :
CUTE_TEST(mytest) { cute_check_ptr((const void *)0xdeafbabe, greater, (const void *)0xdeadbeef); }
Ensure that (void *)0xdeadbeef pointer is higher than or equal to (void *)0xdeadbeef pointer :
CUTE_TEST(mytest) { cute_check_ptr((const void *)0xdeadbeef, greater_equal, (const void *)0xdeadbeef); }
Ensure that (void *)0xdeadbeef pointer is lower than (void *)0xdeafbabe pointer :
CUTE_TEST(mytest) { cute_check_ptr((const void *)0xdeadbeef, lower, (const void *)0xdeafbabe); }
Ensure that (void *)0xdeadbeef pointer is lower than or equal to (void *)0xdeadbeef pointer :
CUTE_TEST(mytest) { cute_check_ptr((const void *)0xdeadbeef, lower_equal, (const void *)0xdeadbeef); }
See also
- Parameters:
_chk – [in] pointer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] expected pointer value to perform the check against
4.2.45. cute_check_ptr_range
-
cute_check_ptr_range(_chk, _op, _xpct)
Check a pointer against a range.
Abort current test and mark it as failed if the comparison of
_chkagainst the_xpctrange using the_opcomparison operator results in a failure. It is similar to the cute_check_uint_range macro with the ability to display pointers as hexadecimal numbers when producing failure report .Comparison is performed according to the following formula :
Where_chk <_op> _xpct
_opMUST be one of :in, to ensure that_xpct.min<=_chk<=_xpct.max;not_into ensure that_chk<_xpct.minor_chk>_xpct.max.
_chkMUST be a pointer, i.e., either avoid *or an equivalent typedef’ed type._xpctMUST be a cute_ptr_range pointer range as defined by the CUTE_PTR_RANGE macro.This macro may be used from within fixture functions as well as test case functions.
Ensure that (void *)0xbabeface is included within the [0xbabaface, 0xdeafbabe] range :
CUTE_TEST(mytest) { cute_check_ptr_range((const void *)0xbabeface, in, CUTE_PTR_RANGE((const void *)0xbabaface, (const void *)0xdeafbabe)); }
Ensure that (void *)0xdeafbabe is not included within the [0xbabaface, 0xdeadc0de] range :
CUTE_TEST(mytest) { const struct cute_uint_range range = CUTE_PTR_RANGE((const void *)0xbabaface, (const void *)0xdeadc0de)); cute_check_ptr_range((const void *)0xdeafbabe, not_in, range); }
See also
- Parameters:
_chk – [in] pointer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] reference pointer range to perform the check against
4.2.46. cute_check_ptr_set
-
cute_check_ptr_set(_chk, _op, _xpct)
Check a pointer against a set.
Abort current test and mark it as failed if the comparison of
_chkagainst the_xpctset using the_opcomparison operator results in a failure. It is similar to the cute_check_uint_set macro with the ability to display pointers as hexadecimal numbers when producing failure report .Comparison is performed according to the following formula :
Where_chk <_op> _xpct
_opMUST be one of :in, to ensure that_chkequals to one the_xpctset values ;not_into ensure that_chkequals to none of the_xpctset values.
_chkMUST be a pointer, i.e., either avoid *or an equivalent typedef’ed type._xpctMUST be a cute_ptr_set pointer set as defined by the CUTE_PTR_SET macro.This macro may be used from within fixture functions as well as test case functions.
Ensure that (void *)0xdeadc0de is included within the {0xbabaface, 0xdeadc0de, 0xdeadbeef} set :
CUTE_TEST(mytest) { cute_check_ptr_set((const void *)0xdeadc0de, in, CUTE_PTR_SET((const void *)0xbabaface, (const void *)0xdeadc0de, (const void *)0xdeadbeef)); }
Ensure that (void *)0xdeafbabe is not included within the {0xbabaface, 0xdeadc0de, 0xdeadbeef} set :
CUTE_TEST(mytest) { cute_check_ptr_set((const void *)0xdeafbabe, not_in, CUTE_PTR_SET((const void *)0xbabaface, (const void *)0xdeadc0de, (const void *)0xdeadbeef)); }
See also
- Parameters:
_chk – [in] pointer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] reference set of pointers to perform the check against
4.2.47. cute_check_sint
-
cute_check_sint(_chk, _op, _xpct)
Check a signed integer.
Abort current test and mark it as failed if the comparison of
_chkand_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :equalto ensure that_chk==_xpct;unequalto ensure that_chk!=_xpct;greater, to ensure that_chk>_xpct;greater_equal, to ensure that_chk>=_xpct;lower, to ensure that_chk<_xpct;lower_equal, to ensure that_chk<=_xpct.
Both
_chkand_xpctMUST be signed integers, i.e., either :signed char,signed short,signed int,signed long,signed long long,or an equivalent typedef’ed type.
This macro may be used from within fixture functions as well as test case functions.
Ensure that 0 equals 0 :
CUTE_TEST(mytest) { cute_check_sint(0, equal, 0); }
Ensure that 0 unequals 1 :
CUTE_TEST(mytest) { cute_check_sint(0, unequal, 1); }
Ensure that 1 is greater than 0 :
CUTE_TEST(mytest) { cute_check_sint(1, greater, 0); }
Ensure that 1 is greater than or equal to 1 :
CUTE_TEST(mytest) { cute_check_sint(1, greater_equal, 1); }
Ensure that 0 is lower than 1 :
CUTE_TEST(mytest) { cute_check_sint(0, lower, 1); }
Ensure that 1 is lower than or equal to 1 :
CUTE_TEST(mytest) { cute_check_sint(1, lower_equal, 1); }
See also
- Parameters:
_chk – [in] signed integer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] expected signed integer value to perform the check against
4.2.48. cute_check_sint_range
-
cute_check_sint_range(_chk, _op, _xpct)
Check a signed integer against a range.
Abort current test and mark it as failed if the comparison of
_chkagainst the_xpctrange using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :in, to ensure that_xpct.min<=_chk<=_xpct.max;not_into ensure that_chk<_xpct.minor_chk>_xpct.max.
_chkMUST be a signed integer, i.e., either :signed char,signed short,signed int,signed long,signed long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_sint_range signed integer range as defined by the CUTE_SINT_RANGE macro.This macro may be used from within fixture functions as well as test case functions.
Ensure that 0 is included within the [-10, 10] range :
CUTE_TEST(mytest) { cute_check_sint_range(0, in, CUTE_SINT_RANGE(-10, 10)); }
Ensure that -10 is not included within the [0, 10] range :
CUTE_TEST(mytest) { const struct cute_sint_range range = CUTE_SINT_RANGE(0, 10); cute_check_sint_range(-10, not_in, range); }
See also
- Parameters:
_chk – [in] signed integer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] reference signed integer range to perform the check against
4.2.49. cute_check_sint_set
-
cute_check_sint_set(_chk, _op, _xpct)
Check a signed integer against a set.
Abort current test and mark it as failed if the comparison of
_chkagainst the_xpctset using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :in, to ensure that_chkequals to one the_xpctset values ;not_into ensure that_chkequals to none of the_xpctset values.
_chkMUST be a signed integer, i.e., either :signed char,signed short,signed int,signed long,signed long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_sint_set signed integer set as defined by the CUTE_SINT_SET macro.This macro may be used from within fixture functions as well as test case functions.
Ensure that 0 is included within the {-10, -5, 0, 5, 10} set :
CUTE_TEST(mytest) { cute_check_sint_set(0, in, CUTE_SINT_SET(-10, -5, 0, 5, 10)); }
Ensure that 1 is not included within the {-5, 0, 5} set :
CUTE_TEST(mytest) { const struct cute_sint_set set = CUTE_SINT_SET(-5, 0, 5); cute_check_sint_set(1, not_in, set); }
See also
- Parameters:
_chk – [in] signed integer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] reference set of signed integers to perform the check against
4.2.50. cute_check_str
-
cute_check_str(_chk, _op, _xpct)
Check string content.
Abort current test and mark it as failed if the comparison of
_chkand_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :equalto ensure that_chkcontent equals to_xpctcontent;unequalto ensure that_chkcontent differs from_xpctcontent;begin, to ensure that_chkcontent begins with_xpctcontent;end, to ensure that_chkcontent ends with_xpctcontent;contain, to ensure that_chkcontent contains_xpctcontent, i.e.,_xpctis a substring of_chk;not_contain, to ensure that_chkcontent does not containt_xpctcontent, i.e.,_xpctis not a substring of_chk.
Both
_chkand_xpctMUST beNULLterminated C strings.This macro may be used from within fixture functions as well as test case functions.
Ensure that “zero” string equals to “zero” string :
CUTE_TEST(mytest) { cute_check_str("zero", equal, "zero"); }
Ensure that “zero” string begins with “ze” string :
CUTE_TEST(mytest) { cute_check_str("zero", begin, "ze"); }
Ensure that “zero” string ends with “ro” string :
CUTE_TEST(mytest) { cute_check_str("zero", end, "ro"); }
Ensure that “er” is a substring of “zero” string :
CUTE_TEST(mytest) { cute_check_str("zero", contain, "er"); }
Ensure that “era” is not a substring of “zero” string :
CUTE_TEST(mytest) { cute_check_str("zero", not_contain, "era"); }
See also
- Parameters:
_chk – [in] string content to check
_op – [in] constraint operation used to perform the check
_xpct – [in] expected string content to perform the check against
4.2.51. cute_check_str_set
-
cute_check_str_set(_chk, _op, _xpct)
Check string content against a set of strings.
Abort current test and mark it as failed if the comparison of
_chkagainst the_xpctset using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :in, to ensure that_chkequals to one the_xpctset strings ;not_into ensure that_chkequals to none of the_xpctset strings.
_chkMUST be aNULLterminated C string._xpctMUST be a cute_str_set set ofNULLterminated C strings as defined by the CUTE_STR_SET macro.This macro may be used from within fixture functions as well as test case functions.
Ensure that “one” string is included within the {“zero”, “one”, “two”} set of strings :
CUTE_TEST(mytest) { cute_check_str_set("one", in, CUTE_STR_SET("zero", "one", "two")); }
Ensure that “three” string is not included within the {“zero”, “one”, “two”} set of strings :
CUTE_TEST(mytest) { const struct cute_str_set set = CUTE_STR_SET("zero", "one", "two"); cute_check_str_set("three", not_in, set); }
See also
- Parameters:
_chk – [in] string content to check
_op – [in] constraint operation used to perform the check
_xpct – [in] reference set of strings to perform the check against
4.2.52. cute_check_uint
-
cute_check_uint(_chk, _op, _xpct)
Check an unsigned integer.
Abort current test and mark it as failed if the comparison of
_chkand_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :equalto ensure that_chk==_xpct;unequalto ensure that_chk!=_xpct;greater, to ensure that_chk>_xpct;greater_equal, to ensure that_chk>=_xpct;lower, to ensure that_chk<_xpct;lower_equal, to ensure that_chk<=_xpct.
Both
_chkand_xpctMUST be unsigned integers, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
This macro may be used from within fixture functions as well as test case functions.
Ensure that 0 equals 0 :
CUTE_TEST(mytest) { cute_check_uint(0, equal, 0); }
Ensure that 0 unequals 1 :
CUTE_TEST(mytest) { cute_check_uint(0, unequal, 1); }
Ensure that 1 is greater than 0 :
CUTE_TEST(mytest) { cute_check_uint(1, greater, 0); }
Ensure that 1 is greater than or equal to 1 :
CUTE_TEST(mytest) { cute_check_uint(1, greater_equal, 1); }
Ensure that 0 is lower than 1 :
CUTE_TEST(mytest) { cute_check_uint(0, lower, 1); }
Ensure that 1 is lower than or equal to 1 :
CUTE_TEST(mytest) { cute_check_uint(1, lower_equal, 1); }
See also
- Parameters:
_chk – [in] unsigned integer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] expected unsigned integer value to perform the check against
4.2.53. cute_check_uint_range
-
cute_check_uint_range(_chk, _op, _xpct)
Check a unsigned integer against a range.
Abort current test and mark it as failed if the comparison of
_chkagainst the_xpctrange using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :in, to ensure that_xpct.min<=_chk<=_xpct.max;not_into ensure that_chk<_xpct.minor_chk>_xpct.max.
_chkMUST be a unsigned integer, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_uint_range unsigned integer range as defined by the CUTE_UINT_RANGE macro.This macro may be used from within fixture functions as well as test case functions.
Ensure that 0 is included within the [0, 10] range :
CUTE_TEST(mytest) { cute_check_uint_range(0, in, CUTE_UINT_RANGE(0, 10)); }
Ensure that 11 is not included within the [0, 10] range :
CUTE_TEST(mytest) { const struct cute_uint_range range = CUTE_UINT_RANGE(0, 10); cute_check_uint_range(11, not_in, range); }
See also
- Parameters:
_chk – [in] unsigned integer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] reference unsigned integer range to perform the check against
4.2.54. cute_check_uint_set
-
cute_check_uint_set(_chk, _op, _xpct)
Check a unsigned integer against a set.
Abort current test and mark it as failed if the comparison of
_chkagainst the_xpctset using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_chk <_op> _xpct
_opMUST be one of :in, to ensure that_chkequals to one the_xpctset values ;not_into ensure that_chkequals to none of the_xpctset values.
_chkMUST be a unsigned integer, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_uint_set unsigned integer set as defined by the CUTE_UINT_SET macro.This macro may be used from within fixture functions as well as test case functions.
Ensure that 0 is included within the {0, 1, 2, 3, 5, 8} set :
CUTE_TEST(mytest) { cute_check_uint_set(0, in, CUTE_UINT_SET(0, 1, 2, 3, 5, 8)); }
Ensure that 4 is not included within the {0, 1, 2, 3, 5, 8} set :
CUTE_TEST(mytest) { const struct cute_uint_set set = CUTE_UINT_SET(0, 1, 2, 3, 5, 8); cute_check_uint_set(4, not_in, set); }
See also
- Parameters:
_chk – [in] unsigned integer value to check
_op – [in] constraint operation used to perform the check
_xpct – [in] reference set of unsigned integers to perform the check against
4.2.55. cute_expect_assertion
-
cute_expect_assertion(_call)
Check that an assertion failure has been thrown.
Abort current test and mark it as failed if
_callexpression does not call cute_mock_assert() to ensure that an assertion failure has been thrown.As shown in the example below, the glibc ‘s
__assert_fail()function is overridden using cute_mock_assert() so that a call to cute_expect_assertion() may check thatfunction_to_test()function causes an assert(3) failure.This macro may be used from within fixture functions as well as test case functions.
Example
#include <assert.h> #include <cute/cute.h> #include <cute/expect.h> void __attribute__((noreturn)) __assert_fail(const char * expression, const char * file, unsigned int line, const char * function) { cute_mock_assert(expression, file, line, function); } static void function_to_test(void) { assert(0); } CUTE_TEST(mytest) { cute_expect_assertion(function_to_test()); }
See also
- Parameters:
_call – [in] function call expression
4.2.56. cute_expect_bool_parm
-
cute_expect_bool_parm(_func, _parm, _op, _xpct)
Schedule a boolean function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_bool_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :isto ensure that_parm==_xpct;is_notto ensure that_parm!=_xpct.
Both
_parmand_xpctMUST be booleans, i.e., either aboolor an equivalent typedef’ed type.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> static void callee(bool value) { cute_mock_bool_parm(value); } static void caller(bool value) { callee(value); } CUTE_TEST(mytest) { cute_expect_bool_parm(callee, value, is, true); cute_expect_bool_parm(callee, value, is_not, true); caller(true); caller(false); }
See also
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] expected boolean value to perform the check against
4.2.57. cute_expect_bool_retval
-
cute_expect_bool_retval(_func, _retval)
Schedule a boolean function return value mock expectation.
Define and schedule an expectation which value is returned when cute_mock_bool_retval() is called.
_retvalMUST be a boolean, i.e., either aboolor an equivalent typedef’ed type.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> static int callee(void) { return cute_mock_bool_retval(); } static int caller(void) { return callee(); } CUTE_TEST(mytest) { cute_expect_bool_retval(callee, false); cute_check_bool(caller(), is, false); }
See also
- Parameters:
_func – [in] function name
_retval – [in] value to be returned from mocked function
4.2.58. cute_expect_call
-
cute_expect_call(_func)
Schedule a function call mock expectation.
Define and schedule an expectation that is checked when cute_mock_call() is called. The check performed ensures that the function which name is given as
_funcargument is called according to the expected schedule order.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> static void callee(void) { cute_mock_call(); } static void caller(void) { callee(); } CUTE_TEST(mytest) { cute_expect_call(callee); caller(); }
See also
- Parameters:
_func – [in] function name
4.2.59. cute_expect_flt_parm
-
cute_expect_flt_parm(_func, _parm, _op, _xpct)
Schedule a floating point number function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_flt_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :equalto ensure that_parm==_xpct;unequalto ensure that_parm!=_xpct;greater, to ensure that_parm>_xpct;greater_equal, to ensure that_parm>=_xpct;lower, to ensure that_parm<_xpct;lower_equal, to ensure that_parm<=_xpct.
Both
_parmand_xpctMUST be floating point numbers, i.e., either :float,double,long double,or an equivalent typedef’ed type.
This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(float float_value, double double_value) { cute_mock_flt_parm(float_value); cute_mock_flt_parm(double_value); } static void caller(float float_value, double double_value) { callee(float_value, double_value); } CUTE_TEST(mytest) { cute_expect_flt_parm(callee, float_value, equal, 1.5f); cute_expect_flt_parm(callee, double_value, greater, 10.005); caller(1.5f, 5.7); }
See also
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] expected floating point value to perform the check against
4.2.60. cute_expect_flt_range
-
cute_expect_flt_range(_func, _parm, _op, _xpct)
Schedule a floating point number range function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_flt_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst the_xpctrange using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :in, to ensure that_xpct.min<=_parm<=_xpct.max;not_into ensure that_parm<_xpct.minor_parm>_xpct.max.
_parmMUST be a floating point number, i.e., either :float,double,long double,or an equivalent typedef’ed type.
_xpctMUST be a cute_flt_range floating point number range as defined by the CUTE_FLT_RANGE macro.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(float float_value, double double_value) { cute_mock_flt_parm(float_value); cute_mock_flt_parm(double_value); } static void caller(float float_value, double double_value) { callee(float_value, double_value); } CUTE_TEST(mytest) { const struct cute_flt_range range = CUTE_FLT_RANGE(-5.005, 5.005); cute_expect_flt_range(callee, float_value, in, CUTE_FLT_RANGE(0.005f, 9.005f)); cute_expect_flt_range(callee, double_value, not_in, range); caller(5.0025f, -7.725); }
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] reference floating point number range to perform the check against
4.2.61. cute_expect_flt_retval
-
cute_expect_flt_retval(_func, _retval)
Schedule a floating point number function return value mock expectation.
Define and schedule an expectation which value is returned when cute_mock_flt_retval() is called.
_retvalMUST be a floating point number, i.e., either :float,double,long double,or an equivalent typedef’ed type.
This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static float callee(void) { return (float)cute_mock_flt_retval(); } static float caller(void) { return callee(); } CUTE_TEST(mytest) { cute_expect_flt_retval(callee, 1.5f); cute_check_flt(caller(), equal, 1.5f); }
See also
- Parameters:
_func – [in] function name
_retval – [in] value to be returned from mocked function
4.2.62. cute_expect_flt_set
-
cute_expect_flt_set(_func, _parm, _op, _xpct)
Schedule a floating point number set function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_flt_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst the_xpctset using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :in, to ensure that_parmequals to one the_xpctset values ;not_into ensure that_parmequals to none of the_xpctset values.
_parmMUST be a floating point number, i.e., either :float,double,long double,or an equivalent typedef’ed type.
_xpctMUST be a cute_flt_set floating point number set as defined by the CUTE_FLT_SET macro.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(float float_value, double double_value) { cute_mock_flt_parm(float_value); cute_mock_flt_parm(double_value); } static void caller(float float_value, double double_value) { callee(float_value, double_value); } CUTE_TEST(mytest) { const struct cute_flt_set set = CUTE_FLT_SET(-10.005, 5.005, 10.005); cute_expect_flt_set(callee, float_value, in, CUTE_FLT_SET(0.5f, 5.5f, 10.5f)); cute_expect_flt_set(callee, double_value, not_in, set); caller(5.5f, 7.005); }
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] reference floating point number set to perform the check against
4.2.63. cute_expect_hex_parm
-
cute_expect_hex_parm(_func, _parm, _op, _xpct)
Schedule an hexadecimal unsigned integer function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_hex_parm() is called. It is similar to the cute_expect_uint_parm macro with the ability to display values as hexadecimal numbers when producing failure report .
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :equalto ensure that_parm==_xpct;unequalto ensure that_parm!=_xpct;greater, to ensure that_parm>_xpct;greater_equal, to ensure that_parm>=_xpct;lower, to ensure that_parm<_xpct;lower_equal, to ensure that_parm<=_xpct.
Both
_parmand_xpctMUST be unsigned integers, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(int word, short half) { cute_mock_hex_parm(word); cute_mock_hex_parm(half); } static void caller(int word, short half) { callee(word, half); } CUTE_TEST(mytest) { cute_expect_hex_parm(callee, word, equal, UINT_MAX); cute_expect_hex_parm(callee, half, greater, USHRT_MAX / 2); caller(UINT_MAX, USHRT_MAX); }
See also
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] expected unsigned integer value to perform the check against
4.2.64. cute_expect_hex_range
-
cute_expect_hex_range(_func, _parm, _op, _xpct)
Schedule an hexadecimal unsigned integer range function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_hex_parm() is called. It is similar to the cute_expect_uint_range macro with the ability to display values as hexadecimal numbers when producing failure report .
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst the_xpctrange using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :in, to ensure that_xpct.min<=_parm<=_xpct.max;not_into ensure that_parm<_xpct.minor_parm>_xpct.max.
_parmMUST be an unsigned integer, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_uint_range unsigned integer range as defined by the CUTE_UINT_RANGE macro.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(int word, short half) { cute_mock_hex_parm(word); cute_mock_hex_parm(half); } static void caller(int word, short half) { callee(word, half); } CUTE_TEST(mytest) { const struct cute_uint_range range = CUTE_UINT_RANGE(0, USHRT_MAX / 2); cute_expect_hex_range(callee, word, in, CUTE_UINT_RANGE(0, 10)); cute_expect_hex_range(callee, half, not_in, range); caller(5, USHRT_MAX); }
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] reference unsigned integer range to perform the check against
4.2.65. cute_expect_hex_set
-
cute_expect_hex_set(_func, _parm, _op, _xpct)
Schedule an hexadecimal unsigned integer set function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_hex_parm() is called. It is similar to the cute_expect_uint_set macro with the ability to display values as hexadecimal numbers when producing failure report .
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst the_xpctset using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :in, to ensure that_parmequals to one the_xpctset values ;not_into ensure that_parmequals to none of the_xpctset values.
_parmMUST be an unsigned integer, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_uint_set unsigned integer set as defined by the CUTE_UINT_SET macro.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(int word, short half) { cute_mock_hex_parm(word); cute_mock_hex_parm(half); } static void caller(int word, short half) { callee(word, half); } CUTE_TEST(mytest) { const struct cute_uint_set set = CUTE_UINT_SET(0, 10, USHRT_MAX / 2); cute_expect_hex_set(callee, word, in, CUTE_UINT_SET(0, 5, 10)); cute_expect_hex_set(callee, half, not_in, set); caller(10, USHRT_MAX); }
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] reference unsigned integer set to perform the check against
4.2.66. cute_expect_mem_parm
-
cute_expect_mem_parm(_func, _parm, _op, _ptr, _sz)
Schedule a memory area function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_mem_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :equalto ensure that content of_parm==_xpctcontent;unequalto ensure that content of_parm!=_xpctcontent.
Both
_parmand_xpctMUST be pointers, i.e., eithervoid *or an equivalent typedef’ed type.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(const int * area) { cute_mock_mem_parm(area); } static void caller(const int * area) { callee(area); } CUTE_TEST(mytest) { const int const array[2] = { 0, 1, 2 }; cute_expect_mem_parm(callee, area, equal, array, sizeof(array)); cute_expect_mem_parm(callee, area, unequal, array, 4U); caller(array); caller(&array[1]); }
See also
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_ptr – [in] address of expected memory area to perform the check against
_sz – [in] size of expected memory area to perform the check against
4.2.67. cute_expect_ptr_parm
-
cute_expect_ptr_parm(_func, _parm, _op, _xpct)
Schedule a pointer function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_ptr_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :equalto ensure that_parm==_xpct;unequalto ensure that_parm!=_xpct;greater, to ensure that_parm>_xpct;greater_equal, to ensure that_parm>=_xpct;lower, to ensure that_parm<_xpct;lower_equal, to ensure that_parm<=_xpct.
Both
_parmand_xpctMUST be pointers, i.e., eithervoid *or an equivalent typedef’ed type.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(const void * ptr) { cute_mock_ptr_parm(ptr); } static void caller(const void * ptr) { callee(ptr); } CUTE_TEST(mytest) { int val = 0; cute_expect_ptr_parm(callee, ptr, equal, (const void *)&val); caller((const void *)&val); }
See also
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] expected pointer value to perform the check against
4.2.68. cute_expect_ptr_range
-
cute_expect_ptr_range(_func, _parm, _op, _xpct)
Schedule a pointer range function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_ptr_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst the_xpctrange using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :in, to ensure that_xpct.min<=_parm<=_xpct.max;not_into ensure that_parm<_xpct.minor_parm>_xpct.max.
_parmMUST be a pointer, i.e., eithervoid *or an equivalent typedef’ed type._xpctMUST be a cute_ptr_range pointer range as defined by the CUTE_PTR_RANGE macro.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(const void * ptr) { cute_mock_ptr_parm(ptr); } static void caller(const void * ptr) { callee(ptr); } CUTE_TEST(mytest) { const int array[2] = { 0, 1, 2 }; const struct cute_ptr_range range = CUTE_PTR_RANGE((const void *)&array[0], (const void *)&array[1]); cute_expect_ptr_range(callee, ptr, in, CUTE_PTR_RANGE((const void *)&array[0], (const void *)&array[2])); cute_expect_ptr_range(callee, ptr, not_in, range); caller((const void *)&array[1]); caller((const void *)&array[2]); }
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] reference pointer range to perform the check against
4.2.69. cute_expect_ptr_retval
-
cute_expect_ptr_retval(_func, _retval)
Schedule a pointer function return value mock expectation.
Define and schedule an expectation which value is returned when cute_mock_ptr_retval() is called.
_retvalMUST be a pointer, i.e., eithervoid *or an equivalent typedef’ed type.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static const void * callee(void) { return cute_mock_ptr_retval(); } static const void * caller(void) { return callee(); } CUTE_TEST(mytest) { cute_expect_ptr_retval(callee, NULL); cute_check_ptr(caller(), equal, NULL); }
See also
- Parameters:
_func – [in] function name
_retval – [in] value to be returned from mocked function
4.2.70. cute_expect_ptr_set
-
cute_expect_ptr_set(_func, _parm, _op, _xpct)
Schedule a pointer set function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_ptr_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst the_xpctset using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :in, to ensure that_parmequals to one the_xpctset values ;not_into ensure that_parmequals to none of the_xpctset values.
_parmMUST be a pointer, i.e., eithervoid *or an equivalent typedef’ed type._xpctMUST be a cute_ptr_set pointer set as defined by the CUTE_PTR_SET macro.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(const void * ptr) { cute_mock_ptr_parm(ptr); } static void caller(const void * ptr) { callee(ptr); } CUTE_TEST(mytest) { int array[2] = { 0, 1, 2 }; const struct cute_ptr_set set = CUTE_PTR_SET((const void *)&array[2], (const void *)&array[0]); cute_expect_ptr_set(callee, ptr, in, CUTE_PTR_SET((const void *)&array[2], (const void *)&array[0], (const void *)&array[1]); cute_expect_ptr_set(callee, ptr, not_in, set); caller((const void *)&array[0]); caller((const void *)&array[1]); }
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] reference pointer set to perform the check against
4.2.71. cute_expect_sint_parm
-
cute_expect_sint_parm(_func, _parm, _op, _xpct)
Schedule a signed integer function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_sint_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :equalto ensure that_parm==_xpct;unequalto ensure that_parm!=_xpct;greater, to ensure that_parm>_xpct;greater_equal, to ensure that_parm>=_xpct;lower, to ensure that_parm<_xpct;lower_equal, to ensure that_parm<=_xpct.
Both
_parmand_xpctMUST be signed integers, i.e., either :signed char,signed short,signed int,signed long,signed long long,or an equivalent typedef’ed type.
This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(int word, short half) { cute_mock_sint_parm(word); cute_mock_sint_parm(half); } static void caller(int word, short half) { callee(word, half); } CUTE_TEST(mytest) { cute_expect_sint_parm(callee, word, equal, INT_MAX); cute_expect_sint_parm(callee, half, greater, SHRT_MAX / 2); caller(INT_MAX, SHRT_MAX); }
See also
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] expected signed integer value to perform the check against
4.2.72. cute_expect_sint_range
-
cute_expect_sint_range(_func, _parm, _op, _xpct)
Schedule a signed integer range function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_sint_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst the_xpctrange using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :in, to ensure that_xpct.min<=_parm<=_xpct.max;not_into ensure that_parm<_xpct.minor_parm>_xpct.max.
_parmMUST be a signed integer, i.e., either :signed char,signed short,signed int,signed long,signed long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_sint_range signed integer range as defined by the CUTE_SINT_RANGE macro.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(int word, short half) { cute_mock_sint_parm(word); cute_mock_sint_parm(half); } static void caller(int word, short half) { callee(word, half); } CUTE_TEST(mytest) { const struct cute_sint_range range = CUTE_SINT_RANGE(0, SHRT_MAX); cute_expect_sint_range(callee, word, in, CUTE_SINT_RANGE(-10, 10)); cute_expect_sint_range(callee, half, not_in, range); caller(-5, SHRT_MIN); }
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] reference signed integer range to perform the check against
4.2.73. cute_expect_sint_retval
-
cute_expect_sint_retval(_func, _retval)
Schedule a signed integer function return value mock expectation.
Define and schedule an expectation which value is returned when cute_mock_sint_retval() is called.
_retvalMUST be a signed integer, i.e., either :signed char,signed short,signed int,signed long,signed long long,or an equivalent typedef’ed type.
This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static int callee(void) { return (int)cute_mock_sint_retval(); } static int caller(void) { return callee(); } CUTE_TEST(mytest) { cute_expect_sint_retval(callee, 1); cute_check_sint(caller(), equal, 1); }
See also
- Parameters:
_func – [in] function name
_retval – [in] value to be returned from mocked function
4.2.74. cute_expect_sint_set
-
cute_expect_sint_set(_func, _parm, _op, _xpct)
Schedule a signed integer set function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_sint_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst the_xpctset using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :in, to ensure that_parmequals to one the_xpctset values ;not_into ensure that_parmequals to none of the_xpctset values.
_parmMUST be a signed integer, i.e., either :signed char,signed short,signed int,signed long,signed long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_sint_set signed integer set as defined by the CUTE_SINT_SET macro.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(int word, short half) { cute_mock_sint_parm(word); cute_mock_sint_parm(half); } static void caller(int word, short half) { callee(word, half); } CUTE_TEST(mytest) { const struct cute_sint_set set = CUTE_SINT_SET(0, 10, SHRT_MAX); cute_expect_sint_set(callee, word, in, CUTE_SINT_SET(-10, 0, 10)); cute_expect_sint_set(callee, half, not_in, set); caller(10, SHRT_MIN); }
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] reference signed integer set to perform the check against
4.2.75. cute_expect_str_parm
-
cute_expect_str_parm(_func, _parm, _op, _xpct)
Schedule a string function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_str_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :equalto ensure that_parmcontent equals to_xpctcontent;unequalto ensure that_parmcontent differs from_xpctcontent;begin, to ensure that_parmcontent begins with_xpctcontent;end, to ensure that_parmcontent ends with_xpctcontent;contain, to ensure that_parmcontent contains_xpctcontent, i.e.,_xpctis a substring of_parm;not_contain, to ensure that_parmcontent does not containt_xpctcontent, i.e.,_xpctis not a substring of_parm.
Both
_parmand_xpctMUST beNULLterminated C strings.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(const char * string) { cute_mock_str_parm(string); } static void caller(const char * string) { callee(string); } CUTE_TEST(mytest) { cute_expect_str_parm(callee, string, equal, "a test string"); cute_expect_str_parm(callee, string, begin, "another"); caller("a test string"); caller("another test string"); }
See also
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] expected string content to perform the check against
4.2.76. cute_expect_str_retval
-
cute_expect_str_retval(_func, _retval)
Schedule a string function return value mock expectation.
Define and schedule an expectation which value is returned when cute_mock_str_retval() is called.
_retvalMUST be aNULLterminated C string.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static const char * callee(void) { return cute_mock_str_retval(); } static const char * caller(void) { return callee(); } CUTE_TEST(mytest) { cute_expect_str_retval(callee, "a test string"); cute_check_str(caller(), contain, "test"); }
See also
- Parameters:
_func – [in] function name
_retval – [in] value to be returned from mocked function
4.2.77. cute_expect_str_set
-
cute_expect_str_set(_func, _parm, _op, _xpct)
Schedule a string set function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_str_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst the_xpctset using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :in, to ensure that_parmequals to one the_xpctset values ;not_into ensure that_parmequals to none of the_xpctset values.
_parmMUST be aNULLterminated C string._xpctMUST be a cute_str_set string set as defined by the CUTE_STR_SET macro.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(const char * string) { cute_mock_str_parm(string); } static void caller(const char * string) { callee(string); } CUTE_TEST(mytest) { const struct cute_str_set set = CUTE_STR_SET("zero", "one", "two"); cute_expect_str_set(callee, string, in, CUTE_STR_SET("Lorem", "ipsum"); cute_expect_str_set(callee, string, not_in, set); caller("one"); caller("dolor"); }
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] reference string set to perform the check against
4.2.78. cute_expect_uint_parm
-
cute_expect_uint_parm(_func, _parm, _op, _xpct)
Schedule an unsigned integer function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_uint_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst_xpctusing the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :equalto ensure that_parm==_xpct;unequalto ensure that_parm!=_xpct;greater, to ensure that_parm>_xpct;greater_equal, to ensure that_parm>=_xpct;lower, to ensure that_parm<_xpct;lower_equal, to ensure that_parm<=_xpct.
Both
_parmand_xpctMUST be unsigned integers, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(int word, short half) { cute_mock_uint_parm(word); cute_mock_uint_parm(half); } static void caller(int word, short half) { callee(word, half); } CUTE_TEST(mytest) { cute_expect_uint_parm(callee, word, equal, UINT_MAX); cute_expect_uint_parm(callee, half, greater, USHRT_MAX / 2); caller(UINT_MAX, USHRT_MAX); }
See also
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] expected unsigned integer value to perform the check against
4.2.79. cute_expect_uint_range
-
cute_expect_uint_range(_func, _parm, _op, _xpct)
Schedule an unsigned integer range function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_uint_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst the_xpctrange using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :in, to ensure that_xpct.min<=_parm<=_xpct.max;not_into ensure that_parm<_xpct.minor_parm>_xpct.max.
_parmMUST be an unsigned integer, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_uint_range unsigned integer range as defined by the CUTE_UINT_RANGE macro.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(int word, short half) { cute_mock_uint_parm(word); cute_mock_uint_parm(half); } static void caller(int word, short half) { callee(word, half); } CUTE_TEST(mytest) { const struct cute_uint_range range = CUTE_UINT_RANGE(0, USHRT_MAX / 2); cute_expect_uint_range(callee, word, in, CUTE_UINT_RANGE(0, 10)); cute_expect_uint_range(callee, half, not_in, range); caller(5, USHRT_MAX); }
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] reference unsigned integer range to perform the check against
4.2.80. cute_expect_uint_retval
-
cute_expect_uint_retval(_func, _retval)
Schedule an unsigned integer function return value mock expectation.
Define and schedule an expectation which value is returned when cute_mock_uint_retval() is called.
_retvalMUST be an unsigned integer, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static unsigned int callee(void) { return (unsigned int)cute_mock_uint_retval(); } static unsigned int caller(void) { return callee(); } CUTE_TEST(mytest) { cute_expect_uint_retval(callee, 1U); cute_check_uint(caller(), equal, 1U); }
See also
- Parameters:
_func – [in] function name
_retval – [in] value to be returned from mocked function
4.2.81. cute_expect_uint_set
-
cute_expect_uint_set(_func, _parm, _op, _xpct)
Schedule an unsigned integer set function parameter mock expectation.
Define and schedule an expectation that is checked when cute_mock_uint_parm() is called.
The check performed aborts current test and marks it as failed if the comparison of
_parmagainst the_xpctset using the_opcomparison operator results in a failure. Comparison is performed according to the following formula :Where_parm <_op> _xpct
_opMUST be one of :in, to ensure that_parmequals to one the_xpctset values ;not_into ensure that_parmequals to none of the_xpctset values.
_parmMUST be an unsigned integer, i.e., either :unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or an equivalent typedef’ed type.
_xpctMUST be a cute_uint_set unsigned integer set as defined by the CUTE_UINT_SET macro.This macro may be used from within fixture functions as well as test case functions.
Example
#include <cute/cute.h> #include <cute/expect.h> #include <limits.h> static void callee(int word, short half) { cute_mock_uint_parm(word); cute_mock_uint_parm(half); } static void caller(int word, short half) { callee(word, half); } CUTE_TEST(mytest) { const struct cute_uint_set set = CUTE_UINT_SET(0, 10, USHRT_MAX / 2); cute_expect_uint_set(callee, word, in, CUTE_UINT_SET(0, 5, 10)); cute_expect_uint_set(callee, half, not_in, set); caller(10, USHRT_MAX); }
- Parameters:
_func – [in] function name
_parm – [in] function parameter name
_op – [in] constraint operation used to check the expectation
_xpct – [in] reference unsigned integer set to perform the check against
4.2.82. cute_fail
-
cute_fail(_reason)
Mark current test as failed.
Stop running current test case or suite and mark it as failed .
When non
NULL, the_reasonargument should be a string describing the reason why the test has failed.See report section for more informations about possible test hierarchy outcomes.
Example
CUTE_TEST(sample_test) { cute_fail(NULL); }
See also
- Parameters:
_reason – [in] reason description string
4.2.83. cute_mock_bool_parm
-
cute_mock_bool_parm(_parm)
Check a boolean function parameter mock expectation.
Check the value of a boolean function parameter expectation scheduled using cute_expect_bool_parm().
This macro must be called from within the mocked function which is given the parameter to verify.
See also
- Parameters:
_parm – [in] function parameter name
4.2.84. cute_mock_bool_retval
-
cute_mock_bool_retval()
Return a boolean function return value mock expectation.
Extract and return a a boolean value scheduled using cute_expect_bool_retval().
This macro must be called from within the mocked function that returns the scheduled value.
See also
- Returns:
scheduled return value cast as an
bool
4.2.85. cute_mock_call
-
cute_mock_call()
Check a function call mock expectation.
Ensure that a function call mock expectation scheduled by cute_expect_call() is called according to the expected schedule order.
Current test is aborted and marked as failed when the check fails.
This macro may be used from within fixture functions as well as test case functions.
See also
4.2.86. cute_mock_flt_parm
-
cute_mock_flt_parm(_parm)
Check a floating point number function parameter mock expectation.
Check the value of a floating point number function parameter expectation scheduled using cute_expect_flt_parm(), cute_expect_flt_range() or cute_expect_flt_set().
This macro must be called from within the mocked function which is given the parameter to verify.
- Parameters:
_parm – [in] function parameter name
4.2.87. cute_mock_flt_retval
-
cute_mock_flt_retval()
Return a floating point number function return value mock expectation.
Extract and return a a floating point number value scheduled using cute_expect_flt_retval().
This macro must be called from within the mocked function that returns the scheduled value.
See also
- Returns:
scheduled return value cast as an
long double
4.2.88. cute_mock_hex_parm
-
cute_mock_hex_parm(_parm)
Check an hexadecimal unsigned integer function parameter mock expectation.
Check the value of an unsigned integer function parameter expectation scheduled using cute_expect_hex_parm(), cute_expect_hex_range() or cute_expect_hex_set(). It is identical to the cute_expect_uint_parm macro and both may be used interchangeably.
This macro must be called from within the mocked function which is given the parameter to verify.
- Parameters:
_parm – [in] function parameter name
4.2.89. cute_mock_mem_parm
-
cute_mock_mem_parm(_parm)
Check a pointer function parameter mock expectation.
Check the content pointed to by a pointer function parameter expectation scheduled using cute_expect_mem_parm().
This macro must be called from within the mocked function which is given the parameter to verify.
See also
- Parameters:
_parm – [in] function parameter name
4.2.90. cute_mock_ptr_parm
-
cute_mock_ptr_parm(_parm)
Check a pointer function parameter mock expectation.
Check the value of a pointer function parameter expectation scheduled using cute_expect_ptr_parm(), cute_expect_ptr_range() or cute_expect_ptr_set().
This macro must be called from within the mocked function which is given the parameter to verify.
- Parameters:
_parm – [in] function parameter name
4.2.91. cute_mock_ptr_retval
-
cute_mock_ptr_retval()
Return a pointer function return value mock expectation.
Extract and return a pointer value scheduled using cute_expect_ptr_retval().
This macro must be called from within the mocked function that returns the scheduled value.
See also
- Returns:
scheduled return value cast as an
void *
4.2.92. cute_mock_sint_parm
-
cute_mock_sint_parm(_parm)
Check a signed integer function parameter mock expectation.
Check the value of a signed integer function parameter expectation scheduled using cute_expect_sint_parm(), cute_expect_sint_range() or cute_expect_sint_set().
This macro must be called from within the mocked function which is given the parameter to verify.
- Parameters:
_parm – [in] function parameter name
4.2.93. cute_mock_sint_retval
-
cute_mock_sint_retval()
Return a signed integer function return value mock expectation.
Extract and return a a signed integer value scheduled using cute_expect_sint_retval().
This macro must be called from within the mocked function that returns the scheduled value.
See also
- Returns:
scheduled return value cast as an
intmax_t
4.2.94. cute_mock_str_parm
-
cute_mock_str_parm(_parm)
Check a string function parameter mock expectation.
Check the content of a string function parameter expectation scheduled using cute_expect_str_parm() or cute_expect_str_set().
This macro must be called from within the mocked function which is given the parameter to verify.
- Parameters:
_parm – [in] function parameter name
4.2.95. cute_mock_str_retval
-
cute_mock_str_retval()
Return a string function return value mock expectation.
Extract and return a pointer to a
NULLterminated C string scheduled using cute_expect_str_retval().This macro must be called from within the mocked function that returns the scheduled value.
See also
- Returns:
scheduled return value cast as a
char *
4.2.96. cute_mock_uint_parm
-
cute_mock_uint_parm(_parm)
Check an unsigned integer function parameter mock expectation.
Check the value of an unsigned integer function parameter expectation scheduled using cute_expect_uint_parm(), cute_expect_uint_range() or cute_expect_uint_set().
This macro must be called from within the mocked function which is given the parameter to verify.
- Parameters:
_parm – [in] function parameter name
4.2.97. cute_mock_uint_retval
-
cute_mock_uint_retval()
Return an unsigned integer function return value mock expectation.
Extract and return an unsigned integer value scheduled using cute_expect_uint_retval().
This macro must be called from within the mocked function that returns the scheduled value.
See also
- Returns:
scheduled return value cast as an
uintmax_t
4.2.98. cute_skip
-
cute_skip(_reason)
Skip current test.
Stop running current test case or suite and mark it as skipped .
When non
NULL, the_reasonargument should be a string describing the reason why the test has been skipped.See report section for more informations about possible test hierarchy outcomes.
Example
#if defined(CONFIG_FEATURE_ENABLED) CUTE_TEST(feature_test) { ... } #else CUTE_TEST(feature_test) { cute_skip("feature disabled"); } #endif
See also
- Parameters:
_reason – [in] reason description string
4.3. Enums
4.3.1. cute_config_report
-
enum cute_config_report
Report type selector.
Select a particular test report format.
See also
Values:
-
enumerator CUTE_CONFIG_SILENT_REPORT
Completly mute console report.
-
enumerator CUTE_CONFIG_TERSE_REPORT
Enable minimalist console report.
-
enumerator CUTE_CONFIG_VERB_REPORT
Enable verbose console report.
-
enumerator CUTE_CONFIG_TAP_REPORT
Enable Test Anything Protocol report.
-
enumerator CUTE_CONFIG_XML_REPORT
Enable JUnit XML report.
-
enumerator CUTE_CONFIG_SILENT_REPORT
4.3.2. cute_config_tty
-
enum cute_config_tty
Console terminal probing strategy selector.
Select the strategy used to probe the underlying console terminal. Probing is needed to setup console output colorization.
See also
Values:
-
enumerator CUTE_CONFIG_FALSE_TTY
Disable console terminal probing and turn colorization off.
-
enumerator CUTE_CONFIG_TRUE_TTY
Disable console terminal probing and turn colorization on.
-
enumerator CUTE_CONFIG_PROBE_TTY
Enable console terminal probing to autodetect colorization support.
-
enumerator CUTE_CONFIG_TTY_NR
-
enumerator CUTE_CONFIG_FALSE_TTY
4.4. Structs
4.4.1. cute_config
-
struct cute_config
Test run configuration.
cute_config is a structure that allows to configure the way a test hierarchy is run.
See also
Public Members
-
const char *match
Test hierarchy matching regular expression.
Allows to select a subset of the test hierarchy to run.
At run initialization time, each node of the test hierarchy is compared against the cute_config::match regular expression and selected for running if matched. Nodes for which the match failed are disabled.
cute_config::match must be specified as a POSIX extended regular expression as described in regex(7) . cute_config::icase alters the matching process.
cute_config::match may also be specified as
NULLin which case, no matching is performed, meaning that the complete test hierarchy is selected for running.See also
-
bool icase
Ignore case when matching test hierarchy nodes.
When matching a test hierarchy node thanks to cute_config::match, ignore case distinctions.
cute_config::icase is ignore when cute_config::match is
NULL.See also
-
bool debug
Enable test hierarchy running debug mode.
Enable cute_config::debug to ease the debugging of a test |hierarchy|.
When enabled, exception handling and timeouts are disabled so that a debugging session is not disturbed by an unexpected signal and / or timer expiry.
-
unsigned int reports
Test report selector mask.
Request that test results be output according to formats specified by report .
cute_config::reports must be specified as a mask of cute_config_report values according to the following restrictions :
CUTE_CONFIG_SILENT_REPORT, CUTE_CONFIG_TERSE_REPORT, and CUTE_CONFIG_VERB_REPORT are exclusive and cannot be simultaneously set within the mask ;
when cute_config::tap_path is
NULL, CUTE_CONFIG_TAP_REPORT cannot be simultaneously set with CUTE_CONFIG_SILENT_REPORT, CUTE_CONFIG_TERSE_REPORT or CUTE_CONFIG_VERB_REPORT ;when cute_config::xml_path is
NULL, CUTE_CONFIG_XML_REPORT cannot be simultaneously set with CUTE_CONFIG_SILENT_REPORT, CUTE_CONFIG_TERSE_REPORT or CUTE_CONFIG_VERB_REPORT.
-
enum cute_config_tty tty
Console terminal probing strategy selector.
Select the strategy used to probe the underlying console terminal for output colorization support.
See also
-
const char *tap_path
TAP report pathname.
Pathname to the file into which Test Anything Protocol report output is stored.
cute_config::tap_path is ignored if CUTE_CONFIG_TAP_REPORT is cleared within cute_config::reports mask.
Setting cute_config::tap_path to
NULLrequests that TAP* report output be redirected to standard output (but see cute_config::reports for restrictions).See also
-
const char *xml_path
JUnit XML report pathname.
Pathname to the file into which JUnit XML report output is stored.
cute_config::xml_path is ignored if CUTE_CONFIG_XML_REPORT is cleared within cute_config::reports mask.
Setting cute_config::xml_path to
NULLrequests that JUnit XML report output be redirected to standard output (but see cute_config::reports for restrictions).See also
-
const char *match
4.4.2. cute_flt_range
-
struct cute_flt_range
Floating point number range descriptor.
Use cute_flt_range to define a range of floating point numbers in combination with the CUTE_FLT_RANGE macro.
The range is defined by minimum and maximum floating point values (inclusive). Suitable value types are one of :
float,double,long double,or equivalent typedef’ed types.
See also
Note
Quad-precision floating point numbers (
__float128) are not yet supported.
4.4.3. cute_flt_set
-
struct cute_flt_set
Floating point number set descriptor.
Use cute_flt_set to define a set of floating point numbers in combination with the CUTE_FLT_SET macro.
The set is defined by an unordered list of floating point values. Suitable value types are one of :
float,double,long double,or equivalent typedef’ed types.
See also
Note
Quad-precision floating point numbers (
__float128) are not yet supported.Public Members
-
const char *expr
Set description string.
-
unsigned int count
Count of set values stored into cute_flt_set::items.
-
const long double *items
Array of set values.
4.4.4. cute_ptr_range
-
struct cute_ptr_range
Pointer range descriptor.
Use cute_ptr_range to define a range of pointers in combination with the CUTE_PTR_RANGE macro.
The range is defined by minimum and maximum pointer values (inclusive). Suitable value type is
void *or equivalent typedef’ed types.See also
4.4.5. cute_ptr_set
-
struct cute_ptr_set
Pointer set descriptor.
Use cute_ptr_set to define a set of pointers in combination with the CUTE_PTR_SET macro.
The set is defined by an unordered list of pointer values. Suitable value type is
void *or equivalent typedef’ed types.See also
Public Members
-
const char *expr
Set description string.
-
unsigned int count
Count of set values stored into cute_ptr_set::items.
-
const void **items
Array of set values.
-
const char *expr
4.4.6. cute_sint_range
-
struct cute_sint_range
Signed integer range descriptor.
Use cute_sint_range to define a range of signed integers in combination with the CUTE_SINT_RANGE macro.
The range is defined by minimum and maximum signed integer values (inclusive). Suitable value types are one of :
signed char,signed short,signed int,signed long,signed long long,or equivalent typedef’ed types.
See also
4.4.7. cute_sint_set
-
struct cute_sint_set
Signed integer set descriptor.
Use cute_sint_set to define a set of signed integers in combination with the CUTE_SINT_SET macro.
The set is defined by an unordered list of signed integer values. Suitable value types are one of :
signed char,signed short,signed int,signed long,signed long long,or equivalent typedef’ed types.
See also
Public Members
-
const char *expr
Set description string.
-
unsigned int count
Count of set values stored into cute_sint_set::items.
-
const intmax_t *items
Array of set values.
4.4.8. cute_str_set
-
struct cute_str_set
String content set descriptor.
Use cute_str_set to define a set of strings in combination with the CUTE_STR_SET macro.
The set is defined by an unordered list of
NULLterminated C strings.See also
Public Members
-
const char *expr
Set description string.
-
unsigned int count
Count of set values stored into cute_str_set::items.
-
const char **items
Array of set values.
-
const char *expr
4.4.9. cute_uint_range
-
struct cute_uint_range
Unsigned integer range descriptor.
Use cute_uint_range to define a range of unsigned integers in combination with the CUTE_UINT_RANGE macro.
The range is defined by minimum and maximum unsigned integer values (inclusive). Suitable value types are one of :
unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or equivalent typedef’ed types.
See also
4.4.10. cute_uint_set
-
struct cute_uint_set
Unsigned integer set descriptor.
Use cute_uint_set to define a set of unsigned integers in combination with the CUTE_UINT_SET macro.
The set is defined by an unordered list of unsigned integer values. Suitable value types are one of :
unsigned char,unsigned short,unsigned int,unsigned long,unsigned long long,or equivalent typedef’ed types.
See also
Public Members
-
const char *expr
Set description string.
-
unsigned int count
Count of set values stored into cute_uint_set::items.
-
const uintmax_t *items
Array of set values.
4.5. Functions
4.5.1. cute_init
-
int cute_init(struct cute_config *config, const char *package, const char *version)
Initialize CUTe API.
cute_init() initializes API internals and configure the way a test hierarchy runs and outputs report .
configargument configures the internal test hierarchy runner.packageshould be given as a string containing the name of the package for which testing code is written.versionshould hold the version string identifying thepackagepackage revision. Bothpackageandversionare optional and may be specified asNULL.After a successful call to cute_init() and once no more API call is required, cute_fini() must be called to release resources allocated internally.
See also
- Parameters:
config – [inout] test hierarchy run configuration
package – [in] package name string
version – [in] package version string
- Returns:
0 if successful, an errno-like error code otherwise.
4.5.2. cute_fini
-
void cute_fini(void)
Close CUTe API.
Flush / close test hierarchy reporting I/O streams and release API resources allocated internally.
Any API usage made after a call to cute_fini() will lead to unexpected results.
See also
4.5.3. cute_mock_assert
-
void cute_mock_assert(const char *expression, const char *file, unsigned int line, const char *function)
Catch an assertion failure.
Use this in combination with cute_expect_assertion() to test assertion failures.
See also
- Parameters:
expression – [in] assertion expression
file – [in] assertion source file pathname
line – [in] assertion source file line
function – [in] assertion function calling function name
4.5.4. cute_run_suite
-
int cute_run_suite(const struct cute_suite *suite)
Run a test suite.
Run a test hierarchy which top-level suite is given in argument. Run is carried out according to cute_config configuration passed as argument to cute_init().
cute_run_suite() returns an error when at least one child test case or suite has failed or crashed. See report section for more informations about possible test hierarchy outcomes.
See also
- Parameters:
suite – [in] suite to run
- Returns:
0 if successful, an errno-like error code otherwise.
4.5.5. cute_show_suite
-
void cute_show_suite(const struct cute_suite *suite)
Display informations of a test suite.
Show informations related to the test hierarchy which top-level suite is given in argument. Informations are displayed according to cute_config::reports setting passed as argument to cute_init().
See also
- Parameters:
suite – [in] suite to run