From 1dfa94fa21d864dbccb140d6216aa194ac23106b Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 17 Apr 2023 22:56:38 -0500 Subject: [PATCH] Update: Unit tests. Get several of the unit tests working. These tests were not updated when their respective code was changed. --- .../f_console/tests/unit/c/test-console-identify.c | 42 +-- .../c/test-console-parameter_prioritize_left.c | 30 +-- .../c/test-console-parameter_prioritize_right.c | 30 +-- .../tests/unit/c/test-console-parameter_process.c | 286 ++++++++++++++------- .../tests/unit/c/test-type_array-states_append.c | 2 +- .../tests/unit/c/test-type_array-statess_append.c | 2 +- 6 files changed, 250 insertions(+), 142 deletions(-) diff --git a/level_0/f_console/tests/unit/c/test-console-identify.c b/level_0/f_console/tests/unit/c/test-console-identify.c index 6d57eea..07ba532 100644 --- a/level_0/f_console/tests/unit/c/test-console-identify.c +++ b/level_0/f_console/tests/unit/c/test-console-identify.c @@ -18,78 +18,78 @@ void test__f_console_identify__parameter_checking(void **state) { void test__f_console_identify__works(void **state) { - f_console_result_t id = f_console_result_t_initialize; + f_console_result_t result = f_console_result_t_initialize; { const f_string_t input = f_string_t_initialize; - const f_status_t status = f_console_identify(input, &id); + const f_status_t status = f_console_identify(input, &result); assert_int_equal(status, F_data_not); - assert_int_equal(id, f_console_none_e); + assert_int_equal(result, f_console_result_none_e); } { - const f_status_t status = f_console_identify("input", &id); + const f_status_t status = f_console_identify("input", &result); assert_int_equal(status, F_none); - assert_int_equal(id, f_console_none_e); + assert_int_equal(result, f_console_result_none_e); } { - const f_status_t status = f_console_identify("-", &id); + const f_status_t status = f_console_identify("-", &result); assert_int_equal(status, F_none); - assert_int_equal(id, f_console_empty_short_enable_e); + assert_int_equal(result, f_console_result_found_e | f_console_result_normal_e | f_console_result_short_e | f_console_result_alone_e); } { - const f_status_t status = f_console_identify("+", &id); + const f_status_t status = f_console_identify("+", &result); assert_int_equal(status, F_none); - assert_int_equal(id, f_console_empty_short_disable_e); + assert_int_equal(result, f_console_result_found_e | f_console_result_inverse_e | f_console_result_short_e | f_console_result_alone_e); } { - const f_status_t status = f_console_identify("-i", &id); + const f_status_t status = f_console_identify("-i", &result); assert_int_equal(status, F_none); - assert_int_equal(id, f_console_short_enable_e); + assert_int_equal(result, f_console_result_found_e | f_console_result_normal_e | f_console_result_short_e); } { - const f_status_t status = f_console_identify("+i", &id); + const f_status_t status = f_console_identify("+i", &result); assert_int_equal(status, F_none); - assert_int_equal(id, f_console_short_disable_e); + assert_int_equal(result, f_console_result_found_e | f_console_result_inverse_e | f_console_result_short_e); } { - const f_status_t status = f_console_identify("--input", &id); + const f_status_t status = f_console_identify("--input", &result); assert_int_equal(status, F_none); - assert_int_equal(id, f_console_long_enable_e); + assert_int_equal(result, f_console_result_found_e | f_console_result_normal_e | f_console_result_long_e); } { - const f_status_t status = f_console_identify("++input", &id); + const f_status_t status = f_console_identify("++input", &result); assert_int_equal(status, F_none); - assert_int_equal(id, f_console_long_disable_e); + assert_int_equal(result, f_console_result_found_e | f_console_result_inverse_e | f_console_result_long_e); } { - const f_status_t status = f_console_identify("--", &id); + const f_status_t status = f_console_identify("--", &result); assert_int_equal(status, F_none); - assert_int_equal(id, f_console_empty_long_enable_e); + assert_int_equal(result, f_console_result_found_e | f_console_result_normal_e | f_console_result_long_e | f_console_result_alone_e); } { - const f_status_t status = f_console_identify("++", &id); + const f_status_t status = f_console_identify("++", &result); assert_int_equal(status, F_none); - assert_int_equal(id, f_console_empty_long_disable_e); + assert_int_equal(result, f_console_result_found_e | f_console_result_inverse_e | f_console_result_long_e | f_console_result_alone_e); } } diff --git a/level_0/f_console/tests/unit/c/test-console-parameter_prioritize_left.c b/level_0/f_console/tests/unit/c/test-console-parameter_prioritize_left.c index ff38833..13ec017 100644 --- a/level_0/f_console/tests/unit/c/test-console-parameter_prioritize_left.c +++ b/level_0/f_console/tests/unit/c/test-console-parameter_prioritize_left.c @@ -8,12 +8,12 @@ extern "C" { void test__f_console_parameter_prioritize_left__fails(void **state) { f_console_parameters_t parameters = f_console_parameters_t_initialize; - f_console_parameter_ids_t choices = f_console_parameter_ids_t_initialize; - f_console_parameter_id_t decision = f_console_parameter_id_t_initialize; + f_uint16s_t choices = f_uint16s_t_initialize; + f_array_length_t decision = f_array_length_t_initialize; { - f_console_parameter_id_t ids_array[1] = { 20 }; - choices.id = ids_array; + uint16_t choices_array[1] = { 20 }; + choices.array = choices_array; choices.used = 1; f_console_parameter_t parameter = f_console_parameter_t_initialize; @@ -32,7 +32,7 @@ void test__f_console_parameter_prioritize_left__fails(void **state) { void test__f_console_parameter_prioritize_left__parameter_checking(void **state) { f_console_parameters_t parameters = f_console_parameters_t_initialize; - f_console_parameter_ids_t choices = f_console_parameter_ids_t_initialize; + f_uint16s_t choices = f_uint16s_t_initialize; { const f_status_t status = f_console_parameter_prioritize_left(parameters, choices, 0); @@ -41,8 +41,8 @@ void test__f_console_parameter_prioritize_left__parameter_checking(void **state) } { - f_console_parameter_id_t ids_array[1] = { f_console_parameter_id_t_initialize }; - choices.id = ids_array; + uint16_t choices_array[1] = { f_array_length_t_initialize }; + choices.array = choices_array; const f_status_t status = f_console_parameter_prioritize_left(parameters, choices, 0); @@ -55,12 +55,12 @@ void test__f_console_parameter_prioritize_left__parameter_checking(void **state) void test__f_console_parameter_prioritize_left__works(void **state) { f_console_parameters_t parameters = f_console_parameters_t_initialize; - f_console_parameter_ids_t choices = f_console_parameter_ids_t_initialize; - f_console_parameter_id_t decision = f_console_parameter_id_t_initialize; + f_uint16s_t choices = f_uint16s_t_initialize; + f_array_length_t decision = f_array_length_t_initialize; { - f_console_parameter_id_t ids_array[1] = { 0 }; - choices.id = ids_array; + uint16_t choices_array[1] = { 0 }; + choices.array = choices_array; const f_status_t status = f_console_parameter_prioritize_left(parameters, choices, &decision); @@ -68,8 +68,8 @@ void test__f_console_parameter_prioritize_left__works(void **state) { } { - f_console_parameter_id_t ids_array[1] = { 0 }; - choices.id = ids_array; + uint16_t choices_array[1] = { 0 }; + choices.array = choices_array; choices.used = 1; f_console_parameter_t parameter = f_console_parameter_t_initialize; @@ -83,8 +83,8 @@ void test__f_console_parameter_prioritize_left__works(void **state) { } { - f_console_parameter_id_t ids_array[2] = { 0, 1 }; - choices.id = ids_array; + uint16_t choices_array[2] = { 0, 1 }; + choices.array = choices_array; choices.used = 2; f_console_parameter_t parameter_1 = f_console_parameter_t_initialize; diff --git a/level_0/f_console/tests/unit/c/test-console-parameter_prioritize_right.c b/level_0/f_console/tests/unit/c/test-console-parameter_prioritize_right.c index 9e01860..a2bf287 100644 --- a/level_0/f_console/tests/unit/c/test-console-parameter_prioritize_right.c +++ b/level_0/f_console/tests/unit/c/test-console-parameter_prioritize_right.c @@ -8,12 +8,12 @@ extern "C" { void test__f_console_parameter_prioritize_right__fails(void **state) { f_console_parameters_t parameters = f_console_parameters_t_initialize; - f_console_parameter_ids_t choices = f_console_parameter_ids_t_initialize; - f_console_parameter_id_t decision = f_console_parameter_id_t_initialize; + f_uint16s_t choices = f_uint16s_t_initialize; + f_array_length_t decision = f_array_length_t_initialize; { - f_console_parameter_id_t ids_array[1] = { 20 }; - choices.id = ids_array; + uint16_t choices_array[1] = { 20 }; + choices.array = choices_array; choices.used = 1; f_console_parameter_t parameter = f_console_parameter_t_initialize; @@ -32,7 +32,7 @@ void test__f_console_parameter_prioritize_right__fails(void **state) { void test__f_console_parameter_prioritize_right__parameter_checking(void **state) { f_console_parameters_t parameters = f_console_parameters_t_initialize; - f_console_parameter_ids_t choices = f_console_parameter_ids_t_initialize; + f_uint16s_t choices = f_uint16s_t_initialize; { const f_status_t status = f_console_parameter_prioritize_right(parameters, choices, 0); @@ -41,8 +41,8 @@ void test__f_console_parameter_prioritize_right__parameter_checking(void **state } { - f_console_parameter_id_t ids_array[1] = { f_console_parameter_id_t_initialize }; - choices.id = ids_array; + uint16_t choices_array[1] = { f_array_length_t_initialize }; + choices.array = choices_array; const f_status_t status = f_console_parameter_prioritize_right(parameters, choices, 0); @@ -55,12 +55,12 @@ void test__f_console_parameter_prioritize_right__parameter_checking(void **state void test__f_console_parameter_prioritize_right__works(void **state) { f_console_parameters_t parameters = f_console_parameters_t_initialize; - f_console_parameter_ids_t choices = f_console_parameter_ids_t_initialize; - f_console_parameter_id_t decision = f_console_parameter_id_t_initialize; + f_uint16s_t choices = f_uint16s_t_initialize; + f_array_length_t decision = f_array_length_t_initialize; { - f_console_parameter_id_t ids_array[1] = { 0 }; - choices.id = ids_array; + uint16_t choices_array[1] = { 0 }; + choices.array = choices_array; const f_status_t status = f_console_parameter_prioritize_right(parameters, choices, &decision); @@ -68,8 +68,8 @@ void test__f_console_parameter_prioritize_right__works(void **state) { } { - f_console_parameter_id_t ids_array[1] = { 0 }; - choices.id = ids_array; + uint16_t choices_array[1] = { 0 }; + choices.array = choices_array; choices.used = 1; f_console_parameter_t parameter = f_console_parameter_t_initialize; @@ -83,8 +83,8 @@ void test__f_console_parameter_prioritize_right__works(void **state) { } { - f_console_parameter_id_t ids_array[2] = { 0, 1 }; - choices.id = ids_array; + uint16_t choices_array[2] = { 0, 1 }; + choices.array = choices_array; choices.used = 2; f_console_parameter_t parameter_1 = f_console_parameter_t_initialize; diff --git a/level_0/f_console/tests/unit/c/test-console-parameter_process.c b/level_0/f_console/tests/unit/c/test-console-parameter_process.c index 0f1db02..0b72651 100644 --- a/level_0/f_console/tests/unit/c/test-console-parameter_process.c +++ b/level_0/f_console/tests/unit/c/test-console-parameter_process.c @@ -13,26 +13,40 @@ void test__f_console_parameter_process__incomplete_arguments(void **state) { 0, }; + const f_string_static_t s_f = macro_f_string_static_t_initialize("f", 0, 1); + const f_string_static_t s_s = macro_f_string_static_t_initialize("s", 0, 1); + const f_string_static_t s_t = macro_f_string_static_t_initialize("t", 0, 1); + const f_string_static_t s_F = macro_f_string_static_t_initialize("F", 0, 1); + const f_string_static_t s_N = macro_f_string_static_t_initialize("N", 0, 1); + const f_string_static_t s_second = macro_f_string_static_t_initialize("second", 0, 6); + const f_string_static_t s_third = macro_f_string_static_t_initialize("third", 0, 5); + const f_string_static_t s_fifth = macro_f_string_static_t_initialize("fifth", 0, 5); + const f_string_static_t s_sixth = macro_f_string_static_t_initialize("sixth", 0, 5); + const f_string_static_t s_seventh = macro_f_string_static_t_initialize("seventh", 0, 7); + const f_string_static_t s_not_found = macro_f_string_static_t_initialize("not_found", 0, 9); + const f_string_static_t s_other = macro_f_string_static_t_initialize("other", 0, 5); + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(2, argv, 0); f_console_parameter_t parameter[] = { - macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("s", "second", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("t", "third", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("F", 0, 0, 0, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "fifth", 0, 1, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "sixth", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, "seventh", 0, 2, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("N", "not_found", 0, 0, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, 0, "other", 0, f_console_type_other_e), + macro_f_console_parameter_t_initialize_2(s_f, f_string_empty_s, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_s, s_second, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_t, s_third, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_F, f_string_empty_s, f_string_empty_s, 0, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_fifth, f_string_empty_s, 1, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_sixth, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_seventh, f_string_empty_s, 2, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_N, s_not_found, f_string_empty_s, 0, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, f_string_empty_s, s_other, 0, f_console_flag_simple_e), }; - f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9); + f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9, 0); { - const f_status_t status = f_console_parameter_process(arguments, ¶meters); + f_state_t state = f_state_t_initialize; + f_console_parameter_process(arguments, ¶meters, &state, 0); - assert_int_equal(status, F_complete_not); + assert_int_equal(state.status, F_complete_not); assert_int_equal(parameter[0].result, f_console_result_none_e); assert_int_equal(parameter[0].locations.used, 0); @@ -41,7 +55,7 @@ void test__f_console_parameter_process__incomplete_arguments(void **state) { assert_int_equal(parameter[0].location, 0); assert_int_equal(parameter[0].location_sub, 0); - assert_int_equal(parameter[1].result, f_console_result_found_e); + assert_int_equal(parameter[1].result & f_console_result_found_e, f_console_result_found_e); assert_int_equal(parameter[1].locations.used, 1); assert_int_equal(parameter[1].locations_sub.used, 1); assert_int_equal(parameter[1].values.used, 0); @@ -111,29 +125,43 @@ void test__f_console_parameter_process__no_arguments_no_program(void **state) { 0, }; + const f_string_static_t s_f = macro_f_string_static_t_initialize("f", 0, 1); + const f_string_static_t s_s = macro_f_string_static_t_initialize("s", 0, 1); + const f_string_static_t s_t = macro_f_string_static_t_initialize("t", 0, 1); + const f_string_static_t s_F = macro_f_string_static_t_initialize("F", 0, 1); + const f_string_static_t s_N = macro_f_string_static_t_initialize("N", 0, 1); + const f_string_static_t s_second = macro_f_string_static_t_initialize("second", 0, 6); + const f_string_static_t s_third = macro_f_string_static_t_initialize("third", 0, 5); + const f_string_static_t s_fifth = macro_f_string_static_t_initialize("fifth", 0, 5); + const f_string_static_t s_sixth = macro_f_string_static_t_initialize("sixth", 0, 5); + const f_string_static_t s_seventh = macro_f_string_static_t_initialize("seventh", 0, 7); + const f_string_static_t s_not_found = macro_f_string_static_t_initialize("not_found", 0, 9); + const f_string_static_t s_other = macro_f_string_static_t_initialize("other", 0, 5); + // Test both a valid and an invalid argc. for (uint8_t argc = 0; argc < 2; ++argc) { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, 0); f_console_parameter_t parameter[] = { - macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("s", "second", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("t", "third", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("F", 0, 0, 0, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "fifth", 0, 1, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "sixth", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, "seventh", 0, 2, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("N", "not_found", 0, 0, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, 0, "other", 0, f_console_type_other_e), + macro_f_console_parameter_t_initialize_2(s_f, f_string_empty_s, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_s, s_second, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_t, s_third, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_F, f_string_empty_s, f_string_empty_s, 0, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_fifth, f_string_empty_s, 1, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_sixth, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_seventh, f_string_empty_s, 2, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_N, s_not_found, f_string_empty_s, 0, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, f_string_empty_s, s_other, 0, f_console_flag_simple_e), }; - f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9); + f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9, 0); { - const f_status_t status = f_console_parameter_process(arguments, ¶meters); + f_state_t state = f_state_t_initialize; + f_console_parameter_process(arguments, ¶meters, &state, 0); - assert_int_equal(status, F_data_not); + assert_int_equal(state.status, F_data_not); assert_int_equal(parameter[0].result, f_console_result_none_e); assert_int_equal(parameter[0].locations.used, 0); @@ -203,29 +231,43 @@ void test__f_console_parameter_process__no_arguments(void **state) { 0, }; + const f_string_static_t s_f = macro_f_string_static_t_initialize("f", 0, 1); + const f_string_static_t s_s = macro_f_string_static_t_initialize("s", 0, 1); + const f_string_static_t s_t = macro_f_string_static_t_initialize("t", 0, 1); + const f_string_static_t s_F = macro_f_string_static_t_initialize("F", 0, 1); + const f_string_static_t s_N = macro_f_string_static_t_initialize("N", 0, 1); + const f_string_static_t s_second = macro_f_string_static_t_initialize("second", 0, 6); + const f_string_static_t s_third = macro_f_string_static_t_initialize("third", 0, 5); + const f_string_static_t s_fifth = macro_f_string_static_t_initialize("fifth", 0, 5); + const f_string_static_t s_sixth = macro_f_string_static_t_initialize("sixth", 0, 5); + const f_string_static_t s_seventh = macro_f_string_static_t_initialize("seventh", 0, 7); + const f_string_static_t s_not_found = macro_f_string_static_t_initialize("not_found", 0, 9); + const f_string_static_t s_other = macro_f_string_static_t_initialize("other", 0, 5); + // Test both valid and invalid argc. for (uint8_t argc = 0; argc < 2; ++argc) { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, 0); f_console_parameter_t parameter[] = { - macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("s", "second", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("t", "third", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("F", 0, 0, 0, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "fifth", 0, 1, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "sixth", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, "seventh", 0, 2, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("N", "not_found", 0, 0, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, 0, "other", 0, f_console_type_other_e), + macro_f_console_parameter_t_initialize_2(s_f, f_string_empty_s, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_s, s_second, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_t, s_third, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_F, f_string_empty_s, f_string_empty_s, 0, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_fifth, f_string_empty_s, 1, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_sixth, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_seventh, f_string_empty_s, 2, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_N, s_not_found, f_string_empty_s, 0, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, f_string_empty_s, s_other, 0, f_console_flag_simple_e), }; - f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9); + f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9, 0); { - const f_status_t status = f_console_parameter_process(arguments, ¶meters); + f_state_t state = f_state_t_initialize; + f_console_parameter_process(arguments, ¶meters, &state, 0); - assert_int_equal(status, argc ? F_none : F_data_not); + assert_int_equal(state.status, argc ? F_none : F_data_not); assert_int_equal(parameter[0].result, f_console_result_none_e); assert_int_equal(parameter[0].locations.used, 0); @@ -301,28 +343,42 @@ void test__f_console_parameter_process__null_arguments(void **state) { const f_string_t *argv = 0; + const f_string_static_t s_f = macro_f_string_static_t_initialize("f", 0, 1); + const f_string_static_t s_s = macro_f_string_static_t_initialize("s", 0, 1); + const f_string_static_t s_t = macro_f_string_static_t_initialize("t", 0, 1); + const f_string_static_t s_F = macro_f_string_static_t_initialize("F", 0, 1); + const f_string_static_t s_N = macro_f_string_static_t_initialize("N", 0, 1); + const f_string_static_t s_second = macro_f_string_static_t_initialize("second", 0, 6); + const f_string_static_t s_third = macro_f_string_static_t_initialize("third", 0, 5); + const f_string_static_t s_fifth = macro_f_string_static_t_initialize("fifth", 0, 5); + const f_string_static_t s_sixth = macro_f_string_static_t_initialize("sixth", 0, 5); + const f_string_static_t s_seventh = macro_f_string_static_t_initialize("seventh", 0, 7); + const f_string_static_t s_not_found = macro_f_string_static_t_initialize("not_found", 0, 9); + const f_string_static_t s_other = macro_f_string_static_t_initialize("other", 0, 5); + // Test both a valid and an invalid argc. for (uint8_t argc = 0; argc < 2; ++argc) { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, 0); f_console_parameter_t parameter[] = { - macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("s", "second", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("t", "third", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("F", 0, 0, 0, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "fifth", 0, 1, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "sixth", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, "seventh", 0, 2, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("N", "not_found", 0, 0, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, 0, "other", 0, f_console_type_other_e), + macro_f_console_parameter_t_initialize_2(s_f, f_string_empty_s, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_s, s_second, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_t, s_third, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_F, f_string_empty_s, f_string_empty_s, 0, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_fifth, f_string_empty_s, 1, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_sixth, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_seventh, f_string_empty_s, 2, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_N, s_not_found, f_string_empty_s, 0, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, f_string_empty_s, s_other, 0, f_console_flag_simple_e), }; - f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9); + f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9, 0); { - const f_status_t status = f_console_parameter_process(arguments, ¶meters); + f_state_t state = f_state_t_initialize; + f_console_parameter_process(arguments, ¶meters, &state, 0); - assert_int_equal(status, F_data_not); + assert_int_equal(state.status, F_data_not); assert_int_equal(parameter[0].result, f_console_result_none_e); assert_int_equal(parameter[0].locations.used, 0); @@ -419,28 +475,42 @@ void test__f_console_parameter_process__only_remaining(void **state) { 0, }; + const f_string_static_t s_f = macro_f_string_static_t_initialize("f", 0, 1); + const f_string_static_t s_s = macro_f_string_static_t_initialize("s", 0, 1); + const f_string_static_t s_t = macro_f_string_static_t_initialize("t", 0, 1); + const f_string_static_t s_F = macro_f_string_static_t_initialize("F", 0, 1); + const f_string_static_t s_N = macro_f_string_static_t_initialize("N", 0, 1); + const f_string_static_t s_second = macro_f_string_static_t_initialize("second", 0, 6); + const f_string_static_t s_third = macro_f_string_static_t_initialize("third", 0, 5); + const f_string_static_t s_fifth = macro_f_string_static_t_initialize("fifth", 0, 5); + const f_string_static_t s_sixth = macro_f_string_static_t_initialize("sixth", 0, 5); + const f_string_static_t s_seventh = macro_f_string_static_t_initialize("seventh", 0, 7); + const f_string_static_t s_not_found = macro_f_string_static_t_initialize("not_found", 0, 9); + const f_string_static_t s_other = macro_f_string_static_t_initialize("other", 0, 5); + const int total = 19; const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(total, argv, 0); f_console_parameter_t parameter[] = { - macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("s", "second", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("t", "third", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("F", 0, 0, 0, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "fifth", 0, 1, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "sixth", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, "seventh", 0, 2, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("N", "not_found", 0, 0, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, 0, "other", 0, f_console_type_other_e), + macro_f_console_parameter_t_initialize_2(s_f, f_string_empty_s, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_s, s_second, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_t, s_third, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_F, f_string_empty_s, f_string_empty_s, 0, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_fifth, f_string_empty_s, 1, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_sixth, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_seventh, f_string_empty_s, 2, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_N, s_not_found, f_string_empty_s, 0, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, f_string_empty_s, s_other, 0, f_console_flag_simple_e), }; - f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9); + f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 9, 0); { - const f_status_t status = f_console_parameter_process(arguments, ¶meters); + f_state_t state = f_state_t_initialize; + f_console_parameter_process(arguments, ¶meters, &state, 0); - assert_int_equal(status, F_none); + assert_int_equal(state.status, F_none); assert_int_equal(parameter[0].result, f_console_result_none_e); assert_int_equal(parameter[0].locations.used, 0); @@ -525,9 +595,27 @@ void test__f_console_parameter_process__parameter_checking(void **state) { const f_console_arguments_t arguments = f_console_arguments_t_initialize; { - const f_status_t status = f_console_parameter_process(arguments, 0); + f_console_parameter_process(arguments, 0, 0, 0); - assert_int_equal(status, F_status_set_error(F_parameter)); + // In this case, because there is no state, status cannot be checked. + // The only thing that can be tested here is that it does not randomly crash. + } + + { + f_console_parameter_t parameter[] = {}; + f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 0, 0); + + f_console_parameter_process(arguments, ¶meters, 0, 0); + + // In this case, because there is no state, status cannot be checked. + // The only thing that can be tested here is that it does not randomly crash. + } + + { + f_state_t state = f_state_t_initialize; + f_console_parameter_process(arguments, 0, &state, 0); + + assert_int_equal(state.status, F_status_set_error(F_parameter)); } } @@ -561,31 +649,51 @@ void test__f_console_parameter_process__works(void **state) { 0, }; + const f_string_static_t s_f = macro_f_string_static_t_initialize("f", 0, 1); + const f_string_static_t s_s = macro_f_string_static_t_initialize("s", 0, 1); + const f_string_static_t s_t = macro_f_string_static_t_initialize("t", 0, 1); + const f_string_static_t s_F = macro_f_string_static_t_initialize("F", 0, 1); + const f_string_static_t s_N = macro_f_string_static_t_initialize("N", 0, 1); + const f_string_static_t s_m = macro_f_string_static_t_initialize("m", 0, 1); + const f_string_static_t s_M = macro_f_string_static_t_initialize("M", 0, 1); + const f_string_static_t s_x = macro_f_string_static_t_initialize("x", 0, 1); + const f_string_static_t s_second = macro_f_string_static_t_initialize("second", 0, 6); + const f_string_static_t s_third = macro_f_string_static_t_initialize("third", 0, 5); + const f_string_static_t s_fifth = macro_f_string_static_t_initialize("fifth", 0, 5); + const f_string_static_t s_sixth = macro_f_string_static_t_initialize("sixth", 0, 5); + const f_string_static_t s_seventh = macro_f_string_static_t_initialize("seventh", 0, 7); + const f_string_static_t s_not_found = macro_f_string_static_t_initialize("not_found", 0, 9); + const f_string_static_t s_mixed_1 = macro_f_string_static_t_initialize("mixed_1", 0, 7); + const f_string_static_t s_mixed_2 = macro_f_string_static_t_initialize("mixed_2", 0, 7); + const f_string_static_t s_mixed_3 = macro_f_string_static_t_initialize("mixed_3", 0, 7); + const f_string_static_t s_other = macro_f_string_static_t_initialize("other", 0, 5); + const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(24, argv, 0); f_console_parameter_t parameter[] = { - macro_f_console_parameter_t_initialize("f", 0, 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("s", "second", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("t", "third", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("F", 0, 0, 0, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "fifth", 0, 1, f_console_type_inverse_e), - macro_f_console_parameter_t_initialize(0, "sixth", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, "seventh", 0, 2, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("N", "not_found", 0, 0, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("m", "mixed_1", 0, 1, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("M", "mixed_2", 0, 2, f_console_type_normal_e), - macro_f_console_parameter_t_initialize("x", "mixed_3", 0, 0, f_console_type_normal_e), - macro_f_console_parameter_t_initialize(0, 0, "other", 0, f_console_type_other_e), + macro_f_console_parameter_t_initialize_2(s_f, f_string_empty_s, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_s, s_second, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_t, s_third, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_F, f_string_empty_s, f_string_empty_s, 0, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_fifth, f_string_empty_s, 1, f_console_flag_inverse_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_sixth, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, s_seventh, f_string_empty_s, 2, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_N, s_not_found, f_string_empty_s, 0, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_m, s_mixed_1, f_string_empty_s, 1, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_M, s_mixed_2, f_string_empty_s, 2, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(s_x, s_mixed_3, f_string_empty_s, 0, f_console_flag_normal_e), + macro_f_console_parameter_t_initialize_2(f_string_empty_s, f_string_empty_s, s_other, 0, f_console_flag_simple_e), }; - f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 12); + f_console_parameters_t parameters = macro_f_console_parameters_t_initialize(parameter, 12, 0); { - const f_status_t status = f_console_parameter_process(arguments, ¶meters); + f_state_t state = f_state_t_initialize; + f_console_parameter_process(arguments, ¶meters, &state, 0); - assert_int_equal(status, F_none); + assert_int_equal(state.status, F_none); - assert_int_equal(parameter[0].result, f_console_result_additional_e); + assert_int_equal(parameter[0].result & f_console_result_value_e, f_console_result_value_e); assert_int_equal(parameter[0].locations.used, 1); assert_int_equal(parameter[0].locations_sub.used, 1); assert_int_equal(parameter[0].values.used, 1); @@ -595,7 +703,7 @@ void test__f_console_parameter_process__works(void **state) { assert_int_equal(parameter[0].locations_sub.array[0], 1); assert_string_equal(argv[parameter[0].values.array[0]], argv[2]); - assert_int_equal(parameter[1].result, f_console_result_additional_e); + assert_int_equal(parameter[1].result & f_console_result_value_e, f_console_result_value_e); assert_int_equal(parameter[1].locations.used, 1); assert_int_equal(parameter[1].locations_sub.used, 1); assert_int_equal(parameter[1].values.used, 1); @@ -605,7 +713,7 @@ void test__f_console_parameter_process__works(void **state) { assert_int_equal(parameter[1].locations_sub.array[0], 1); assert_string_equal(argv[parameter[1].values.array[0]], argv[4]); - assert_int_equal(parameter[2].result, f_console_result_additional_e); + assert_int_equal(parameter[2].result & f_console_result_value_e, f_console_result_value_e); assert_int_equal(parameter[2].locations.used, 1); assert_int_equal(parameter[2].locations_sub.used, 1); assert_int_equal(parameter[2].values.used, 1); @@ -615,7 +723,7 @@ void test__f_console_parameter_process__works(void **state) { assert_int_equal(parameter[2].locations_sub.array[0], 2); assert_string_equal(argv[parameter[2].values.array[0]], argv[5]); - assert_int_equal(parameter[3].result, f_console_result_found_e); + assert_int_equal(parameter[3].result & f_console_result_found_e, f_console_result_found_e); assert_int_equal(parameter[3].locations.used, 1); assert_int_equal(parameter[3].locations_sub.used, 1); assert_int_equal(parameter[3].values.used, 0); @@ -624,7 +732,7 @@ void test__f_console_parameter_process__works(void **state) { assert_int_equal(parameter[3].locations.array[0], 7); assert_int_equal(parameter[3].locations_sub.array[0], 1); - assert_int_equal(parameter[4].result, f_console_result_additional_e); + assert_int_equal(parameter[4].result & f_console_result_value_e, f_console_result_value_e); assert_int_equal(parameter[4].locations.used, 1); assert_int_equal(parameter[4].locations_sub.used, 1); assert_int_equal(parameter[4].values.used, 1); @@ -634,7 +742,7 @@ void test__f_console_parameter_process__works(void **state) { assert_int_equal(parameter[4].locations_sub.array[0], 0); assert_string_equal(argv[parameter[4].values.array[0]], argv[9]); - assert_int_equal(parameter[5].result, f_console_result_additional_e); + assert_int_equal(parameter[5].result & f_console_result_value_e, f_console_result_value_e); assert_int_equal(parameter[5].locations.used, 1); assert_int_equal(parameter[5].locations_sub.used, 1); assert_int_equal(parameter[5].values.used, 1); @@ -644,7 +752,7 @@ void test__f_console_parameter_process__works(void **state) { assert_int_equal(parameter[5].locations_sub.array[0], 0); assert_string_equal(argv[parameter[5].values.array[0]], argv[11]); - assert_int_equal(parameter[6].result, f_console_result_additional_e); + assert_int_equal(parameter[6].result & f_console_result_value_e, f_console_result_value_e); assert_int_equal(parameter[6].locations.used, 1); assert_int_equal(parameter[6].locations_sub.used, 1); assert_int_equal(parameter[6].values.used, 2); @@ -662,7 +770,7 @@ void test__f_console_parameter_process__works(void **state) { assert_int_equal(parameter[7].location, 0); assert_int_equal(parameter[7].location_sub, 0); - assert_int_equal(parameter[8].result, f_console_result_additional_e); + assert_int_equal(parameter[8].result & f_console_result_value_e, f_console_result_value_e); assert_int_equal(parameter[8].locations.used, 1); assert_int_equal(parameter[8].locations_sub.used, 1); assert_int_equal(parameter[8].values.used, 1); @@ -672,7 +780,7 @@ void test__f_console_parameter_process__works(void **state) { assert_int_equal(parameter[8].locations_sub.array[0], 1); assert_string_equal(argv[parameter[8].values.array[0]], argv[21]); - assert_int_equal(parameter[9].result, f_console_result_additional_e); + assert_int_equal(parameter[9].result & f_console_result_value_e, f_console_result_value_e); assert_int_equal(parameter[9].locations.used, 1); assert_int_equal(parameter[9].locations_sub.used, 1); assert_int_equal(parameter[9].values.used, 2); @@ -683,7 +791,7 @@ void test__f_console_parameter_process__works(void **state) { assert_string_equal(argv[parameter[9].values.array[0]], argv[22]); assert_string_equal(argv[parameter[9].values.array[1]], argv[23]); - assert_int_equal(parameter[10].result, f_console_result_found_e); + assert_int_equal(parameter[10].result & f_console_result_found_e, f_console_result_found_e); assert_int_equal(parameter[10].locations.used, 1); assert_int_equal(parameter[10].locations_sub.used, 2); assert_int_equal(parameter[10].values.used, 0); @@ -693,7 +801,7 @@ void test__f_console_parameter_process__works(void **state) { assert_int_equal(parameter[10].locations_sub.array[0], 3); assert_int_equal(parameter[10].locations_sub.array[1], 4); - assert_int_equal(parameter[11].result, f_console_result_found_e); + assert_int_equal(parameter[11].result & f_console_result_found_e, f_console_result_found_e); assert_int_equal(parameter[11].locations.used, 2); assert_int_equal(parameter[11].locations_sub.used, 2); assert_int_equal(parameter[11].values.used, 0); diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-states_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-states_append.c index 11d2fe4..33cf0e2 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-states_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-states_append.c @@ -22,7 +22,7 @@ void test__f_type_array_states_append__works(void **state) { int fake_2 = 2; int fake_3 = 3; - const f_state_t source = macro_f_state_t_initialize(12, 6, 0, 0, 0, (void *) &fake_1, (void *) &fake_2, (void *) &fake_3); + const f_state_t source = macro_f_state_t_initialize_1(12, 6, 0, 0, 0, 0, 0, (void *) &fake_1, (void *) &fake_2, (void *) &fake_3); f_states_t destination = f_states_t_initialize; { diff --git a/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.c b/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.c index 600d61a..d84f8ca 100644 --- a/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.c +++ b/level_0/f_type_array/tests/unit/c/test-type_array-statess_append.c @@ -52,7 +52,7 @@ void test__f_type_array_statess_append__works(void **state) { int fake_2 = 2; int fake_3 = 3; - const f_state_t state_data = macro_f_state_t_initialize(12, 6, 0, 0, 0, (void *) &fake_1, (void *) &fake_2, (void *) &fake_3); + const f_state_t state_data = macro_f_state_t_initialize_1(12, 6, 0, 0, 0, 0, 0, (void *) &fake_1, (void *) &fake_2, (void *) &fake_3); { const f_status_t status = f_states_resize(length, &source); -- 1.8.3.1