OpenVPN
|
Go to the source code of this file.
Data Structures | |
struct | OperatorFunction |
Macros | |
#define | vsnprintf _vsnprintf |
#define | array_length(x) (sizeof(x) / sizeof((x)[0])) |
Typedefs | |
typedef int(* | BinaryOperator) (int a, int b) |
typedef struct OperatorFunction | OperatorFunction |
Functions | |
int | add (int a, int b) |
int | subtract (int a, int b) |
int | multiply (int a, int b) |
int | divide (int a, int b) |
BinaryOperator | find_operator_function_by_string (const size_t number_of_operator_functions, const OperatorFunction *const operator_functions, const char *const operator_string) |
int | perform_operation (int number_of_arguments, char *arguments[], const size_t number_of_operator_functions, const OperatorFunction *const operator_functions, int *const number_of_intermediate_values, int **const intermediate_values, int *const error_occurred) |
int | example_main (int argc, char *argv[]) |
int | example_test_fprintf (FILE *const file, const char *format,...) CMOCKA_PRINTF_ATTRIBUTE(2 |
int int | example_test_printf (const char *format,...) CMOCKA_PRINTF_ATTRIBUTE(1 |
static int | binary_operator (int a, int b) |
static void | test_add (void **state) |
static void | test_subtract (void **state) |
static void | test_multiply (void **state) |
static void | test_divide (void **state) |
static void | test_divide_by_zero (void **state) |
static void | test_find_operator_function_by_string_null_functions (void **state) |
static void | test_find_operator_function_by_string_null_string (void **state) |
static void | test_find_operator_function_by_string_valid_null_functions (void **state) |
static void | test_find_operator_function_by_string_not_found (void **state) |
static void | test_find_operator_function_by_string_found (void **state) |
static void | test_perform_operation_null_args (void **state) |
static void | test_perform_operation_null_operator_functions (void **state) |
static void | test_perform_operation_null_number_of_intermediate_values (void **state) |
static void | test_perform_operation_null_intermediate_values (void **state) |
static void | test_perform_operation_no_arguments (void **state) |
static void | test_perform_operation_first_arg_not_integer (void **state) |
static void | test_perform_operation_unknown_operator (void **state) |
static void | test_perform_operation_missing_argument (void **state) |
static void | test_perform_operation_no_integer_after_operator (void **state) |
static void | test_perform_operation (void **state) |
static void | test_example_main_no_args (void **state) |
static void | test_example_main (void **state) |
int | main (void) |
Variables | |
int int static char | temporary_buffer [256] |
#define array_length | ( | x | ) | (sizeof(x) / sizeof((x)[0])) |
Definition at line 27 of file calculator_test.c.
Referenced by test_example_main(), test_example_main_no_args(), test_find_operator_function_by_string_found(), test_find_operator_function_by_string_not_found(), test_find_operator_function_by_string_null_string(), test_perform_operation(), test_perform_operation_first_arg_not_integer(), test_perform_operation_missing_argument(), test_perform_operation_no_integer_after_operator(), test_perform_operation_null_args(), test_perform_operation_null_intermediate_values(), test_perform_operation_null_number_of_intermediate_values(), test_perform_operation_null_operator_functions(), and test_perform_operation_unknown_operator().
#define vsnprintf _vsnprintf |
Definition at line 24 of file calculator_test.c.
Referenced by argv_printf_arglist(), buf_printf(), example_test_fprintf(), example_test_printf(), openvpn_snprintf(), push_option_fmt(), status_printf(), vcm_print_error(), vprint_error(), vprint_message(), and x_msg_va().
typedef int(* BinaryOperator) (int a, int b) |
Definition at line 34 of file calculator_test.c.
typedef struct OperatorFunction OperatorFunction |
int add | ( | int | a, |
int | b | ||
) |
Referenced by add_in6_addr(), HandleAddressMessage(), HandleRouteMessage(), and test_add().
|
static |
Definition at line 90 of file calculator_test.c.
References check_expected, and mock.
Referenced by test_find_operator_function_by_string_not_found(), test_find_operator_function_by_string_null_string(), test_perform_operation(), test_perform_operation_first_arg_not_integer(), test_perform_operation_missing_argument(), test_perform_operation_no_integer_after_operator(), test_perform_operation_null_args(), test_perform_operation_null_intermediate_values(), test_perform_operation_null_number_of_intermediate_values(), and test_perform_operation_unknown_operator().
int divide | ( | int | a, |
int | b | ||
) |
Referenced by test_divide(), and test_divide_by_zero().
int example_main | ( | int | argc, |
char * | argv[] | ||
) |
Referenced by test_example_main(), and test_example_main_no_args().
int example_test_fprintf | ( | FILE *const | file, |
const char * | format, | ||
... | |||
) |
Definition at line 64 of file calculator_test.c.
References assert_true, check_expected_ptr, and vsnprintf.
Referenced by test_perform_operation_first_arg_not_integer(), test_perform_operation_missing_argument(), test_perform_operation_no_integer_after_operator(), and test_perform_operation_unknown_operator().
int example_test_printf | ( | const char * | format, |
... | |||
) |
Definition at line 78 of file calculator_test.c.
References check_expected_ptr, temporary_buffer, and vsnprintf.
Referenced by test_example_main().
BinaryOperator find_operator_function_by_string | ( | const size_t | number_of_operator_functions, |
const OperatorFunction *const | operator_functions, | ||
const char *const | operator_string | ||
) |
Definition at line 143 of file calculator.c.
References OperatorFunction::function, and OperatorFunction::operator.
Referenced by perform_operation(), test_find_operator_function_by_string_found(), test_find_operator_function_by_string_not_found(), test_find_operator_function_by_string_null_functions(), test_find_operator_function_by_string_null_string(), and test_find_operator_function_by_string_valid_null_functions().
int main | ( | void | ) |
Definition at line 456 of file calculator_test.c.
References cmocka_run_group_tests, cmocka_unit_test, test_add(), test_divide(), test_divide_by_zero(), test_example_main(), test_example_main_no_args(), test_find_operator_function_by_string_found(), test_find_operator_function_by_string_not_found(), test_find_operator_function_by_string_null_functions(), test_find_operator_function_by_string_null_string(), test_find_operator_function_by_string_valid_null_functions(), test_multiply(), test_perform_operation(), test_perform_operation_first_arg_not_integer(), test_perform_operation_missing_argument(), test_perform_operation_no_arguments(), test_perform_operation_no_integer_after_operator(), test_perform_operation_null_args(), test_perform_operation_null_intermediate_values(), test_perform_operation_null_number_of_intermediate_values(), test_perform_operation_null_operator_functions(), test_perform_operation_unknown_operator(), and test_subtract().
int multiply | ( | int | a, |
int | b | ||
) |
Referenced by test_multiply().
int perform_operation | ( | int | number_of_arguments, |
char * | arguments[], | ||
const size_t | number_of_operator_functions, | ||
const OperatorFunction *const | operator_functions, | ||
int *const | number_of_intermediate_values, | ||
int **const | intermediate_values, | ||
int *const | error_occurred | ||
) |
Definition at line 175 of file calculator.c.
References find_operator_function_by_string(), and free.
Referenced by main(), test_perform_operation(), test_perform_operation_first_arg_not_integer(), test_perform_operation_missing_argument(), test_perform_operation_no_arguments(), test_perform_operation_no_integer_after_operator(), test_perform_operation_null_args(), test_perform_operation_null_intermediate_values(), test_perform_operation_null_number_of_intermediate_values(), test_perform_operation_null_operator_functions(), and test_perform_operation_unknown_operator().
int subtract | ( | int | a, |
int | b | ||
) |
Referenced by test_subtract().
|
static |
Definition at line 98 of file calculator_test.c.
References add(), and assert_int_equal.
Referenced by main().
|
static |
Definition at line 122 of file calculator_test.c.
References assert_int_equal, and divide().
Referenced by main().
|
static |
Definition at line 130 of file calculator_test.c.
References divide(), and expect_assert_failure.
Referenced by main().
|
static |
Definition at line 440 of file calculator_test.c.
References array_length, assert_int_equal, example_main(), example_test_printf(), expect_string, and temporary_buffer.
Referenced by main().
|
static |
Definition at line 427 of file calculator_test.c.
References array_length, assert_int_equal, and example_main().
Referenced by main().
|
static |
Definition at line 182 of file calculator_test.c.
References array_length, assert_int_equal, cast_ptr_to_largest_integral_type, and find_operator_function_by_string().
Referenced by main().
|
static |
Definition at line 167 of file calculator_test.c.
References array_length, assert_null, binary_operator(), and find_operator_function_by_string().
Referenced by main().
|
static |
Definition at line 138 of file calculator_test.c.
References expect_assert_failure, and find_operator_function_by_string().
Referenced by main().
|
static |
Definition at line 146 of file calculator_test.c.
References array_length, binary_operator(), expect_assert_failure, and find_operator_function_by_string().
Referenced by main().
|
static |
Definition at line 159 of file calculator_test.c.
References assert_null, and find_operator_function_by_string().
Referenced by main().
|
static |
Definition at line 114 of file calculator_test.c.
References assert_int_equal, and multiply().
Referenced by main().
|
static |
Definition at line 388 of file calculator_test.c.
References array_length, assert_int_equal, assert_non_null, binary_operator(), expect_value, perform_operation(), test_free, and will_return.
Referenced by main().
|
static |
Definition at line 288 of file calculator_test.c.
References array_length, assert_int_equal, binary_operator(), example_test_fprintf(), expect_string, perform_operation(), and temporary_buffer.
Referenced by main().
|
static |
Definition at line 338 of file calculator_test.c.
References array_length, assert_int_equal, binary_operator(), example_test_fprintf(), expect_string, perform_operation(), and temporary_buffer.
Referenced by main().
|
static |
Definition at line 273 of file calculator_test.c.
References assert_int_equal, and perform_operation().
Referenced by main().
|
static |
Definition at line 363 of file calculator_test.c.
References array_length, assert_int_equal, binary_operator(), example_test_fprintf(), expect_string, perform_operation(), and temporary_buffer.
Referenced by main().
|
static |
Definition at line 200 of file calculator_test.c.
References array_length, binary_operator(), expect_assert_failure, and perform_operation().
Referenced by main().
|
static |
Definition at line 254 of file calculator_test.c.
References array_length, binary_operator(), expect_assert_failure, and perform_operation().
Referenced by main().
|
static |
Definition at line 235 of file calculator_test.c.
References array_length, binary_operator(), expect_assert_failure, and perform_operation().
Referenced by main().
|
static |
Definition at line 218 of file calculator_test.c.
References array_length, expect_assert_failure, and perform_operation().
Referenced by main().
|
static |
Definition at line 313 of file calculator_test.c.
References array_length, assert_int_equal, binary_operator(), example_test_fprintf(), expect_string, perform_operation(), and temporary_buffer.
Referenced by main().
|
static |
Definition at line 106 of file calculator_test.c.
References assert_int_equal, and subtract().
Referenced by main().
|
static |