OpenVPN
|
Functionality to store expected values for mock function parameters. More...
Macros | |
#define | expect_check(function, parameter, check_function, check_data) |
#define | expect_in_set(function, parameter, value_array) expect_in_set_count(function, parameter, value_array, 1) |
#define | expect_in_set_count(function, parameter, value_array, count) |
#define | expect_not_in_set(function, parameter, value_array) expect_not_in_set_count(function, parameter, value_array, 1) |
#define | expect_not_in_set_count(function, parameter, value_array, count) |
#define | expect_in_range(function, parameter, minimum, maximum) expect_in_range_count(function, parameter, minimum, maximum, 1) |
#define | expect_in_range_count(function, parameter, minimum, maximum, count) |
#define | expect_not_in_range(function, parameter, minimum, maximum) expect_not_in_range_count(function, parameter, minimum, maximum, 1) |
#define | expect_not_in_range_count(function, parameter, minimum, maximum, count) |
#define | expect_value(function, parameter, value) expect_value_count(function, parameter, value, 1) |
#define | expect_value_count(function, parameter, value, count) |
#define | expect_not_value(function, parameter, value) expect_not_value_count(function, parameter, value, 1) |
#define | expect_not_value_count(function, parameter, value, count) |
#define | expect_string(function, parameter, string) expect_string_count(function, parameter, string, 1) |
#define | expect_string_count(function, parameter, string, count) |
#define | expect_not_string(function, parameter, string) expect_not_string_count(function, parameter, string, 1) |
#define | expect_not_string_count(function, parameter, string, count) |
#define | expect_memory(function, parameter, memory, size) expect_memory_count(function, parameter, memory, size, 1) |
#define | expect_memory_count(function, parameter, memory, size, count) |
#define | expect_not_memory(function, parameter, memory, size) expect_not_memory_count(function, parameter, memory, size, 1) |
#define | expect_not_memory_count(function, parameter, memory, size, count) |
#define | expect_any(function, parameter) expect_any_count(function, parameter, 1) |
#define | expect_any_count(function, parameter, count) _expect_any(#function, #parameter, __FILE__, __LINE__, count) |
#define | check_expected(parameter) |
#define | check_expected_ptr(parameter) |
Functionality to store expected values for mock function parameters.
In addition to storing the return values of mock functions, cmocka provides functionality to store expected values for mock function parameters using the expect_*() functions provided. A mock function parameter can then be validated using the check_expected() macro.
Successive calls to expect_*() macros for a parameter queues values to check the specified parameter. check_expected() checks a function parameter against the next value queued using expect_*(), if the parameter check fails a test failure is signalled. In addition if check_expected() is called and no more parameter values are queued a test failure occurs.
The following test stub illustrates how to do this. First is the the function we call in the test driver:
Now the chef_cook function can check if the parameter we got passed is the parameter which is expected by the test driver. This can be done the following way:
For a complete example please at a look at here
#define check_expected | ( | parameter | ) |
Definition at line 986 of file cmocka.h.
Referenced by __wrap_buffer_read_from_file(), __wrap_buffer_write_file(), binary_operator(), and connect_to_database().
#define check_expected_ptr | ( | parameter | ) |
Definition at line 1004 of file cmocka.h.
Referenced by __wrap_chef_cook(), connect_to_database(), example_test_fprintf(), and example_test_printf().
#define expect_any | ( | function, | |
parameter | |||
) | expect_any_count(function, parameter, 1) |
#define expect_any_count | ( | function, | |
parameter, | |||
count | |||
) | _expect_any(#function, #parameter, __FILE__, __LINE__, count) |
#define expect_check | ( | function, | |
parameter, | |||
check_function, | |||
check_data | |||
) |
#define expect_in_range | ( | function, | |
parameter, | |||
minimum, | |||
maximum | |||
) | expect_in_range_count(function, parameter, minimum, maximum, 1) |
#define expect_in_range_count | ( | function, | |
parameter, | |||
minimum, | |||
maximum, | |||
count | |||
) |
#define expect_in_set | ( | function, | |
parameter, | |||
value_array | |||
) | expect_in_set_count(function, parameter, value_array, 1) |
#define expect_in_set_count | ( | function, | |
parameter, | |||
value_array, | |||
count | |||
) |
#define expect_memory | ( | function, | |
parameter, | |||
memory, | |||
size | |||
) | expect_memory_count(function, parameter, memory, size, 1) |
Definition at line 848 of file cmocka.h.
Referenced by test_tls_crypt_v2_write_client_key_file(), test_tls_crypt_v2_write_client_key_file_metadata(), and test_tls_crypt_v2_write_server_key_file().
#define expect_memory_count | ( | function, | |
parameter, | |||
memory, | |||
size, | |||
count | |||
) |
#define expect_not_in_range | ( | function, | |
parameter, | |||
minimum, | |||
maximum | |||
) | expect_not_in_range_count(function, parameter, minimum, maximum, 1) |
#define expect_not_in_range_count | ( | function, | |
parameter, | |||
minimum, | |||
maximum, | |||
count | |||
) |
#define expect_not_in_set | ( | function, | |
parameter, | |||
value_array | |||
) | expect_not_in_set_count(function, parameter, value_array, 1) |
#define expect_not_in_set_count | ( | function, | |
parameter, | |||
value_array, | |||
count | |||
) |
#define expect_not_memory | ( | function, | |
parameter, | |||
memory, | |||
size | |||
) | expect_not_memory_count(function, parameter, memory, size, 1) |
#define expect_not_memory_count | ( | function, | |
parameter, | |||
memory, | |||
size, | |||
count | |||
) |
#define expect_not_string | ( | function, | |
parameter, | |||
string | |||
) | expect_not_string_count(function, parameter, string, 1) |
#define expect_not_string_count | ( | function, | |
parameter, | |||
string, | |||
count | |||
) |
#define expect_not_value | ( | function, | |
parameter, | |||
value | |||
) | expect_not_value_count(function, parameter, value, 1) |
#define expect_not_value_count | ( | function, | |
parameter, | |||
value, | |||
count | |||
) |
#define expect_string | ( | function, | |
parameter, | |||
string | |||
) | expect_string_count(function, parameter, string, 1) |
Definition at line 753 of file cmocka.h.
Referenced by test_bad_dish(), test_connect_to_product_database(), test_connect_to_product_database_bad_url(), test_connect_to_product_database_missing_parameter(), test_example_main(), test_order_hotdog(), test_perform_operation_first_arg_not_integer(), test_perform_operation_missing_argument(), test_perform_operation_no_integer_after_operator(), test_perform_operation_unknown_operator(), test_tls_crypt_v2_write_client_key_file(), test_tls_crypt_v2_write_client_key_file_metadata(), and test_tls_crypt_v2_write_server_key_file().
#define expect_string_count | ( | function, | |
parameter, | |||
string, | |||
count | |||
) |
#define expect_value | ( | function, | |
parameter, | |||
value | |||
) | expect_value_count(function, parameter, value, 1) |
Definition at line 662 of file cmocka.h.
Referenced by test_connect_to_product_database(), test_connect_to_product_database_bad_url(), and test_perform_operation().
#define expect_value_count | ( | function, | |
parameter, | |||
value, | |||
count | |||
) |