| 1 | #cxx . . $ `<file>/tools/runner_unit_tests.c`/include <cgreen/cgreen.h>cxx . . $ `<file>/include/cgreen/cgreen.h`/ |
| 2 | |
| 3 | #include "../src/utils.h"cxx . . $ `<file>/src/utils.h`/ |
| 4 | |
| 5 | #ifdef __cplusplus |
| 6 | using namespace cgreen; |
| 7 | #endif |
| 8 | |
| 9 | #include "runner.c"cxx . . $ `<file>/tools/runner.c`/ |
| 10 | |
| 11 | #include "test_item.h"cxx . . $ `<file>/tools/test_item.h`/ |
| 12 | |
| 13 | #include "discoverer.mock"cxx . . $ `<file>/tools/discoverer.mock`/ |
| 14 | #include "io.mock"cxx . . $ `<file>/tools/io.mock`/ |
| 15 | |
| 16 | |
| 17 | Describecxx . . $ `include/cgreen/unit.h:12:9`!(Runner); |
| 18 | |
| 19 | BeforeEachcxx . . $ `include/cgreen/unit.h:15:9`!(Runner){} |
| 20 | |
| 21 | AfterEachcxx . . $ `include/cgreen/unit.h:18:9`!(Runner){} |
| 22 | |
| 23 | #define CONTEXT_NAMEcxx . . $ `tools/runner_unit_tests.c:23:9`! "context" |
| 24 | #define TEST_NAMEcxx . . $ `tools/runner_unit_tests.c:24:9`! "test" |
| 25 | |
| 26 | #define STRINGIFY_Xcxx . . $ `tools/runner_unit_tests.c:26:9`!(x) #x |
| 27 | #define STRINGIFYcxx . . $ `tools/runner_unit_tests.c:27:9`!(x) STRINGIFY_X(x) |
| 28 | |
| 29 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Runner, can_get_context_name_of_name) { |
| 30 | char *context_name = context_name_ofcxx . . $ context_name_of(a8b8e32347182212).("Context:Test"); |
| 31 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(context_name, is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!("Context")); |
| 32 | freecxx . . $ free(5d22bdacc48458e8).(context_name); |
| 33 | |
| 34 | context_name = context_name_ofcxx . . $ context_name_of(a8b8e32347182212).("Test"); |
| 35 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(context_name, is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!(CGREEN_DEFAULT_SUITEcxx . . $ `tools/runner.c:43:9`!)); |
| 36 | freecxx . . $ free(5d22bdacc48458e8).(context_name); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Runner, can_get_test_name_of_symbolic_name) { |
| 41 | char *test_name = test_name_ofcxx . . $ test_name_of(a8b8e32347182212).("Context:Test"); |
| 42 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_name, is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!("Test")); |
| 43 | freecxx . . $ free(5d22bdacc48458e8).(test_name); |
| 44 | |
| 45 | test_name = test_name_ofcxx . . $ test_name_of(a8b8e32347182212).("Test"); |
| 46 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_name, is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!("Test")); |
| 47 | freecxx . . $ free(5d22bdacc48458e8).(test_name); |
| 48 | } |
| 49 | |
| 50 | |
| 51 | static void add_test_items_to_vectorcxx . . $ add_test_items_to_vector(57836e2b9b7e9fb1).(TestItemcxx . . $ TestItem# items[], CgreenVectorcxx . . $ CgreenVector# *test_items, int count) { |
| 52 | for (int i=0; i < count; i++) |
| 53 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(test_items, &items[i]); |
| 54 | } |
| 55 | |
| 56 | |
| 57 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Runner, can_ensure_test_exists_from_context_and_name) { |
| 58 | TestItemcxx . . $ TestItem# test_items[5] = { |
| 59 | {(char *)"", (char *)"Context1", (char *)"Test1"}, |
| 60 | {(char *)"", (char *)"Context1", (char *)"Test2"}, |
| 61 | {(char *)"", (char *)"Context2", (char *)"Test1"}, |
| 62 | {(char *)"", (char *)"Context2", (char *)"Test2"}}; |
| 63 | CgreenVectorcxx . . $ CgreenVector# *tests = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 64 | add_test_items_to_vectorcxx . . $ add_test_items_to_vector(57836e2b9b7e9fb1).(test_items, tests, 5); |
| 65 | |
| 66 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(matching_test_exists("Context1:Test1", tests)); |
| 67 | } |
| 68 | |
| 69 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Runner, can_match_test_name) { |
| 70 | TestItemcxx . . $ TestItem# test_item = {(char *)"", (char *)"Context1", (char *)"Test1"}; |
| 71 | |
| 72 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_matches_pattern("Context1:Test1", &test_item)); |
| 73 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_matches_pattern("Context*:Test1", &test_item)); |
| 74 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_matches_pattern("*:Test1", &test_item)); |
| 75 | |
| 76 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_matches_pattern("Context*:Test1", &test_item)); |
| 77 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_matches_pattern("*:Test1", &test_item)); |
| 78 | |
| 79 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_matches_pattern("Context1:Test*", &test_item)); |
| 80 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_matches_pattern("Context*:Test*", &test_item)); |
| 81 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_matches_pattern("Context*:*", &test_item)); |
| 82 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_matches_pattern("*:Test*", &test_item)); |
| 83 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(test_matches_pattern("*:*", &test_item)); |
| 84 | } |
| 85 | |
| 86 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Runner, can_add_test_to_the_suite_for_its_context) { |
| 87 | ContextSuitecxx . . $ ContextSuite# *suite_list = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 88 | CgreenTestcxx . . $ CgreenTest# *test = (CgreenTestcxx . . $ CgreenTest# *)&test; |
| 89 | TestSuitecxx . . $ TestSuite# *parent_suite = create_test_suitecxx . . $ `include/cgreen/suite.h:20:9`!(); |
| 90 | TestSuitecxx . . $ TestSuite# *first_suite, *second_suite; |
| 91 | TestItemcxx . . $ TestItem# test_item1 = {"", "TheFirstContext", "TheName"}; |
| 92 | TestItemcxx . . $ TestItem# test_item2 = {"", "TheSecondContext", "TheName"}; |
| 93 | |
| 94 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(suite_list, is_nullcxx . . $ `include/cgreen/constraint_syntax_helpers.h:31:9`!); |
| 95 | |
| 96 | add_test_to_contextcxx . . $ add_test_to_context(ae670815293584f3).(parent_suite, &suite_list, &test_item1, test); |
| 97 | first_suite = find_suite_for_contextcxx . . $ find_suite_for_context(9002edde03db5291).(suite_list, "TheFirstContext"); |
| 98 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(first_suite, is_non_nullcxx . . $ `include/cgreen/constraint_syntax_helpers.h:29:9`!); |
| 99 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(first_suite->size, is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(1)); |
| 100 | |
| 101 | second_suite = find_suite_for_contextcxx . . $ find_suite_for_context(9002edde03db5291).(suite_list, "TheSecondContext"); |
| 102 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(second_suite, is_nullcxx . . $ `include/cgreen/constraint_syntax_helpers.h:31:9`!); |
| 103 | |
| 104 | add_test_to_contextcxx . . $ add_test_to_context(ae670815293584f3).(parent_suite, &suite_list, &test_item2, test); |
| 105 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(find_suite_for_context(suite_list, "TheFirstContext")->size, is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(1)); |
| 106 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(find_suite_for_context(suite_list, "TheSecondContext")->size, is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(1)); |
| 107 | |
| 108 | destroy_test_suitecxx . . $ destroy_test_suite(8fc5cbd6a65ffd2d).(parent_suite); |
| 109 | destroy_context_suitescxx . . $ destroy_context_suites(81216f34e928c6bc).(suite_list); |
| 110 | } |
| 111 | |
| 112 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Runner, can_sort_an_empty_list_of_tests) { |
| 113 | CgreenVectorcxx . . $ CgreenVector# *test_items = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 114 | |
| 115 | test_items = sorted_test_items_fromcxx . . $ sorted_test_items_from(c0d2b0aaae5c9a42).(test_items); |
| 116 | |
| 117 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(cgreen_vector_size(test_items) == 0); |
| 118 | } |
| 119 | |
| 120 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Runner, can_sort_a_list_of_a_single_tests) { |
| 121 | TestItemcxx . . $ TestItem# test_item = { |
| 122 | (char *)"", (char *)"Context1", (char *)"Test1", |
| 123 | }; |
| 124 | CgreenVectorcxx . . $ CgreenVector# *test_items = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 125 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(test_items, &test_item); |
| 126 | |
| 127 | test_items = sorted_test_items_fromcxx . . $ sorted_test_items_from(c0d2b0aaae5c9a42).(test_items); |
| 128 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(((TestItem *)cgreen_vector_get(test_items, 0))->test_name, |
| 129 | is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!("Test1")); |
| 130 | } |
| 131 | |
| 132 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Runner, can_sort_a_list_of_two_unordered_tests) { |
| 133 | TestItemcxx . . $ TestItem# test_items[] = { |
| 134 | {(char *)"", (char *)"Context1", (char *)"Test2"}, |
| 135 | {(char *)"", (char *)"Context1", (char *)"Test1"}, |
| 136 | }; |
| 137 | |
| 138 | CgreenVectorcxx . . $ CgreenVector# *tests = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 139 | add_test_items_to_vectorcxx . . $ add_test_items_to_vector(57836e2b9b7e9fb1).(test_items, tests, 2); |
| 140 | |
| 141 | tests = sorted_test_items_fromcxx . . $ sorted_test_items_from(c0d2b0aaae5c9a42).(tests); |
| 142 | |
| 143 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(((TestItem *)cgreen_vector_get(tests, 0))->test_name, |
| 144 | is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!("Test1")); |
| 145 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(((TestItem *)cgreen_vector_get(tests, 1))->test_name, |
| 146 | is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!("Test2")); |
| 147 | } |
| 148 | |
| 149 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Runner, can_sort_an_ordered_list_of_two_tests) { |
| 150 | TestItemcxx . . $ TestItem# test_item[] = { |
| 151 | {(char *)"", (char *)"Context1", (char *)"Test1"}, |
| 152 | {(char *)"", (char *)"Context1", (char *)"Test2"} |
| 153 | }; |
| 154 | |
| 155 | CgreenVectorcxx . . $ CgreenVector# *test_items = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 156 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(test_items, &test_item[0]); |
| 157 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(test_items, &test_item[1]); |
| 158 | |
| 159 | test_items = sorted_test_items_fromcxx . . $ sorted_test_items_from(c0d2b0aaae5c9a42).(test_items); |
| 160 | |
| 161 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(((TestItem *)cgreen_vector_get(test_items, 0))->test_name, |
| 162 | is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!("Test1")); |
| 163 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(((TestItem *)cgreen_vector_get(test_items, 1))->test_name, |
| 164 | is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!("Test2")); |
| 165 | } |
| 166 | |
| 167 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Runner, can_sort_an_unordered_list_of_tests) { |
| 168 | TestItemcxx . . $ TestItem# unordered_test_items[] = { |
| 169 | {(char *)"", (char *)"Context1", (char *)"Test9"}, |
| 170 | {(char *)"", (char *)"Context1", (char *)"Test6"}, |
| 171 | {(char *)"", (char *)"Context1", (char *)"Test3"}, |
| 172 | {(char *)"", (char *)"Context1", (char *)"Test1"}, |
| 173 | {(char *)"", (char *)"Context1", (char *)"Test5"}, |
| 174 | {(char *)"", (char *)"Context1", (char *)"Test8"}, |
| 175 | {(char *)"", (char *)"Context1", (char *)"Test7"}, |
| 176 | {(char *)"", (char *)"Context1", (char *)"Test4"}, |
| 177 | {(char *)"", (char *)"Context1", (char *)"Test2"}, |
| 178 | }; |
| 179 | const char *expected_test_name[] = { |
| 180 | "Test1", "Test2", "Test3", "Test4", "Test5", "Test6", "Test7", "Test8", "Test9" }; |
| 181 | |
| 182 | CgreenVectorcxx . . $ CgreenVector# *tests = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 183 | add_test_items_to_vectorcxx . . $ add_test_items_to_vector(57836e2b9b7e9fb1).(unordered_test_items, tests, |
| 184 | sizeof(unordered_test_items)/sizeof(unordered_test_items[0])); |
| 185 | |
| 186 | tests = sorted_test_items_fromcxx . . $ sorted_test_items_from(c0d2b0aaae5c9a42).(tests); |
| 187 | |
| 188 | for (int i=0; i<cgreen_vector_sizecxx . . $ cgreen_vector_size(d6a9fa4a29061fe2).(tests); i++) |
| 189 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(((TestItem *)cgreen_vector_get(tests, i))->test_name, |
| 190 | is_equal_to_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:41:9`!(expected_test_name[i])); |
| 191 | } |
| 192 | |
| 193 | /* vim: set ts=4 sw=4 et cindent: */ |
| 194 | /* Local variables: */ |
| 195 | /* tab-width: 4 */ |
| 196 | /* End: */ |