refactor dynamic array API: rename builder functions, update memory management, and improve tests
This commit is contained in:
@@ -10,28 +10,36 @@ void tearDown() {
|
||||
}
|
||||
|
||||
|
||||
void test_array_builder_without_options(void) {
|
||||
Array *array = array_builder(NULL);
|
||||
void test_array_create_without_options(void) {
|
||||
Array *array = array_create(nullptr);
|
||||
TEST_ASSERT_EQUAL(DEFAULT_ARRAY_SIZE, array->capacity);
|
||||
}
|
||||
|
||||
|
||||
void test_array_builder_with_options(void) {
|
||||
void test_array_create_with_options(void) {
|
||||
const int EXPECTED_CAPACITY = 20;
|
||||
|
||||
Array *array = array_builder(&(ArrayBuilderOptions){
|
||||
const Array *array = array_create(&(ArrayCreateOptions){
|
||||
.initial_size = EXPECTED_CAPACITY
|
||||
});
|
||||
TEST_ASSERT_EQUAL(EXPECTED_CAPACITY, array->capacity);
|
||||
}
|
||||
|
||||
|
||||
void test_array_deconstruct(void) {
|
||||
Array *array = array_create(nullptr);
|
||||
array_deconstructor(&array);
|
||||
TEST_ASSERT_NULL(array);
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
|
||||
RUN_TEST(test_array_builder_without_options);
|
||||
RUN_TEST(test_array_builder_with_options);
|
||||
RUN_TEST(test_array_create_without_options);
|
||||
RUN_TEST(test_array_create_with_options);
|
||||
RUN_TEST(test_array_deconstruct);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
Reference in New Issue
Block a user