| 1 | #cxx . . $ `<file>/tests/vector_tests.c`/include <cgreen/cgreen.h>cxx . . $ `<file>/include/cgreen/cgreen.h`/ |
| 2 | #include <cgreen/vector.h>cxx . . $ `<file>/include/cgreen/vector.h`/ |
| 3 | #include <stdlib.h> |
| 4 | |
| 5 | #include "../src/utils.h"cxx . . $ `<file>/src/utils.h`/ |
| 6 | |
| 7 | #ifdef __cpluspluscxx . . $ `<built-in>:440:9`! |
| 8 | using namespace cgreen; |
| 9 | #endif |
| 10 | |
| 11 | static CgreenVectorcxx . . $ CgreenVector# *vectorcxx . . $ vector.; |
| 12 | static char acxx . . $ a. = 'a', bcxx . . $ b. = 'b', ccxx . . $ c. = 'c'; |
| 13 | static int times_calledcxx . . $ times_called. = 0; |
| 14 | |
| 15 | static void set_up_vectorcxx . . $ set_up_vector(49f6e7a06ebc5aa8).(void) { |
| 16 | vectorcxx . . $ vector. = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 17 | times_calledcxx . . $ times_called. = 0; |
| 18 | } |
| 19 | |
| 20 | static void tear_down_vectorcxx . . $ tear_down_vector(49f6e7a06ebc5aa8).(void) { |
| 21 | destroy_cgreen_vectorcxx . . $ destroy_cgreen_vector(fe9e7a16718af6c0).(vectorcxx . . $ vector.); |
| 22 | } |
| 23 | |
| 24 | Describecxx . . $ CgreenContext#(Vector); |
| 25 | BeforeEachcxx . . $ BeforeEach_For_Vector.(Vector) { |
| 26 | set_up_vectorcxx . . $ set_up_vector(49f6e7a06ebc5aa8).(); |
| 27 | } |
| 28 | AfterEachcxx . . $ AfterEach_For_Vector_Function(49f6e7a06ebc5aa8).(Vector) { |
| 29 | tear_down_vectorcxx . . $ tear_down_vector(49f6e7a06ebc5aa8).(); |
| 30 | } |
| 31 | |
| 32 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Vector, new_vector_is_empty) { |
| 33 | assert_thatcxx . . $ vector.(cgreen_vector_size(vector), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(0)); |
| 34 | } |
| 35 | |
| 36 | Ensurecxx . . $ CgreenSpec__Vector__single_item_gives_count_of_one__.(Vector, single_item_gives_count_of_one) { |
| 37 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &acxx . . $ a.); |
| 38 | assert_thatcxx . . $ vector.(cgreen_vector_size(vector), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(1)); |
| 39 | } |
| 40 | |
| 41 | Ensurecxx . . $ CgreenTest#(Vector, single_item_is_readable) { |
| 42 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &acxx . . $ a.); |
| 43 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(*(char *)cgreen_vector_get(vector, 0), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('a')); |
| 44 | } |
| 45 | |
| 46 | Ensurecxx . . $ Vector__double_item_gives_count_of_two(49f6e7a06ebc5aa8).(Vector, double_item_gives_count_of_two) { |
| 47 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &acxx . . $ a.); |
| 48 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &bcxx . . $ b.); |
| 49 | assert_thatcxx . . $ cgreen/(cgreen_vector_size(vector), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(2)); |
| 50 | } |
| 51 | |
| 52 | Ensurecxx . . $ Vector__two_items_are_readable(49f6e7a06ebc5aa8).(Vector, two_items_are_readable) { |
| 53 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &acxx . . $ a.); |
| 54 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &bcxx . . $ b.); |
| 55 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(*(char *)cgreen_vector_get(vector, 0), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('a')); |
| 56 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(*(char *)cgreen_vector_get(vector, 1), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('b')); |
| 57 | } |
| 58 | |
| 59 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Vector, can_extract_only_item) { |
| 60 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &acxx . . $ a.); |
| 61 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(*(char *)cgreen_vector_remove(vector, 0), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('a')); |
| 62 | assert_thatcxx . . $ vector.(cgreen_vector_size(vector), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(0)); |
| 63 | } |
| 64 | |
| 65 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Vector, can_extract_head_item) { |
| 66 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &acxx . . $ a.); |
| 67 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &bcxx . . $ b.); |
| 68 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &ccxx . . $ c.); |
| 69 | assert_thatcxx . . $ cgreen/(*(char *)cgreen_vector_remove(vector, 0), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('a')); |
| 70 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(*(char *)cgreen_vector_get(vector, 0), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('b')); |
| 71 | assert_thatcxx . . $ vector.(*(char *)cgreen_vector_get(vector, 1), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('c')); |
| 72 | } |
| 73 | |
| 74 | Ensurecxx . . $ Vector__can_extract_tail_item(49f6e7a06ebc5aa8).(Vector, can_extract_tail_item) { |
| 75 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &acxx . . $ a.); |
| 76 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &bcxx . . $ b.); |
| 77 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &ccxx . . $ c.); |
| 78 | assert_thatcxx . . $ cgreen/assert_that_(b064aa216885589).(*(char *)cgreen_vector_remove(vector, 2), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('c')); |
| 79 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(*(char *)cgreen_vector_get(vector, 0), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('a')); |
| 80 | assert_thatcxx . . $ cgreen/assert_that_(b064aa216885589).(*(char *)cgreen_vector_get(vector, 1), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('b')); |
| 81 | } |
| 82 | |
| 83 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Vector, can_extract_middle_item) { |
| 84 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &acxx . . $ a.); |
| 85 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &bcxx . . $ b.); |
| 86 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &ccxx . . $ c.); |
| 87 | assert_thatcxx . . $ vector.(*(char *)cgreen_vector_remove(vector, 1), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('b')); |
| 88 | assert_thatcxx . . $ cgreen/assert_that_(b064aa216885589).(*(char *)cgreen_vector_get(vector, 0), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('a')); |
| 89 | assert_thatcxx . . $ intptr_t#(*(char *)cgreen_vector_get(vector, 1), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!('c')); |
| 90 | } |
| 91 | |
| 92 | static void sample_destructorcxx . . $ sample_destructor(5d22bdacc48458e8).(void *item) { |
| 93 | (void)item; |
| 94 | times_calledcxx . . $ times_called.++; |
| 95 | } |
| 96 | |
| 97 | Ensurecxx . . $ CgreenSpec__Vector__destructor_is_called_on_single_item__.(Vector, destructor_is_called_on_single_item) { |
| 98 | CgreenVectorcxx . . $ CgreenVector# *vector = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(&sample_destructorcxx . . $ sample_destructor(5d22bdacc48458e8).); |
| 99 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vector, &acxx . . $ a.); |
| 100 | destroy_cgreen_vectorcxx . . $ destroy_cgreen_vector(fe9e7a16718af6c0).(vector); |
| 101 | assert_thatcxx . . $ intptr_t#(times_called, is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(1)); |
| 102 | } |
| 103 | |
| 104 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Vector, destructor_is_not_called_on_empty_vector) { |
| 105 | CgreenVectorcxx . . $ CgreenVector# *vector = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(&sample_destructorcxx . . $ sample_destructor(5d22bdacc48458e8).); |
| 106 | destroy_cgreen_vectorcxx . . $ destroy_cgreen_vector(fe9e7a16718af6c0).(vector); |
| 107 | assert_thatcxx . . $ times_called.(times_called, is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(0)); |
| 108 | } |
| 109 | |
| 110 | Ensurecxx . . $ contextForVector.(Vector, destructor_is_called_three_times_on_three_item_vector) { |
| 111 | CgreenVectorcxx . . $ CgreenVector# *vector = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(&sample_destructorcxx . . $ sample_destructor(5d22bdacc48458e8).); |
| 112 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vector, &acxx . . $ a.); |
| 113 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vector, &bcxx . . $ b.); |
| 114 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vector, &ccxx . . $ c.); |
| 115 | destroy_cgreen_vectorcxx . . $ destroy_cgreen_vector(fe9e7a16718af6c0).(vector); |
| 116 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(times_called, is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(3)); |
| 117 | } |
| 118 | |
| 119 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Vector, vector_size_of_null_pointer_is_zero) { |
| 120 | assert_thatcxx . . $ cgreen/assert_that_(b064aa216885589).(cgreen_vector_size(NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(0)); |
| 121 | } |
| 122 | |
| 123 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Vector, returns_null_for_get_on_illegal_index) { |
| 124 | CgreenVectorcxx . . $ CgreenVector# *vector = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 125 | char panic_message[1000]; |
| 126 | |
| 127 | panic_set_output_buffercxx . . $ panic_set_output_buffer(85c52e162fed56f9).(panic_message); |
| 128 | |
| 129 | assert_thatcxx . . $ intptr_t#(cgreen_vector_get(vector, -1), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!)); |
| 130 | assert_thatcxx . . $ intptr_t#(panic_message, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("illegal position (-1) in vector operation")); |
| 131 | destroy_cgreen_vectorcxx . . $ destroy_cgreen_vector(fe9e7a16718af6c0).(vector); |
| 132 | } |
| 133 | |
| 134 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(Vector, returns_null_for_remove_from_illegal_index) { |
| 135 | CgreenVectorcxx . . $ CgreenVector# *vector = create_cgreen_vectorcxx . . $ create_cgreen_vector(940ca2d138a76a1b).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 136 | char panic_message[1000]; |
| 137 | |
| 138 | panic_set_output_buffercxx . . $ panic_set_output_buffer(85c52e162fed56f9).(panic_message); |
| 139 | |
| 140 | assert_thatcxx . . $ cgreen/(cgreen_vector_remove(vector, 1), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!)); |
| 141 | assert_thatcxx . . $ cgreen/(panic_message, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("illegal position (1) in vector operation")); |
| 142 | destroy_cgreen_vectorcxx . . $ destroy_cgreen_vector(fe9e7a16718af6c0).(vector); |
| 143 | } |
| 144 | |
| 145 | Ensurecxx . . $ CgreenSpec__Vector__returns_null_for_get_one_past_the_last_item__.(Vector, returns_null_for_get_one_past_the_last_item) { |
| 146 | char panic_message[1000] = ""; |
| 147 | |
| 148 | panic_set_output_buffercxx . . $ panic_set_output_buffer(85c52e162fed56f9).(panic_message); |
| 149 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &acxx . . $ a.); |
| 150 | |
| 151 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(cgreen_vector_get(vector, 1), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!)); |
| 152 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(panic_message, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("illegal position (1) in vector operation")); |
| 153 | } |
| 154 | |
| 155 | Ensurecxx . . $ contextForVector.(Vector, returns_null_for_remove_one_past_the_last_item) { |
| 156 | char panic_message[1000] = ""; |
| 157 | |
| 158 | panic_set_output_buffercxx . . $ panic_set_output_buffer(85c52e162fed56f9).(panic_message); |
| 159 | cgreen_vector_addcxx . . $ cgreen_vector_add(77a2afb5bdbc2be1).(vectorcxx . . $ vector., &acxx . . $ a.); |
| 160 | |
| 161 | assert_thatcxx . . $ cgreen/(cgreen_vector_remove(vector, 1), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!)); |
| 162 | assert_thatcxx . . $ cgreen/(panic_message, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("illegal position (1) in vector operation")); |
| 163 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(cgreen_vector_size(vector), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(1)); |
| 164 | } |
| 165 | |
| 166 | TestSuitecxx . . $ TestSuite# *vector_testscxx . . $ vector_tests(564401a81ded3a53).(void) { |
| 167 | TestSuitecxx . . $ TestSuite# *suite = create_test_suitecxx . . $ `include/cgreen/suite.h:20:9`!(); |
| 168 | set_setupcxx . . $ set_setup(375347ed146b1459).(suite, set_up_vectorcxx . . $ set_up_vector(49f6e7a06ebc5aa8).); |
| 169 | set_teardowncxx . . $ set_teardown(375347ed146b1459).(suite, tear_down_vectorcxx . . $ tear_down_vector(49f6e7a06ebc5aa8).); |
| 170 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, new_vector_is_empty); |
| 171 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, single_item_gives_count_of_one); |
| 172 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, single_item_is_readable); |
| 173 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, double_item_gives_count_of_two); |
| 174 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, two_items_are_readable); |
| 175 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, can_extract_only_item); |
| 176 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, can_extract_head_item); |
| 177 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, can_extract_tail_item); |
| 178 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, can_extract_middle_item); |
| 179 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, destructor_is_called_on_single_item); |
| 180 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, destructor_is_not_called_on_empty_vector); |
| 181 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, destructor_is_called_three_times_on_three_item_vector); |
| 182 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, vector_size_of_null_pointer_is_zero); |
| 183 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, returns_null_for_get_on_illegal_index); |
| 184 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, returns_null_for_remove_from_illegal_index); |
| 185 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, returns_null_for_get_one_past_the_last_item); |
| 186 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, Vector, returns_null_for_remove_one_past_the_last_item); |
| 187 | return suite; |
| 188 | } |