From 43aedc8aa104aea73e43747495ee00fa3d690abc Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 26 Jun 2022 20:54:20 -0500 Subject: [PATCH] Progress: Add unit tests for f_thread. There is still a long way to go but this is a good start. Ideally, the f_thread will be the last project I write unit tests before the stable release is made. --- level_0/f_thread/data/build/dependencies-tests | 3 + level_0/f_thread/data/build/settings-mocks | 84 +++++ level_0/f_thread/data/build/settings-tests | 82 +++++ level_0/f_thread/data/build/testfile | 55 +++ level_0/f_thread/tests/unit/c/mock-thread.c | 237 ++++++++++++ level_0/f_thread/tests/unit/c/mock-thread.h | 146 ++++++++ .../f_thread/tests/unit/c/test-thread-at_fork.c | 89 +++++ .../f_thread/tests/unit/c/test-thread-at_fork.h | 34 ++ .../unit/c/test-thread-attribute_affinity_get.c | 79 ++++ .../unit/c/test-thread-attribute_affinity_get.h | 34 ++ .../unit/c/test-thread-attribute_affinity_set.c | 83 +++++ .../unit/c/test-thread-attribute_affinity_set.h | 34 ++ .../c/test-thread-attribute_condition_clock_get.c | 65 ++++ .../c/test-thread-attribute_condition_clock_get.h | 34 ++ .../c/test-thread-attribute_condition_clock_set.c | 57 +++ .../c/test-thread-attribute_condition_clock_set.h | 34 ++ .../c/test-thread-attribute_condition_shared_get.c | 74 ++++ .../c/test-thread-attribute_condition_shared_get.h | 34 ++ .../c/test-thread-attribute_condition_shared_set.c | 57 +++ .../c/test-thread-attribute_condition_shared_set.h | 34 ++ .../tests/unit/c/test-thread-attribute_create.c | 57 +++ .../tests/unit/c/test-thread-attribute_create.h | 34 ++ .../unit/c/test-thread-attribute_default_get.c | 57 +++ .../unit/c/test-thread-attribute_default_get.h | 34 ++ .../unit/c/test-thread-attribute_default_set.c | 59 +++ .../unit/c/test-thread-attribute_default_set.h | 34 ++ .../tests/unit/c/test-thread-attribute_delete.c | 55 +++ .../tests/unit/c/test-thread-attribute_delete.h | 34 ++ .../unit/c/test-thread-attribute_detach_get.c | 61 ++++ .../unit/c/test-thread-attribute_detach_get.h | 34 ++ .../unit/c/test-thread-attribute_detach_set.c | 61 ++++ .../unit/c/test-thread-attribute_detach_set.h | 34 ++ .../tests/unit/c/test-thread-attribute_guard_get.c | 61 ++++ .../tests/unit/c/test-thread-attribute_guard_get.h | 34 ++ .../tests/unit/c/test-thread-attribute_guard_set.c | 61 ++++ .../tests/unit/c/test-thread-attribute_guard_set.h | 34 ++ .../test-thread-attribute_scheduler_inherit_get.c | 61 ++++ .../test-thread-attribute_scheduler_inherit_get.h | 34 ++ .../test-thread-attribute_scheduler_inherit_set.c | 61 ++++ .../test-thread-attribute_scheduler_inherit_set.h | 34 ++ ...test-thread-attribute_scheduler_parameter_get.c | 65 ++++ ...test-thread-attribute_scheduler_parameter_get.h | 34 ++ ...test-thread-attribute_scheduler_parameter_set.c | 67 ++++ ...test-thread-attribute_scheduler_parameter_set.h | 34 ++ .../tests/unit/c/test-thread-attributes_adjust.c | 42 +++ .../tests/unit/c/test-thread-attributes_adjust.h | 27 ++ .../unit/c/test-thread-attributes_decimate_by.c | 78 ++++ .../unit/c/test-thread-attributes_decimate_by.h | 34 ++ .../unit/c/test-thread-attributes_decrease_by.c | 78 ++++ .../unit/c/test-thread-attributes_decrease_by.h | 34 ++ .../tests/unit/c/test-thread-attributes_increase.c | 76 ++++ .../tests/unit/c/test-thread-attributes_increase.h | 34 ++ .../unit/c/test-thread-attributes_increase_by.c | 76 ++++ .../unit/c/test-thread-attributes_increase_by.h | 34 ++ .../tests/unit/c/test-thread-attributes_resize.c | 42 +++ .../tests/unit/c/test-thread-attributes_resize.h | 27 ++ .../unit/c/test-thread-barrier_attributes_adjust.c | 42 +++ .../unit/c/test-thread-barrier_attributes_adjust.h | 27 ++ .../c/test-thread-barrier_attributes_decimate_by.c | 74 ++++ .../c/test-thread-barrier_attributes_decimate_by.h | 34 ++ .../c/test-thread-barrier_attributes_decrease_by.c | 74 ++++ .../c/test-thread-barrier_attributes_decrease_by.h | 34 ++ .../c/test-thread-barrier_attributes_increase.c | 76 ++++ .../c/test-thread-barrier_attributes_increase.h | 34 ++ .../c/test-thread-barrier_attributes_increase_by.c | 76 ++++ .../c/test-thread-barrier_attributes_increase_by.h | 34 ++ .../unit/c/test-thread-barrier_attributes_resize.c | 42 +++ .../unit/c/test-thread-barrier_attributes_resize.h | 27 ++ .../tests/unit/c/test-thread-barriers_adjust.c | 42 +++ .../tests/unit/c/test-thread-barriers_adjust.h | 27 ++ .../unit/c/test-thread-barriers_decimate_by.c | 78 ++++ .../unit/c/test-thread-barriers_decimate_by.h | 34 ++ .../unit/c/test-thread-barriers_decrease_by.c | 78 ++++ .../unit/c/test-thread-barriers_decrease_by.h | 34 ++ .../tests/unit/c/test-thread-barriers_increase.c | 76 ++++ .../tests/unit/c/test-thread-barriers_increase.h | 34 ++ .../unit/c/test-thread-barriers_increase_by.c | 76 ++++ .../unit/c/test-thread-barriers_increase_by.h | 34 ++ .../tests/unit/c/test-thread-barriers_resize.c | 42 +++ .../tests/unit/c/test-thread-barriers_resize.h | 27 ++ .../c/test-thread-condition_attributes_adjust.c | 42 +++ .../c/test-thread-condition_attributes_adjust.h | 27 ++ .../test-thread-condition_attributes_decimate_by.c | 74 ++++ .../test-thread-condition_attributes_decimate_by.h | 34 ++ .../test-thread-condition_attributes_decrease_by.c | 74 ++++ .../test-thread-condition_attributes_decrease_by.h | 34 ++ .../c/test-thread-condition_attributes_increase.c | 76 ++++ .../c/test-thread-condition_attributes_increase.h | 34 ++ .../test-thread-condition_attributes_increase_by.c | 76 ++++ .../test-thread-condition_attributes_increase_by.h | 34 ++ .../c/test-thread-condition_attributes_resize.c | 42 +++ .../c/test-thread-condition_attributes_resize.h | 27 ++ .../tests/unit/c/test-thread-conditions_adjust.c | 42 +++ .../tests/unit/c/test-thread-conditions_adjust.h | 27 ++ .../unit/c/test-thread-conditions_decimate_by.c | 74 ++++ .../unit/c/test-thread-conditions_decimate_by.h | 34 ++ .../unit/c/test-thread-conditions_decrease_by.c | 74 ++++ .../unit/c/test-thread-conditions_decrease_by.h | 34 ++ .../tests/unit/c/test-thread-conditions_increase.c | 76 ++++ .../tests/unit/c/test-thread-conditions_increase.h | 34 ++ .../unit/c/test-thread-conditions_increase_by.c | 76 ++++ .../unit/c/test-thread-conditions_increase_by.h | 34 ++ .../tests/unit/c/test-thread-conditions_resize.c | 42 +++ .../tests/unit/c/test-thread-conditions_resize.h | 27 ++ .../f_thread/tests/unit/c/test-thread-ids_adjust.c | 42 +++ .../f_thread/tests/unit/c/test-thread-ids_adjust.h | 27 ++ .../tests/unit/c/test-thread-ids_decimate_by.c | 74 ++++ .../tests/unit/c/test-thread-ids_decimate_by.h | 34 ++ .../tests/unit/c/test-thread-ids_decrease_by.c | 74 ++++ .../tests/unit/c/test-thread-ids_decrease_by.h | 34 ++ .../tests/unit/c/test-thread-ids_increase.c | 76 ++++ .../tests/unit/c/test-thread-ids_increase.h | 34 ++ .../tests/unit/c/test-thread-ids_increase_by.c | 76 ++++ .../tests/unit/c/test-thread-ids_increase_by.h | 34 ++ .../f_thread/tests/unit/c/test-thread-ids_resize.c | 42 +++ .../f_thread/tests/unit/c/test-thread-ids_resize.h | 27 ++ .../tests/unit/c/test-thread-keys_adjust.c | 42 +++ .../tests/unit/c/test-thread-keys_adjust.h | 27 ++ .../tests/unit/c/test-thread-keys_decimate_by.c | 78 ++++ .../tests/unit/c/test-thread-keys_decimate_by.h | 34 ++ .../tests/unit/c/test-thread-keys_decrease_by.c | 78 ++++ .../tests/unit/c/test-thread-keys_decrease_by.h | 34 ++ .../tests/unit/c/test-thread-keys_increase.c | 76 ++++ .../tests/unit/c/test-thread-keys_increase.h | 34 ++ .../tests/unit/c/test-thread-keys_increase_by.c | 76 ++++ .../tests/unit/c/test-thread-keys_increase_by.h | 34 ++ .../tests/unit/c/test-thread-keys_resize.c | 42 +++ .../tests/unit/c/test-thread-keys_resize.h | 27 ++ .../unit/c/test-thread-lock_attributes_adjust.c | 42 +++ .../unit/c/test-thread-lock_attributes_adjust.h | 27 ++ .../c/test-thread-lock_attributes_decimate_by.c | 74 ++++ .../c/test-thread-lock_attributes_decimate_by.h | 34 ++ .../c/test-thread-lock_attributes_decrease_by.c | 74 ++++ .../c/test-thread-lock_attributes_decrease_by.h | 34 ++ .../unit/c/test-thread-lock_attributes_increase.c | 76 ++++ .../unit/c/test-thread-lock_attributes_increase.h | 34 ++ .../c/test-thread-lock_attributes_increase_by.c | 76 ++++ .../c/test-thread-lock_attributes_increase_by.h | 34 ++ .../unit/c/test-thread-lock_attributes_resize.c | 42 +++ .../unit/c/test-thread-lock_attributes_resize.h | 27 ++ .../tests/unit/c/test-thread-locks_adjust.c | 42 +++ .../tests/unit/c/test-thread-locks_adjust.h | 27 ++ .../tests/unit/c/test-thread-locks_decimate_by.c | 74 ++++ .../tests/unit/c/test-thread-locks_decimate_by.h | 34 ++ .../tests/unit/c/test-thread-locks_decrease_by.c | 74 ++++ .../tests/unit/c/test-thread-locks_decrease_by.h | 34 ++ .../tests/unit/c/test-thread-locks_increase.c | 76 ++++ .../tests/unit/c/test-thread-locks_increase.h | 34 ++ .../tests/unit/c/test-thread-locks_increase_by.c | 76 ++++ .../tests/unit/c/test-thread-locks_increase_by.h | 34 ++ .../tests/unit/c/test-thread-locks_resize.c | 42 +++ .../tests/unit/c/test-thread-locks_resize.h | 27 ++ .../unit/c/test-thread-mutex_attributes_adjust.c | 42 +++ .../unit/c/test-thread-mutex_attributes_adjust.h | 27 ++ .../c/test-thread-mutex_attributes_decimate_by.c | 74 ++++ .../c/test-thread-mutex_attributes_decimate_by.h | 34 ++ .../c/test-thread-mutex_attributes_decrease_by.c | 74 ++++ .../c/test-thread-mutex_attributes_decrease_by.h | 34 ++ .../unit/c/test-thread-mutex_attributes_increase.c | 76 ++++ .../unit/c/test-thread-mutex_attributes_increase.h | 34 ++ .../c/test-thread-mutex_attributes_increase_by.c | 76 ++++ .../c/test-thread-mutex_attributes_increase_by.h | 34 ++ .../unit/c/test-thread-mutex_attributes_resize.c | 42 +++ .../unit/c/test-thread-mutex_attributes_resize.h | 27 ++ .../tests/unit/c/test-thread-mutexs_adjust.c | 42 +++ .../tests/unit/c/test-thread-mutexs_adjust.h | 27 ++ .../tests/unit/c/test-thread-mutexs_decimate_by.c | 74 ++++ .../tests/unit/c/test-thread-mutexs_decimate_by.h | 34 ++ .../tests/unit/c/test-thread-mutexs_decrease_by.c | 74 ++++ .../tests/unit/c/test-thread-mutexs_decrease_by.h | 34 ++ .../tests/unit/c/test-thread-mutexs_increase.c | 76 ++++ .../tests/unit/c/test-thread-mutexs_increase.h | 34 ++ .../tests/unit/c/test-thread-mutexs_increase_by.c | 76 ++++ .../tests/unit/c/test-thread-mutexs_increase_by.h | 34 ++ .../tests/unit/c/test-thread-mutexs_resize.c | 42 +++ .../tests/unit/c/test-thread-mutexs_resize.h | 27 ++ .../tests/unit/c/test-thread-onces_adjust.c | 42 +++ .../tests/unit/c/test-thread-onces_adjust.h | 27 ++ .../tests/unit/c/test-thread-onces_decimate_by.c | 74 ++++ .../tests/unit/c/test-thread-onces_decimate_by.h | 34 ++ .../tests/unit/c/test-thread-onces_decrease_by.c | 74 ++++ .../tests/unit/c/test-thread-onces_decrease_by.h | 34 ++ .../tests/unit/c/test-thread-onces_increase.c | 76 ++++ .../tests/unit/c/test-thread-onces_increase.h | 34 ++ .../tests/unit/c/test-thread-onces_increase_by.c | 76 ++++ .../tests/unit/c/test-thread-onces_increase_by.h | 34 ++ .../tests/unit/c/test-thread-onces_resize.c | 42 +++ .../tests/unit/c/test-thread-onces_resize.h | 27 ++ .../tests/unit/c/test-thread-semaphores_adjust.c | 42 +++ .../tests/unit/c/test-thread-semaphores_adjust.h | 27 ++ .../unit/c/test-thread-semaphores_decimate_by.c | 74 ++++ .../unit/c/test-thread-semaphores_decimate_by.h | 34 ++ .../unit/c/test-thread-semaphores_decrease_by.c | 74 ++++ .../unit/c/test-thread-semaphores_decrease_by.h | 34 ++ .../tests/unit/c/test-thread-semaphores_increase.c | 76 ++++ .../tests/unit/c/test-thread-semaphores_increase.h | 34 ++ .../unit/c/test-thread-semaphores_increase_by.c | 76 ++++ .../unit/c/test-thread-semaphores_increase_by.h | 34 ++ .../tests/unit/c/test-thread-semaphores_resize.c | 42 +++ .../tests/unit/c/test-thread-semaphores_resize.h | 27 ++ .../tests/unit/c/test-thread-sets_adjust.c | 42 +++ .../tests/unit/c/test-thread-sets_adjust.h | 27 ++ .../tests/unit/c/test-thread-sets_decimate_by.c | 78 ++++ .../tests/unit/c/test-thread-sets_decimate_by.h | 34 ++ .../tests/unit/c/test-thread-sets_decrease_by.c | 78 ++++ .../tests/unit/c/test-thread-sets_decrease_by.h | 34 ++ .../tests/unit/c/test-thread-sets_increase.c | 76 ++++ .../tests/unit/c/test-thread-sets_increase.h | 34 ++ .../tests/unit/c/test-thread-sets_increase_by.c | 76 ++++ .../tests/unit/c/test-thread-sets_increase_by.h | 34 ++ .../tests/unit/c/test-thread-sets_resize.c | 42 +++ .../tests/unit/c/test-thread-sets_resize.h | 27 ++ .../tests/unit/c/test-thread-spins_adjust.c | 42 +++ .../tests/unit/c/test-thread-spins_adjust.h | 27 ++ .../tests/unit/c/test-thread-spins_decimate_by.c | 74 ++++ .../tests/unit/c/test-thread-spins_decimate_by.h | 34 ++ .../tests/unit/c/test-thread-spins_decrease_by.c | 74 ++++ .../tests/unit/c/test-thread-spins_decrease_by.h | 34 ++ .../tests/unit/c/test-thread-spins_increase.c | 76 ++++ .../tests/unit/c/test-thread-spins_increase.h | 34 ++ .../tests/unit/c/test-thread-spins_increase_by.c | 76 ++++ .../tests/unit/c/test-thread-spins_increase_by.h | 34 ++ .../tests/unit/c/test-thread-spins_resize.c | 42 +++ .../tests/unit/c/test-thread-spins_resize.h | 27 ++ level_0/f_thread/tests/unit/c/test-thread.c | 405 +++++++++++++++++++++ level_0/f_thread/tests/unit/c/test-thread.h | 182 +++++++++ 226 files changed, 11712 insertions(+) create mode 100644 level_0/f_thread/data/build/dependencies-tests create mode 100644 level_0/f_thread/data/build/settings-mocks create mode 100644 level_0/f_thread/data/build/settings-tests create mode 100644 level_0/f_thread/data/build/testfile create mode 100644 level_0/f_thread/tests/unit/c/mock-thread.c create mode 100644 level_0/f_thread/tests/unit/c/mock-thread.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-at_fork.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-at_fork.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_get.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_get.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_set.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_set.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_get.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_get.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_set.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_set.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_get.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_get.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_set.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_set.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_create.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_create.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_default_get.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_default_get.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_default_set.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_default_set.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_delete.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_delete.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_detach_get.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_detach_get.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_detach_set.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_detach_set.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_guard_get.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_guard_get.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_guard_set.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_guard_set.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_get.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_get.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_set.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_set.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_get.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_get.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_set.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_set.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_adjust.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_increase.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_increase.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_resize.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread.h diff --git a/level_0/f_thread/data/build/dependencies-tests b/level_0/f_thread/data/build/dependencies-tests new file mode 100644 index 0000000..dea3179 --- /dev/null +++ b/level_0/f_thread/data/build/dependencies-tests @@ -0,0 +1,3 @@ +# fss-0001 + +cmocka 1.* diff --git a/level_0/f_thread/data/build/settings-mocks b/level_0/f_thread/data/build/settings-mocks new file mode 100644 index 0000000..41b0ec7 --- /dev/null +++ b/level_0/f_thread/data/build/settings-mocks @@ -0,0 +1,84 @@ +# fss-0001 +# +# Build the project with appropriate mocks linked in via the dynamic linker's "--wrap" functionality. +# +# The -Wl,--wrap does not work across shared files. +# Therefore, this file is a work-around to inject the mocks into the library for testing purposes. +# This should exactly match the "settings" file, except for the additional "-Wl,--wrap" parts and the additional mock source file. +# +# The flags -o0 must be passed to prevent the compiler from optimizing away any functions being mocked (which results in the mock not happening and a real function being called). +# Alternatively, figure out which optimization that is disabled by -o0 and have that specific optimization disabled. +# + +build_name f_thread + +version_major 0 +version_minor 5 +version_micro 10 +version_file micro +version_target minor + +modes individual clang test coverage +modes_default individual test + +build_compiler gcc +build_compiler-clang clang +build_indexer ar +build_indexer_arguments rcs +build_language c + +build_libraries -pthread -lc +build_libraries-individual -lf_memory -lf_string + +build_sources_library thread.c private-thread.c thread/attribute.c thread/barrier.c thread/barrier_attribute.c thread/condition.c thread/condition_attribute.c thread/id.c thread/key.c thread/lock.c thread/lock_attribute.c thread/mutex.c thread/mutex_attribute.c thread/once.c thread/semaphore.c thread/set.c thread/spin.c ../../tests/unit/c/mock-thread.c + +build_sources_headers thread.h thread/attribute.h thread/barrier.h thread/barrier_attribute.h thread/condition.h thread/condition_attribute.h thread/id.h thread/key.h thread/lock.h thread/lock_attribute.h thread/mutex.h thread/mutex_attribute.h thread/once.h thread/semaphore.h thread/set.h thread/spin.h + +build_script yes +build_shared yes +build_static no + +path_headers fll/level_0 +path_library_script script +path_library_shared shared +path_library_static static + +has_path_standard yes +preserve_path_headers yes + +search_exclusive yes +search_shared yes +search_static yes + +#defines -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines -D_pthread_sigqueue_unsupported_ + +flags -O0 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses +flags-clang -Wno-logical-op-parentheses +flags-test -fstack-protector -Wall +flags-coverage --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ + +flags_library -fPIC + +# Inject mocks. +flags -Wl,--wrap=pthread_atfork +flags -Wl,--wrap=pthread_attr_destroy +flags -Wl,--wrap=pthread_attr_getaffinity_np +flags -Wl,--wrap=pthread_attr_getdetachstate +flags -Wl,--wrap=pthread_attr_getguardsize +flags -Wl,--wrap=pthread_attr_getinheritsched +flags -Wl,--wrap=pthread_attr_getschedparam +flags -Wl,--wrap=pthread_attr_init +flags -Wl,--wrap=pthread_attr_setaffinity_np +flags -Wl,--wrap=pthread_attr_setdetachstate +flags -Wl,--wrap=pthread_attr_setguardsize +flags -Wl,--wrap=pthread_attr_setinheritsched +flags -Wl,--wrap=pthread_attr_setschedparam +flags -Wl,--wrap=pthread_barrier_destroy +flags -Wl,--wrap=pthread_condattr_getclock +flags -Wl,--wrap=pthread_condattr_getpshared +flags -Wl,--wrap=pthread_condattr_setclock +flags -Wl,--wrap=pthread_condattr_setpshared +flags -Wl,--wrap=pthread_getattr_default_np +flags -Wl,--wrap=pthread_key_delete +flags -Wl,--wrap=pthread_setattr_default_np diff --git a/level_0/f_thread/data/build/settings-tests b/level_0/f_thread/data/build/settings-tests new file mode 100644 index 0000000..af89c6a --- /dev/null +++ b/level_0/f_thread/data/build/settings-tests @@ -0,0 +1,82 @@ +# fss-0001 +# +# Builds a program that is links to the generated library and is executed to perform tests. +# +# Memory leaks in the test program can be checked for by running valgrind with this executable. +# + +build_name test-f_thread + +version_major 0 +version_minor 5 +version_micro 10 +version_file major +version_target major + +modes individual clang test coverage +modes_default individual test + +build_compiler gcc +build_compiler-clang clang +build_indexer ar +build_indexer_arguments rcs +build_language c + +build_libraries -lc -lcmocka +build_libraries-individual -lf_memory -lf_string -lf_thread + +build_sources_program test-thread-attributes_adjust.c test-thread-attributes_decimate_by.c test-thread-attributes_decrease_by.c test-thread-attributes_increase.c test-thread-attributes_increase_by.c test-thread-attributes_resize.c +build_sources_program test-thread-barrier_attributes_adjust.c test-thread-barrier_attributes_decimate_by.c test-thread-barrier_attributes_decrease_by.c test-thread-barrier_attributes_increase.c test-thread-barrier_attributes_increase_by.c test-thread-barrier_attributes_resize.c +build_sources_program test-thread-barriers_adjust.c test-thread-barriers_decimate_by.c test-thread-barriers_decrease_by.c test-thread-barriers_increase.c test-thread-barriers_increase_by.c test-thread-barriers_resize.c +build_sources_program test-thread-condition_attributes_adjust.c test-thread-condition_attributes_decimate_by.c test-thread-condition_attributes_decrease_by.c test-thread-condition_attributes_increase.c test-thread-condition_attributes_increase_by.c test-thread-condition_attributes_resize.c +build_sources_program test-thread-conditions_adjust.c test-thread-conditions_decimate_by.c test-thread-conditions_decrease_by.c test-thread-conditions_increase.c test-thread-conditions_increase_by.c test-thread-conditions_resize.c +build_sources_program test-thread-ids_adjust.c test-thread-ids_decimate_by.c test-thread-ids_decrease_by.c test-thread-ids_increase.c test-thread-ids_increase_by.c test-thread-ids_resize.c +build_sources_program test-thread-keys_adjust.c test-thread-keys_decimate_by.c test-thread-keys_decrease_by.c test-thread-keys_increase.c test-thread-keys_increase_by.c test-thread-keys_resize.c +build_sources_program test-thread-lock_attributes_adjust.c test-thread-lock_attributes_decimate_by.c test-thread-lock_attributes_decrease_by.c test-thread-lock_attributes_increase.c test-thread-lock_attributes_increase_by.c test-thread-lock_attributes_resize.c +build_sources_program test-thread-locks_adjust.c test-thread-locks_decimate_by.c test-thread-locks_decrease_by.c test-thread-locks_increase.c test-thread-locks_increase_by.c test-thread-locks_resize.c +build_sources_program test-thread-mutex_attributes_adjust.c test-thread-mutex_attributes_decimate_by.c test-thread-mutex_attributes_decrease_by.c test-thread-mutex_attributes_increase.c test-thread-mutex_attributes_increase_by.c test-thread-mutex_attributes_resize.c +build_sources_program test-thread-mutexs_adjust.c test-thread-mutexs_decimate_by.c test-thread-mutexs_decrease_by.c test-thread-mutexs_increase.c test-thread-mutexs_increase_by.c test-thread-mutexs_resize.c +build_sources_program test-thread-onces_adjust.c test-thread-onces_decimate_by.c test-thread-onces_decrease_by.c test-thread-onces_increase.c test-thread-onces_increase_by.c test-thread-onces_resize.c +build_sources_program test-thread-semaphores_adjust.c test-thread-semaphores_decimate_by.c test-thread-semaphores_decrease_by.c test-thread-semaphores_increase.c test-thread-semaphores_increase_by.c test-thread-semaphores_resize.c +build_sources_program test-thread-sets_adjust.c test-thread-sets_decimate_by.c test-thread-sets_decrease_by.c test-thread-sets_increase.c test-thread-sets_increase_by.c test-thread-sets_resize.c +build_sources_program test-thread-spins_adjust.c test-thread-spins_decimate_by.c test-thread-spins_decrease_by.c test-thread-spins_increase.c test-thread-spins_increase_by.c test-thread-spins_resize.c + +build_sources_program test-thread-at_fork.c +build_sources_program test-thread-attribute_affinity_get.c test-thread-attribute_affinity_set.c +build_sources_program test-thread-attribute_condition_clock_get.c test-thread-attribute_condition_clock_set.c +build_sources_program test-thread-attribute_condition_shared_get.c test-thread-attribute_condition_shared_set.c +build_sources_program test-thread-attribute_create.c test-thread-attribute_delete.c +build_sources_program test-thread-attribute_default_get.c test-thread-attribute_default_set.c +build_sources_program test-thread-attribute_detach_get.c test-thread-attribute_detach_set.c +build_sources_program test-thread-attribute_guard_get.c test-thread-attribute_guard_set.c +build_sources_program test-thread-attribute_scheduler_inherit_get.c test-thread-attribute_scheduler_inherit_set.c +build_sources_program test-thread-attribute_scheduler_parameter_get.c test-thread-attribute_scheduler_parameter_set.c + +build_sources_program test-thread.c + +build_script no +build_shared yes +build_static no + +path_headers tests/unit/c +path_sources tests/unit/c + +has_path_standard no +preserve_path_headers yes + +search_exclusive yes +search_shared yes +search_static yes + +#defines -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_ +defines -D_pthread_sigqueue_unsupported_ +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-parentheses +flags-clang -Wno-logical-op-parentheses +flags-test -fstack-protector -Wall +flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ + +flags_program -fPIE diff --git a/level_0/f_thread/data/build/testfile b/level_0/f_thread/data/build/testfile new file mode 100644 index 0000000..643a58e --- /dev/null +++ b/level_0/f_thread/data/build/testfile @@ -0,0 +1,55 @@ +# fss-0005 iki-0002 + +settings: + load_build yes + fail exit + + environment LD_LIBRARY_PATH + environment CMOCKA_XML_FILE CMOCKA_MESSAGE_OUTPUT CMOCKA_TEST_ABORT + + # Cmcka is not fully thread-safe, set this to "1" to have cmocka call abort() on a test failure. + #CMOCKA_TEST_ABORT 1 + + # One of: STDOUT, SUBUNIT, TAP, or XML. + #define CMOCKA_MESSAGE_OUTPUT STDOUT + + # When in "XML" output mode, output to this file rather than stdout. + #define CMOCKA_XML_FILE ./out.xml + +main: + build settings-mocks individual test + build settings-tests individual test + + operate ld_library_path + + if exists build/programs/shared/test-f_thread + shell build/programs/shared/test-f_thread + + if exists build/programs/static/test-f_thread + shell build/programs/static/test-f_thread + + if not exists build/programs/shared/test-f_thread + and not exists build/programs/static/test-f_thread + operate not_created + +not_created: + print + print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"' + + exit failure + +ld_library_path: + if defined environment LD_LIBRARY_PATH + and defined parameter work + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared:define:"LD_LIBRARY_PATH"' + + else + if defined environment LD_LIBRARY_PATH + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:define:"LD_LIBRARY_PATH"' + + else + if defined parameter work + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared' + + else + define LD_LIBRARY_PATH build/libraries/shared diff --git a/level_0/f_thread/tests/unit/c/mock-thread.c b/level_0/f_thread/tests/unit/c/mock-thread.c new file mode 100644 index 0000000..a5ac7c5 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/mock-thread.c @@ -0,0 +1,237 @@ +#include "mock-thread.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int __wrap_pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_destroy(pthread_attr_t *attr) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_getaffinity_np(const pthread_attr_t *__attr, size_t __cpusetsize, cpu_set_t *__cpuset) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_getguardsize(const pthread_attr_t *restrict attr, size_t *restrict guardsize) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_getinheritsched(const pthread_attr_t *restrict attr, int *restrict inheritsched) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_getschedparam(const pthread_attr_t *restrict attr, struct sched_param *restrict param) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_setaffinity_np(pthread_t __id, size_t __cpusetsize, const cpu_set_t *__cpuset) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_barrier_destroy(pthread_barrier_t barrier) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_condattr_getclock(const pthread_condattr_t *__restrict __attr, clockid_t *__restrict __clock_id) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_condattr_setclock(pthread_condattr_t *__attr, clockid_t __clock_id) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_condattr_getpshared(const pthread_condattr_t *__attr, int *__pshared) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_condattr_setpshared(pthread_condattr_t *__attr, int __pshared) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_getattr_default_np(pthread_attr_t *attr) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_setattr_default_np(const pthread_attr_t *attr) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_init(pthread_attr_t *__attr) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_attr_setschedparam(pthread_attr_t *restrict attr, const struct sched_param *restrict param) { + + const bool failure = mock_type(bool); + + if (failure) { + return mock_type(int); + } + + return 0; +} + +int __wrap_pthread_key_delete(pthread_key_t key) { + + return mock_type(int); +} + +void stub(void) { +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/mock-thread.h b/level_0/f_thread/tests/unit/c/mock-thread.h new file mode 100644 index 0000000..20fa3b5 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/mock-thread.h @@ -0,0 +1,146 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _MOCK__thread_h +#define _MOCK__thread_h + +// Libc includes. +#include +#include +#include +#include + +// cmocka includes. +#include + +// FLL-0 includes. +#include + +#ifdef __cplusplus +extern "C" { +#endif + +const static int mock_errno_generic = 32767; + +extern int __wrap_pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); +extern int __wrap_pthread_attr_destroy(pthread_attr_t *attr); +extern int __wrap_pthread_attr_getaffinity_np(const pthread_attr_t *__attr, size_t __cpusetsize, cpu_set_t *__cpuset); +extern int __wrap_pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate); +extern int __wrap_pthread_attr_getguardsize(const pthread_attr_t *restrict attr, size_t *restrict guardsize); +extern int __wrap_pthread_attr_getinheritsched(const pthread_attr_t *restrict attr, int *restrict inheritsched); +extern int __wrap_pthread_attr_getschedparam(const pthread_attr_t *restrict attr, struct sched_param *restrict param); +extern int __wrap_pthread_attr_init(pthread_attr_t *__attr); +extern int __wrap_pthread_attr_setaffinity_np(pthread_t __id, size_t __cpusetsize, const cpu_set_t *__cpuset); +extern int __wrap_pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); +extern int __wrap_pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize); +extern int __wrap_pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched); +extern int __wrap_pthread_attr_setschedparam(pthread_attr_t *restrict attr, const struct sched_param *restrict param); +extern int __wrap_pthread_barrier_destroy(pthread_barrier_t barrier); +extern int __wrap_pthread_condattr_getclock(const pthread_condattr_t *__restrict __attr, clockid_t *__restrict __clock_id); +extern int __wrap_pthread_condattr_getpshared(const pthread_condattr_t *__attr, int *__pshared); +extern int __wrap_pthread_condattr_setclock(pthread_condattr_t *__attr, clockid_t __clock_id); +extern int __wrap_pthread_condattr_setpshared(pthread_condattr_t *__attr, int __pshared); +extern int __wrap_pthread_getattr_default_np(pthread_attr_t *attr); +extern int __wrap_pthread_key_delete(pthread_key_t key); +extern int __wrap_pthread_setattr_default_np(const pthread_attr_t *attr); + +/* +pthread_attr_getschedpolicy +pthread_attr_setschedpolicy +pthread_attr_getscope +pthread_attr_setscope +pthread_attr_getstack +pthread_attr_setstack +pthread_attr_getstacksize +pthread_attr_setstacksize +pthread_barrierattr_init +pthread_barrierattr_getpshared +pthread_barrierattr_setpshared +pthread_barrier_init +pthread_barrier_wait +pthread_setcancelstate +pthread_testcancel +pthread_setcanceltype +pthread_getcpuclockid +pthread_equal +pthread_getconcurrency +pthread_setconcurrency +pthread_condattr_init +pthread_cond_init +pthread_cond_broadcast +pthread_cond_signal +pthread_cond_wait +pthread_cond_timedwait +pthread_create +pthread_detach +pthread_exit +pthread_join +pthread_tryjoin_np +pthread_timedjoin_np +pthread_key_create +pthread_getspecific +pthread_setspecific +pthread_rwlockattr_init +pthread_rwlockattr_getpshared +pthread_rwlockattr_setpshared +pthread_rwlock_init +pthread_rwlock_rdlock +pthread_rwlock_timedrdlock +pthread_rwlock_tryrdlock +pthread_rwlock_wrlock +pthread_rwlock_timedwrlock +pthread_rwlock_trywrlock +pthread_mutexattr_init +pthread_mutexattr_getprioceiling +pthread_mutexattr_setprioceiling +pthread_mutexattr_getpshared +pthread_mutexattr_setpshared +pthread_mutexattr_gettype +pthread_mutexattr_settype +pthread_mutexattr_getprotocol +pthread_mutexattr_setprotocol +pthread_mutex_init +pthread_mutex_lock +pthread_mutex_timedlock +pthread_mutex_trylock +sem_init +sem_open +sem_close +sem_unlink +sem_wait +sem_timedwait +sem_trywait +sem_post +sem_getvalue +pthread_mutex_getprioceiling +pthread_mutex_setprioceiling +pthread_mutex_unlock +pthread_once +pthread_getschedparam +pthread_setschedparam +pthread_setschedprio +pthread_sigmask +pthread_sigqueue +pthread_spin_init +pthread_spin_lock +pthread_spin_trylock +pthread_spin_unlock +pthread_rwlock_unlock +*/ + +/** + * A stub intended to be used for passing to functions like f_thread_at_fork(). + */ +extern void stub(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _MOCK__thread_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-at_fork.c b/level_0/f_thread/tests/unit/c/test-thread-at_fork.c new file mode 100644 index 0000000..6b06723 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-at_fork.c @@ -0,0 +1,89 @@ +#include "test-thread.h" +#include "test-thread-at_fork.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_at_fork__fails(void **state) { + + int errnos[] = { + ENOMEM, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_memory_not, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_atfork, true); + will_return(__wrap_pthread_atfork, errnos[i]); + + const f_status_t status = f_thread_at_fork(stub, stub, stub); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_at_fork__parameter_checking(void **state) { + + { + const f_status_t status = f_thread_at_fork(0, 0, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } + + { + const f_status_t status = f_thread_at_fork(stub, 0, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } + + { + const f_status_t status = f_thread_at_fork(0, stub, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } + + { + const f_status_t status = f_thread_at_fork(0, 0, stub); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } + + { + const f_status_t status = f_thread_at_fork(stub, stub, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } + + { + const f_status_t status = f_thread_at_fork(stub, 0, stub); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } + + { + const f_status_t status = f_thread_at_fork(0, stub, stub); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_at_fork__works(void **state) { + + { + will_return(__wrap_pthread_atfork, false); + + const f_status_t status = f_thread_at_fork(stub, stub, stub); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-at_fork.h b/level_0/f_thread/tests/unit/c/test-thread-at_fork.h new file mode 100644 index 0000000..c535956 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-at_fork.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__at_fork_h +#define _TEST__F_thread__at_fork_h + +/** + * Test that function fails. + * + * @see f_thread_at_fork() + */ +extern void test__f_thread_at_fork__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_at_fork() + */ +extern void test__f_thread_at_fork__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_at_fork() + */ +extern void test__f_thread_at_fork__works(void **state); + +#endif // _TEST__F_thread__at_fork_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_get.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_get.c new file mode 100644 index 0000000..449a75d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_get.c @@ -0,0 +1,79 @@ +#include "test-thread.h" +#include "test-thread-attribute_affinity_get.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_affinity_get__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + cpu_set_t cpu_set; + + memset(&cpu_set, 0, sizeof(cpu_set_t)); + + #if defined(_pthread_attr_unsupported_) + const f_status_t status = f_thread_attribute_affinity_get(attribute, 0, &cpu_set); + + assert_int_equal(status, F_status_set_error(F_implemented_not)); + #else + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_getaffinity_np, true); + will_return(__wrap_pthread_attr_getaffinity_np, errnos[i]); + + const f_status_t status = f_thread_attribute_affinity_get(attribute, 0, &cpu_set); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for + #endif // defined(_pthread_attr_unsupported_) +} + +void test__f_thread_attribute_affinity_get__parameter_checking(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + { + const f_status_t status = f_thread_attribute_affinity_get(attribute, 0, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_affinity_get__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + cpu_set_t cpu_set; + + memset(&cpu_set, 0, sizeof(cpu_set_t)); + + #if defined(_pthread_attr_unsupported_) + { + const f_status_t status = f_thread_attribute_affinity_get(attribute, 0, &cpu_set); + + assert_int_equal(status, F_status_set_error(F_implemented_not)); + } + #else + { + will_return(__wrap_pthread_attr_getaffinity_np, false); + + const f_status_t status = f_thread_attribute_affinity_get(attribute, 0, &cpu_set); + + assert_int_equal(status, F_none); + } + #endif // defined(_pthread_attr_unsupported_) +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_get.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_get.h new file mode 100644 index 0000000..467e1cf --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_get.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_affinity_get_h +#define _TEST__F_thread__attribute_affinity_get_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_affinity_get() + */ +extern void test__f_thread_attribute_affinity_get__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_affinity_get() + */ +extern void test__f_thread_attribute_affinity_get__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_affinity_get() + */ +extern void test__f_thread_attribute_affinity_get__works(void **state); + +#endif // _TEST__F_thread__attribute_affinity_get_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_set.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_set.c new file mode 100644 index 0000000..bd1f403 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_set.c @@ -0,0 +1,83 @@ +#include "test-thread.h" +#include "test-thread-attribute_affinity_set.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_affinity_set__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + cpu_set_t cpu_set; + + memset(&cpu_set, 0, sizeof(cpu_set_t)); + + #if defined(_pthread_attr_unsupported_) + const f_status_t status = f_thread_attribute_affinity_set(0, &cpu_set, &attribute); + + assert_int_equal(status, F_status_set_error(F_implemented_not)); + #else + int errnos[] = { + EINVAL, + ENOMEM, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_memory_not, + F_failure, + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_attr_setaffinity_np, true); + will_return(__wrap_pthread_attr_setaffinity_np, errnos[i]); + + const f_status_t status = f_thread_attribute_affinity_set(0, &cpu_set, &attribute); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for + #endif // defined(_pthread_attr_unsupported_) +} + +void test__f_thread_attribute_affinity_set__parameter_checking(void **state) { + + cpu_set_t cpu_set; + + memset(&cpu_set, 0, sizeof(cpu_set_t)); + + { + const f_status_t status = f_thread_attribute_affinity_set(0, &cpu_set, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_affinity_set__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + cpu_set_t cpu_set; + + memset(&cpu_set, 0, sizeof(cpu_set_t)); + + #if defined(_pthread_attr_unsupported_) + { + const f_status_t status = f_thread_attribute_affinity_set(0, &cpu_set, &attribute); + + assert_int_equal(status, F_status_set_error(F_implemented_not)); + } + #else + { + will_return(__wrap_pthread_attr_setaffinity_np, false); + + const f_status_t status = f_thread_attribute_affinity_set(0, &cpu_set, &attribute); + + assert_int_equal(status, F_none); + } + #endif // defined(_pthread_attr_unsupported_) +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_set.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_set.h new file mode 100644 index 0000000..0e48728 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_affinity_set.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_affinity_set_h +#define _TEST__F_thread__attribute_affinity_set_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_affinity_set() + */ +extern void test__f_thread_attribute_affinity_set__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_affinity_set() + */ +extern void test__f_thread_attribute_affinity_set__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_affinity_set() + */ +extern void test__f_thread_attribute_affinity_set__works(void **state); + +#endif // _TEST__F_thread__attribute_affinity_set_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_get.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_get.c new file mode 100644 index 0000000..aa0b1f8 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_get.c @@ -0,0 +1,65 @@ +#include "test-thread.h" +#include "test-thread-attribute_condition_clock_get.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_condition_clock_get__fails(void **state) { + + f_thread_condition_attribute_t attribute = f_thread_condition_attribute_t_initialize; + clockid_t id; + + memset(&id, 0, sizeof(clockid_t)); + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_condattr_getclock, true); + will_return(__wrap_pthread_condattr_getclock, errnos[i]); + + const f_status_t status = f_thread_attribute_condition_clock_get(&attribute, &id); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_condition_clock_get__parameter_checking(void **state) { + + f_thread_condition_attribute_t attribute = f_thread_condition_attribute_t_initialize; + + { + const f_status_t status = f_thread_attribute_condition_clock_get(&attribute, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_condition_clock_get__works(void **state) { + + f_thread_condition_attribute_t attribute = f_thread_condition_attribute_t_initialize; + clockid_t id; + + memset(&id, 0, sizeof(clockid_t)); + + { + will_return(__wrap_pthread_condattr_getclock, false); + + const f_status_t status = f_thread_attribute_condition_clock_get(&attribute, &id); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_get.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_get.h new file mode 100644 index 0000000..c0bc8b4 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_get.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_condition_clock_get_h +#define _TEST__F_thread__attribute_condition_clock_get_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_condition_clock_get() + */ +extern void test__f_thread_attribute_condition_clock_get__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_condition_clock_get() + */ +extern void test__f_thread_attribute_condition_clock_get__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_condition_clock_get() + */ +extern void test__f_thread_attribute_condition_clock_get__works(void **state); + +#endif // _TEST__F_thread__attribute_condition_clock_get_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_set.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_set.c new file mode 100644 index 0000000..2283aaa --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_set.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-attribute_condition_clock_set.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_condition_clock_set__fails(void **state) { + + f_thread_condition_attribute_t attribute = f_thread_condition_attribute_t_initialize; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_condattr_setclock, true); + will_return(__wrap_pthread_condattr_setclock, errnos[i]); + + const f_status_t status = f_thread_attribute_condition_clock_set(0, &attribute); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_condition_clock_set__parameter_checking(void **state) { + + { + const f_status_t status = f_thread_attribute_condition_clock_set(0, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_condition_clock_set__works(void **state) { + + f_thread_condition_attribute_t attribute = f_thread_condition_attribute_t_initialize; + + { + will_return(__wrap_pthread_condattr_setclock, false); + + const f_status_t status = f_thread_attribute_condition_clock_set(0, &attribute); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_set.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_set.h new file mode 100644 index 0000000..b54f26f --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_clock_set.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_condition_clock_set_h +#define _TEST__F_thread__attribute_condition_clock_set_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_condition_clock_set() + */ +extern void test__f_thread_attribute_condition_clock_set__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_condition_clock_set() + */ +extern void test__f_thread_attribute_condition_clock_set__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_condition_clock_set() + */ +extern void test__f_thread_attribute_condition_clock_set__works(void **state); + +#endif // _TEST__F_thread__attribute_condition_clock_set_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_get.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_get.c new file mode 100644 index 0000000..c343475 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_get.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-attribute_condition_shared_get.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_condition_shared_get__fails(void **state) { + + f_thread_condition_attribute_t attribute = f_thread_condition_attribute_t_initialize; + int shared = 0; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_condattr_getpshared, true); + will_return(__wrap_pthread_condattr_getpshared, errnos[i]); + + const f_status_t status = f_thread_attribute_condition_shared_get(&attribute, &shared); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_condition_shared_get__parameter_checking(void **state) { + + f_thread_condition_attribute_t attribute = f_thread_condition_attribute_t_initialize; + int shared = 0; + + { + const f_status_t status = f_thread_attribute_condition_shared_get(0, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } + + { + const f_status_t status = f_thread_attribute_condition_shared_get(&attribute, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } + + { + const f_status_t status = f_thread_attribute_condition_shared_get(0, &shared); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_condition_shared_get__works(void **state) { + + f_thread_condition_attribute_t attribute = f_thread_condition_attribute_t_initialize; + int shared = 0; + + { + will_return(__wrap_pthread_condattr_getpshared, false); + + const f_status_t status = f_thread_attribute_condition_shared_get(&attribute, &shared); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_get.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_get.h new file mode 100644 index 0000000..4f0330e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_get.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_condition_shared_get_h +#define _TEST__F_thread__attribute_condition_shared_get_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_condition_shared_get() + */ +extern void test__f_thread_attribute_condition_shared_get__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_condition_shared_get() + */ +extern void test__f_thread_attribute_condition_shared_get__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_condition_shared_get() + */ +extern void test__f_thread_attribute_condition_shared_get__works(void **state); + +#endif // _TEST__F_thread__attribute_condition_shared_get_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_set.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_set.c new file mode 100644 index 0000000..0b57e29 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_set.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-attribute_condition_shared_set.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_condition_shared_set__fails(void **state) { + + f_thread_condition_attribute_t attribute = f_thread_condition_attribute_t_initialize; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_condattr_setpshared, true); + will_return(__wrap_pthread_condattr_setpshared, errnos[i]); + + const f_status_t status = f_thread_attribute_condition_shared_set(0, &attribute); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_condition_shared_set__parameter_checking(void **state) { + + { + const f_status_t status = f_thread_attribute_condition_shared_set(0, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_condition_shared_set__works(void **state) { + + f_thread_condition_attribute_t attribute = f_thread_condition_attribute_t_initialize; + + { + will_return(__wrap_pthread_condattr_setpshared, false); + + const f_status_t status = f_thread_attribute_condition_shared_set(0, &attribute); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_set.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_set.h new file mode 100644 index 0000000..a3431f4 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_condition_shared_set.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_condition_shared_set_h +#define _TEST__F_thread__attribute_condition_shared_set_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_condition_shared_set() + */ +extern void test__f_thread_attribute_condition_shared_set__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_condition_shared_set() + */ +extern void test__f_thread_attribute_condition_shared_set__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_condition_shared_set() + */ +extern void test__f_thread_attribute_condition_shared_set__works(void **state); + +#endif // _TEST__F_thread__attribute_condition_shared_set_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_create.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_create.c new file mode 100644 index 0000000..089cf36 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_create.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-attribute_create.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_create__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + int errnos[] = { + ENOMEM, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_memory_not, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_init, true); + will_return(__wrap_pthread_attr_init, errnos[i]); + + const f_status_t status = f_thread_attribute_create(&attribute); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_create__parameter_checking(void **state) { + + { + const f_status_t status = f_thread_attribute_create(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_create__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + { + will_return(__wrap_pthread_attr_init, false); + + const f_status_t status = f_thread_attribute_create(&attribute); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_create.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_create.h new file mode 100644 index 0000000..95fb03d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_create.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_create_h +#define _TEST__F_thread__attribute_create_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_create() + */ +extern void test__f_thread_attribute_create__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_create() + */ +extern void test__f_thread_attribute_create__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_create() + */ +extern void test__f_thread_attribute_create__works(void **state); + +#endif // _TEST__F_thread__attribute_create_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_default_get.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_default_get.c new file mode 100644 index 0000000..5dd3484 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_default_get.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-attribute_default_get.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_default_get__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_getattr_default_np, true); + will_return(__wrap_pthread_getattr_default_np, errnos[i]); + + const f_status_t status = f_thread_attribute_default_get(&attribute); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_default_get__parameter_checking(void **state) { + + { + const f_status_t status = f_thread_attribute_default_get(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_default_get__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + { + will_return(__wrap_pthread_getattr_default_np, false); + + const f_status_t status = f_thread_attribute_default_get(&attribute); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_default_get.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_default_get.h new file mode 100644 index 0000000..a3cb99d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_default_get.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_default_get_h +#define _TEST__F_thread__attribute_default_get_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_default_get() + */ +extern void test__f_thread_attribute_default_get__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_default_get() + */ +extern void test__f_thread_attribute_default_get__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_default_get() + */ +extern void test__f_thread_attribute_default_get__works(void **state); + +#endif // _TEST__F_thread__attribute_default_get_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_default_set.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_default_set.c new file mode 100644 index 0000000..072e45f --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_default_set.c @@ -0,0 +1,59 @@ +#include "test-thread.h" +#include "test-thread-attribute_default_set.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_default_set__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + int errnos[] = { + EINVAL, + ENOMEM, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_memory_not, + F_failure, + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_setattr_default_np, true); + will_return(__wrap_pthread_setattr_default_np, errnos[i]); + + const f_status_t status = f_thread_attribute_default_set(&attribute); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_default_set__parameter_checking(void **state) { + + { + const f_status_t status = f_thread_attribute_default_set(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_default_set__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + { + will_return(__wrap_pthread_setattr_default_np, false); + + const f_status_t status = f_thread_attribute_default_set(&attribute); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_default_set.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_default_set.h new file mode 100644 index 0000000..9d976b5 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_default_set.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_default_set_h +#define _TEST__F_thread__attribute_default_set_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_default_set() + */ +extern void test__f_thread_attribute_default_set__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_default_set() + */ +extern void test__f_thread_attribute_default_set__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_default_set() + */ +extern void test__f_thread_attribute_default_set__works(void **state); + +#endif // _TEST__F_thread__attribute_default_set_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_delete.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_delete.c new file mode 100644 index 0000000..5d3559e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_delete.c @@ -0,0 +1,55 @@ +#include "test-thread.h" +#include "test-thread-attribute_delete.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_delete__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + int errnos[] = { + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_failure, + }; + + for (uint8_t i = 0; i < 1; ++i) { + + will_return(__wrap_pthread_attr_destroy, true); + will_return(__wrap_pthread_attr_destroy, errnos[i]); + + const f_status_t status = f_thread_attribute_delete(&attribute); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_delete__parameter_checking(void **state) { + + { + const f_status_t status = f_thread_attribute_delete(0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_delete__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + { + will_return(__wrap_pthread_attr_destroy, false); + + const f_status_t status = f_thread_attribute_delete(&attribute); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_delete.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_delete.h new file mode 100644 index 0000000..7f7fc41 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_delete.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_delete_h +#define _TEST__F_thread__attribute_delete_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_delete() + */ +extern void test__f_thread_attribute_delete__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_delete() + */ +extern void test__f_thread_attribute_delete__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_delete() + */ +extern void test__f_thread_attribute_delete__works(void **state); + +#endif // _TEST__F_thread__attribute_delete_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_get.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_get.c new file mode 100644 index 0000000..5315e97 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_get.c @@ -0,0 +1,61 @@ +#include "test-thread.h" +#include "test-thread-attribute_detach_get.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_detach_get__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + int state_data = 0; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_getdetachstate, true); + will_return(__wrap_pthread_attr_getdetachstate, errnos[i]); + + const f_status_t status = f_thread_attribute_detach_get(attribute, &state_data); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_detach_get__parameter_checking(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + { + const f_status_t status = f_thread_attribute_detach_get(attribute, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_detach_get__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + int state_data = 0; + + { + will_return(__wrap_pthread_attr_getdetachstate, false); + + const f_status_t status = f_thread_attribute_detach_get(attribute, &state_data); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_get.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_get.h new file mode 100644 index 0000000..8302d82 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_get.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_detach_get_h +#define _TEST__F_thread__attribute_detach_get_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_detach_get() + */ +extern void test__f_thread_attribute_detach_get__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_detach_get() + */ +extern void test__f_thread_attribute_detach_get__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_detach_get() + */ +extern void test__f_thread_attribute_detach_get__works(void **state); + +#endif // _TEST__F_thread__attribute_detach_get_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_set.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_set.c new file mode 100644 index 0000000..0c3d8b2 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_set.c @@ -0,0 +1,61 @@ +#include "test-thread.h" +#include "test-thread-attribute_detach_set.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_detach_set__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + int state_data = 0; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_setdetachstate, true); + will_return(__wrap_pthread_attr_setdetachstate, errnos[i]); + + const f_status_t status = f_thread_attribute_detach_set(state_data, &attribute); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_detach_set__parameter_checking(void **state) { + + int state_data = 0; + + { + const f_status_t status = f_thread_attribute_detach_set(state_data, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_detach_set__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + int state_data = 0; + + { + will_return(__wrap_pthread_attr_setdetachstate, false); + + const f_status_t status = f_thread_attribute_detach_set(state_data, &attribute); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_set.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_set.h new file mode 100644 index 0000000..5331eb3 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_detach_set.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_detach_set_h +#define _TEST__F_thread__attribute_detach_set_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_detach_set() + */ +extern void test__f_thread_attribute_detach_set__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_detach_set() + */ +extern void test__f_thread_attribute_detach_set__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_detach_set() + */ +extern void test__f_thread_attribute_detach_set__works(void **state); + +#endif // _TEST__F_thread__attribute_detach_set_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_get.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_get.c new file mode 100644 index 0000000..8dd41b0 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_get.c @@ -0,0 +1,61 @@ +#include "test-thread.h" +#include "test-thread-attribute_guard_get.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_guard_get__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + size_t guard = 0; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_getguardsize, true); + will_return(__wrap_pthread_attr_getguardsize, errnos[i]); + + const f_status_t status = f_thread_attribute_guard_get(attribute, &guard); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_guard_get__parameter_checking(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + { + const f_status_t status = f_thread_attribute_guard_get(attribute, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_guard_get__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + size_t guard = 0; + + { + will_return(__wrap_pthread_attr_getguardsize, false); + + const f_status_t status = f_thread_attribute_guard_get(attribute, &guard); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_get.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_get.h new file mode 100644 index 0000000..fd9f4dc --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_get.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_guard_get_h +#define _TEST__F_thread__attribute_guard_get_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_guard_get() + */ +extern void test__f_thread_attribute_guard_get__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_guard_get() + */ +extern void test__f_thread_attribute_guard_get__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_guard_get() + */ +extern void test__f_thread_attribute_guard_get__works(void **state); + +#endif // _TEST__F_thread__attribute_guard_get_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_set.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_set.c new file mode 100644 index 0000000..c7313a4 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_set.c @@ -0,0 +1,61 @@ +#include "test-thread.h" +#include "test-thread-attribute_guard_set.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_guard_set__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + size_t guard = 0; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_setguardsize, true); + will_return(__wrap_pthread_attr_setguardsize, errnos[i]); + + const f_status_t status = f_thread_attribute_guard_set(guard, &attribute); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_guard_set__parameter_checking(void **state) { + + size_t guard = 0; + + { + const f_status_t status = f_thread_attribute_guard_set(guard, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_guard_set__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + size_t guard = 0; + + { + will_return(__wrap_pthread_attr_setguardsize, false); + + const f_status_t status = f_thread_attribute_guard_set(guard, &attribute); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_set.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_set.h new file mode 100644 index 0000000..a54dacd --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_guard_set.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_guard_set_h +#define _TEST__F_thread__attribute_guard_set_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_guard_set() + */ +extern void test__f_thread_attribute_guard_set__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_guard_set() + */ +extern void test__f_thread_attribute_guard_set__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_guard_set() + */ +extern void test__f_thread_attribute_guard_set__works(void **state); + +#endif // _TEST__F_thread__attribute_guard_set_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_get.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_get.c new file mode 100644 index 0000000..581d686 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_get.c @@ -0,0 +1,61 @@ +#include "test-thread.h" +#include "test-thread-attribute_scheduler_inherit_get.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_scheduler_inherit_get__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + int inherit = 0; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_getinheritsched, true); + will_return(__wrap_pthread_attr_getinheritsched, errnos[i]); + + const f_status_t status = f_thread_attribute_scheduler_inherit_get(attribute, &inherit); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_scheduler_inherit_get__parameter_checking(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + { + const f_status_t status = f_thread_attribute_scheduler_inherit_get(attribute, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_scheduler_inherit_get__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + int inherit = 0; + + { + will_return(__wrap_pthread_attr_getinheritsched, false); + + const f_status_t status = f_thread_attribute_scheduler_inherit_get(attribute, &inherit); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_get.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_get.h new file mode 100644 index 0000000..5fe04b4 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_get.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_scheduler_inherit_get_h +#define _TEST__F_thread__attribute_scheduler_inherit_get_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_scheduler_inherit_get() + */ +extern void test__f_thread_attribute_scheduler_inherit_get__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_scheduler_inherit_get() + */ +extern void test__f_thread_attribute_scheduler_inherit_get__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_scheduler_inherit_get() + */ +extern void test__f_thread_attribute_scheduler_inherit_get__works(void **state); + +#endif // _TEST__F_thread__attribute_scheduler_inherit_get_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_set.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_set.c new file mode 100644 index 0000000..f04cd9c --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_set.c @@ -0,0 +1,61 @@ +#include "test-thread.h" +#include "test-thread-attribute_scheduler_inherit_set.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_scheduler_inherit_set__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + int inherit = 0; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_setinheritsched, true); + will_return(__wrap_pthread_attr_setinheritsched, errnos[i]); + + const f_status_t status = f_thread_attribute_scheduler_inherit_set(inherit, &attribute); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_scheduler_inherit_set__parameter_checking(void **state) { + + int inherit = 0; + + { + const f_status_t status = f_thread_attribute_scheduler_inherit_set(inherit, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_scheduler_inherit_set__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + int inherit = 0; + + { + will_return(__wrap_pthread_attr_setinheritsched, false); + + const f_status_t status = f_thread_attribute_scheduler_inherit_set(inherit, &attribute); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_set.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_set.h new file mode 100644 index 0000000..524ba36 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_inherit_set.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_scheduler_inherit_set_h +#define _TEST__F_thread__attribute_scheduler_inherit_set_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_scheduler_inherit_set() + */ +extern void test__f_thread_attribute_scheduler_inherit_set__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_scheduler_inherit_set() + */ +extern void test__f_thread_attribute_scheduler_inherit_set__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_scheduler_inherit_set() + */ +extern void test__f_thread_attribute_scheduler_inherit_set__works(void **state); + +#endif // _TEST__F_thread__attribute_scheduler_inherit_set_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_get.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_get.c new file mode 100644 index 0000000..271d4bd --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_get.c @@ -0,0 +1,65 @@ +#include "test-thread.h" +#include "test-thread-attribute_scheduler_parameter_get.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_scheduler_parameter_get__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + struct sched_param parameter; + + memset(¶meter, 0, sizeof(struct sched_param)); + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_getschedparam, true); + will_return(__wrap_pthread_attr_getschedparam, errnos[i]); + + const f_status_t status = f_thread_attribute_scheduler_parameter_get(attribute, ¶meter); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_scheduler_parameter_get__parameter_checking(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + + { + const f_status_t status = f_thread_attribute_scheduler_parameter_get(attribute, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_scheduler_parameter_get__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + struct sched_param parameter; + + memset(¶meter, 0, sizeof(struct sched_param)); + + { + will_return(__wrap_pthread_attr_getschedparam, false); + + const f_status_t status = f_thread_attribute_scheduler_parameter_get(attribute, ¶meter); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_get.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_get.h new file mode 100644 index 0000000..72b7c20 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_get.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_scheduler_parameter_get_h +#define _TEST__F_thread__attribute_scheduler_parameter_get_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_scheduler_parameter_get() + */ +extern void test__f_thread_attribute_scheduler_parameter_get__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_scheduler_parameter_get() + */ +extern void test__f_thread_attribute_scheduler_parameter_get__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_scheduler_parameter_get() + */ +extern void test__f_thread_attribute_scheduler_parameter_get__works(void **state); + +#endif // _TEST__F_thread__attribute_scheduler_parameter_get_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_set.c b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_set.c new file mode 100644 index 0000000..667496e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_set.c @@ -0,0 +1,67 @@ +#include "test-thread.h" +#include "test-thread-attribute_scheduler_parameter_set.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attribute_scheduler_parameter_set__fails(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + struct sched_param parameter; + + memset(¶meter, 0, sizeof(struct sched_param)); + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_parameter, + F_failure, + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_setschedparam, true); + will_return(__wrap_pthread_attr_setschedparam, errnos[i]); + + const f_status_t status = f_thread_attribute_scheduler_parameter_set(parameter, &attribute); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_thread_attribute_scheduler_parameter_set__parameter_checking(void **state) { + + struct sched_param parameter; + + memset(¶meter, 0, sizeof(struct sched_param)); + + { + const f_status_t status = f_thread_attribute_scheduler_parameter_set(parameter, 0); + + assert_int_equal(status, F_status_set_error(F_parameter)); + } +} + +void test__f_thread_attribute_scheduler_parameter_set__works(void **state) { + + f_thread_attribute_t attribute = f_thread_attribute_t_initialize; + struct sched_param parameter; + + memset(¶meter, 0, sizeof(struct sched_param)); + + { + will_return(__wrap_pthread_attr_setschedparam, false); + + const f_status_t status = f_thread_attribute_scheduler_parameter_set(parameter, &attribute); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_set.h b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_set.h new file mode 100644 index 0000000..06da0dd --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attribute_scheduler_parameter_set.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread__attribute_scheduler_parameter_set_h +#define _TEST__F_thread__attribute_scheduler_parameter_set_h + +/** + * Test that function fails. + * + * @see f_thread_attribute_scheduler_parameter_set() + */ +extern void test__f_thread_attribute_scheduler_parameter_set__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_thread_attribute_scheduler_parameter_set() + */ +extern void test__f_thread_attribute_scheduler_parameter_set__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_thread_attribute_scheduler_parameter_set() + */ +extern void test__f_thread_attribute_scheduler_parameter_set__works(void **state); + +#endif // _TEST__F_thread__attribute_scheduler_parameter_set_h diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.c new file mode 100644 index 0000000..e8c1a2d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-attributes_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attributes_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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); +} + +void test__f_thread_attributes_adjust__works(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.h new file mode 100644 index 0000000..9242d5a --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_attributes_adjust +#define _TEST__F_thread__thread_attributes_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_attributes_adjust() + */ +extern void test__f_thread_attributes_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_attributes_adjust() + */ +extern void test__f_thread_attributes_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_attributes_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.c new file mode 100644 index 0000000..713cf52 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.c @@ -0,0 +1,78 @@ +#include "test-thread.h" +#include "test-thread-attributes_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attributes_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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); +} + +void test__f_thread_attributes_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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_thread_attributes_decimate_by(0, &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_thread_attributes_decimate_by__works(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + for (uint8_t i = 0; i < length; ++i) { + will_return(__wrap_pthread_attr_destroy, false); + } // for + + const f_status_t status = f_thread_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.h new file mode 100644 index 0000000..0b973ac --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_attributes_decimate_by +#define _TEST__F_thread__thread_attributes_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_attributes_decimate_by() + */ +extern void test__f_thread_attributes_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_attributes_decimate_by() + */ +extern void test__f_thread_attributes_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_attributes_decimate_by() + */ +extern void test__f_thread_attributes_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_attributes_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.c new file mode 100644 index 0000000..6e650bc --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.c @@ -0,0 +1,78 @@ +#include "test-thread.h" +#include "test-thread-attributes_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attributes_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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); +} + +void test__f_thread_attributes_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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_thread_attributes_decrease_by(0, &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_thread_attributes_decrease_by__works(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + for (uint8_t i = 0; i < length; ++i) { + will_return(__wrap_pthread_attr_destroy, false); + } // for + + const f_status_t status = f_thread_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.h new file mode 100644 index 0000000..89a7719 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_attributes_decrease_by +#define _TEST__F_thread__thread_attributes_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_attributes_decrease_by() + */ +extern void test__f_thread_attributes_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_attributes_decrease_by() + */ +extern void test__f_thread_attributes_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_attributes_decrease_by() + */ +extern void test__f_thread_attributes_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_attributes_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.c new file mode 100644 index 0000000..134b72d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-attributes_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attributes_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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); +} + +void test__f_thread_attributes_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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_thread_attributes_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_thread_attributes_increase__works(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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_thread_attributes_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.h new file mode 100644 index 0000000..e83cd2a --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_attributes_increase +#define _TEST__F_thread__thread_attributes_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_attributes_increase() + */ +extern void test__f_thread_attributes_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_attributes_increase() + */ +extern void test__f_thread_attributes_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_attributes_increase() + */ +extern void test__f_thread_attributes_increase__works(void **state); + +#endif // _TEST__F_thread__thread_attributes_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.c new file mode 100644 index 0000000..98cb6ed --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-attributes_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attributes_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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); +} + +void test__f_thread_attributes_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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_thread_attributes_increase_by(0, &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_thread_attributes_increase_by__works(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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_thread_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.h new file mode 100644 index 0000000..3d0acff --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_attributes_increase_by +#define _TEST__F_thread__thread_attributes_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_attributes_increase_by() + */ +extern void test__f_thread_attributes_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_attributes_increase_by() + */ +extern void test__f_thread_attributes_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_attributes_increase_by() + */ +extern void test__f_thread_attributes_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_attributes_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.c new file mode 100644 index 0000000..5bca614 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-attributes_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attributes_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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); +} + +void test__f_thread_attributes_resize__works(void **state) { + + const int length = 5; + f_thread_attributes_t data = f_thread_attributes_t_initialize; + + { + const f_status_t status = f_thread_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.h new file mode 100644 index 0000000..be2b86d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_attributes_resize +#define _TEST__F_thread__thread_attributes_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_attributes_resize() + */ +extern void test__f_thread_attributes_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_attributes_resize() + */ +extern void test__f_thread_attributes_resize__works(void **state); + +#endif // _TEST__F_thread__thread_attributes_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.c new file mode 100644 index 0000000..d1c47f3 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-barrier_attributes_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barrier_attributes_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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); +} + +void test__f_thread_barrier_attributes_adjust__works(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.h new file mode 100644 index 0000000..60ace26 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barrier_attributes_adjust +#define _TEST__F_thread__thread_barrier_attributes_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barrier_attributes_adjust() + */ +extern void test__f_thread_barrier_attributes_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barrier_attributes_adjust() + */ +extern void test__f_thread_barrier_attributes_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_barrier_attributes_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.c new file mode 100644 index 0000000..54c162e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-barrier_attributes_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barrier_attributes_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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); +} + +void test__f_thread_barrier_attributes_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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_thread_barrier_attributes_decimate_by(0, &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_thread_barrier_attributes_decimate_by__works(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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_thread_barrier_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.h new file mode 100644 index 0000000..13ed8ef --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barrier_attributes_decimate_by +#define _TEST__F_thread__thread_barrier_attributes_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barrier_attributes_decimate_by() + */ +extern void test__f_thread_barrier_attributes_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_barrier_attributes_decimate_by() + */ +extern void test__f_thread_barrier_attributes_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barrier_attributes_decimate_by() + */ +extern void test__f_thread_barrier_attributes_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_barrier_attributes_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.c new file mode 100644 index 0000000..fe767d6 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-barrier_attributes_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barrier_attributes_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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); +} + +void test__f_thread_barrier_attributes_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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_thread_barrier_attributes_decrease_by(0, &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_thread_barrier_attributes_decrease_by__works(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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_thread_barrier_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.h new file mode 100644 index 0000000..442b797 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barrier_attributes_decrease_by +#define _TEST__F_thread__thread_barrier_attributes_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barrier_attributes_decrease_by() + */ +extern void test__f_thread_barrier_attributes_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_barrier_attributes_decrease_by() + */ +extern void test__f_thread_barrier_attributes_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barrier_attributes_decrease_by() + */ +extern void test__f_thread_barrier_attributes_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_barrier_attributes_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.c new file mode 100644 index 0000000..a51e3da --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-barrier_attributes_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barrier_attributes_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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); +} + +void test__f_thread_barrier_attributes_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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_thread_barrier_attributes_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_thread_barrier_attributes_increase__works(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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_thread_barrier_attributes_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.h new file mode 100644 index 0000000..fa04d0d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barrier_attributes_increase +#define _TEST__F_thread__thread_barrier_attributes_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barrier_attributes_increase() + */ +extern void test__f_thread_barrier_attributes_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_barrier_attributes_increase() + */ +extern void test__f_thread_barrier_attributes_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barrier_attributes_increase() + */ +extern void test__f_thread_barrier_attributes_increase__works(void **state); + +#endif // _TEST__F_thread__thread_barrier_attributes_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.c new file mode 100644 index 0000000..30382ab --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-barrier_attributes_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barrier_attributes_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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); +} + +void test__f_thread_barrier_attributes_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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_thread_barrier_attributes_increase_by(0, &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_thread_barrier_attributes_increase_by__works(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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_thread_barrier_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.h new file mode 100644 index 0000000..4467b94 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barrier_attributes_increase_by +#define _TEST__F_thread__thread_barrier_attributes_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barrier_attributes_increase_by() + */ +extern void test__f_thread_barrier_attributes_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_barrier_attributes_increase_by() + */ +extern void test__f_thread_barrier_attributes_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barrier_attributes_increase_by() + */ +extern void test__f_thread_barrier_attributes_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_barrier_attributes_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.c new file mode 100644 index 0000000..8255c02 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-barrier_attributes_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barrier_attributes_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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); +} + +void test__f_thread_barrier_attributes_resize__works(void **state) { + + const int length = 5; + f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; + + { + const f_status_t status = f_thread_barrier_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.h new file mode 100644 index 0000000..efb7ff9 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barrier_attributes_resize +#define _TEST__F_thread__thread_barrier_attributes_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barrier_attributes_resize() + */ +extern void test__f_thread_barrier_attributes_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barrier_attributes_resize() + */ +extern void test__f_thread_barrier_attributes_resize__works(void **state); + +#endif // _TEST__F_thread__thread_barrier_attributes_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.c new file mode 100644 index 0000000..75dd228 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-barriers_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barriers_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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); +} + +void test__f_thread_barriers_adjust__works(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.h new file mode 100644 index 0000000..acb10f1 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barriers_adjust +#define _TEST__F_thread__thread_barriers_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barriers_adjust() + */ +extern void test__f_thread_barriers_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barriers_adjust() + */ +extern void test__f_thread_barriers_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_barriers_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.c new file mode 100644 index 0000000..ac22ea8 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.c @@ -0,0 +1,78 @@ +#include "test-thread.h" +#include "test-thread-barriers_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barriers_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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); +} + +void test__f_thread_barriers_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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_thread_barriers_decimate_by(0, &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_thread_barriers_decimate_by__works(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + for (uint8_t i = 0; i < length; ++i) { + will_return(__wrap_pthread_barrier_destroy, F_false); + } // for + + const f_status_t status = f_thread_barriers_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.h new file mode 100644 index 0000000..a183eb1 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barriers_decimate_by +#define _TEST__F_thread__thread_barriers_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barriers_decimate_by() + */ +extern void test__f_thread_barriers_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_barriers_decimate_by() + */ +extern void test__f_thread_barriers_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barriers_decimate_by() + */ +extern void test__f_thread_barriers_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_barriers_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.c new file mode 100644 index 0000000..0af5a54 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.c @@ -0,0 +1,78 @@ +#include "test-thread.h" +#include "test-thread-barriers_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barriers_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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); +} + +void test__f_thread_barriers_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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_thread_barriers_decrease_by(0, &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_thread_barriers_decrease_by__works(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + for (uint8_t i = 0; i < length; ++i) { + will_return(__wrap_pthread_barrier_destroy, F_false); + } // for + + const f_status_t status = f_thread_barriers_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.h new file mode 100644 index 0000000..c72c4f2 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barriers_decrease_by +#define _TEST__F_thread__thread_barriers_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barriers_decrease_by() + */ +extern void test__f_thread_barriers_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_barriers_decrease_by() + */ +extern void test__f_thread_barriers_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barriers_decrease_by() + */ +extern void test__f_thread_barriers_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_barriers_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.c new file mode 100644 index 0000000..f70549b --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-barriers_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barriers_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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); +} + +void test__f_thread_barriers_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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_thread_barriers_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_thread_barriers_increase__works(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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_thread_barriers_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.h new file mode 100644 index 0000000..e5f4909 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barriers_increase +#define _TEST__F_thread__thread_barriers_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barriers_increase() + */ +extern void test__f_thread_barriers_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_barriers_increase() + */ +extern void test__f_thread_barriers_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barriers_increase() + */ +extern void test__f_thread_barriers_increase__works(void **state); + +#endif // _TEST__F_thread__thread_barriers_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.c new file mode 100644 index 0000000..478e3dc --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-barriers_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barriers_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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); +} + +void test__f_thread_barriers_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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_thread_barriers_increase_by(0, &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_thread_barriers_increase_by__works(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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_thread_barriers_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.h new file mode 100644 index 0000000..8780a8d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barriers_increase_by +#define _TEST__F_thread__thread_barriers_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barriers_increase_by() + */ +extern void test__f_thread_barriers_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_barriers_increase_by() + */ +extern void test__f_thread_barriers_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barriers_increase_by() + */ +extern void test__f_thread_barriers_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_barriers_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.c new file mode 100644 index 0000000..1c617e2 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-barriers_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barriers_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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); +} + +void test__f_thread_barriers_resize__works(void **state) { + + const int length = 5; + f_thread_barriers_t data = f_thread_barriers_t_initialize; + + { + const f_status_t status = f_thread_barriers_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.h new file mode 100644 index 0000000..a8e889f --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_barriers_resize +#define _TEST__F_thread__thread_barriers_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_barriers_resize() + */ +extern void test__f_thread_barriers_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barriers_resize() + */ +extern void test__f_thread_barriers_resize__works(void **state); + +#endif // _TEST__F_thread__thread_barriers_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.c new file mode 100644 index 0000000..5751d5c --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-condition_attributes_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_condition_attributes_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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); +} + +void test__f_thread_condition_attributes_adjust__works(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.h new file mode 100644 index 0000000..8f64904 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_condition_attributes_adjust +#define _TEST__F_thread__thread_condition_attributes_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_condition_attributes_adjust() + */ +extern void test__f_thread_condition_attributes_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_condition_attributes_adjust() + */ +extern void test__f_thread_condition_attributes_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_condition_attributes_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.c new file mode 100644 index 0000000..caba115 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-condition_attributes_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_condition_attributes_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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); +} + +void test__f_thread_condition_attributes_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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_thread_condition_attributes_decimate_by(0, &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_thread_condition_attributes_decimate_by__works(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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_thread_condition_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.h new file mode 100644 index 0000000..30aaade --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_condition_attributes_decimate_by +#define _TEST__F_thread__thread_condition_attributes_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_condition_attributes_decimate_by() + */ +extern void test__f_thread_condition_attributes_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_condition_attributes_decimate_by() + */ +extern void test__f_thread_condition_attributes_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_condition_attributes_decimate_by() + */ +extern void test__f_thread_condition_attributes_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_condition_attributes_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.c new file mode 100644 index 0000000..76fc5e5 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-condition_attributes_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_condition_attributes_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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); +} + +void test__f_thread_condition_attributes_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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_thread_condition_attributes_decrease_by(0, &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_thread_condition_attributes_decrease_by__works(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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_thread_condition_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.h new file mode 100644 index 0000000..9b11986 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_condition_attributes_decrease_by +#define _TEST__F_thread__thread_condition_attributes_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_condition_attributes_decrease_by() + */ +extern void test__f_thread_condition_attributes_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_condition_attributes_decrease_by() + */ +extern void test__f_thread_condition_attributes_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_condition_attributes_decrease_by() + */ +extern void test__f_thread_condition_attributes_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_condition_attributes_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.c new file mode 100644 index 0000000..6ab17e6 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-condition_attributes_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_condition_attributes_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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); +} + +void test__f_thread_condition_attributes_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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_thread_condition_attributes_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_thread_condition_attributes_increase__works(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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_thread_condition_attributes_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.h new file mode 100644 index 0000000..bc08aba --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_condition_attributes_increase +#define _TEST__F_thread__thread_condition_attributes_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_condition_attributes_increase() + */ +extern void test__f_thread_condition_attributes_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_condition_attributes_increase() + */ +extern void test__f_thread_condition_attributes_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_condition_attributes_increase() + */ +extern void test__f_thread_condition_attributes_increase__works(void **state); + +#endif // _TEST__F_thread__thread_condition_attributes_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.c new file mode 100644 index 0000000..10f3398 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-condition_attributes_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_condition_attributes_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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); +} + +void test__f_thread_condition_attributes_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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_thread_condition_attributes_increase_by(0, &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_thread_condition_attributes_increase_by__works(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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_thread_condition_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.h new file mode 100644 index 0000000..3c1e36d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_condition_attributes_increase_by +#define _TEST__F_thread__thread_condition_attributes_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_condition_attributes_increase_by() + */ +extern void test__f_thread_condition_attributes_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_condition_attributes_increase_by() + */ +extern void test__f_thread_condition_attributes_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_condition_attributes_increase_by() + */ +extern void test__f_thread_condition_attributes_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_condition_attributes_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.c new file mode 100644 index 0000000..3bfd003 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-condition_attributes_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_condition_attributes_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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); +} + +void test__f_thread_condition_attributes_resize__works(void **state) { + + const int length = 5; + f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; + + { + const f_status_t status = f_thread_condition_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.h new file mode 100644 index 0000000..c1d74ad --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_condition_attributes_resize +#define _TEST__F_thread__thread_condition_attributes_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_condition_attributes_resize() + */ +extern void test__f_thread_condition_attributes_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_condition_attributes_resize() + */ +extern void test__f_thread_condition_attributes_resize__works(void **state); + +#endif // _TEST__F_thread__thread_condition_attributes_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.c new file mode 100644 index 0000000..69f85a3 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-conditions_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_conditions_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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); +} + +void test__f_thread_conditions_adjust__works(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.h new file mode 100644 index 0000000..d343931 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_conditions_adjust +#define _TEST__F_thread__thread_conditions_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_conditions_adjust() + */ +extern void test__f_thread_conditions_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_conditions_adjust() + */ +extern void test__f_thread_conditions_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_conditions_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.c new file mode 100644 index 0000000..2a19c3b --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-conditions_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_conditions_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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); +} + +void test__f_thread_conditions_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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_thread_conditions_decimate_by(0, &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_thread_conditions_decimate_by__works(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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_thread_conditions_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.h new file mode 100644 index 0000000..1aeec08 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_conditions_decimate_by +#define _TEST__F_thread__thread_conditions_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_conditions_decimate_by() + */ +extern void test__f_thread_conditions_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_conditions_decimate_by() + */ +extern void test__f_thread_conditions_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_conditions_decimate_by() + */ +extern void test__f_thread_conditions_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_conditions_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.c new file mode 100644 index 0000000..5351022 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-conditions_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_conditions_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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); +} + +void test__f_thread_conditions_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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_thread_conditions_decrease_by(0, &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_thread_conditions_decrease_by__works(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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_thread_conditions_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.h new file mode 100644 index 0000000..7f9be3f --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_conditions_decrease_by +#define _TEST__F_thread__thread_conditions_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_conditions_decrease_by() + */ +extern void test__f_thread_conditions_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_conditions_decrease_by() + */ +extern void test__f_thread_conditions_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_conditions_decrease_by() + */ +extern void test__f_thread_conditions_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_conditions_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.c new file mode 100644 index 0000000..640b590 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-conditions_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_conditions_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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); +} + +void test__f_thread_conditions_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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_thread_conditions_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_thread_conditions_increase__works(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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_thread_conditions_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.h new file mode 100644 index 0000000..d179b74 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_conditions_increase +#define _TEST__F_thread__thread_conditions_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_conditions_increase() + */ +extern void test__f_thread_conditions_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_conditions_increase() + */ +extern void test__f_thread_conditions_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_conditions_increase() + */ +extern void test__f_thread_conditions_increase__works(void **state); + +#endif // _TEST__F_thread__thread_conditions_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.c new file mode 100644 index 0000000..1b7772e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-conditions_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_conditions_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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); +} + +void test__f_thread_conditions_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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_thread_conditions_increase_by(0, &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_thread_conditions_increase_by__works(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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_thread_conditions_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.h new file mode 100644 index 0000000..e9cec5f --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_conditions_increase_by +#define _TEST__F_thread__thread_conditions_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_conditions_increase_by() + */ +extern void test__f_thread_conditions_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_conditions_increase_by() + */ +extern void test__f_thread_conditions_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_conditions_increase_by() + */ +extern void test__f_thread_conditions_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_conditions_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.c new file mode 100644 index 0000000..b630119 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-conditions_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_conditions_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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); +} + +void test__f_thread_conditions_resize__works(void **state) { + + const int length = 5; + f_thread_conditions_t data = f_thread_conditions_t_initialize; + + { + const f_status_t status = f_thread_conditions_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.h new file mode 100644 index 0000000..20d1cdd --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_conditions_resize +#define _TEST__F_thread__thread_conditions_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_conditions_resize() + */ +extern void test__f_thread_conditions_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_conditions_resize() + */ +extern void test__f_thread_conditions_resize__works(void **state); + +#endif // _TEST__F_thread__thread_conditions_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.c new file mode 100644 index 0000000..2ce2fc3 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-ids_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_ids_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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); +} + +void test__f_thread_ids_adjust__works(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.h new file mode 100644 index 0000000..68925de --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_ids_adjust +#define _TEST__F_thread__thread_ids_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_ids_adjust() + */ +extern void test__f_thread_ids_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_ids_adjust() + */ +extern void test__f_thread_ids_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_ids_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.c new file mode 100644 index 0000000..d55dfb6 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-ids_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_ids_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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); +} + +void test__f_thread_ids_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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_thread_ids_decimate_by(0, &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_thread_ids_decimate_by__works(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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_thread_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.h new file mode 100644 index 0000000..ba59c26 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_ids_decimate_by +#define _TEST__F_thread__thread_ids_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_ids_decimate_by() + */ +extern void test__f_thread_ids_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_ids_decimate_by() + */ +extern void test__f_thread_ids_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_ids_decimate_by() + */ +extern void test__f_thread_ids_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_ids_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.c new file mode 100644 index 0000000..c7d0bf7 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-ids_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_ids_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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); +} + +void test__f_thread_ids_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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_thread_ids_decrease_by(0, &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_thread_ids_decrease_by__works(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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_thread_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.h new file mode 100644 index 0000000..b2e99b6 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_ids_decrease_by +#define _TEST__F_thread__thread_ids_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_ids_decrease_by() + */ +extern void test__f_thread_ids_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_ids_decrease_by() + */ +extern void test__f_thread_ids_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_ids_decrease_by() + */ +extern void test__f_thread_ids_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_ids_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_increase.c b/level_0/f_thread/tests/unit/c/test-thread-ids_increase.c new file mode 100644 index 0000000..cc6d6eb --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-ids_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_ids_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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); +} + +void test__f_thread_ids_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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_thread_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_thread_ids_increase__works(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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_thread_ids_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_increase.h b/level_0/f_thread/tests/unit/c/test-thread-ids_increase.h new file mode 100644 index 0000000..81de43e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_ids_increase +#define _TEST__F_thread__thread_ids_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_ids_increase() + */ +extern void test__f_thread_ids_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_ids_increase() + */ +extern void test__f_thread_ids_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_ids_increase() + */ +extern void test__f_thread_ids_increase__works(void **state); + +#endif // _TEST__F_thread__thread_ids_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.c new file mode 100644 index 0000000..55195d6 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-ids_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_ids_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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); +} + +void test__f_thread_ids_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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_thread_ids_increase_by(0, &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_thread_ids_increase_by__works(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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_thread_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.h new file mode 100644 index 0000000..190f5c6 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_ids_increase_by +#define _TEST__F_thread__thread_ids_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_ids_increase_by() + */ +extern void test__f_thread_ids_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_ids_increase_by() + */ +extern void test__f_thread_ids_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_ids_increase_by() + */ +extern void test__f_thread_ids_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_ids_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_resize.c b/level_0/f_thread/tests/unit/c/test-thread-ids_resize.c new file mode 100644 index 0000000..e2f5ccc --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-ids_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_ids_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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); +} + +void test__f_thread_ids_resize__works(void **state) { + + const int length = 5; + f_thread_ids_t data = f_thread_ids_t_initialize; + + { + const f_status_t status = f_thread_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_resize.h b/level_0/f_thread/tests/unit/c/test-thread-ids_resize.h new file mode 100644 index 0000000..b37838c --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-ids_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_ids_resize +#define _TEST__F_thread__thread_ids_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_ids_resize() + */ +extern void test__f_thread_ids_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_ids_resize() + */ +extern void test__f_thread_ids_resize__works(void **state); + +#endif // _TEST__F_thread__thread_ids_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.c new file mode 100644 index 0000000..5527b06 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-keys_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_keys_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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); +} + +void test__f_thread_keys_adjust__works(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.h new file mode 100644 index 0000000..96c5cf9 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_keys_adjust +#define _TEST__F_thread__thread_keys_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_keys_adjust() + */ +extern void test__f_thread_keys_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_keys_adjust() + */ +extern void test__f_thread_keys_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_keys_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.c new file mode 100644 index 0000000..460f57b --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.c @@ -0,0 +1,78 @@ +#include "test-thread.h" +#include "test-thread-keys_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_keys_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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); +} + +void test__f_thread_keys_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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_thread_keys_decimate_by(0, &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_thread_keys_decimate_by__works(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + for (uint8_t i = 0; i < length; ++i) { + will_return(__wrap_pthread_key_delete, F_false); + } // for + + const f_status_t status = f_thread_keys_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.h new file mode 100644 index 0000000..1b70c2e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_keys_decimate_by +#define _TEST__F_thread__thread_keys_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_keys_decimate_by() + */ +extern void test__f_thread_keys_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_keys_decimate_by() + */ +extern void test__f_thread_keys_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_keys_decimate_by() + */ +extern void test__f_thread_keys_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_keys_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.c new file mode 100644 index 0000000..229ce77 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.c @@ -0,0 +1,78 @@ +#include "test-thread.h" +#include "test-thread-keys_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_keys_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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); +} + +void test__f_thread_keys_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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_thread_keys_decrease_by(0, &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_thread_keys_decrease_by__works(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + for (uint8_t i = 0; i < length; ++i) { + will_return(__wrap_pthread_key_delete, F_false); + } // for + + const f_status_t status = f_thread_keys_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.h new file mode 100644 index 0000000..3d56527 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_keys_decrease_by +#define _TEST__F_thread__thread_keys_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_keys_decrease_by() + */ +extern void test__f_thread_keys_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_keys_decrease_by() + */ +extern void test__f_thread_keys_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_keys_decrease_by() + */ +extern void test__f_thread_keys_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_keys_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_increase.c b/level_0/f_thread/tests/unit/c/test-thread-keys_increase.c new file mode 100644 index 0000000..7a78b0e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-keys_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_keys_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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); +} + +void test__f_thread_keys_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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_thread_keys_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_thread_keys_increase__works(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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_thread_keys_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_increase.h b/level_0/f_thread/tests/unit/c/test-thread-keys_increase.h new file mode 100644 index 0000000..e7793ff --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_keys_increase +#define _TEST__F_thread__thread_keys_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_keys_increase() + */ +extern void test__f_thread_keys_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_keys_increase() + */ +extern void test__f_thread_keys_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_keys_increase() + */ +extern void test__f_thread_keys_increase__works(void **state); + +#endif // _TEST__F_thread__thread_keys_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.c new file mode 100644 index 0000000..3a4bfcf --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-keys_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_keys_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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); +} + +void test__f_thread_keys_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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_thread_keys_increase_by(0, &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_thread_keys_increase_by__works(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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_thread_keys_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.h new file mode 100644 index 0000000..f0fd474 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_keys_increase_by +#define _TEST__F_thread__thread_keys_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_keys_increase_by() + */ +extern void test__f_thread_keys_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_keys_increase_by() + */ +extern void test__f_thread_keys_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_keys_increase_by() + */ +extern void test__f_thread_keys_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_keys_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_resize.c b/level_0/f_thread/tests/unit/c/test-thread-keys_resize.c new file mode 100644 index 0000000..a5c290c --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-keys_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_keys_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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); +} + +void test__f_thread_keys_resize__works(void **state) { + + const int length = 5; + f_thread_keys_t data = f_thread_keys_t_initialize; + + { + const f_status_t status = f_thread_keys_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_resize.h b/level_0/f_thread/tests/unit/c/test-thread-keys_resize.h new file mode 100644 index 0000000..c13450d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_keys_resize +#define _TEST__F_thread__thread_keys_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_keys_resize() + */ +extern void test__f_thread_keys_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_keys_resize() + */ +extern void test__f_thread_keys_resize__works(void **state); + +#endif // _TEST__F_thread__thread_keys_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.c new file mode 100644 index 0000000..9c93521 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-lock_attributes_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_lock_attributes_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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); +} + +void test__f_thread_lock_attributes_adjust__works(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.h new file mode 100644 index 0000000..bcdb6d9 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_lock_attributes_adjust +#define _TEST__F_thread__thread_lock_attributes_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_lock_attributes_adjust() + */ +extern void test__f_thread_lock_attributes_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_lock_attributes_adjust() + */ +extern void test__f_thread_lock_attributes_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_lock_attributes_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.c new file mode 100644 index 0000000..2f55aef --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-lock_attributes_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_lock_attributes_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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); +} + +void test__f_thread_lock_attributes_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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_thread_lock_attributes_decimate_by(0, &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_thread_lock_attributes_decimate_by__works(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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_thread_lock_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.h new file mode 100644 index 0000000..71e68ff --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_lock_attributes_decimate_by +#define _TEST__F_thread__thread_lock_attributes_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_lock_attributes_decimate_by() + */ +extern void test__f_thread_lock_attributes_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_lock_attributes_decimate_by() + */ +extern void test__f_thread_lock_attributes_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_lock_attributes_decimate_by() + */ +extern void test__f_thread_lock_attributes_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_lock_attributes_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.c new file mode 100644 index 0000000..0f67eb0 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-lock_attributes_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_lock_attributes_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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); +} + +void test__f_thread_lock_attributes_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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_thread_lock_attributes_decrease_by(0, &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_thread_lock_attributes_decrease_by__works(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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_thread_lock_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.h new file mode 100644 index 0000000..ba29a0f --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_lock_attributes_decrease_by +#define _TEST__F_thread__thread_lock_attributes_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_lock_attributes_decrease_by() + */ +extern void test__f_thread_lock_attributes_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_lock_attributes_decrease_by() + */ +extern void test__f_thread_lock_attributes_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_lock_attributes_decrease_by() + */ +extern void test__f_thread_lock_attributes_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_lock_attributes_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.c new file mode 100644 index 0000000..4600307 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-lock_attributes_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_lock_attributes_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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); +} + +void test__f_thread_lock_attributes_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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_thread_lock_attributes_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_thread_lock_attributes_increase__works(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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_thread_lock_attributes_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.h new file mode 100644 index 0000000..2ea11de --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_lock_attributes_increase +#define _TEST__F_thread__thread_lock_attributes_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_lock_attributes_increase() + */ +extern void test__f_thread_lock_attributes_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_lock_attributes_increase() + */ +extern void test__f_thread_lock_attributes_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_lock_attributes_increase() + */ +extern void test__f_thread_lock_attributes_increase__works(void **state); + +#endif // _TEST__F_thread__thread_lock_attributes_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.c new file mode 100644 index 0000000..c217c6f --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-lock_attributes_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_lock_attributes_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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); +} + +void test__f_thread_lock_attributes_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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_thread_lock_attributes_increase_by(0, &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_thread_lock_attributes_increase_by__works(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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_thread_lock_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.h new file mode 100644 index 0000000..88d3e84 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_lock_attributes_increase_by +#define _TEST__F_thread__thread_lock_attributes_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_lock_attributes_increase_by() + */ +extern void test__f_thread_lock_attributes_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_lock_attributes_increase_by() + */ +extern void test__f_thread_lock_attributes_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_lock_attributes_increase_by() + */ +extern void test__f_thread_lock_attributes_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_lock_attributes_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.c new file mode 100644 index 0000000..5f2f839 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-lock_attributes_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_lock_attributes_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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); +} + +void test__f_thread_lock_attributes_resize__works(void **state) { + + const int length = 5; + f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; + + { + const f_status_t status = f_thread_lock_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.h new file mode 100644 index 0000000..cbc8d2d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_lock_attributes_resize +#define _TEST__F_thread__thread_lock_attributes_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_lock_attributes_resize() + */ +extern void test__f_thread_lock_attributes_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_lock_attributes_resize() + */ +extern void test__f_thread_lock_attributes_resize__works(void **state); + +#endif // _TEST__F_thread__thread_lock_attributes_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.c new file mode 100644 index 0000000..3494da4 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-locks_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_locks_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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); +} + +void test__f_thread_locks_adjust__works(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.h new file mode 100644 index 0000000..40c4ef9 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_locks_adjust +#define _TEST__F_thread__thread_locks_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_locks_adjust() + */ +extern void test__f_thread_locks_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_locks_adjust() + */ +extern void test__f_thread_locks_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_locks_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.c new file mode 100644 index 0000000..77df7c1 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-locks_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_locks_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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); +} + +void test__f_thread_locks_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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_thread_locks_decimate_by(0, &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_thread_locks_decimate_by__works(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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_thread_locks_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.h new file mode 100644 index 0000000..7bd0561 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_locks_decimate_by +#define _TEST__F_thread__thread_locks_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_locks_decimate_by() + */ +extern void test__f_thread_locks_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_locks_decimate_by() + */ +extern void test__f_thread_locks_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_locks_decimate_by() + */ +extern void test__f_thread_locks_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_locks_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.c new file mode 100644 index 0000000..de5f11a --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-locks_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_locks_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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); +} + +void test__f_thread_locks_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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_thread_locks_decrease_by(0, &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_thread_locks_decrease_by__works(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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_thread_locks_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.h new file mode 100644 index 0000000..920f658 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_locks_decrease_by +#define _TEST__F_thread__thread_locks_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_locks_decrease_by() + */ +extern void test__f_thread_locks_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_locks_decrease_by() + */ +extern void test__f_thread_locks_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_locks_decrease_by() + */ +extern void test__f_thread_locks_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_locks_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_increase.c b/level_0/f_thread/tests/unit/c/test-thread-locks_increase.c new file mode 100644 index 0000000..9863205 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-locks_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_locks_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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); +} + +void test__f_thread_locks_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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_thread_locks_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_thread_locks_increase__works(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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_thread_locks_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_increase.h b/level_0/f_thread/tests/unit/c/test-thread-locks_increase.h new file mode 100644 index 0000000..1f2d879 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_locks_increase +#define _TEST__F_thread__thread_locks_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_locks_increase() + */ +extern void test__f_thread_locks_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_locks_increase() + */ +extern void test__f_thread_locks_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_locks_increase() + */ +extern void test__f_thread_locks_increase__works(void **state); + +#endif // _TEST__F_thread__thread_locks_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.c new file mode 100644 index 0000000..29d428a --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-locks_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_locks_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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); +} + +void test__f_thread_locks_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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_thread_locks_increase_by(0, &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_thread_locks_increase_by__works(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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_thread_locks_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.h new file mode 100644 index 0000000..4121806 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_locks_increase_by +#define _TEST__F_thread__thread_locks_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_locks_increase_by() + */ +extern void test__f_thread_locks_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_locks_increase_by() + */ +extern void test__f_thread_locks_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_locks_increase_by() + */ +extern void test__f_thread_locks_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_locks_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_resize.c b/level_0/f_thread/tests/unit/c/test-thread-locks_resize.c new file mode 100644 index 0000000..195dfdd --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-locks_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_locks_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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); +} + +void test__f_thread_locks_resize__works(void **state) { + + const int length = 5; + f_thread_locks_t data = f_thread_locks_t_initialize; + + { + const f_status_t status = f_thread_locks_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_resize.h b/level_0/f_thread/tests/unit/c/test-thread-locks_resize.h new file mode 100644 index 0000000..f9b4c59 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_locks_resize +#define _TEST__F_thread__thread_locks_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_locks_resize() + */ +extern void test__f_thread_locks_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_locks_resize() + */ +extern void test__f_thread_locks_resize__works(void **state); + +#endif // _TEST__F_thread__thread_locks_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.c new file mode 100644 index 0000000..6cf1b7e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-mutex_attributes_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutex_attributes_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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); +} + +void test__f_thread_mutex_attributes_adjust__works(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.h new file mode 100644 index 0000000..10b2b32 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutex_attributes_adjust +#define _TEST__F_thread__thread_mutex_attributes_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutex_attributes_adjust() + */ +extern void test__f_thread_mutex_attributes_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutex_attributes_adjust() + */ +extern void test__f_thread_mutex_attributes_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_mutex_attributes_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.c new file mode 100644 index 0000000..2db5786 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-mutex_attributes_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutex_attributes_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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); +} + +void test__f_thread_mutex_attributes_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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_thread_mutex_attributes_decimate_by(0, &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_thread_mutex_attributes_decimate_by__works(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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_thread_mutex_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.h new file mode 100644 index 0000000..ecfaaab --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutex_attributes_decimate_by +#define _TEST__F_thread__thread_mutex_attributes_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutex_attributes_decimate_by() + */ +extern void test__f_thread_mutex_attributes_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_mutex_attributes_decimate_by() + */ +extern void test__f_thread_mutex_attributes_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutex_attributes_decimate_by() + */ +extern void test__f_thread_mutex_attributes_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_mutex_attributes_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.c new file mode 100644 index 0000000..9bd8ced --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-mutex_attributes_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutex_attributes_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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); +} + +void test__f_thread_mutex_attributes_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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_thread_mutex_attributes_decrease_by(0, &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_thread_mutex_attributes_decrease_by__works(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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_thread_mutex_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.h new file mode 100644 index 0000000..6020650 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutex_attributes_decrease_by +#define _TEST__F_thread__thread_mutex_attributes_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutex_attributes_decrease_by() + */ +extern void test__f_thread_mutex_attributes_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_mutex_attributes_decrease_by() + */ +extern void test__f_thread_mutex_attributes_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutex_attributes_decrease_by() + */ +extern void test__f_thread_mutex_attributes_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_mutex_attributes_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.c new file mode 100644 index 0000000..daac9e5 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-mutex_attributes_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutex_attributes_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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); +} + +void test__f_thread_mutex_attributes_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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_thread_mutex_attributes_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_thread_mutex_attributes_increase__works(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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_thread_mutex_attributes_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.h new file mode 100644 index 0000000..f4cb0bf --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutex_attributes_increase +#define _TEST__F_thread__thread_mutex_attributes_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutex_attributes_increase() + */ +extern void test__f_thread_mutex_attributes_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_mutex_attributes_increase() + */ +extern void test__f_thread_mutex_attributes_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutex_attributes_increase() + */ +extern void test__f_thread_mutex_attributes_increase__works(void **state); + +#endif // _TEST__F_thread__thread_mutex_attributes_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.c new file mode 100644 index 0000000..3e7725e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-mutex_attributes_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutex_attributes_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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); +} + +void test__f_thread_mutex_attributes_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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_thread_mutex_attributes_increase_by(0, &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_thread_mutex_attributes_increase_by__works(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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_thread_mutex_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.h new file mode 100644 index 0000000..a46b588 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutex_attributes_increase_by +#define _TEST__F_thread__thread_mutex_attributes_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutex_attributes_increase_by() + */ +extern void test__f_thread_mutex_attributes_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_mutex_attributes_increase_by() + */ +extern void test__f_thread_mutex_attributes_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutex_attributes_increase_by() + */ +extern void test__f_thread_mutex_attributes_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_mutex_attributes_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.c new file mode 100644 index 0000000..4d0fc65 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-mutex_attributes_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutex_attributes_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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); +} + +void test__f_thread_mutex_attributes_resize__works(void **state) { + + const int length = 5; + f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; + + { + const f_status_t status = f_thread_mutex_attributes_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.h new file mode 100644 index 0000000..a298c1e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutex_attributes_resize +#define _TEST__F_thread__thread_mutex_attributes_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutex_attributes_resize() + */ +extern void test__f_thread_mutex_attributes_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutex_attributes_resize() + */ +extern void test__f_thread_mutex_attributes_resize__works(void **state); + +#endif // _TEST__F_thread__thread_mutex_attributes_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.c new file mode 100644 index 0000000..5b8d6e6 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-mutexs_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutexs_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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); +} + +void test__f_thread_mutexs_adjust__works(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.h new file mode 100644 index 0000000..f57a193 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutexs_adjust +#define _TEST__F_thread__thread_mutexs_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutexs_adjust() + */ +extern void test__f_thread_mutexs_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutexs_adjust() + */ +extern void test__f_thread_mutexs_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_mutexs_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.c new file mode 100644 index 0000000..b4d0965 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-mutexs_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutexs_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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); +} + +void test__f_thread_mutexs_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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_thread_mutexs_decimate_by(0, &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_thread_mutexs_decimate_by__works(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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_thread_mutexs_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.h new file mode 100644 index 0000000..e016562 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutexs_decimate_by +#define _TEST__F_thread__thread_mutexs_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutexs_decimate_by() + */ +extern void test__f_thread_mutexs_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_mutexs_decimate_by() + */ +extern void test__f_thread_mutexs_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutexs_decimate_by() + */ +extern void test__f_thread_mutexs_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_mutexs_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.c new file mode 100644 index 0000000..8ae2ebb --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-mutexs_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutexs_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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); +} + +void test__f_thread_mutexs_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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_thread_mutexs_decrease_by(0, &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_thread_mutexs_decrease_by__works(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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_thread_mutexs_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.h new file mode 100644 index 0000000..e9fe6dd --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutexs_decrease_by +#define _TEST__F_thread__thread_mutexs_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutexs_decrease_by() + */ +extern void test__f_thread_mutexs_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_mutexs_decrease_by() + */ +extern void test__f_thread_mutexs_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutexs_decrease_by() + */ +extern void test__f_thread_mutexs_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_mutexs_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.c new file mode 100644 index 0000000..af1186e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-mutexs_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutexs_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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); +} + +void test__f_thread_mutexs_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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_thread_mutexs_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_thread_mutexs_increase__works(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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_thread_mutexs_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.h new file mode 100644 index 0000000..e29aaae --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutexs_increase +#define _TEST__F_thread__thread_mutexs_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutexs_increase() + */ +extern void test__f_thread_mutexs_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_mutexs_increase() + */ +extern void test__f_thread_mutexs_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutexs_increase() + */ +extern void test__f_thread_mutexs_increase__works(void **state); + +#endif // _TEST__F_thread__thread_mutexs_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.c new file mode 100644 index 0000000..d5f41d8 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-mutexs_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutexs_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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); +} + +void test__f_thread_mutexs_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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_thread_mutexs_increase_by(0, &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_thread_mutexs_increase_by__works(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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_thread_mutexs_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.h new file mode 100644 index 0000000..10be250 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutexs_increase_by +#define _TEST__F_thread__thread_mutexs_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutexs_increase_by() + */ +extern void test__f_thread_mutexs_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_mutexs_increase_by() + */ +extern void test__f_thread_mutexs_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutexs_increase_by() + */ +extern void test__f_thread_mutexs_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_mutexs_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.c new file mode 100644 index 0000000..1b98c29 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-mutexs_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutexs_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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); +} + +void test__f_thread_mutexs_resize__works(void **state) { + + const int length = 5; + f_thread_mutexs_t data = f_thread_mutexs_t_initialize; + + { + const f_status_t status = f_thread_mutexs_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.h new file mode 100644 index 0000000..97e6b98 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_mutexs_resize +#define _TEST__F_thread__thread_mutexs_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_mutexs_resize() + */ +extern void test__f_thread_mutexs_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutexs_resize() + */ +extern void test__f_thread_mutexs_resize__works(void **state); + +#endif // _TEST__F_thread__thread_mutexs_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.c new file mode 100644 index 0000000..7635ddd --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-onces_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_onces_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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); +} + +void test__f_thread_onces_adjust__works(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.h new file mode 100644 index 0000000..79b9e5c --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_onces_adjust +#define _TEST__F_thread__thread_onces_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_onces_adjust() + */ +extern void test__f_thread_onces_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_onces_adjust() + */ +extern void test__f_thread_onces_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_onces_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.c new file mode 100644 index 0000000..3b8bae4 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-onces_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_onces_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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); +} + +void test__f_thread_onces_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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_thread_onces_decimate_by(0, &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_thread_onces_decimate_by__works(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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_thread_onces_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.h new file mode 100644 index 0000000..648be3d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_onces_decimate_by +#define _TEST__F_thread__thread_onces_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_onces_decimate_by() + */ +extern void test__f_thread_onces_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_onces_decimate_by() + */ +extern void test__f_thread_onces_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_onces_decimate_by() + */ +extern void test__f_thread_onces_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_onces_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.c new file mode 100644 index 0000000..4af8293 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-onces_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_onces_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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); +} + +void test__f_thread_onces_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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_thread_onces_decrease_by(0, &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_thread_onces_decrease_by__works(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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_thread_onces_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.h new file mode 100644 index 0000000..2554c15 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_onces_decrease_by +#define _TEST__F_thread__thread_onces_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_onces_decrease_by() + */ +extern void test__f_thread_onces_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_onces_decrease_by() + */ +extern void test__f_thread_onces_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_onces_decrease_by() + */ +extern void test__f_thread_onces_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_onces_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_increase.c b/level_0/f_thread/tests/unit/c/test-thread-onces_increase.c new file mode 100644 index 0000000..e527b0e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-onces_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_onces_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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); +} + +void test__f_thread_onces_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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_thread_onces_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_thread_onces_increase__works(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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_thread_onces_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_increase.h b/level_0/f_thread/tests/unit/c/test-thread-onces_increase.h new file mode 100644 index 0000000..f29fb31 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_onces_increase +#define _TEST__F_thread__thread_onces_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_onces_increase() + */ +extern void test__f_thread_onces_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_onces_increase() + */ +extern void test__f_thread_onces_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_onces_increase() + */ +extern void test__f_thread_onces_increase__works(void **state); + +#endif // _TEST__F_thread__thread_onces_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.c new file mode 100644 index 0000000..7cc6803 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-onces_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_onces_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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); +} + +void test__f_thread_onces_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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_thread_onces_increase_by(0, &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_thread_onces_increase_by__works(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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_thread_onces_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.h new file mode 100644 index 0000000..28d746e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_onces_increase_by +#define _TEST__F_thread__thread_onces_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_onces_increase_by() + */ +extern void test__f_thread_onces_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_onces_increase_by() + */ +extern void test__f_thread_onces_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_onces_increase_by() + */ +extern void test__f_thread_onces_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_onces_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_resize.c b/level_0/f_thread/tests/unit/c/test-thread-onces_resize.c new file mode 100644 index 0000000..1f7a4d6 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-onces_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_onces_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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); +} + +void test__f_thread_onces_resize__works(void **state) { + + const int length = 5; + f_thread_onces_t data = f_thread_onces_t_initialize; + + { + const f_status_t status = f_thread_onces_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_resize.h b/level_0/f_thread/tests/unit/c/test-thread-onces_resize.h new file mode 100644 index 0000000..bf6df89 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_onces_resize +#define _TEST__F_thread__thread_onces_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_onces_resize() + */ +extern void test__f_thread_onces_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_onces_resize() + */ +extern void test__f_thread_onces_resize__works(void **state); + +#endif // _TEST__F_thread__thread_onces_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.c new file mode 100644 index 0000000..d848ddb --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-semaphores_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_semaphores_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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); +} + +void test__f_thread_semaphores_adjust__works(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.h new file mode 100644 index 0000000..3b6a913 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_semaphores_adjust +#define _TEST__F_thread__thread_semaphores_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_semaphores_adjust() + */ +extern void test__f_thread_semaphores_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_semaphores_adjust() + */ +extern void test__f_thread_semaphores_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_semaphores_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.c new file mode 100644 index 0000000..9e210b9 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-semaphores_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_semaphores_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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); +} + +void test__f_thread_semaphores_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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_thread_semaphores_decimate_by(0, &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_thread_semaphores_decimate_by__works(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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_thread_semaphores_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.h new file mode 100644 index 0000000..916e4bb --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_semaphores_decimate_by +#define _TEST__F_thread__thread_semaphores_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_semaphores_decimate_by() + */ +extern void test__f_thread_semaphores_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_semaphores_decimate_by() + */ +extern void test__f_thread_semaphores_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_semaphores_decimate_by() + */ +extern void test__f_thread_semaphores_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_semaphores_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.c new file mode 100644 index 0000000..78f614e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-semaphores_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_semaphores_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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); +} + +void test__f_thread_semaphores_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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_thread_semaphores_decrease_by(0, &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_thread_semaphores_decrease_by__works(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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_thread_semaphores_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.h new file mode 100644 index 0000000..61d4b9d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_semaphores_decrease_by +#define _TEST__F_thread__thread_semaphores_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_semaphores_decrease_by() + */ +extern void test__f_thread_semaphores_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_semaphores_decrease_by() + */ +extern void test__f_thread_semaphores_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_semaphores_decrease_by() + */ +extern void test__f_thread_semaphores_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_semaphores_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.c new file mode 100644 index 0000000..42a101d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-semaphores_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_semaphores_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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); +} + +void test__f_thread_semaphores_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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_thread_semaphores_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_thread_semaphores_increase__works(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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_thread_semaphores_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.h new file mode 100644 index 0000000..d14df1c --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_semaphores_increase +#define _TEST__F_thread__thread_semaphores_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_semaphores_increase() + */ +extern void test__f_thread_semaphores_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_semaphores_increase() + */ +extern void test__f_thread_semaphores_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_semaphores_increase() + */ +extern void test__f_thread_semaphores_increase__works(void **state); + +#endif // _TEST__F_thread__thread_semaphores_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.c new file mode 100644 index 0000000..1ece24a --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-semaphores_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_semaphores_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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); +} + +void test__f_thread_semaphores_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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_thread_semaphores_increase_by(0, &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_thread_semaphores_increase_by__works(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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_thread_semaphores_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.h new file mode 100644 index 0000000..b143bdf --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_semaphores_increase_by +#define _TEST__F_thread__thread_semaphores_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_semaphores_increase_by() + */ +extern void test__f_thread_semaphores_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_semaphores_increase_by() + */ +extern void test__f_thread_semaphores_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_semaphores_increase_by() + */ +extern void test__f_thread_semaphores_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_semaphores_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.c new file mode 100644 index 0000000..46d4275 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-semaphores_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_semaphores_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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); +} + +void test__f_thread_semaphores_resize__works(void **state) { + + const int length = 5; + f_thread_semaphores_t data = f_thread_semaphores_t_initialize; + + { + const f_status_t status = f_thread_semaphores_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.h new file mode 100644 index 0000000..0696554 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_semaphores_resize +#define _TEST__F_thread__thread_semaphores_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_semaphores_resize() + */ +extern void test__f_thread_semaphores_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_semaphores_resize() + */ +extern void test__f_thread_semaphores_resize__works(void **state); + +#endif // _TEST__F_thread__thread_semaphores_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.c new file mode 100644 index 0000000..9ada163 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-sets_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_sets_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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); +} + +void test__f_thread_sets_adjust__works(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.h new file mode 100644 index 0000000..4f43a88 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_sets_adjust +#define _TEST__F_thread__thread_sets_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_sets_adjust() + */ +extern void test__f_thread_sets_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_sets_adjust() + */ +extern void test__f_thread_sets_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_sets_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.c new file mode 100644 index 0000000..58f5a61 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.c @@ -0,0 +1,78 @@ +#include "test-thread.h" +#include "test-thread-sets_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_sets_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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); +} + +void test__f_thread_sets_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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_thread_sets_decimate_by(0, &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_thread_sets_decimate_by__works(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + for (uint8_t i = 0; i < length; ++i) { + will_return(__wrap_pthread_attr_destroy, false); + } // for + + const f_status_t status = f_thread_sets_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.h new file mode 100644 index 0000000..a2fd3d6 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_sets_decimate_by +#define _TEST__F_thread__thread_sets_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_sets_decimate_by() + */ +extern void test__f_thread_sets_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_sets_decimate_by() + */ +extern void test__f_thread_sets_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_sets_decimate_by() + */ +extern void test__f_thread_sets_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_sets_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.c new file mode 100644 index 0000000..252d4b6 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.c @@ -0,0 +1,78 @@ +#include "test-thread.h" +#include "test-thread-sets_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_sets_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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); +} + +void test__f_thread_sets_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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_thread_sets_decrease_by(0, &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_thread_sets_decrease_by__works(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_resize(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, 0); + assert_int_equal(data.size, length); + } + + { + for (uint8_t i = 0; i < length; ++i) { + will_return(__wrap_pthread_attr_destroy, false); + } // for + + const f_status_t status = f_thread_sets_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.h new file mode 100644 index 0000000..f150cdc --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_sets_decrease_by +#define _TEST__F_thread__thread_sets_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_sets_decrease_by() + */ +extern void test__f_thread_sets_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_sets_decrease_by() + */ +extern void test__f_thread_sets_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_sets_decrease_by() + */ +extern void test__f_thread_sets_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_sets_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_increase.c b/level_0/f_thread/tests/unit/c/test-thread-sets_increase.c new file mode 100644 index 0000000..c06b768 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-sets_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_sets_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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); +} + +void test__f_thread_sets_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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_thread_sets_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_thread_sets_increase__works(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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_thread_sets_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_increase.h b/level_0/f_thread/tests/unit/c/test-thread-sets_increase.h new file mode 100644 index 0000000..83a4afd --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_sets_increase +#define _TEST__F_thread__thread_sets_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_sets_increase() + */ +extern void test__f_thread_sets_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_sets_increase() + */ +extern void test__f_thread_sets_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_sets_increase() + */ +extern void test__f_thread_sets_increase__works(void **state); + +#endif // _TEST__F_thread__thread_sets_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.c new file mode 100644 index 0000000..bea0a6d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-sets_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_sets_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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); +} + +void test__f_thread_sets_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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_thread_sets_increase_by(0, &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_thread_sets_increase_by__works(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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_thread_sets_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.h new file mode 100644 index 0000000..85a2326 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_sets_increase_by +#define _TEST__F_thread__thread_sets_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_sets_increase_by() + */ +extern void test__f_thread_sets_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_sets_increase_by() + */ +extern void test__f_thread_sets_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_sets_increase_by() + */ +extern void test__f_thread_sets_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_sets_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_resize.c b/level_0/f_thread/tests/unit/c/test-thread-sets_resize.c new file mode 100644 index 0000000..e690f5c --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-sets_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_sets_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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); +} + +void test__f_thread_sets_resize__works(void **state) { + + const int length = 5; + f_thread_sets_t data = f_thread_sets_t_initialize; + + { + const f_status_t status = f_thread_sets_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_resize.h b/level_0/f_thread/tests/unit/c/test-thread-sets_resize.h new file mode 100644 index 0000000..a17283c --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_sets_resize +#define _TEST__F_thread__thread_sets_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_sets_resize() + */ +extern void test__f_thread_sets_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_sets_resize() + */ +extern void test__f_thread_sets_resize__works(void **state); + +#endif // _TEST__F_thread__thread_sets_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.c new file mode 100644 index 0000000..b7d39b7 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-spins_adjust.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_spins_adjust__parameter_checking(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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); +} + +void test__f_thread_spins_adjust__works(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.h new file mode 100644 index 0000000..b644eb4 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_spins_adjust +#define _TEST__F_thread__thread_spins_adjust + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_spins_adjust() + */ +extern void test__f_thread_spins_adjust__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_spins_adjust() + */ +extern void test__f_thread_spins_adjust__works(void **state); + +#endif // _TEST__F_thread__thread_spins_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.c new file mode 100644 index 0000000..2c9f451 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-spins_decimate_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_spins_decimate_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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); +} + +void test__f_thread_spins_decimate_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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_thread_spins_decimate_by(0, &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_thread_spins_decimate_by__works(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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_thread_spins_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.h new file mode 100644 index 0000000..9735bfe --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_spins_decimate_by +#define _TEST__F_thread__thread_spins_decimate_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_spins_decimate_by() + */ +extern void test__f_thread_spins_decimate_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_spins_decimate_by() + */ +extern void test__f_thread_spins_decimate_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_spins_decimate_by() + */ +extern void test__f_thread_spins_decimate_by__works(void **state); + +#endif // _TEST__F_thread__thread_spins_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.c new file mode 100644 index 0000000..852e749 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.c @@ -0,0 +1,74 @@ +#include "test-thread.h" +#include "test-thread-spins_decrease_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_spins_decrease_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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); +} + +void test__f_thread_spins_decrease_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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_thread_spins_decrease_by(0, &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_thread_spins_decrease_by__works(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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_thread_spins_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.h new file mode 100644 index 0000000..0cbb9fd --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_spins_decrease_by +#define _TEST__F_thread__thread_spins_decrease_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_spins_decrease_by() + */ +extern void test__f_thread_spins_decrease_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_spins_decrease_by() + */ +extern void test__f_thread_spins_decrease_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_spins_decrease_by() + */ +extern void test__f_thread_spins_decrease_by__works(void **state); + +#endif // _TEST__F_thread__thread_spins_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_increase.c b/level_0/f_thread/tests/unit/c/test-thread-spins_increase.c new file mode 100644 index 0000000..daf465f --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_increase.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-spins_increase.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_spins_increase__parameter_checking(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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); +} + +void test__f_thread_spins_increase__returns_data_not(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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_thread_spins_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_thread_spins_increase__works(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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_thread_spins_increase(length, &data); + + assert_int_equal(status, F_none); + assert_int_equal(data.used, length); + assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); + } + + free((void *) data.array); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_increase.h b/level_0/f_thread/tests/unit/c/test-thread-spins_increase.h new file mode 100644 index 0000000..da50092 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_increase.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_spins_increase +#define _TEST__F_thread__thread_spins_increase + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_spins_increase() + */ +extern void test__f_thread_spins_increase__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_spins_increase() + */ +extern void test__f_thread_spins_increase__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_spins_increase() + */ +extern void test__f_thread_spins_increase__works(void **state); + +#endif // _TEST__F_thread__thread_spins_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.c new file mode 100644 index 0000000..7d404c2 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.c @@ -0,0 +1,76 @@ +#include "test-thread.h" +#include "test-thread-spins_increase_by.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_spins_increase_by__parameter_checking(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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); +} + +void test__f_thread_spins_increase_by__returns_data_not(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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_thread_spins_increase_by(0, &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_thread_spins_increase_by__works(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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_thread_spins_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.h new file mode 100644 index 0000000..5b08f7b --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_spins_increase_by +#define _TEST__F_thread__thread_spins_increase_by + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_spins_increase_by() + */ +extern void test__f_thread_spins_increase_by__parameter_checking(void **state); + +/** + * Test that the function returns F_data_not. + * + * @see f_thread_spins_increase_by() + */ +extern void test__f_thread_spins_increase_by__returns_data_not(void **state); + +/** + * Test that the function works. + * + * @see f_thread_spins_increase_by() + */ +extern void test__f_thread_spins_increase_by__works(void **state); + +#endif // _TEST__F_thread__thread_spins_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_resize.c b/level_0/f_thread/tests/unit/c/test-thread-spins_resize.c new file mode 100644 index 0000000..0d5b60a --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_resize.c @@ -0,0 +1,42 @@ +#include "test-thread.h" +#include "test-thread-spins_resize.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_spins_resize__parameter_checking(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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); +} + +void test__f_thread_spins_resize__works(void **state) { + + const int length = 5; + f_thread_spins_t data = f_thread_spins_t_initialize; + + { + const f_status_t status = f_thread_spins_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); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_resize.h b/level_0/f_thread/tests/unit/c/test-thread-spins_resize.h new file mode 100644 index 0000000..bde71d9 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_resize.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the thread project. + */ +#ifndef _TEST__F_thread__thread_spins_resize +#define _TEST__F_thread__thread_spins_resize + +/** + * Test that the function correctly fails on invalid parameter. + * + * @see f_thread_spins_resize() + */ +extern void test__f_thread_spins_resize__parameter_checking(void **state); + +/** + * Test that the function works. + * + * @see f_thread_spins_resize() + */ +extern void test__f_thread_spins_resize__works(void **state); + +#endif // _TEST__F_thread__thread_spins_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread.c b/level_0/f_thread/tests/unit/c/test-thread.c new file mode 100644 index 0000000..46b7bb7 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread.c @@ -0,0 +1,405 @@ +#include "test-thread.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int setup(void **state) { + + return 0; +} + +int setdown(void **state) { + + errno = 0; + + return 0; +} + +int main(void) { + + const struct CMUnitTest tests[] = { + cmocka_unit_test(test__f_thread_attributes_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_attributes_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_attributes_increase__returns_data_not), + cmocka_unit_test(test__f_thread_attributes_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_attributes_adjust__works), + cmocka_unit_test(test__f_thread_attributes_decimate_by__works), + cmocka_unit_test(test__f_thread_attributes_decrease_by__works), + cmocka_unit_test(test__f_thread_attributes_increase__works), + cmocka_unit_test(test__f_thread_attributes_increase_by__works), + cmocka_unit_test(test__f_thread_attributes_resize__works), + + cmocka_unit_test(test__f_thread_barrier_attributes_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_barrier_attributes_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_barrier_attributes_increase__returns_data_not), + cmocka_unit_test(test__f_thread_barrier_attributes_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_barrier_attributes_adjust__works), + cmocka_unit_test(test__f_thread_barrier_attributes_decimate_by__works), + cmocka_unit_test(test__f_thread_barrier_attributes_decrease_by__works), + cmocka_unit_test(test__f_thread_barrier_attributes_increase__works), + cmocka_unit_test(test__f_thread_barrier_attributes_increase_by__works), + cmocka_unit_test(test__f_thread_barrier_attributes_resize__works), + + cmocka_unit_test(test__f_thread_barriers_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_barriers_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_barriers_increase__returns_data_not), + cmocka_unit_test(test__f_thread_barriers_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_barriers_adjust__works), + cmocka_unit_test(test__f_thread_barriers_decimate_by__works), + cmocka_unit_test(test__f_thread_barriers_decrease_by__works), + cmocka_unit_test(test__f_thread_barriers_increase__works), + cmocka_unit_test(test__f_thread_barriers_increase_by__works), + cmocka_unit_test(test__f_thread_barriers_resize__works), + + cmocka_unit_test(test__f_thread_condition_attributes_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_condition_attributes_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_condition_attributes_increase__returns_data_not), + cmocka_unit_test(test__f_thread_condition_attributes_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_condition_attributes_adjust__works), + cmocka_unit_test(test__f_thread_condition_attributes_decimate_by__works), + cmocka_unit_test(test__f_thread_condition_attributes_decrease_by__works), + cmocka_unit_test(test__f_thread_condition_attributes_increase__works), + cmocka_unit_test(test__f_thread_condition_attributes_increase_by__works), + cmocka_unit_test(test__f_thread_condition_attributes_resize__works), + + cmocka_unit_test(test__f_thread_conditions_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_conditions_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_conditions_increase__returns_data_not), + cmocka_unit_test(test__f_thread_conditions_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_conditions_adjust__works), + cmocka_unit_test(test__f_thread_conditions_decimate_by__works), + cmocka_unit_test(test__f_thread_conditions_decrease_by__works), + cmocka_unit_test(test__f_thread_conditions_increase__works), + cmocka_unit_test(test__f_thread_conditions_increase_by__works), + cmocka_unit_test(test__f_thread_conditions_resize__works), + + cmocka_unit_test(test__f_thread_ids_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_ids_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_ids_increase__returns_data_not), + cmocka_unit_test(test__f_thread_ids_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_ids_adjust__works), + cmocka_unit_test(test__f_thread_ids_decimate_by__works), + cmocka_unit_test(test__f_thread_ids_decrease_by__works), + cmocka_unit_test(test__f_thread_ids_increase__works), + cmocka_unit_test(test__f_thread_ids_increase_by__works), + cmocka_unit_test(test__f_thread_ids_resize__works), + + cmocka_unit_test(test__f_thread_keys_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_keys_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_keys_increase__returns_data_not), + cmocka_unit_test(test__f_thread_keys_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_keys_adjust__works), + cmocka_unit_test(test__f_thread_keys_decimate_by__works), + cmocka_unit_test(test__f_thread_keys_decrease_by__works), + cmocka_unit_test(test__f_thread_keys_increase__works), + cmocka_unit_test(test__f_thread_keys_increase_by__works), + cmocka_unit_test(test__f_thread_keys_resize__works), + + cmocka_unit_test(test__f_thread_lock_attributes_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_lock_attributes_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_lock_attributes_increase__returns_data_not), + cmocka_unit_test(test__f_thread_lock_attributes_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_lock_attributes_adjust__works), + cmocka_unit_test(test__f_thread_lock_attributes_decimate_by__works), + cmocka_unit_test(test__f_thread_lock_attributes_decrease_by__works), + cmocka_unit_test(test__f_thread_lock_attributes_increase__works), + cmocka_unit_test(test__f_thread_lock_attributes_increase_by__works), + cmocka_unit_test(test__f_thread_lock_attributes_resize__works), + + cmocka_unit_test(test__f_thread_locks_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_locks_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_locks_increase__returns_data_not), + cmocka_unit_test(test__f_thread_locks_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_locks_adjust__works), + cmocka_unit_test(test__f_thread_locks_decimate_by__works), + cmocka_unit_test(test__f_thread_locks_decrease_by__works), + cmocka_unit_test(test__f_thread_locks_increase__works), + cmocka_unit_test(test__f_thread_locks_increase_by__works), + cmocka_unit_test(test__f_thread_locks_resize__works), + + cmocka_unit_test(test__f_thread_mutex_attributes_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_mutex_attributes_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_mutex_attributes_increase__returns_data_not), + cmocka_unit_test(test__f_thread_mutex_attributes_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_mutex_attributes_adjust__works), + cmocka_unit_test(test__f_thread_mutex_attributes_decimate_by__works), + cmocka_unit_test(test__f_thread_mutex_attributes_decrease_by__works), + cmocka_unit_test(test__f_thread_mutex_attributes_increase__works), + cmocka_unit_test(test__f_thread_mutex_attributes_increase_by__works), + cmocka_unit_test(test__f_thread_mutex_attributes_resize__works), + + cmocka_unit_test(test__f_thread_mutexs_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_mutexs_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_mutexs_increase__returns_data_not), + cmocka_unit_test(test__f_thread_mutexs_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_mutexs_adjust__works), + cmocka_unit_test(test__f_thread_mutexs_decimate_by__works), + cmocka_unit_test(test__f_thread_mutexs_decrease_by__works), + cmocka_unit_test(test__f_thread_mutexs_increase__works), + cmocka_unit_test(test__f_thread_mutexs_increase_by__works), + cmocka_unit_test(test__f_thread_mutexs_resize__works), + + cmocka_unit_test(test__f_thread_onces_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_onces_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_onces_increase__returns_data_not), + cmocka_unit_test(test__f_thread_onces_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_onces_adjust__works), + cmocka_unit_test(test__f_thread_onces_decimate_by__works), + cmocka_unit_test(test__f_thread_onces_decrease_by__works), + cmocka_unit_test(test__f_thread_onces_increase__works), + cmocka_unit_test(test__f_thread_onces_increase_by__works), + cmocka_unit_test(test__f_thread_onces_resize__works), + + cmocka_unit_test(test__f_thread_semaphores_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_semaphores_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_semaphores_increase__returns_data_not), + cmocka_unit_test(test__f_thread_semaphores_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_semaphores_adjust__works), + cmocka_unit_test(test__f_thread_semaphores_decimate_by__works), + cmocka_unit_test(test__f_thread_semaphores_decrease_by__works), + cmocka_unit_test(test__f_thread_semaphores_increase__works), + cmocka_unit_test(test__f_thread_semaphores_increase_by__works), + cmocka_unit_test(test__f_thread_semaphores_resize__works), + + cmocka_unit_test(test__f_thread_sets_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_sets_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_sets_increase__returns_data_not), + cmocka_unit_test(test__f_thread_sets_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_sets_adjust__works), + cmocka_unit_test(test__f_thread_sets_decimate_by__works), + cmocka_unit_test(test__f_thread_sets_decrease_by__works), + cmocka_unit_test(test__f_thread_sets_increase__works), + cmocka_unit_test(test__f_thread_sets_increase_by__works), + cmocka_unit_test(test__f_thread_sets_resize__works), + + cmocka_unit_test(test__f_thread_spins_decimate_by__returns_data_not), + cmocka_unit_test(test__f_thread_spins_decrease_by__returns_data_not), + cmocka_unit_test(test__f_thread_spins_increase__returns_data_not), + cmocka_unit_test(test__f_thread_spins_increase_by__returns_data_not), + + cmocka_unit_test(test__f_thread_spins_adjust__works), + cmocka_unit_test(test__f_thread_spins_decimate_by__works), + cmocka_unit_test(test__f_thread_spins_decrease_by__works), + cmocka_unit_test(test__f_thread_spins_increase__works), + cmocka_unit_test(test__f_thread_spins_increase_by__works), + cmocka_unit_test(test__f_thread_spins_resize__works), + + cmocka_unit_test(test__f_thread_at_fork__fails), + cmocka_unit_test(test__f_thread_at_fork__works), + + cmocka_unit_test(test__f_thread_attribute_affinity_get__fails), + cmocka_unit_test(test__f_thread_attribute_affinity_get__works), + + cmocka_unit_test(test__f_thread_attribute_affinity_set__fails), + cmocka_unit_test(test__f_thread_attribute_affinity_set__works), + + cmocka_unit_test(test__f_thread_attribute_condition_clock_get__fails), + cmocka_unit_test(test__f_thread_attribute_condition_clock_get__works), + + cmocka_unit_test(test__f_thread_attribute_condition_clock_set__fails), + cmocka_unit_test(test__f_thread_attribute_condition_clock_set__works), + + cmocka_unit_test(test__f_thread_attribute_condition_shared_get__fails), + cmocka_unit_test(test__f_thread_attribute_condition_shared_get__works), + + cmocka_unit_test(test__f_thread_attribute_condition_shared_set__fails), + cmocka_unit_test(test__f_thread_attribute_condition_shared_set__works), + + cmocka_unit_test(test__f_thread_attribute_create__fails), + cmocka_unit_test(test__f_thread_attribute_create__works), + + cmocka_unit_test(test__f_thread_attribute_default_get__fails), + cmocka_unit_test(test__f_thread_attribute_default_get__works), + + cmocka_unit_test(test__f_thread_attribute_default_set__fails), + cmocka_unit_test(test__f_thread_attribute_default_set__works), + + cmocka_unit_test(test__f_thread_attribute_delete__fails), + cmocka_unit_test(test__f_thread_attribute_delete__works), + + cmocka_unit_test(test__f_thread_attribute_detach_get__fails), + cmocka_unit_test(test__f_thread_attribute_detach_get__works), + + cmocka_unit_test(test__f_thread_attribute_detach_set__fails), + cmocka_unit_test(test__f_thread_attribute_detach_set__works), + + cmocka_unit_test(test__f_thread_attribute_guard_get__fails), + cmocka_unit_test(test__f_thread_attribute_guard_get__works), + + cmocka_unit_test(test__f_thread_attribute_guard_set__fails), + cmocka_unit_test(test__f_thread_attribute_guard_set__works), + + cmocka_unit_test(test__f_thread_attribute_scheduler_inherit_get__fails), + cmocka_unit_test(test__f_thread_attribute_scheduler_inherit_get__works), + + cmocka_unit_test(test__f_thread_attribute_scheduler_inherit_set__fails), + cmocka_unit_test(test__f_thread_attribute_scheduler_inherit_set__works), + + cmocka_unit_test(test__f_thread_attribute_scheduler_parameter_get__fails), + cmocka_unit_test(test__f_thread_attribute_scheduler_parameter_get__works), + + cmocka_unit_test(test__f_thread_attribute_scheduler_parameter_set__fails), + cmocka_unit_test(test__f_thread_attribute_scheduler_parameter_set__works), + + #ifndef _di_level_0_parameter_checking_ + cmocka_unit_test(test__f_thread_attributes_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_attributes_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_attributes_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_attributes_increase__parameter_checking), + cmocka_unit_test(test__f_thread_attributes_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_attributes_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_barrier_attributes_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_barrier_attributes_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_barrier_attributes_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_barrier_attributes_increase__parameter_checking), + cmocka_unit_test(test__f_thread_barrier_attributes_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_barrier_attributes_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_barriers_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_barriers_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_barriers_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_barriers_increase__parameter_checking), + cmocka_unit_test(test__f_thread_barriers_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_barriers_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_condition_attributes_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_condition_attributes_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_condition_attributes_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_condition_attributes_increase__parameter_checking), + cmocka_unit_test(test__f_thread_condition_attributes_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_condition_attributes_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_conditions_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_conditions_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_conditions_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_conditions_increase__parameter_checking), + cmocka_unit_test(test__f_thread_conditions_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_conditions_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_ids_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_ids_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_ids_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_ids_increase__parameter_checking), + cmocka_unit_test(test__f_thread_ids_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_ids_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_keys_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_keys_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_keys_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_keys_increase__parameter_checking), + cmocka_unit_test(test__f_thread_keys_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_keys_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_lock_attributes_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_lock_attributes_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_lock_attributes_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_lock_attributes_increase__parameter_checking), + cmocka_unit_test(test__f_thread_lock_attributes_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_lock_attributes_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_locks_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_locks_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_locks_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_locks_increase__parameter_checking), + cmocka_unit_test(test__f_thread_locks_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_locks_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_mutex_attributes_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_mutex_attributes_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_mutex_attributes_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_mutex_attributes_increase__parameter_checking), + cmocka_unit_test(test__f_thread_mutex_attributes_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_mutex_attributes_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_mutexs_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_mutexs_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_mutexs_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_mutexs_increase__parameter_checking), + cmocka_unit_test(test__f_thread_mutexs_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_mutexs_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_onces_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_onces_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_onces_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_onces_increase__parameter_checking), + cmocka_unit_test(test__f_thread_onces_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_onces_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_semaphores_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_semaphores_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_semaphores_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_semaphores_increase__parameter_checking), + cmocka_unit_test(test__f_thread_semaphores_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_semaphores_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_sets_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_sets_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_sets_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_sets_increase__parameter_checking), + cmocka_unit_test(test__f_thread_sets_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_sets_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_spins_adjust__parameter_checking), + cmocka_unit_test(test__f_thread_spins_decimate_by__parameter_checking), + cmocka_unit_test(test__f_thread_spins_decrease_by__parameter_checking), + cmocka_unit_test(test__f_thread_spins_increase__parameter_checking), + cmocka_unit_test(test__f_thread_spins_increase_by__parameter_checking), + cmocka_unit_test(test__f_thread_spins_resize__parameter_checking), + + cmocka_unit_test(test__f_thread_at_fork__parameter_checking), + + cmocka_unit_test(test__f_thread_attribute_affinity_get__parameter_checking), + cmocka_unit_test(test__f_thread_attribute_affinity_set__parameter_checking), + + cmocka_unit_test(test__f_thread_attribute_condition_clock_get__parameter_checking), + cmocka_unit_test(test__f_thread_attribute_condition_clock_set__parameter_checking), + + cmocka_unit_test(test__f_thread_attribute_condition_shared_get__parameter_checking), + cmocka_unit_test(test__f_thread_attribute_condition_shared_set__parameter_checking), + + cmocka_unit_test(test__f_thread_attribute_create__parameter_checking), + + cmocka_unit_test(test__f_thread_attribute_default_get__parameter_checking), + cmocka_unit_test(test__f_thread_attribute_default_set__parameter_checking), + + cmocka_unit_test(test__f_thread_attribute_delete__parameter_checking), + + cmocka_unit_test(test__f_thread_attribute_detach_get__parameter_checking), + cmocka_unit_test(test__f_thread_attribute_detach_set__parameter_checking), + + cmocka_unit_test(test__f_thread_attribute_guard_get__parameter_checking), + cmocka_unit_test(test__f_thread_attribute_guard_set__parameter_checking), + + cmocka_unit_test(test__f_thread_attribute_scheduler_inherit_get__parameter_checking), + cmocka_unit_test(test__f_thread_attribute_scheduler_inherit_set__parameter_checking), + + cmocka_unit_test(test__f_thread_attribute_scheduler_parameter_get__parameter_checking), + cmocka_unit_test(test__f_thread_attribute_scheduler_parameter_set__parameter_checking), + + #endif // _di_level_0_parameter_checking_ + + // f_thread_user_set() doesn't use parameter checking. + }; + + return cmocka_run_group_tests(tests, setup, setdown); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread.h b/level_0/f_thread/tests/unit/c/test-thread.h new file mode 100644 index 0000000..ebef6b4 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread.h @@ -0,0 +1,182 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the thread project. + */ +#ifndef _TEST__F_thread_h +#define _TEST__F_thread_h + +// Libc includes. +#include +#include +#include +#include +#include + +// cmocka includes. +#include + +// FLL-0 includes. +#include + +// Mock includes. +#include "mock-thread.h" + +// Test includes. +#include "test-thread-attributes_adjust.h" +#include "test-thread-attributes_decimate_by.h" +#include "test-thread-attributes_decrease_by.h" +#include "test-thread-attributes_increase.h" +#include "test-thread-attributes_increase_by.h" +#include "test-thread-attributes_resize.h" +#include "test-thread-barriers_adjust.h" +#include "test-thread-barriers_decimate_by.h" +#include "test-thread-barriers_decrease_by.h" +#include "test-thread-barriers_increase.h" +#include "test-thread-barriers_increase_by.h" +#include "test-thread-barriers_resize.h" +#include "test-thread-barrier_attributes_adjust.h" +#include "test-thread-barrier_attributes_decimate_by.h" +#include "test-thread-barrier_attributes_decrease_by.h" +#include "test-thread-barrier_attributes_increase.h" +#include "test-thread-barrier_attributes_increase_by.h" +#include "test-thread-barrier_attributes_resize.h" +#include "test-thread-conditions_adjust.h" +#include "test-thread-conditions_decimate_by.h" +#include "test-thread-conditions_decrease_by.h" +#include "test-thread-conditions_increase.h" +#include "test-thread-conditions_increase_by.h" +#include "test-thread-conditions_resize.h" +#include "test-thread-condition_attributes_adjust.h" +#include "test-thread-condition_attributes_decimate_by.h" +#include "test-thread-condition_attributes_decrease_by.h" +#include "test-thread-condition_attributes_increase.h" +#include "test-thread-condition_attributes_increase_by.h" +#include "test-thread-condition_attributes_resize.h" +#include "test-thread-ids_adjust.h" +#include "test-thread-ids_decimate_by.h" +#include "test-thread-ids_decrease_by.h" +#include "test-thread-ids_increase.h" +#include "test-thread-ids_increase_by.h" +#include "test-thread-ids_resize.h" +#include "test-thread-keys_adjust.h" +#include "test-thread-keys_decimate_by.h" +#include "test-thread-keys_decrease_by.h" +#include "test-thread-keys_increase.h" +#include "test-thread-keys_increase_by.h" +#include "test-thread-keys_resize.h" +#include "test-thread-locks_adjust.h" +#include "test-thread-locks_decimate_by.h" +#include "test-thread-locks_decrease_by.h" +#include "test-thread-locks_increase.h" +#include "test-thread-locks_increase_by.h" +#include "test-thread-locks_resize.h" +#include "test-thread-lock_attributes_adjust.h" +#include "test-thread-lock_attributes_decimate_by.h" +#include "test-thread-lock_attributes_decrease_by.h" +#include "test-thread-lock_attributes_increase.h" +#include "test-thread-lock_attributes_increase_by.h" +#include "test-thread-lock_attributes_resize.h" +#include "test-thread-mutexs_adjust.h" +#include "test-thread-mutexs_decimate_by.h" +#include "test-thread-mutexs_decrease_by.h" +#include "test-thread-mutexs_increase.h" +#include "test-thread-mutexs_increase_by.h" +#include "test-thread-mutexs_resize.h" +#include "test-thread-mutex_attributes_adjust.h" +#include "test-thread-mutex_attributes_decimate_by.h" +#include "test-thread-mutex_attributes_decrease_by.h" +#include "test-thread-mutex_attributes_increase.h" +#include "test-thread-mutex_attributes_increase_by.h" +#include "test-thread-mutex_attributes_resize.h" +#include "test-thread-onces_adjust.h" +#include "test-thread-onces_decimate_by.h" +#include "test-thread-onces_decrease_by.h" +#include "test-thread-onces_increase.h" +#include "test-thread-onces_increase_by.h" +#include "test-thread-onces_resize.h" +#include "test-thread-semaphores_adjust.h" +#include "test-thread-semaphores_decimate_by.h" +#include "test-thread-semaphores_decrease_by.h" +#include "test-thread-semaphores_increase.h" +#include "test-thread-semaphores_increase_by.h" +#include "test-thread-semaphores_resize.h" +#include "test-thread-sets_adjust.h" +#include "test-thread-sets_decimate_by.h" +#include "test-thread-sets_decrease_by.h" +#include "test-thread-sets_increase.h" +#include "test-thread-sets_increase_by.h" +#include "test-thread-sets_resize.h" +#include "test-thread-spins_adjust.h" +#include "test-thread-spins_decimate_by.h" +#include "test-thread-spins_decrease_by.h" +#include "test-thread-spins_increase.h" +#include "test-thread-spins_increase_by.h" +#include "test-thread-spins_resize.h" + +#include "test-thread-at_fork.h" +#include "test-thread-attribute_affinity_get.h" +#include "test-thread-attribute_affinity_set.h" +#include "test-thread-attribute_condition_clock_get.h" +#include "test-thread-attribute_condition_clock_set.h" +#include "test-thread-attribute_condition_shared_get.h" +#include "test-thread-attribute_condition_shared_set.h" +#include "test-thread-attribute_create.h" +#include "test-thread-attribute_default_get.h" +#include "test-thread-attribute_default_set.h" +#include "test-thread-attribute_delete.h" +#include "test-thread-attribute_detach_get.h" +#include "test-thread-attribute_detach_set.h" +#include "test-thread-attribute_guard_get.h" +#include "test-thread-attribute_guard_set.h" +#include "test-thread-attribute_scheduler_inherit_get.h" +#include "test-thread-attribute_scheduler_inherit_set.h" +#include "test-thread-attribute_scheduler_parameter_get.h" +#include "test-thread-attribute_scheduler_parameter_set.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_thread_h -- 1.8.3.1