From: Kevin Day Date: Thu, 23 Dec 2021 17:38:21 +0000 (-0600) Subject: Update: Add tests for f_type_array. X-Git-Tag: 0.5.7~4 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=0469e4f9d8d797eba868f706637bb29f940da6f8;p=fll Update: Add tests for f_type_array. Given the size of the task and my relative inexperience with cmocka, I opted to keep the tests as simple as possible. This means that my tests are likely not thorough. These are intended to be good enough for a first pass tests. After all, I have the entire rest of the FLL projects to write tests for (as well as for the programs). --- diff --git a/level_0/f_type_array/data/build/dependencies-tests b/level_0/f_type_array/data/build/dependencies-tests new file mode 100644 index 000000000..ef33c6ae9 --- /dev/null +++ b/level_0/f_type_array/data/build/dependencies-tests @@ -0,0 +1,3 @@ +# fss-0000 + +cmocka 1.* diff --git a/level_0/f_type_array/data/build/settings-tests b/level_0/f_type_array/data/build/settings-tests new file mode 100644 index 000000000..dad2630bd --- /dev/null +++ b/level_0/f_type_array/data/build/settings-tests @@ -0,0 +1,54 @@ +# fss-0001 + +project_name test-f_type_array + +version_major 0 +version_file major +version_target major + +modes individual level monolithic +modes_default individual + +build_compiler gcc +build_indexer ar +build_indexer_arguments rcs +build_language c +build_libraries -lc -lcmocka +build_libraries-individual -lf_memory -lf_type_array +build_libraries-level -lfll_0 +build_libraries-monolithic -lfll +build_sources_program test-type_array-array_lengths_adjust.c test-type_array-array_lengths_append.c test-type_array-array_lengths_decimate_by.c test-type_array-array_lengths_decrease_by.c test-type_array-array_lengths_increase.c test-type_array-array_lengths_increase_by.c test-type_array-array_lengths_resize.c +build_sources_program test-type_array-array_lengthss_adjust.c test-type_array-array_lengthss_append.c test-type_array-array_lengthss_decimate_by.c test-type_array-array_lengthss_decrease_by.c test-type_array-array_lengthss_increase.c test-type_array-array_lengthss_increase_by.c test-type_array-array_lengthss_resize.c +build_sources_program test-type_array-fll_ids_adjust.c test-type_array-fll_ids_append.c test-type_array-fll_ids_decimate_by.c test-type_array-fll_ids_decrease_by.c test-type_array-fll_ids_increase.c test-type_array-fll_ids_increase_by.c test-type_array-fll_ids_resize.c +build_sources_program test-type_array-fll_idss_adjust.c test-type_array-fll_idss_append.c test-type_array-fll_idss_decimate_by.c test-type_array-fll_idss_decrease_by.c test-type_array-fll_idss_increase.c test-type_array-fll_idss_increase_by.c test-type_array-fll_idss_resize.c +build_sources_program test-type_array-cells_adjust.c test-type_array-cells_append.c test-type_array-cells_decimate_by.c test-type_array-cells_decrease_by.c test-type_array-cells_increase.c test-type_array-cells_increase_by.c test-type_array-cells_resize.c +build_sources_program test-type_array-states_adjust.c test-type_array-states_append.c test-type_array-states_decimate_by.c test-type_array-states_decrease_by.c test-type_array-states_increase.c test-type_array-states_increase_by.c test-type_array-states_resize.c +build_sources_program test-type_array-statess_adjust.c test-type_array-statess_append.c test-type_array-statess_decimate_by.c test-type_array-statess_decrease_by.c test-type_array-statess_increase.c test-type_array-statess_increase_by.c test-type_array-statess_resize.c +build_sources_program test-type_array-cellss_adjust.c test-type_array-cellss_append.c test-type_array-cellss_decimate_by.c test-type_array-cellss_decrease_by.c test-type_array-cellss_increase.c test-type_array-cellss_increase_by.c test-type_array-cellss_resize.c +build_sources_program test-type_array-statuss_adjust.c test-type_array-statuss_append.c test-type_array-statuss_decimate_by.c test-type_array-statuss_decrease_by.c test-type_array-statuss_increase.c test-type_array-statuss_increase_by.c test-type_array-statuss_resize.c +build_sources_program test-type_array-statusss_adjust.c test-type_array-statusss_append.c test-type_array-statusss_decimate_by.c test-type_array-statusss_decrease_by.c test-type_array-statusss_increase.c test-type_array-statusss_increase_by.c test-type_array-statusss_resize.c + +build_sources_program test-type_array.c +build_script no +build_shared yes +build_static no + +path_headers tests/c +path_headers_preserve no +path_sources tests/c +path_standard no + +search_exclusive yes +search_shared yes +search_static yes + +defines -Ibuild/includes +defines_static -Lbuild/libraries/static +defines_shared -Lbuild/libraries/shared + +flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-logical-op-parentheses -Wno-parentheses +flags_program -fPIE +flags_program_shared +flags_program_static +flags_shared +flags_static diff --git a/level_0/f_type_array/data/build/testfile b/level_0/f_type_array/data/build/testfile new file mode 100644 index 000000000..11ea717f4 --- /dev/null +++ b/level_0/f_type_array/data/build/testfile @@ -0,0 +1,27 @@ +# fss-0005 iki-0002 + +settings: + load_build yes + fail exit + + environment LD_LIBRARY_PATH + +main: + build settings + build settings-tests + + if exists build/programs/shared/test-f_type_array + shell build/programs/shared/test-f_type_array + + if exists build/programs/static/test-f_type_array + run build/programs/static/test-f_type_array + + if not exists build/programs/shared/test-f_type_array + and not exists build/programs/static/test-f_type_array + operate not_created + +not_created: + print + print Faled to test due to being unable to find either a shared or static test binary to perform tests. + + exit failure diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_adjust.c b/level_0/f_type_array/tests/c/test-type_array-array_lengths_adjust.c new file mode 100644 index 000000000..2e24ad63d --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_adjust.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengths_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengths_adjust__works(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_array_lengths_adjust__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_adjust.h b/level_0/f_type_array/tests/c/test-type_array-array_lengths_adjust.h new file mode 100644 index 000000000..431fa8265 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengths_adjust +#define _TEST__F_type_array__array_lengths_adjust + +/** + * Test that the function works. + * + * @see f_type_array_array_lengths_adjust() + */ +extern void test__f_type_array_array_lengths_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengths_adjust() + */ +extern void test__f_type_array_array_lengths_adjust__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengths_adjust diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_append.c b/level_0/f_type_array/tests/c/test-type_array-array_lengths_append.c new file mode 100644 index 000000000..e64448b2c --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_append.c @@ -0,0 +1,87 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengths_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengths_append__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_array_lengths_t source = f_array_lengths_t_initialize; + f_array_lengths_t destination = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_type_array_lengths_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_array_lengths_append__returns_data_not(void **state) { + + const int length = 5; + f_array_lengths_t source = f_array_lengths_t_initialize; + f_array_lengths_t destination = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_type_array_lengths_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + } + + free((void *) source.array); + assert_null(destination.array); +} + +void test__f_type_array_array_lengths_append__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_append.h b/level_0/f_type_array/tests/c/test-type_array-array_lengths_append.h new file mode 100644 index 000000000..366669eca --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengths_append +#define _TEST__F_type_array__array_lengths_append + +/** + * Test that the function works. + * + * @see f_type_array_array_lengths_append() + */ +extern void test__f_type_array_array_lengths_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_array_lengths_append() + */ +extern void test__f_type_array_array_lengths_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengths_append() + */ +extern void test__f_type_array_array_lengths_append__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengths_append diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_decimate_by.c b/level_0/f_type_array/tests/c/test-type_array-array_lengths_decimate_by.c new file mode 100644 index 000000000..943628d9d --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengths_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengths_decimate_by__works(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_array_lengths_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_array_lengths_decimate_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_decimate_by.h b/level_0/f_type_array/tests/c/test-type_array-array_lengths_decimate_by.h new file mode 100644 index 000000000..ae9599783 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengths_decimate_by +#define _TEST__F_type_array__array_lengths_decimate_by + +/** + * Test that the function works. + * + * @see f_type_array_array_lengths_decimate_by() + */ +extern void test__f_type_array_array_lengths_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengths_decimate_by() + */ +extern void test__f_type_array_array_lengths_decimate_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengths_decimate_by diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_decrease_by.c b/level_0/f_type_array/tests/c/test-type_array-array_lengths_decrease_by.c new file mode 100644 index 000000000..6f38eab31 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengths_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengths_decrease_by__works(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_array_lengths_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_array_lengths_decrease_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_decrease_by.h b/level_0/f_type_array/tests/c/test-type_array-array_lengths_decrease_by.h new file mode 100644 index 000000000..3197742b9 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengths_decrease_by +#define _TEST__F_type_array__array_lengths_decrease_by + +/** + * Test that the function works. + * + * @see f_type_array_array_lengths_decrease_by() + */ +extern void test__f_type_array_array_lengths_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengths_decrease_by() + */ +extern void test__f_type_array_array_lengths_decrease_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengths_decrease_by diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase.c b/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase.c new file mode 100644 index 000000000..56d7e99ed --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase.c @@ -0,0 +1,76 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengths_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengths_increase__works(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_array_lengths_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_array_lengths_increase__returns_data_not(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_array_lengths_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_array_lengths_increase__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase.h b/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase.h new file mode 100644 index 000000000..9e5d4c1d2 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengths_increase +#define _TEST__F_type_array__array_lengths_increase + +/** + * Test that the function works. + * + * @see f_type_array_array_lengths_increase() + */ +extern void test__f_type_array_array_lengths_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_array_lengths_increase() + */ +extern void test__f_type_array_array_lengths_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengths_increase() + */ +extern void test__f_type_array_array_lengths_increase__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengths_increase diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase_by.c b/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase_by.c new file mode 100644 index 000000000..b0e6ec117 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase_by.c @@ -0,0 +1,52 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengths_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengths_increase_by__works(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_array_lengths_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_array_lengths_increase_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase_by.h b/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase_by.h new file mode 100644 index 000000000..99cfc3047 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengths_increase_by +#define _TEST__F_type_array__array_lengths_increase_by + +/** + * Test that the function works. + * + * @see f_type_array_array_lengths_increase_by() + */ +extern void test__f_type_array_array_lengths_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengths_increase_by() + */ +extern void test__f_type_array_array_lengths_increase_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengths_increase_by diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_resize.c b/level_0/f_type_array/tests/c/test-type_array-array_lengths_resize.c new file mode 100644 index 000000000..dcdf79916 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_resize.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengths_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengths_resize__works(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_array_lengths_resize__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengths_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengths_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengths_resize.h b/level_0/f_type_array/tests/c/test-type_array-array_lengths_resize.h new file mode 100644 index 000000000..297f223dd --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengths_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengths_resize +#define _TEST__F_type_array__array_lengths_resize + +/** + * Test that the function works. + * + * @see f_type_array_array_lengths_resize() + */ +extern void test__f_type_array_array_lengths_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengths_resize() + */ +extern void test__f_type_array_array_lengths_resize__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengths_resize diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_adjust.c b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_adjust.c new file mode 100644 index 000000000..e806c1ccd --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_adjust.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengthss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengthss_adjust__works(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengthss_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_array_lengthss_adjust__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengthss_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_adjust.h b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_adjust.h new file mode 100644 index 000000000..c75c5aeda --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengthss_adjust +#define _TEST__F_type_array__array_lengthss_adjust + +/** + * Test that the function works. + * + * @see f_type_array_array_lengthss_adjust() + */ +extern void test__f_type_array_array_lengthss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengthss_adjust() + */ +extern void test__f_type_array_array_lengthss_adjust__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengthss_adjust diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_append.c b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_append.c new file mode 100644 index 000000000..012a17382 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_append.c @@ -0,0 +1,110 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengthss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengthss_append__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_array_lengthss_t source = f_array_lengths_t_initialize; + f_array_lengthss_t destination = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_type_array_lengths_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_type_array_lengthss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_array_lengthss_append__returns_data_not(void **state) { + + const int length = 5; + f_array_lengthss_t source = f_array_lengths_t_initialize; + f_array_lengthss_t destination = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_type_array_lengthss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + } + + free((void *) source.array); + assert_null(destination.array); +} + +void test__f_type_array_array_lengthss_append__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_append.h b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_append.h new file mode 100644 index 000000000..451b2e080 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengthss_append +#define _TEST__F_type_array__array_lengthss_append + +/** + * Test that the function works. + * + * @see f_type_array_array_lengthss_append() + */ +extern void test__f_type_array_array_lengthss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_array_lengthss_append() + */ +extern void test__f_type_array_array_lengthss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengthss_append() + */ +extern void test__f_type_array_array_lengthss_append__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengthss_append diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decimate_by.c b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decimate_by.c new file mode 100644 index 000000000..6033e39e0 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengthss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengthss_decimate_by__works(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_array_lengthss_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_array_lengthss_decimate_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decimate_by.h b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decimate_by.h new file mode 100644 index 000000000..f1ca46562 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengthss_decimate_by +#define _TEST__F_type_array__array_lengthss_decimate_by + +/** + * Test that the function works. + * + * @see f_type_array_array_lengthss_decimate_by() + */ +extern void test__f_type_array_array_lengthss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengthss_decimate_by() + */ +extern void test__f_type_array_array_lengthss_decimate_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengthss_decimate_by diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decrease_by.c b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decrease_by.c new file mode 100644 index 000000000..5ecacda14 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengthss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengthss_decrease_by__works(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_array_lengthss_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_array_lengthss_decrease_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decrease_by.h b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decrease_by.h new file mode 100644 index 000000000..02b5980a7 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengthss_decrease_by +#define _TEST__F_type_array__array_lengthss_decrease_by + +/** + * Test that the function works. + * + * @see f_type_array_array_lengthss_decrease_by() + */ +extern void test__f_type_array_array_lengthss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengthss_decrease_by() + */ +extern void test__f_type_array_array_lengthss_decrease_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengthss_decrease_by diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase.c b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase.c new file mode 100644 index 000000000..57b944e99 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase.c @@ -0,0 +1,76 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengthss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengthss_increase__works(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_array_lengthss_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_array_lengthss_increase__returns_data_not(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_array_lengthss_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_array_lengthss_increase__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase.h b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase.h new file mode 100644 index 000000000..88a71cb12 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengthss_increase +#define _TEST__F_type_array__array_lengthss_increase + +/** + * Test that the function works. + * + * @see f_type_array_array_lengthss_increase() + */ +extern void test__f_type_array_array_lengthss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_array_lengthss_increase() + */ +extern void test__f_type_array_array_lengthss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengthss_increase() + */ +extern void test__f_type_array_array_lengthss_increase__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengthss_increase diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase_by.c b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase_by.c new file mode 100644 index 000000000..45d1c8a5b --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengthss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengthss_increase_by__works(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_array_lengthss_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_array_lengthss_increase_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengths_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase_by.h b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase_by.h new file mode 100644 index 000000000..05eb52650 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengthss_increase_by +#define _TEST__F_type_array__array_lengthss_increase_by + +/** + * Test that the function works. + * + * @see f_type_array_array_lengthss_increase_by() + */ +extern void test__f_type_array_array_lengthss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengthss_increase_by() + */ +extern void test__f_type_array_array_lengthss_increase_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengthss_increase_by diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_resize.c b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_resize.c new file mode 100644 index 000000000..7346c5ebf --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_resize.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-array_lengthss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_array_lengthss_resize__works(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengthss_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_array_lengthss_resize__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_array_lengthss_t data = f_array_lengthss_t_initialize; + + { + const f_status_t status = f_type_array_lengthss_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-array_lengthss_resize.h b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_resize.h new file mode 100644 index 000000000..a8fd772ec --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-array_lengthss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__array_lengthss_resize +#define _TEST__F_type_array__array_lengthss_resize + +/** + * Test that the function works. + * + * @see f_type_array_array_lengthss_resize() + */ +extern void test__f_type_array_array_lengthss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_array_lengthss_resize() + */ +extern void test__f_type_array_array_lengthss_resize__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__array_lengthss_resize diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_adjust.c b/level_0/f_type_array/tests/c/test-type_array-cells_adjust.c new file mode 100644 index 000000000..9202e4261 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_adjust.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-cells_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cells_adjust__works(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_cells_adjust__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_adjust.h b/level_0/f_type_array/tests/c/test-type_array-cells_adjust.h new file mode 100644 index 000000000..49443d389 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cells_adjust +#define _TEST__F_type_array__cells_adjust + +/** + * Test that the function works. + * + * @see f_type_array_cells_adjust() + */ +extern void test__f_type_array_cells_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cells_adjust() + */ +extern void test__f_type_array_cells_adjust__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cells_adjust diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_append.c b/level_0/f_type_array/tests/c/test-type_array-cells_append.c new file mode 100644 index 000000000..d8155b9e1 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_append.c @@ -0,0 +1,90 @@ +#include "test-type_array.h" +#include "test-type_array-cells_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cells_append__works(void **state) { + + const int length = 5; + f_cells_t source = f_cells_t_initialize; + f_cells_t destination = f_cells_t_initialize; + + const f_cell_t cell_0 = { row: 1, column: 2 }; + const f_cell_t cell_1 = { row: 3, column: 4 }; + + { + const f_status_t status = f_type_cells_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + memcpy(&source.array[source.used++], (void *) &cell_0, sizeof(f_cell_t)); + memcpy(&source.array[source.used++], (void *) &cell_1, sizeof(f_cell_t)); + + { + const f_status_t status = f_type_cells_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + assert_int_equal(destination.array[0].row, cell_0.row); + assert_int_equal(destination.array[0].column, cell_0.column); + + assert_int_equal(destination.array[1].row, cell_1.row); + assert_int_equal(destination.array[1].column, cell_1.column); + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_cells_append__returns_data_not(void **state) { + + const int length = 5; + f_cells_t source = f_cells_t_initialize; + f_cells_t destination = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_type_cells_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + } + + free((void *) source.array); + assert_null(destination.array); +} + +void test__f_type_array_cells_append__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_append.h b/level_0/f_type_array/tests/c/test-type_array-cells_append.h new file mode 100644 index 000000000..e5145842e --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cells_append +#define _TEST__F_type_array__cells_append + +/** + * Test that the function works. + * + * @see f_type_array_cells_append() + */ +extern void test__f_type_array_cells_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_cells_append() + */ +extern void test__f_type_array_cells_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cells_append() + */ +extern void test__f_type_array_cells_append__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cells_append diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_decimate_by.c b/level_0/f_type_array/tests/c/test-type_array-cells_decimate_by.c new file mode 100644 index 000000000..5a19814b7 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-cells_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cells_decimate_by__works(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_cells_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_cells_decimate_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_decimate_by.h b/level_0/f_type_array/tests/c/test-type_array-cells_decimate_by.h new file mode 100644 index 000000000..0d3fcbc33 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cells_decimate_by +#define _TEST__F_type_array__cells_decimate_by + +/** + * Test that the function works. + * + * @see f_type_array_cells_decimate_by() + */ +extern void test__f_type_array_cells_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cells_decimate_by() + */ +extern void test__f_type_array_cells_decimate_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cells_decimate_by diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_decrease_by.c b/level_0/f_type_array/tests/c/test-type_array-cells_decrease_by.c new file mode 100644 index 000000000..411799221 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-cells_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cells_decrease_by__works(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_cells_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_cells_decrease_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_decrease_by.h b/level_0/f_type_array/tests/c/test-type_array-cells_decrease_by.h new file mode 100644 index 000000000..abb091ea6 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cells_decrease_by +#define _TEST__F_type_array__cells_decrease_by + +/** + * Test that the function works. + * + * @see f_type_array_cells_decrease_by() + */ +extern void test__f_type_array_cells_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cells_decrease_by() + */ +extern void test__f_type_array_cells_decrease_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cells_decrease_by diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_increase.c b/level_0/f_type_array/tests/c/test-type_array-cells_increase.c new file mode 100644 index 000000000..806dde0f2 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_increase.c @@ -0,0 +1,76 @@ +#include "test-type_array.h" +#include "test-type_array-cells_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cells_increase__works(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_cells_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_cells_increase__returns_data_not(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_cells_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_cells_increase__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_increase.h b/level_0/f_type_array/tests/c/test-type_array-cells_increase.h new file mode 100644 index 000000000..cf7d40891 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cells_increase +#define _TEST__F_type_array__cells_increase + +/** + * Test that the function works. + * + * @see f_type_array_cells_increase() + */ +extern void test__f_type_array_cells_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_cells_increase() + */ +extern void test__f_type_array_cells_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cells_increase() + */ +extern void test__f_type_array_cells_increase__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cells_increase diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_increase_by.c b/level_0/f_type_array/tests/c/test-type_array-cells_increase_by.c new file mode 100644 index 000000000..a5abfabf0 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_increase_by.c @@ -0,0 +1,52 @@ +#include "test-type_array.h" +#include "test-type_array-cells_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cells_increase_by__works(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_cells_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_cells_increase_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_increase_by.h b/level_0/f_type_array/tests/c/test-type_array-cells_increase_by.h new file mode 100644 index 000000000..b55f0817a --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cells_increase_by +#define _TEST__F_type_array__cells_increase_by + +/** + * Test that the function works. + * + * @see f_type_array_cells_increase_by() + */ +extern void test__f_type_array_cells_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cells_increase_by() + */ +extern void test__f_type_array_cells_increase_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cells_increase_by diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_resize.c b/level_0/f_type_array/tests/c/test-type_array-cells_resize.c new file mode 100644 index 000000000..dccdd8290 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_resize.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-cells_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cells_resize__works(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_cells_resize__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cells_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cells_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cells_resize.h b/level_0/f_type_array/tests/c/test-type_array-cells_resize.h new file mode 100644 index 000000000..f263e6b06 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cells_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cells_resize +#define _TEST__F_type_array__cells_resize + +/** + * Test that the function works. + * + * @see f_type_array_cells_resize() + */ +extern void test__f_type_array_cells_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cells_resize() + */ +extern void test__f_type_array_cells_resize__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cells_resize diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_adjust.c b/level_0/f_type_array/tests/c/test-type_array-cellss_adjust.c new file mode 100644 index 000000000..840dbd756 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_adjust.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-cellss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cellss_adjust__works(void **state) { + + const int length = 5; + f_cellss_t data = f_cellss_t_initialize; + + { + const f_status_t status = f_type_cellss_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_cellss_adjust__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cellss_t data = f_cellss_t_initialize; + + { + const f_status_t status = f_type_cellss_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_adjust.h b/level_0/f_type_array/tests/c/test-type_array-cellss_adjust.h new file mode 100644 index 000000000..1111bdc0c --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cellss_adjust +#define _TEST__F_type_array__cellss_adjust + +/** + * Test that the function works. + * + * @see f_type_array_cellss_adjust() + */ +extern void test__f_type_array_cellss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cellss_adjust() + */ +extern void test__f_type_array_cellss_adjust__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cellss_adjust diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_append.c b/level_0/f_type_array/tests/c/test-type_array-cellss_append.c new file mode 100644 index 000000000..97aacc340 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_append.c @@ -0,0 +1,114 @@ +#include "test-type_array.h" +#include "test-type_array-cellss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cellss_append__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_cellss_t source = f_cells_t_initialize; + f_cellss_t destination = f_cells_t_initialize; + + const f_cell_t cell_0 = { row: 1, column: 2 }; + const f_cell_t cell_1 = { row: 3, column: 4 }; + + { + const f_status_t status = f_type_cellss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_type_cells_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &cell_0, sizeof(f_cell_t)); + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &cell_1, sizeof(f_cell_t)); + } // for + } + + { + const f_status_t status = f_type_cellss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + assert_int_equal(destination.array[i].array[0].row, cell_0.row); + assert_int_equal(destination.array[i].array[0].column, cell_0.column); + + assert_int_equal(destination.array[i].array[1].row, cell_1.row); + assert_int_equal(destination.array[i].array[1].column, cell_1.column); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_cellss_append__returns_data_not(void **state) { + + const int length = 5; + f_cellss_t source = f_cells_t_initialize; + f_cellss_t destination = f_cells_t_initialize; + + { + const f_status_t status = f_type_cellss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_type_cellss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + } + + free((void *) source.array); + assert_null(destination.array); +} + +void test__f_type_array_cellss_append__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cellss_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cellss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_append.h b/level_0/f_type_array/tests/c/test-type_array-cellss_append.h new file mode 100644 index 000000000..74f4c784f --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cellss_append +#define _TEST__F_type_array__cellss_append + +/** + * Test that the function works. + * + * @see f_type_array_cellss_append() + */ +extern void test__f_type_array_cellss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_cellss_append() + */ +extern void test__f_type_array_cellss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cellss_append() + */ +extern void test__f_type_array_cellss_append__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cellss_append diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_decimate_by.c b/level_0/f_type_array/tests/c/test-type_array-cellss_decimate_by.c new file mode 100644 index 000000000..ded28e43a --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-cellss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cellss_decimate_by__works(void **state) { + + const int length = 5; + f_cellss_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cellss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_cellss_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_cellss_decimate_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cellss_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cellss_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_decimate_by.h b/level_0/f_type_array/tests/c/test-type_array-cellss_decimate_by.h new file mode 100644 index 000000000..93509eed2 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cellss_decimate_by +#define _TEST__F_type_array__cellss_decimate_by + +/** + * Test that the function works. + * + * @see f_type_array_cellss_decimate_by() + */ +extern void test__f_type_array_cellss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cellss_decimate_by() + */ +extern void test__f_type_array_cellss_decimate_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cellss_decimate_by diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_decrease_by.c b/level_0/f_type_array/tests/c/test-type_array-cellss_decrease_by.c new file mode 100644 index 000000000..3d2c626ff --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-cellss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cellss_decrease_by__works(void **state) { + + const int length = 5; + f_cellss_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cellss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_cellss_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_cellss_decrease_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cellss_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cellss_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_decrease_by.h b/level_0/f_type_array/tests/c/test-type_array-cellss_decrease_by.h new file mode 100644 index 000000000..b3cdd0a95 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cellss_decrease_by +#define _TEST__F_type_array__cellss_decrease_by + +/** + * Test that the function works. + * + * @see f_type_array_cellss_decrease_by() + */ +extern void test__f_type_array_cellss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cellss_decrease_by() + */ +extern void test__f_type_array_cellss_decrease_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cellss_decrease_by diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_increase.c b/level_0/f_type_array/tests/c/test-type_array-cellss_increase.c new file mode 100644 index 000000000..80185199c --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_increase.c @@ -0,0 +1,76 @@ +#include "test-type_array.h" +#include "test-type_array-cellss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cellss_increase__works(void **state) { + + const int length = 5; + f_cellss_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cellss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_cellss_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_cellss_increase__returns_data_not(void **state) { + + const int length = 5; + f_cellss_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cellss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_cellss_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_cellss_increase__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cellss_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cellss_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_increase.h b/level_0/f_type_array/tests/c/test-type_array-cellss_increase.h new file mode 100644 index 000000000..e5ce06b94 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cellss_increase +#define _TEST__F_type_array__cellss_increase + +/** + * Test that the function works. + * + * @see f_type_array_cellss_increase() + */ +extern void test__f_type_array_cellss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_cellss_increase() + */ +extern void test__f_type_array_cellss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cellss_increase() + */ +extern void test__f_type_array_cellss_increase__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cellss_increase diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_increase_by.c b/level_0/f_type_array/tests/c/test-type_array-cellss_increase_by.c new file mode 100644 index 000000000..897f0c667 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-type_array.h" +#include "test-type_array-cellss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cellss_increase_by__works(void **state) { + + const int length = 5; + f_cellss_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cellss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_cellss_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_cellss_increase_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cellss_t data = f_cells_t_initialize; + + { + const f_status_t status = f_type_cellss_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_increase_by.h b/level_0/f_type_array/tests/c/test-type_array-cellss_increase_by.h new file mode 100644 index 000000000..16267cf4b --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cellss_increase_by +#define _TEST__F_type_array__cellss_increase_by + +/** + * Test that the function works. + * + * @see f_type_array_cellss_increase_by() + */ +extern void test__f_type_array_cellss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cellss_increase_by() + */ +extern void test__f_type_array_cellss_increase_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cellss_increase_by diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_resize.c b/level_0/f_type_array/tests/c/test-type_array-cellss_resize.c new file mode 100644 index 000000000..6aa0bf827 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_resize.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-cellss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_cellss_resize__works(void **state) { + + const int length = 5; + f_cellss_t data = f_cellss_t_initialize; + + { + const f_status_t status = f_type_cellss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_cellss_resize__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_cellss_t data = f_cellss_t_initialize; + + { + const f_status_t status = f_type_cellss_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-cellss_resize.h b/level_0/f_type_array/tests/c/test-type_array-cellss_resize.h new file mode 100644 index 000000000..03c7df1ba --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-cellss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__cellss_resize +#define _TEST__F_type_array__cellss_resize + +/** + * Test that the function works. + * + * @see f_type_array_cellss_resize() + */ +extern void test__f_type_array_cellss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_cellss_resize() + */ +extern void test__f_type_array_cellss_resize__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__cellss_resize diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_adjust.c b/level_0/f_type_array/tests/c/test-type_array-fll_ids_adjust.c new file mode 100644 index 000000000..ba3d8e036 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_adjust.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-fll_ids_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_ids_adjust__works(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_fll_ids_adjust__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_adjust.h b/level_0/f_type_array/tests/c/test-type_array-fll_ids_adjust.h new file mode 100644 index 000000000..d63264d3a --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_ids_adjust +#define _TEST__F_type_array__fll_ids_adjust + +/** + * Test that the function works. + * + * @see f_type_array_fll_ids_adjust() + */ +extern void test__f_type_array_fll_ids_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_ids_adjust() + */ +extern void test__f_type_array_fll_ids_adjust__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_ids_adjust diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_append.c b/level_0/f_type_array/tests/c/test-type_array-fll_ids_append.c new file mode 100644 index 000000000..90b06bc2b --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_append.c @@ -0,0 +1,92 @@ +#include "test-type_array.h" +#include "test-type_array-fll_ids_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_ids_append__works(void **state) { + + const int length = 5; + f_fll_ids_t source = f_fll_ids_t_initialize; + f_fll_ids_t destination = f_fll_ids_t_initialize; + + const f_fll_id_t fll_id_0 = { name: "test", type: 1, used: 4 }; + const f_fll_id_t fll_id_1 = { name: "other", type: 2, used: 5 }; + + { + const f_status_t status = f_type_fll_ids_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + memcpy(&source.array[source.used++], (void *) &fll_id_0, sizeof(f_fll_id_t)); + memcpy(&source.array[source.used++], (void *) &fll_id_1, sizeof(f_fll_id_t)); + + { + const f_status_t status = f_type_fll_ids_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + assert_string_equal(destination.array[0].name, fll_id_0.name); + assert_int_equal(destination.array[0].type, fll_id_0.type); + assert_int_equal(destination.array[0].used, fll_id_0.used); + + assert_string_equal(destination.array[1].name, fll_id_1.name); + assert_int_equal(destination.array[1].type, fll_id_1.type); + assert_int_equal(destination.array[1].used, fll_id_1.used); + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_fll_ids_append__returns_data_not(void **state) { + + const int length = 5; + f_fll_ids_t source = f_fll_ids_t_initialize; + f_fll_ids_t destination = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_type_fll_ids_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + } + + free((void *) source.array); + assert_null(destination.array); +} + +void test__f_type_array_fll_ids_append__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_append.h b/level_0/f_type_array/tests/c/test-type_array-fll_ids_append.h new file mode 100644 index 000000000..3b051fd8f --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_ids_append +#define _TEST__F_type_array__fll_ids_append + +/** + * Test that the function works. + * + * @see f_type_array_fll_ids_append() + */ +extern void test__f_type_array_fll_ids_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_fll_ids_append() + */ +extern void test__f_type_array_fll_ids_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_ids_append() + */ +extern void test__f_type_array_fll_ids_append__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_ids_append diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_decimate_by.c b/level_0/f_type_array/tests/c/test-type_array-fll_ids_decimate_by.c new file mode 100644 index 000000000..3efedb4fa --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-fll_ids_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_ids_decimate_by__works(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_fll_ids_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_fll_ids_decimate_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_decimate_by.h b/level_0/f_type_array/tests/c/test-type_array-fll_ids_decimate_by.h new file mode 100644 index 000000000..36a0149cd --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_ids_decimate_by +#define _TEST__F_type_array__fll_ids_decimate_by + +/** + * Test that the function works. + * + * @see f_type_array_fll_ids_decimate_by() + */ +extern void test__f_type_array_fll_ids_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_ids_decimate_by() + */ +extern void test__f_type_array_fll_ids_decimate_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_ids_decimate_by diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_decrease_by.c b/level_0/f_type_array/tests/c/test-type_array-fll_ids_decrease_by.c new file mode 100644 index 000000000..bf484d104 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-fll_ids_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_ids_decrease_by__works(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_fll_ids_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_fll_ids_decrease_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_decrease_by.h b/level_0/f_type_array/tests/c/test-type_array-fll_ids_decrease_by.h new file mode 100644 index 000000000..8d47fe01b --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_ids_decrease_by +#define _TEST__F_type_array__fll_ids_decrease_by + +/** + * Test that the function works. + * + * @see f_type_array_fll_ids_decrease_by() + */ +extern void test__f_type_array_fll_ids_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_ids_decrease_by() + */ +extern void test__f_type_array_fll_ids_decrease_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_ids_decrease_by diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase.c b/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase.c new file mode 100644 index 000000000..0058686f9 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase.c @@ -0,0 +1,76 @@ +#include "test-type_array.h" +#include "test-type_array-fll_ids_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_ids_increase__works(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_fll_ids_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_fll_ids_increase__returns_data_not(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_fll_ids_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_fll_ids_increase__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase.h b/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase.h new file mode 100644 index 000000000..313b6d6f4 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_ids_increase +#define _TEST__F_type_array__fll_ids_increase + +/** + * Test that the function works. + * + * @see f_type_array_fll_ids_increase() + */ +extern void test__f_type_array_fll_ids_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_fll_ids_increase() + */ +extern void test__f_type_array_fll_ids_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_ids_increase() + */ +extern void test__f_type_array_fll_ids_increase__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_ids_increase diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase_by.c b/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase_by.c new file mode 100644 index 000000000..e78e351ce --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase_by.c @@ -0,0 +1,52 @@ +#include "test-type_array.h" +#include "test-type_array-fll_ids_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_ids_increase_by__works(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_fll_ids_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_fll_ids_increase_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase_by.h b/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase_by.h new file mode 100644 index 000000000..5a9866771 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_ids_increase_by +#define _TEST__F_type_array__fll_ids_increase_by + +/** + * Test that the function works. + * + * @see f_type_array_fll_ids_increase_by() + */ +extern void test__f_type_array_fll_ids_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_ids_increase_by() + */ +extern void test__f_type_array_fll_ids_increase_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_ids_increase_by diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_resize.c b/level_0/f_type_array/tests/c/test-type_array-fll_ids_resize.c new file mode 100644 index 000000000..73e15befd --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_resize.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-fll_ids_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_ids_resize__works(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_fll_ids_resize__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_ids_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_ids_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_ids_resize.h b/level_0/f_type_array/tests/c/test-type_array-fll_ids_resize.h new file mode 100644 index 000000000..7f034bbea --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_ids_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_ids_resize +#define _TEST__F_type_array__fll_ids_resize + +/** + * Test that the function works. + * + * @see f_type_array_fll_ids_resize() + */ +extern void test__f_type_array_fll_ids_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_ids_resize() + */ +extern void test__f_type_array_fll_ids_resize__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_ids_resize diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_adjust.c b/level_0/f_type_array/tests/c/test-type_array-fll_idss_adjust.c new file mode 100644 index 000000000..4cffd3bf8 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_adjust.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-fll_idss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_idss_adjust__works(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_idss_t_initialize; + + { + const f_status_t status = f_type_fll_idss_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_fll_idss_adjust__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_idss_t_initialize; + + { + const f_status_t status = f_type_fll_idss_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_adjust.h b/level_0/f_type_array/tests/c/test-type_array-fll_idss_adjust.h new file mode 100644 index 000000000..98f5d3797 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_idss_adjust +#define _TEST__F_type_array__fll_idss_adjust + +/** + * Test that the function works. + * + * @see f_type_array_fll_idss_adjust() + */ +extern void test__f_type_array_fll_idss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_idss_adjust() + */ +extern void test__f_type_array_fll_idss_adjust__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_idss_adjust diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_append.c b/level_0/f_type_array/tests/c/test-type_array-fll_idss_append.c new file mode 100644 index 000000000..a78e88568 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_append.c @@ -0,0 +1,116 @@ +#include "test-type_array.h" +#include "test-type_array-fll_idss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_idss_append__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_fll_idss_t source = f_fll_ids_t_initialize; + f_fll_idss_t destination = f_fll_ids_t_initialize; + + const f_fll_id_t fll_id_0 = { name: "test", type: 1, used: 4 }; + const f_fll_id_t fll_id_1 = { name: "other", type: 2, used: 5 }; + + { + const f_status_t status = f_type_fll_idss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_type_fll_ids_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &fll_id_0, sizeof(f_fll_id_t)); + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &fll_id_1, sizeof(f_fll_id_t)); + } // for + } + + { + const f_status_t status = f_type_fll_idss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + assert_string_equal(destination.array[i].array[0].name, fll_id_0.name); + assert_int_equal(destination.array[i].array[0].type, fll_id_0.type); + assert_int_equal(destination.array[i].array[0].used, fll_id_0.used); + + assert_string_equal(destination.array[i].array[1].name, fll_id_1.name); + assert_int_equal(destination.array[i].array[1].type, fll_id_1.type); + assert_int_equal(destination.array[i].array[1].used, fll_id_1.used); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_fll_idss_append__returns_data_not(void **state) { + + const int length = 5; + f_fll_idss_t source = f_fll_ids_t_initialize; + f_fll_idss_t destination = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_idss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_type_fll_idss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + } + + free((void *) source.array); + assert_null(destination.array); +} + +void test__f_type_array_fll_idss_append__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_idss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_append.h b/level_0/f_type_array/tests/c/test-type_array-fll_idss_append.h new file mode 100644 index 000000000..43a851e5e --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_idss_append +#define _TEST__F_type_array__fll_idss_append + +/** + * Test that the function works. + * + * @see f_type_array_fll_idss_append() + */ +extern void test__f_type_array_fll_idss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_fll_idss_append() + */ +extern void test__f_type_array_fll_idss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_idss_append() + */ +extern void test__f_type_array_fll_idss_append__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_idss_append diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_decimate_by.c b/level_0/f_type_array/tests/c/test-type_array-fll_idss_decimate_by.c new file mode 100644 index 000000000..75ecc98b1 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-fll_idss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_idss_decimate_by__works(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_idss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_fll_idss_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_fll_idss_decimate_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_idss_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_decimate_by.h b/level_0/f_type_array/tests/c/test-type_array-fll_idss_decimate_by.h new file mode 100644 index 000000000..30f011e08 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_idss_decimate_by +#define _TEST__F_type_array__fll_idss_decimate_by + +/** + * Test that the function works. + * + * @see f_type_array_fll_idss_decimate_by() + */ +extern void test__f_type_array_fll_idss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_idss_decimate_by() + */ +extern void test__f_type_array_fll_idss_decimate_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_idss_decimate_by diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_decrease_by.c b/level_0/f_type_array/tests/c/test-type_array-fll_idss_decrease_by.c new file mode 100644 index 000000000..e382d2d56 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-fll_idss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_idss_decrease_by__works(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_idss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_fll_idss_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_fll_idss_decrease_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_idss_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_decrease_by.h b/level_0/f_type_array/tests/c/test-type_array-fll_idss_decrease_by.h new file mode 100644 index 000000000..21fa83130 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_idss_decrease_by +#define _TEST__F_type_array__fll_idss_decrease_by + +/** + * Test that the function works. + * + * @see f_type_array_fll_idss_decrease_by() + */ +extern void test__f_type_array_fll_idss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_idss_decrease_by() + */ +extern void test__f_type_array_fll_idss_decrease_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_idss_decrease_by diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase.c b/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase.c new file mode 100644 index 000000000..d16f586ed --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase.c @@ -0,0 +1,76 @@ +#include "test-type_array.h" +#include "test-type_array-fll_idss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_idss_increase__works(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_idss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_fll_idss_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_fll_idss_increase__returns_data_not(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_idss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_fll_idss_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_fll_idss_increase__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_idss_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase.h b/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase.h new file mode 100644 index 000000000..5a9773a63 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_idss_increase +#define _TEST__F_type_array__fll_idss_increase + +/** + * Test that the function works. + * + * @see f_type_array_fll_idss_increase() + */ +extern void test__f_type_array_fll_idss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_fll_idss_increase() + */ +extern void test__f_type_array_fll_idss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_idss_increase() + */ +extern void test__f_type_array_fll_idss_increase__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_idss_increase diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase_by.c b/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase_by.c new file mode 100644 index 000000000..8c671dc09 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-type_array.h" +#include "test-type_array-fll_idss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_idss_increase_by__works(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_idss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_fll_idss_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_fll_idss_increase_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_ids_t_initialize; + + { + const f_status_t status = f_type_fll_idss_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase_by.h b/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase_by.h new file mode 100644 index 000000000..0636d44ce --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_idss_increase_by +#define _TEST__F_type_array__fll_idss_increase_by + +/** + * Test that the function works. + * + * @see f_type_array_fll_idss_increase_by() + */ +extern void test__f_type_array_fll_idss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_idss_increase_by() + */ +extern void test__f_type_array_fll_idss_increase_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_idss_increase_by diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_resize.c b/level_0/f_type_array/tests/c/test-type_array-fll_idss_resize.c new file mode 100644 index 000000000..6db6835bd --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_resize.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-fll_idss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_fll_idss_resize__works(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_idss_t_initialize; + + { + const f_status_t status = f_type_fll_idss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_fll_idss_resize__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_fll_idss_t data = f_fll_idss_t_initialize; + + { + const f_status_t status = f_type_fll_idss_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-fll_idss_resize.h b/level_0/f_type_array/tests/c/test-type_array-fll_idss_resize.h new file mode 100644 index 000000000..9d8db2789 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-fll_idss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__fll_idss_resize +#define _TEST__F_type_array__fll_idss_resize + +/** + * Test that the function works. + * + * @see f_type_array_fll_idss_resize() + */ +extern void test__f_type_array_fll_idss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_fll_idss_resize() + */ +extern void test__f_type_array_fll_idss_resize__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__fll_idss_resize diff --git a/level_0/f_type_array/tests/c/test-type_array-states_adjust.c b/level_0/f_type_array/tests/c/test-type_array-states_adjust.c new file mode 100644 index 000000000..84e533b87 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_adjust.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-states_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_states_adjust__works(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_states_adjust__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-states_adjust.h b/level_0/f_type_array/tests/c/test-type_array-states_adjust.h new file mode 100644 index 000000000..ef92edc79 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__states_adjust +#define _TEST__F_type_array__states_adjust + +/** + * Test that the function works. + * + * @see f_type_array_states_adjust() + */ +extern void test__f_type_array_states_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_states_adjust() + */ +extern void test__f_type_array_states_adjust__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__states_adjust diff --git a/level_0/f_type_array/tests/c/test-type_array-states_append.c b/level_0/f_type_array/tests/c/test-type_array-states_append.c new file mode 100644 index 000000000..ddd375de0 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_append.c @@ -0,0 +1,100 @@ +#include "test-type_array.h" +#include "test-type_array-states_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_states_append__works(void **state) { + + const int length = 5; + f_states_t source = f_states_t_initialize; + f_states_t destination = f_states_t_initialize; + + const f_state_t state_0 = { step_large: 10, step_small: 1, handle: 0, interrupt: 0, callbacks: 0, custom: 0, data: 0 }; + const f_state_t state_1 = { step_large: 20, step_small: 2, handle: 0, interrupt: 0, callbacks: 0, custom: 0, data: 0 }; + + { + const f_status_t status = f_type_states_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + memcpy(&source.array[source.used++], (void *) &state_0, sizeof(f_state_t)); + memcpy(&source.array[source.used++], (void *) &state_1, sizeof(f_state_t)); + + { + const f_status_t status = f_type_states_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + assert_int_equal(destination.array[0].step_large, state_0.step_large); + assert_int_equal(destination.array[0].step_small, state_0.step_small); + assert_null(destination.array[0].handle); + assert_null(destination.array[0].interrupt); + assert_null(destination.array[0].callbacks); + assert_null(destination.array[0].custom); + assert_null(destination.array[0].data); + + assert_int_equal(destination.array[1].step_large, state_1.step_large); + assert_int_equal(destination.array[1].step_small, state_1.step_small); + assert_null(destination.array[1].handle); + assert_null(destination.array[1].interrupt); + assert_null(destination.array[1].callbacks); + assert_null(destination.array[1].custom); + assert_null(destination.array[1].data); + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_states_append__returns_data_not(void **state) { + + const int length = 5; + f_states_t source = f_states_t_initialize; + f_states_t destination = f_states_t_initialize; + + { + const f_status_t status = f_type_states_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_type_states_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + } + + free((void *) source.array); + assert_null(destination.array); +} + +void test__f_type_array_states_append__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-states_append.h b/level_0/f_type_array/tests/c/test-type_array-states_append.h new file mode 100644 index 000000000..7afc0e0a8 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__states_append +#define _TEST__F_type_array__states_append + +/** + * Test that the function works. + * + * @see f_type_array_states_append() + */ +extern void test__f_type_array_states_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_states_append() + */ +extern void test__f_type_array_states_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_states_append() + */ +extern void test__f_type_array_states_append__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__states_append diff --git a/level_0/f_type_array/tests/c/test-type_array-states_decimate_by.c b/level_0/f_type_array/tests/c/test-type_array-states_decimate_by.c new file mode 100644 index 000000000..026c95459 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-states_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_states_decimate_by__works(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_states_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_states_decimate_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-states_decimate_by.h b/level_0/f_type_array/tests/c/test-type_array-states_decimate_by.h new file mode 100644 index 000000000..4b397bac3 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__states_decimate_by +#define _TEST__F_type_array__states_decimate_by + +/** + * Test that the function works. + * + * @see f_type_array_states_decimate_by() + */ +extern void test__f_type_array_states_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_states_decimate_by() + */ +extern void test__f_type_array_states_decimate_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__states_decimate_by diff --git a/level_0/f_type_array/tests/c/test-type_array-states_decrease_by.c b/level_0/f_type_array/tests/c/test-type_array-states_decrease_by.c new file mode 100644 index 000000000..218c8c678 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-states_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_states_decrease_by__works(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_states_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_states_decrease_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-states_decrease_by.h b/level_0/f_type_array/tests/c/test-type_array-states_decrease_by.h new file mode 100644 index 000000000..04cf75b94 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__states_decrease_by +#define _TEST__F_type_array__states_decrease_by + +/** + * Test that the function works. + * + * @see f_type_array_states_decrease_by() + */ +extern void test__f_type_array_states_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_states_decrease_by() + */ +extern void test__f_type_array_states_decrease_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__states_decrease_by diff --git a/level_0/f_type_array/tests/c/test-type_array-states_increase.c b/level_0/f_type_array/tests/c/test-type_array-states_increase.c new file mode 100644 index 000000000..857f47e61 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_increase.c @@ -0,0 +1,76 @@ +#include "test-type_array.h" +#include "test-type_array-states_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_states_increase__works(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_states_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_states_increase__returns_data_not(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_states_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_states_increase__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-states_increase.h b/level_0/f_type_array/tests/c/test-type_array-states_increase.h new file mode 100644 index 000000000..a653df20b --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__states_increase +#define _TEST__F_type_array__states_increase + +/** + * Test that the function works. + * + * @see f_type_array_states_increase() + */ +extern void test__f_type_array_states_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_states_increase() + */ +extern void test__f_type_array_states_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_states_increase() + */ +extern void test__f_type_array_states_increase__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__states_increase diff --git a/level_0/f_type_array/tests/c/test-type_array-states_increase_by.c b/level_0/f_type_array/tests/c/test-type_array-states_increase_by.c new file mode 100644 index 000000000..711944eb8 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_increase_by.c @@ -0,0 +1,52 @@ +#include "test-type_array.h" +#include "test-type_array-states_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_states_increase_by__works(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_states_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_states_increase_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-states_increase_by.h b/level_0/f_type_array/tests/c/test-type_array-states_increase_by.h new file mode 100644 index 000000000..34a8cb0f8 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__states_increase_by +#define _TEST__F_type_array__states_increase_by + +/** + * Test that the function works. + * + * @see f_type_array_states_increase_by() + */ +extern void test__f_type_array_states_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_states_increase_by() + */ +extern void test__f_type_array_states_increase_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__states_increase_by diff --git a/level_0/f_type_array/tests/c/test-type_array-states_resize.c b/level_0/f_type_array/tests/c/test-type_array-states_resize.c new file mode 100644 index 000000000..1366ba493 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_resize.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-states_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_states_resize__works(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_states_resize__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_states_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_states_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-states_resize.h b/level_0/f_type_array/tests/c/test-type_array-states_resize.h new file mode 100644 index 000000000..9b8e35b7c --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-states_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__states_resize +#define _TEST__F_type_array__states_resize + +/** + * Test that the function works. + * + * @see f_type_array_states_resize() + */ +extern void test__f_type_array_states_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_states_resize() + */ +extern void test__f_type_array_states_resize__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__states_resize diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_adjust.c b/level_0/f_type_array/tests/c/test-type_array-statess_adjust.c new file mode 100644 index 000000000..ceb323dce --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_adjust.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-statess_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statess_adjust__works(void **state) { + + const int length = 5; + f_statess_t data = f_statess_t_initialize; + + { + const f_status_t status = f_type_statess_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_statess_adjust__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statess_t data = f_statess_t_initialize; + + { + const f_status_t status = f_type_statess_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_adjust.h b/level_0/f_type_array/tests/c/test-type_array-statess_adjust.h new file mode 100644 index 000000000..6537c779d --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statess_adjust +#define _TEST__F_type_array__statess_adjust + +/** + * Test that the function works. + * + * @see f_type_array_statess_adjust() + */ +extern void test__f_type_array_statess_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statess_adjust() + */ +extern void test__f_type_array_statess_adjust__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statess_adjust diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_append.c b/level_0/f_type_array/tests/c/test-type_array-statess_append.c new file mode 100644 index 000000000..216dc0f2a --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_append.c @@ -0,0 +1,124 @@ +#include "test-type_array.h" +#include "test-type_array-statess_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statess_append__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_statess_t source = f_states_t_initialize; + f_statess_t destination = f_states_t_initialize; + + const f_state_t state_0 = { step_large: 10, step_small: 1, handle: 0, interrupt: 0, callbacks: 0, custom: 0, data: 0 }; + const f_state_t state_1 = { step_large: 20, step_small: 2, handle: 0, interrupt: 0, callbacks: 0, custom: 0, data: 0 }; + + { + const f_status_t status = f_type_statess_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_type_states_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &state_0, sizeof(f_state_t)); + memcpy(&source.array[source.used].array[source.array[source.used].used++], (void *) &state_1, sizeof(f_state_t)); + } // for + } + + { + const f_status_t status = f_type_statess_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + assert_int_equal(destination.array[i].array[0].step_large, state_0.step_large); + assert_int_equal(destination.array[i].array[0].step_small, state_0.step_small); + assert_null(destination.array[i].array[0].handle); + assert_null(destination.array[i].array[0].interrupt); + assert_null(destination.array[i].array[0].callbacks); + assert_null(destination.array[i].array[0].custom); + assert_null(destination.array[i].array[0].data); + + assert_int_equal(destination.array[i].array[1].step_large, state_1.step_large); + assert_int_equal(destination.array[i].array[1].step_small, state_1.step_small); + assert_null(destination.array[i].array[1].handle); + assert_null(destination.array[i].array[1].interrupt); + assert_null(destination.array[i].array[1].callbacks); + assert_null(destination.array[i].array[1].custom); + assert_null(destination.array[i].array[1].data); + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_statess_append__returns_data_not(void **state) { + + const int length = 5; + f_statess_t source = f_states_t_initialize; + f_statess_t destination = f_states_t_initialize; + + { + const f_status_t status = f_type_statess_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_type_statess_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + } + + free((void *) source.array); + assert_null(destination.array); +} + +void test__f_type_array_statess_append__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statess_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_statess_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_append.h b/level_0/f_type_array/tests/c/test-type_array-statess_append.h new file mode 100644 index 000000000..7aca8b8e7 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statess_append +#define _TEST__F_type_array__statess_append + +/** + * Test that the function works. + * + * @see f_type_array_statess_append() + */ +extern void test__f_type_array_statess_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_statess_append() + */ +extern void test__f_type_array_statess_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statess_append() + */ +extern void test__f_type_array_statess_append__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statess_append diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_decimate_by.c b/level_0/f_type_array/tests/c/test-type_array-statess_decimate_by.c new file mode 100644 index 000000000..3f41a47dc --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-statess_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statess_decimate_by__works(void **state) { + + const int length = 5; + f_statess_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_statess_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_statess_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_statess_decimate_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statess_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_statess_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_decimate_by.h b/level_0/f_type_array/tests/c/test-type_array-statess_decimate_by.h new file mode 100644 index 000000000..56f8d038a --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statess_decimate_by +#define _TEST__F_type_array__statess_decimate_by + +/** + * Test that the function works. + * + * @see f_type_array_statess_decimate_by() + */ +extern void test__f_type_array_statess_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statess_decimate_by() + */ +extern void test__f_type_array_statess_decimate_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statess_decimate_by diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_decrease_by.c b/level_0/f_type_array/tests/c/test-type_array-statess_decrease_by.c new file mode 100644 index 000000000..cd39f4edf --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-statess_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statess_decrease_by__works(void **state) { + + const int length = 5; + f_statess_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_statess_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_statess_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_statess_decrease_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statess_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_statess_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_decrease_by.h b/level_0/f_type_array/tests/c/test-type_array-statess_decrease_by.h new file mode 100644 index 000000000..6b6d36f86 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statess_decrease_by +#define _TEST__F_type_array__statess_decrease_by + +/** + * Test that the function works. + * + * @see f_type_array_statess_decrease_by() + */ +extern void test__f_type_array_statess_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statess_decrease_by() + */ +extern void test__f_type_array_statess_decrease_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statess_decrease_by diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_increase.c b/level_0/f_type_array/tests/c/test-type_array-statess_increase.c new file mode 100644 index 000000000..8c674efb1 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_increase.c @@ -0,0 +1,76 @@ +#include "test-type_array.h" +#include "test-type_array-statess_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statess_increase__works(void **state) { + + const int length = 5; + f_statess_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_statess_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_statess_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_statess_increase__returns_data_not(void **state) { + + const int length = 5; + f_statess_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_statess_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_statess_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_statess_increase__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statess_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_statess_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_increase.h b/level_0/f_type_array/tests/c/test-type_array-statess_increase.h new file mode 100644 index 000000000..fa39f7eb0 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statess_increase +#define _TEST__F_type_array__statess_increase + +/** + * Test that the function works. + * + * @see f_type_array_statess_increase() + */ +extern void test__f_type_array_statess_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_statess_increase() + */ +extern void test__f_type_array_statess_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statess_increase() + */ +extern void test__f_type_array_statess_increase__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statess_increase diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_increase_by.c b/level_0/f_type_array/tests/c/test-type_array-statess_increase_by.c new file mode 100644 index 000000000..f33af7855 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_increase_by.c @@ -0,0 +1,52 @@ +#include "test-type_array.h" +#include "test-type_array-statess_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statess_increase_by__works(void **state) { + + const int length = 5; + f_statess_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_statess_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_statess_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_statess_increase_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statess_t data = f_states_t_initialize; + + { + const f_status_t status = f_type_statess_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_increase_by.h b/level_0/f_type_array/tests/c/test-type_array-statess_increase_by.h new file mode 100644 index 000000000..fca473b2e --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statess_increase_by +#define _TEST__F_type_array__statess_increase_by + +/** + * Test that the function works. + * + * @see f_type_array_statess_increase_by() + */ +extern void test__f_type_array_statess_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statess_increase_by() + */ +extern void test__f_type_array_statess_increase_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statess_increase_by diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_resize.c b/level_0/f_type_array/tests/c/test-type_array-statess_resize.c new file mode 100644 index 000000000..57daa3873 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_resize.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-statess_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statess_resize__works(void **state) { + + const int length = 5; + f_statess_t data = f_statess_t_initialize; + + { + const f_status_t status = f_type_statess_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_statess_resize__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statess_t data = f_statess_t_initialize; + + { + const f_status_t status = f_type_statess_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statess_resize.h b/level_0/f_type_array/tests/c/test-type_array-statess_resize.h new file mode 100644 index 000000000..5ec100772 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statess_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statess_resize +#define _TEST__F_type_array__statess_resize + +/** + * Test that the function works. + * + * @see f_type_array_statess_resize() + */ +extern void test__f_type_array_statess_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statess_resize() + */ +extern void test__f_type_array_statess_resize__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statess_resize diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_adjust.c b/level_0/f_type_array/tests/c/test-type_array-statuss_adjust.c new file mode 100644 index 000000000..f7b6a3a20 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_adjust.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-statuss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statuss_adjust__works(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_statuss_adjust__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_adjust.h b/level_0/f_type_array/tests/c/test-type_array-statuss_adjust.h new file mode 100644 index 000000000..412065f1c --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statuss_adjust +#define _TEST__F_type_array__statuss_adjust + +/** + * Test that the function works. + * + * @see f_type_array_statuss_adjust() + */ +extern void test__f_type_array_statuss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statuss_adjust() + */ +extern void test__f_type_array_statuss_adjust__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statuss_adjust diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_append.c b/level_0/f_type_array/tests/c/test-type_array-statuss_append.c new file mode 100644 index 000000000..2130d8c2e --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_append.c @@ -0,0 +1,87 @@ +#include "test-type_array.h" +#include "test-type_array-statuss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statuss_append__works(void **state) { + + const int length = 5; + const int length_used = 2; + f_statuss_t source = f_statuss_t_initialize; + f_statuss_t destination = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + for (; source.used < length_used; ++source.used) { + source.array[source.used] = source.used + 1; + } // for + + { + const f_status_t status = f_type_statuss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < source.used; ++i) { + assert_int_equal(destination.array[i], i + 1); + } // for + } + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_statuss_append__returns_data_not(void **state) { + + const int length = 5; + f_statuss_t source = f_statuss_t_initialize; + f_statuss_t destination = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_type_statuss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + } + + free((void *) source.array); + assert_null(destination.array); +} + +void test__f_type_array_statuss_append__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_append.h b/level_0/f_type_array/tests/c/test-type_array-statuss_append.h new file mode 100644 index 000000000..e4d1d99b0 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statuss_append +#define _TEST__F_type_array__statuss_append + +/** + * Test that the function works. + * + * @see f_type_array_statuss_append() + */ +extern void test__f_type_array_statuss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_statuss_append() + */ +extern void test__f_type_array_statuss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statuss_append() + */ +extern void test__f_type_array_statuss_append__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statuss_append diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_decimate_by.c b/level_0/f_type_array/tests/c/test-type_array-statuss_decimate_by.c new file mode 100644 index 000000000..7aa762b57 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-statuss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statuss_decimate_by__works(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_statuss_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_statuss_decimate_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_decimate_by.h b/level_0/f_type_array/tests/c/test-type_array-statuss_decimate_by.h new file mode 100644 index 000000000..f6e8bb249 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statuss_decimate_by +#define _TEST__F_type_array__statuss_decimate_by + +/** + * Test that the function works. + * + * @see f_type_array_statuss_decimate_by() + */ +extern void test__f_type_array_statuss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statuss_decimate_by() + */ +extern void test__f_type_array_statuss_decimate_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statuss_decimate_by diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_decrease_by.c b/level_0/f_type_array/tests/c/test-type_array-statuss_decrease_by.c new file mode 100644 index 000000000..d8818b3be --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-statuss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statuss_decrease_by__works(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_statuss_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_statuss_decrease_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_decrease_by.h b/level_0/f_type_array/tests/c/test-type_array-statuss_decrease_by.h new file mode 100644 index 000000000..8b8f43b50 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statuss_decrease_by +#define _TEST__F_type_array__statuss_decrease_by + +/** + * Test that the function works. + * + * @see f_type_array_statuss_decrease_by() + */ +extern void test__f_type_array_statuss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statuss_decrease_by() + */ +extern void test__f_type_array_statuss_decrease_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statuss_decrease_by diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_increase.c b/level_0/f_type_array/tests/c/test-type_array-statuss_increase.c new file mode 100644 index 000000000..fde1b7713 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_increase.c @@ -0,0 +1,76 @@ +#include "test-type_array.h" +#include "test-type_array-statuss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statuss_increase__works(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_statuss_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_statuss_increase__returns_data_not(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_statuss_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_statuss_increase__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_increase.h b/level_0/f_type_array/tests/c/test-type_array-statuss_increase.h new file mode 100644 index 000000000..6c30bf036 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statuss_increase +#define _TEST__F_type_array__statuss_increase + +/** + * Test that the function works. + * + * @see f_type_array_statuss_increase() + */ +extern void test__f_type_array_statuss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_statuss_increase() + */ +extern void test__f_type_array_statuss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statuss_increase() + */ +extern void test__f_type_array_statuss_increase__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statuss_increase diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_increase_by.c b/level_0/f_type_array/tests/c/test-type_array-statuss_increase_by.c new file mode 100644 index 000000000..1ea2da2dc --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-type_array.h" +#include "test-type_array-statuss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statuss_increase_by__works(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_statuss_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_statuss_increase_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_increase_by.h b/level_0/f_type_array/tests/c/test-type_array-statuss_increase_by.h new file mode 100644 index 000000000..0f410bfd0 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statuss_increase_by +#define _TEST__F_type_array__statuss_increase_by + +/** + * Test that the function works. + * + * @see f_type_array_statuss_increase_by() + */ +extern void test__f_type_array_statuss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statuss_increase_by() + */ +extern void test__f_type_array_statuss_increase_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statuss_increase_by diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_resize.c b/level_0/f_type_array/tests/c/test-type_array-statuss_resize.c new file mode 100644 index 000000000..d29085958 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_resize.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-statuss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statuss_resize__works(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_statuss_resize__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statuss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statuss_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statuss_resize.h b/level_0/f_type_array/tests/c/test-type_array-statuss_resize.h new file mode 100644 index 000000000..e4e7ec105 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statuss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statuss_resize +#define _TEST__F_type_array__statuss_resize + +/** + * Test that the function works. + * + * @see f_type_array_statuss_resize() + */ +extern void test__f_type_array_statuss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statuss_resize() + */ +extern void test__f_type_array_statuss_resize__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statuss_resize diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_adjust.c b/level_0/f_type_array/tests/c/test-type_array-statusss_adjust.c new file mode 100644 index 000000000..e08608edf --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_adjust.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-statusss_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statusss_adjust__works(void **state) { + + const int length = 5; + f_statusss_t data = f_statusss_t_initialize; + + { + const f_status_t status = f_type_statusss_adjust(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_statusss_adjust__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statusss_t data = f_statusss_t_initialize; + + { + const f_status_t status = f_type_statusss_adjust(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_adjust.h b/level_0/f_type_array/tests/c/test-type_array-statusss_adjust.h new file mode 100644 index 000000000..9dfb7caaa --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statusss_adjust +#define _TEST__F_type_array__statusss_adjust + +/** + * Test that the function works. + * + * @see f_type_array_statusss_adjust() + */ +extern void test__f_type_array_statusss_adjust__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statusss_adjust() + */ +extern void test__f_type_array_statusss_adjust__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statusss_adjust diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_append.c b/level_0/f_type_array/tests/c/test-type_array-statusss_append.c new file mode 100644 index 000000000..5e0169063 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_append.c @@ -0,0 +1,110 @@ +#include "test-type_array.h" +#include "test-type_array-statusss_append.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statusss_append__works(void **state) { + + const int length = 5; + const int length_inner = 2; + f_statusss_t source = f_statuss_t_initialize; + f_statusss_t destination = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + for (; source.used < length; ++source.used) { + + const f_status_t status = f_type_statuss_resize(length_inner, &source.array[source.used]); + + assert_int_equal(status, F_none); + + for (f_array_length_t i = 0; i < length_inner; ++i) { + source.array[source.used].array[source.array[source.used].used++] = i + 1; + } // for + } // for + } + + { + const f_status_t status = f_type_statusss_append(source, &destination); + + assert_int_equal(status, F_none); + assert_int_equal(destination.used, source.used); + assert_int_equal(destination.size, source.used); + + for (f_array_length_t i = 0; i < destination.used; ++i) { + + assert_int_equal(destination.array[i].used, length_inner); + assert_int_equal(destination.array[i].size, length_inner); + + for (f_array_length_t j = 0; j < length_inner; ++j) { + assert_int_equal(destination.array[i].array[j], j + 1); + } // for + } // for + } + + for (f_array_length_t i = 0; i < source.used; ++i) { + free((void *) source.array[i].array); + } // for + + for (f_array_length_t i = 0; i < destination.used; ++i) { + free((void *) destination.array[i].array); + } // for + + free((void *) source.array); + free((void *) destination.array); +} + +void test__f_type_array_statusss_append__returns_data_not(void **state) { + + const int length = 5; + f_statusss_t source = f_statuss_t_initialize; + f_statusss_t destination = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_resize(length, &source); + + assert_int_equal(status, F_none); + assert_int_equal(source.used, 0); + assert_int_equal(source.size, length); + } + + { + const f_status_t status = f_type_statusss_append(source, &destination); + + assert_int_equal(status, F_data_not); + assert_int_equal(destination.used, 0); + assert_int_equal(destination.size, 0); + } + + free((void *) source.array); + assert_null(destination.array); +} + +void test__f_type_array_statusss_append__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statusss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_append(data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_append.h b/level_0/f_type_array/tests/c/test-type_array-statusss_append.h new file mode 100644 index 000000000..f67a8b5b8 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_append.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statusss_append +#define _TEST__F_type_array__statusss_append + +/** + * Test that the function works. + * + * @see f_type_array_statusss_append() + */ +extern void test__f_type_array_statusss_append__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_statusss_append() + */ +extern void test__f_type_array_statusss_append__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statusss_append() + */ +extern void test__f_type_array_statusss_append__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statusss_append diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_decimate_by.c b/level_0/f_type_array/tests/c/test-type_array-statusss_decimate_by.c new file mode 100644 index 000000000..9f97b4ee4 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_decimate_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-statusss_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statusss_decimate_by__works(void **state) { + + const int length = 5; + f_statusss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_statusss_decimate_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_statusss_decimate_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statusss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_decimate_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_decimate_by.h b/level_0/f_type_array/tests/c/test-type_array-statusss_decimate_by.h new file mode 100644 index 000000000..87d1f3ce0 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_decimate_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statusss_decimate_by +#define _TEST__F_type_array__statusss_decimate_by + +/** + * Test that the function works. + * + * @see f_type_array_statusss_decimate_by() + */ +extern void test__f_type_array_statusss_decimate_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statusss_decimate_by() + */ +extern void test__f_type_array_statusss_decimate_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statusss_decimate_by diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_decrease_by.c b/level_0/f_type_array/tests/c/test-type_array-statusss_decrease_by.c new file mode 100644 index 000000000..8e10ea4f8 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_decrease_by.c @@ -0,0 +1,50 @@ +#include "test-type_array.h" +#include "test-type_array-statusss_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statusss_decrease_by__works(void **state) { + + const int length = 5; + f_statusss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_statusss_decrease_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +void test__f_type_array_statusss_decrease_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statusss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_decrease_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_decrease_by.h b/level_0/f_type_array/tests/c/test-type_array-statusss_decrease_by.h new file mode 100644 index 000000000..deaa87a0c --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_decrease_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statusss_decrease_by +#define _TEST__F_type_array__statusss_decrease_by + +/** + * Test that the function works. + * + * @see f_type_array_statusss_decrease_by() + */ +extern void test__f_type_array_statusss_decrease_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statusss_decrease_by() + */ +extern void test__f_type_array_statusss_decrease_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statusss_decrease_by diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_increase.c b/level_0/f_type_array/tests/c/test-type_array-statusss_increase.c new file mode 100644 index 000000000..a90fde6b2 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_increase.c @@ -0,0 +1,76 @@ +#include "test-type_array.h" +#include "test-type_array-statusss_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statusss_increase__works(void **state) { + + const int length = 5; + f_statusss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_statusss_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_statusss_increase__returns_data_not(void **state) { + + const int length = 5; + f_statusss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + const f_status_t status = f_type_statusss_increase(length, &data); + + assert_int_equal(status, F_data_not); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_statusss_increase__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statusss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_increase(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_increase.h b/level_0/f_type_array/tests/c/test-type_array-statusss_increase.h new file mode 100644 index 000000000..faa511e49 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statusss_increase +#define _TEST__F_type_array__statusss_increase + +/** + * Test that the function works. + * + * @see f_type_array_statusss_increase() + */ +extern void test__f_type_array_statusss_increase__works(void **state); + +/** + * Test that the function returns F_data_not when asked to copy an empty structure. + * + * @see f_type_array_statusss_increase() + */ +extern void test__f_type_array_statusss_increase__returns_data_not(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statusss_increase() + */ +extern void test__f_type_array_statusss_increase__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statusss_increase diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_increase_by.c b/level_0/f_type_array/tests/c/test-type_array-statusss_increase_by.c new file mode 100644 index 000000000..83ef55d7f --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_increase_by.c @@ -0,0 +1,52 @@ +#include "test-type_array.h" +#include "test-type_array-statusss_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statusss_increase_by__works(void **state) { + + const int length = 5; + f_statusss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + data.used = length; + + const f_status_t status = f_type_statusss_increase_by(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_int_equal(data.size, length * 2); + } + + free((void *) data.array); +} + +void test__f_type_array_statusss_increase_by__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statusss_t data = f_statuss_t_initialize; + + { + const f_status_t status = f_type_statusss_increase_by(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_increase_by.h b/level_0/f_type_array/tests/c/test-type_array-statusss_increase_by.h new file mode 100644 index 000000000..934a1d315 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_increase_by.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statusss_increase_by +#define _TEST__F_type_array__statusss_increase_by + +/** + * Test that the function works. + * + * @see f_type_array_statusss_increase_by() + */ +extern void test__f_type_array_statusss_increase_by__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statusss_increase_by() + */ +extern void test__f_type_array_statusss_increase_by__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statusss_increase_by diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_resize.c b/level_0/f_type_array/tests/c/test-type_array-statusss_resize.c new file mode 100644 index 000000000..2e1d22aa0 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_resize.c @@ -0,0 +1,42 @@ +#include "test-type_array.h" +#include "test-type_array-statusss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_type_array_statusss_resize__works(void **state) { + + const int length = 5; + f_statusss_t data = f_statusss_t_initialize; + + { + const f_status_t status = f_type_statusss_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + free((void *) data.array); +} + +void test__f_type_array_statusss_resize__fails_on_invalid_parameter(void **state) { + + const int length = 5; + f_statusss_t data = f_statusss_t_initialize; + + { + const f_status_t status = f_type_statusss_resize(length, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, 0); + } + + assert_null(data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array-statusss_resize.h b/level_0/f_type_array/tests/c/test-type_array-statusss_resize.h new file mode 100644 index 000000000..e893fd2f1 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array-statusss_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_type_array__statusss_resize +#define _TEST__F_type_array__statusss_resize + +/** + * Test that the function works. + * + * @see f_type_array_statusss_resize() + */ +extern void test__f_type_array_statusss_resize__works(void **state); + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_type_array_statusss_resize() + */ +extern void test__f_type_array_statusss_resize__fails_on_invalid_parameter(void **state); + +#endif // _TEST__F_type_array__statusss_resize diff --git a/level_0/f_type_array/tests/c/test-type_array.c b/level_0/f_type_array/tests/c/test-type_array.c new file mode 100644 index 000000000..836026c25 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array.c @@ -0,0 +1,196 @@ +#include "test-type_array.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int setup(void **state) { + + return 0; +} + +int setdown(void **state) { + + return 0; +} + +int main(void) { + + const struct CMUnitTest tests[] = { + cmocka_unit_test(test__f_type_array_array_lengths_adjust__works), + cmocka_unit_test(test__f_type_array_array_lengths_adjust__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengths_append__works), + cmocka_unit_test(test__f_type_array_array_lengths_append__returns_data_not), + cmocka_unit_test(test__f_type_array_array_lengths_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengths_decimate_by__works), + cmocka_unit_test(test__f_type_array_array_lengths_decimate_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengths_decrease_by__works), + cmocka_unit_test(test__f_type_array_array_lengths_decrease_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengths_increase__works), + cmocka_unit_test(test__f_type_array_array_lengths_increase__returns_data_not), + cmocka_unit_test(test__f_type_array_array_lengths_increase__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengths_increase_by__works), + cmocka_unit_test(test__f_type_array_array_lengths_increase_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengths_resize__works), + cmocka_unit_test(test__f_type_array_array_lengths_resize__fails_on_invalid_parameter), + + cmocka_unit_test(test__f_type_array_array_lengthss_adjust__works), + cmocka_unit_test(test__f_type_array_array_lengthss_adjust__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengthss_append__works), + cmocka_unit_test(test__f_type_array_array_lengthss_append__returns_data_not), + cmocka_unit_test(test__f_type_array_array_lengthss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengthss_decimate_by__works), + cmocka_unit_test(test__f_type_array_array_lengthss_decimate_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengthss_decrease_by__works), + cmocka_unit_test(test__f_type_array_array_lengthss_decrease_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengthss_increase__works), + cmocka_unit_test(test__f_type_array_array_lengthss_increase__returns_data_not), + cmocka_unit_test(test__f_type_array_array_lengthss_increase__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengthss_increase_by__works), + cmocka_unit_test(test__f_type_array_array_lengthss_increase_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_array_lengthss_resize__works), + cmocka_unit_test(test__f_type_array_array_lengthss_resize__fails_on_invalid_parameter), + + cmocka_unit_test(test__f_type_array_cells_adjust__works), + cmocka_unit_test(test__f_type_array_cells_adjust__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cells_append__works), + cmocka_unit_test(test__f_type_array_cells_append__returns_data_not), + cmocka_unit_test(test__f_type_array_cells_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cells_decimate_by__works), + cmocka_unit_test(test__f_type_array_cells_decimate_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cells_decrease_by__works), + cmocka_unit_test(test__f_type_array_cells_decrease_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cells_increase__works), + cmocka_unit_test(test__f_type_array_cells_increase__returns_data_not), + cmocka_unit_test(test__f_type_array_cells_increase__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cells_increase_by__works), + cmocka_unit_test(test__f_type_array_cells_increase_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cells_resize__works), + cmocka_unit_test(test__f_type_array_cells_resize__fails_on_invalid_parameter), + + cmocka_unit_test(test__f_type_array_cellss_adjust__works), + cmocka_unit_test(test__f_type_array_cellss_adjust__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cellss_append__works), + cmocka_unit_test(test__f_type_array_cellss_append__returns_data_not), + cmocka_unit_test(test__f_type_array_cellss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cellss_decimate_by__works), + cmocka_unit_test(test__f_type_array_cellss_decimate_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cellss_decrease_by__works), + cmocka_unit_test(test__f_type_array_cellss_decrease_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cellss_increase__works), + cmocka_unit_test(test__f_type_array_cellss_increase__returns_data_not), + cmocka_unit_test(test__f_type_array_cellss_increase__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cellss_increase_by__works), + cmocka_unit_test(test__f_type_array_cellss_increase_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_cellss_resize__works), + cmocka_unit_test(test__f_type_array_cellss_resize__fails_on_invalid_parameter), + + cmocka_unit_test(test__f_type_array_fll_ids_adjust__works), + cmocka_unit_test(test__f_type_array_fll_ids_adjust__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_ids_append__works), + cmocka_unit_test(test__f_type_array_fll_ids_append__returns_data_not), + cmocka_unit_test(test__f_type_array_fll_ids_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_ids_decimate_by__works), + cmocka_unit_test(test__f_type_array_fll_ids_decimate_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_ids_decrease_by__works), + cmocka_unit_test(test__f_type_array_fll_ids_decrease_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_ids_increase__works), + cmocka_unit_test(test__f_type_array_fll_ids_increase__returns_data_not), + cmocka_unit_test(test__f_type_array_fll_ids_increase__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_ids_increase_by__works), + cmocka_unit_test(test__f_type_array_fll_ids_increase_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_ids_resize__works), + cmocka_unit_test(test__f_type_array_fll_ids_resize__fails_on_invalid_parameter), + + cmocka_unit_test(test__f_type_array_fll_idss_adjust__works), + cmocka_unit_test(test__f_type_array_fll_idss_adjust__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_idss_append__works), + cmocka_unit_test(test__f_type_array_fll_idss_append__returns_data_not), + cmocka_unit_test(test__f_type_array_fll_idss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_idss_decimate_by__works), + cmocka_unit_test(test__f_type_array_fll_idss_decimate_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_idss_decrease_by__works), + cmocka_unit_test(test__f_type_array_fll_idss_decrease_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_idss_increase__works), + cmocka_unit_test(test__f_type_array_fll_idss_increase__returns_data_not), + cmocka_unit_test(test__f_type_array_fll_idss_increase__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_idss_increase_by__works), + cmocka_unit_test(test__f_type_array_fll_idss_increase_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_fll_idss_resize__works), + cmocka_unit_test(test__f_type_array_fll_idss_resize__fails_on_invalid_parameter), + + cmocka_unit_test(test__f_type_array_states_adjust__works), + cmocka_unit_test(test__f_type_array_states_adjust__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_states_append__works), + cmocka_unit_test(test__f_type_array_states_append__returns_data_not), + cmocka_unit_test(test__f_type_array_states_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_states_decimate_by__works), + cmocka_unit_test(test__f_type_array_states_decimate_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_states_decrease_by__works), + cmocka_unit_test(test__f_type_array_states_decrease_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_states_increase__works), + cmocka_unit_test(test__f_type_array_states_increase__returns_data_not), + cmocka_unit_test(test__f_type_array_states_increase__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_states_increase_by__works), + cmocka_unit_test(test__f_type_array_states_increase_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_states_resize__works), + cmocka_unit_test(test__f_type_array_states_resize__fails_on_invalid_parameter), + + cmocka_unit_test(test__f_type_array_statess_adjust__works), + cmocka_unit_test(test__f_type_array_statess_adjust__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statess_append__works), + cmocka_unit_test(test__f_type_array_statess_append__returns_data_not), + cmocka_unit_test(test__f_type_array_statess_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statess_decimate_by__works), + cmocka_unit_test(test__f_type_array_statess_decimate_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statess_decrease_by__works), + cmocka_unit_test(test__f_type_array_statess_decrease_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statess_increase__works), + cmocka_unit_test(test__f_type_array_statess_increase__returns_data_not), + cmocka_unit_test(test__f_type_array_statess_increase__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statess_increase_by__works), + cmocka_unit_test(test__f_type_array_statess_increase_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statess_resize__works), + cmocka_unit_test(test__f_type_array_statess_resize__fails_on_invalid_parameter), + + cmocka_unit_test(test__f_type_array_statuss_adjust__works), + cmocka_unit_test(test__f_type_array_statuss_adjust__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statuss_append__works), + cmocka_unit_test(test__f_type_array_statuss_append__returns_data_not), + cmocka_unit_test(test__f_type_array_statuss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statuss_decimate_by__works), + cmocka_unit_test(test__f_type_array_statuss_decimate_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statuss_decrease_by__works), + cmocka_unit_test(test__f_type_array_statuss_decrease_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statuss_increase__works), + cmocka_unit_test(test__f_type_array_statuss_increase__returns_data_not), + cmocka_unit_test(test__f_type_array_statuss_increase__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statuss_increase_by__works), + cmocka_unit_test(test__f_type_array_statuss_increase_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statuss_resize__works), + cmocka_unit_test(test__f_type_array_statuss_resize__fails_on_invalid_parameter), + + cmocka_unit_test(test__f_type_array_statusss_adjust__works), + cmocka_unit_test(test__f_type_array_statusss_adjust__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statusss_append__works), + cmocka_unit_test(test__f_type_array_statusss_append__returns_data_not), + cmocka_unit_test(test__f_type_array_statusss_append__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statusss_decimate_by__works), + cmocka_unit_test(test__f_type_array_statusss_decimate_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statusss_decrease_by__works), + cmocka_unit_test(test__f_type_array_statusss_decrease_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statusss_increase__works), + cmocka_unit_test(test__f_type_array_statusss_increase__returns_data_not), + cmocka_unit_test(test__f_type_array_statusss_increase__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statusss_increase_by__works), + cmocka_unit_test(test__f_type_array_statusss_increase_by__fails_on_invalid_parameter), + cmocka_unit_test(test__f_type_array_statusss_resize__works), + cmocka_unit_test(test__f_type_array_statusss_resize__fails_on_invalid_parameter), + }; + + return cmocka_run_group_tests(tests, setup, setdown); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_type_array/tests/c/test-type_array.h b/level_0/f_type_array/tests/c/test-type_array.h new file mode 100644 index 000000000..21eb60b54 --- /dev/null +++ b/level_0/f_type_array/tests/c/test-type_array.h @@ -0,0 +1,140 @@ +/** + * FLL - Level 0 + * + * Project: Type + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the type arrays in the project. + */ +#ifndef _TEST__F_type_array_h +#define _TEST__F_type_array_h + +// libc includes. +#include +#include +#include +#include + +// cmocka includes. +#include + +// fll-0 includes. +#include +#include +#include + +// test includes. +#include "test-type_array-array_lengths_adjust.h" +#include "test-type_array-array_lengths_append.h" +#include "test-type_array-array_lengths_decimate_by.h" +#include "test-type_array-array_lengths_decrease_by.h" +#include "test-type_array-array_lengths_increase.h" +#include "test-type_array-array_lengths_increase_by.h" +#include "test-type_array-array_lengths_resize.h" +#include "test-type_array-array_lengthss_adjust.h" +#include "test-type_array-array_lengthss_append.h" +#include "test-type_array-array_lengthss_decimate_by.h" +#include "test-type_array-array_lengthss_decrease_by.h" +#include "test-type_array-array_lengthss_increase.h" +#include "test-type_array-array_lengthss_increase_by.h" +#include "test-type_array-array_lengthss_resize.h" +#include "test-type_array-cells_adjust.h" +#include "test-type_array-cells_append.h" +#include "test-type_array-cells_decimate_by.h" +#include "test-type_array-cells_decrease_by.h" +#include "test-type_array-cells_increase.h" +#include "test-type_array-cells_increase_by.h" +#include "test-type_array-cells_resize.h" +#include "test-type_array-cellss_adjust.h" +#include "test-type_array-cellss_append.h" +#include "test-type_array-cellss_decimate_by.h" +#include "test-type_array-cellss_decrease_by.h" +#include "test-type_array-cellss_increase.h" +#include "test-type_array-cellss_increase_by.h" +#include "test-type_array-cellss_resize.h" +#include "test-type_array-fll_ids_adjust.h" +#include "test-type_array-fll_ids_append.h" +#include "test-type_array-fll_ids_decimate_by.h" +#include "test-type_array-fll_ids_decrease_by.h" +#include "test-type_array-fll_ids_increase.h" +#include "test-type_array-fll_ids_increase_by.h" +#include "test-type_array-fll_ids_resize.h" +#include "test-type_array-fll_idss_adjust.h" +#include "test-type_array-fll_idss_append.h" +#include "test-type_array-fll_idss_decimate_by.h" +#include "test-type_array-fll_idss_decrease_by.h" +#include "test-type_array-fll_idss_increase.h" +#include "test-type_array-fll_idss_increase_by.h" +#include "test-type_array-fll_idss_resize.h" +#include "test-type_array-states_adjust.h" +#include "test-type_array-states_append.h" +#include "test-type_array-states_decimate_by.h" +#include "test-type_array-states_decrease_by.h" +#include "test-type_array-states_increase.h" +#include "test-type_array-states_increase_by.h" +#include "test-type_array-states_resize.h" +#include "test-type_array-statess_adjust.h" +#include "test-type_array-statess_append.h" +#include "test-type_array-statess_decimate_by.h" +#include "test-type_array-statess_decrease_by.h" +#include "test-type_array-statess_increase.h" +#include "test-type_array-statess_increase_by.h" +#include "test-type_array-statess_resize.h" +#include "test-type_array-statuss_adjust.h" +#include "test-type_array-statuss_append.h" +#include "test-type_array-statuss_decimate_by.h" +#include "test-type_array-statuss_decrease_by.h" +#include "test-type_array-statuss_increase.h" +#include "test-type_array-statuss_increase_by.h" +#include "test-type_array-statuss_resize.h" +#include "test-type_array-statusss_adjust.h" +#include "test-type_array-statusss_append.h" +#include "test-type_array-statusss_decimate_by.h" +#include "test-type_array-statusss_decrease_by.h" +#include "test-type_array-statusss_increase.h" +#include "test-type_array-statusss_increase_by.h" +#include "test-type_array-statusss_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Perform any setup operations. + * + * @param state + * The test state. + * + * @return + * The status of this function, where 0 means success. + */ +extern int setup(void **state); + +/** + * Peform any setdown operations. + * + * @param state + * The test state. + * + * @return + * The status of this function, where 0 means success. + */ +extern int setdown(void **state); + +/** + * Run all tests. + * + * @return + * The final result of the tests. + * + * @see cmocka_run_group_tests() + * @see cmocka_unit_test() + */ +extern int main(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _TEST__F_type_array_h