From 008b334d44a9a8556ef6ff5c74d11ee1078bdd20 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 28 May 2022 22:27:44 -0500 Subject: [PATCH] Update: Add unit tests for f_print. I opted to perform the bare minimum needed tests due to the size of this. Eventually I need to check to see that the correct characters are printed. --- level_0/f_print/data/build/dependencies-tests | 3 + level_0/f_print/data/build/settings-mocks | 64 +++ level_0/f_print/data/build/settings-tests | 73 ++++ level_0/f_print/data/build/testfile | 55 +++ level_0/f_print/tests/unit/c/mock-print.c | 35 ++ level_0/f_print/tests/unit/c/mock-print.h | 40 ++ level_0/f_print/tests/unit/c/test-print-.c | 72 ++++ level_0/f_print/tests/unit/c/test-print-.h | 41 ++ .../f_print/tests/unit/c/test-print-character.c | 47 +++ .../f_print/tests/unit/c/test-print-character.h | 34 ++ .../tests/unit/c/test-print-character_safely.c | 110 +++++ .../tests/unit/c/test-print-character_safely.h | 41 ++ .../tests/unit/c/test-print-character_safely_get.c | 68 ++++ .../tests/unit/c/test-print-character_safely_get.h | 41 ++ level_0/f_print/tests/unit/c/test-print-dynamic.c | 58 +++ level_0/f_print/tests/unit/c/test-print-dynamic.h | 41 ++ .../tests/unit/c/test-print-dynamic_partial.c | 63 +++ .../tests/unit/c/test-print-dynamic_partial.h | 41 ++ .../tests/unit/c/test-print-dynamic_partial_raw.c | 63 +++ .../tests/unit/c/test-print-dynamic_partial_raw.h | 41 ++ .../unit/c/test-print-dynamic_partial_raw_safely.c | 63 +++ .../unit/c/test-print-dynamic_partial_raw_safely.h | 41 ++ .../unit/c/test-print-dynamic_partial_safely.c | 63 +++ .../unit/c/test-print-dynamic_partial_safely.h | 41 ++ .../f_print/tests/unit/c/test-print-dynamic_raw.c | 58 +++ .../f_print/tests/unit/c/test-print-dynamic_raw.h | 41 ++ .../tests/unit/c/test-print-dynamic_raw_safely.c | 58 +++ .../tests/unit/c/test-print-dynamic_raw_safely.h | 41 ++ .../tests/unit/c/test-print-dynamic_safely.c | 58 +++ .../tests/unit/c/test-print-dynamic_safely.h | 41 ++ level_0/f_print/tests/unit/c/test-print-except.c | 100 +++++ level_0/f_print/tests/unit/c/test-print-except.h | 41 ++ .../tests/unit/c/test-print-except_dynamic.c | 76 ++++ .../tests/unit/c/test-print-except_dynamic.h | 41 ++ .../unit/c/test-print-except_dynamic_partial.c | 80 ++++ .../unit/c/test-print-except_dynamic_partial.h | 41 ++ .../unit/c/test-print-except_dynamic_partial_raw.c | 80 ++++ .../unit/c/test-print-except_dynamic_partial_raw.h | 41 ++ .../test-print-except_dynamic_partial_raw_safely.c | 80 ++++ .../test-print-except_dynamic_partial_raw_safely.h | 41 ++ .../c/test-print-except_dynamic_partial_safely.c | 80 ++++ .../c/test-print-except_dynamic_partial_safely.h | 41 ++ .../tests/unit/c/test-print-except_dynamic_raw.c | 76 ++++ .../tests/unit/c/test-print-except_dynamic_raw.h | 41 ++ .../unit/c/test-print-except_dynamic_raw_safely.c | 76 ++++ .../unit/c/test-print-except_dynamic_raw_safely.h | 41 ++ .../unit/c/test-print-except_dynamic_safely.c | 76 ++++ .../unit/c/test-print-except_dynamic_safely.h | 41 ++ .../f_print/tests/unit/c/test-print-except_in.c | 109 +++++ .../f_print/tests/unit/c/test-print-except_in.h | 41 ++ .../tests/unit/c/test-print-except_in_dynamic.c | 84 ++++ .../tests/unit/c/test-print-except_in_dynamic.h | 41 ++ .../unit/c/test-print-except_in_dynamic_partial.c | 88 ++++ .../unit/c/test-print-except_in_dynamic_partial.h | 41 ++ .../c/test-print-except_in_dynamic_partial_raw.c | 88 ++++ .../c/test-print-except_in_dynamic_partial_raw.h | 41 ++ ...st-print-except_in_dynamic_partial_raw_safely.c | 88 ++++ ...st-print-except_in_dynamic_partial_raw_safely.h | 41 ++ .../test-print-except_in_dynamic_partial_safely.c | 88 ++++ .../test-print-except_in_dynamic_partial_safely.h | 41 ++ .../unit/c/test-print-except_in_dynamic_raw.c | 84 ++++ .../unit/c/test-print-except_in_dynamic_raw.h | 41 ++ .../c/test-print-except_in_dynamic_raw_safely.c | 84 ++++ .../c/test-print-except_in_dynamic_raw_safely.h | 41 ++ .../unit/c/test-print-except_in_dynamic_safely.c | 84 ++++ .../unit/c/test-print-except_in_dynamic_safely.h | 41 ++ .../tests/unit/c/test-print-except_in_raw.c | 109 +++++ .../tests/unit/c/test-print-except_in_raw.h | 41 ++ .../tests/unit/c/test-print-except_in_raw_safely.c | 109 +++++ .../tests/unit/c/test-print-except_in_raw_safely.h | 41 ++ .../tests/unit/c/test-print-except_in_safely.c | 109 +++++ .../tests/unit/c/test-print-except_in_safely.h | 41 ++ .../f_print/tests/unit/c/test-print-except_raw.c | 100 +++++ .../f_print/tests/unit/c/test-print-except_raw.h | 41 ++ .../tests/unit/c/test-print-except_raw_safely.c | 100 +++++ .../tests/unit/c/test-print-except_raw_safely.h | 41 ++ .../tests/unit/c/test-print-except_safely.c | 100 +++++ .../tests/unit/c/test-print-except_safely.h | 41 ++ level_0/f_print/tests/unit/c/test-print-raw.c | 72 ++++ level_0/f_print/tests/unit/c/test-print-raw.h | 41 ++ .../f_print/tests/unit/c/test-print-raw_safely.c | 72 ++++ .../f_print/tests/unit/c/test-print-raw_safely.h | 41 ++ .../tests/unit/c/test-print-raw_terminated.c | 58 +++ .../tests/unit/c/test-print-raw_terminated.h | 41 ++ level_0/f_print/tests/unit/c/test-print-safely.c | 72 ++++ level_0/f_print/tests/unit/c/test-print-safely.h | 41 ++ .../f_print/tests/unit/c/test-print-safely_get.c | 72 ++++ .../f_print/tests/unit/c/test-print-safely_get.h | 41 ++ .../tests/unit/c/test-print-safely_terminated.c | 58 +++ .../tests/unit/c/test-print-safely_terminated.h | 41 ++ .../f_print/tests/unit/c/test-print-terminated.c | 58 +++ .../f_print/tests/unit/c/test-print-terminated.h | 41 ++ level_0/f_print/tests/unit/c/test-print-to.c | 107 +++++ level_0/f_print/tests/unit/c/test-print-to.h | 41 ++ .../f_print/tests/unit/c/test-print-to_character.c | 84 ++++ .../f_print/tests/unit/c/test-print-to_character.h | 34 ++ .../tests/unit/c/test-print-to_character_safely.c | 158 ++++++++ .../tests/unit/c/test-print-to_character_safely.h | 41 ++ .../f_print/tests/unit/c/test-print-to_dynamic.c | 93 +++++ .../f_print/tests/unit/c/test-print-to_dynamic.h | 41 ++ .../tests/unit/c/test-print-to_dynamic_partial.c | 98 +++++ .../tests/unit/c/test-print-to_dynamic_partial.h | 41 ++ .../unit/c/test-print-to_dynamic_partial_raw.c | 98 +++++ .../unit/c/test-print-to_dynamic_partial_raw.h | 41 ++ .../c/test-print-to_dynamic_partial_raw_safely.c | 98 +++++ .../c/test-print-to_dynamic_partial_raw_safely.h | 41 ++ .../unit/c/test-print-to_dynamic_partial_safely.c | 98 +++++ .../unit/c/test-print-to_dynamic_partial_safely.h | 41 ++ .../tests/unit/c/test-print-to_dynamic_raw.c | 93 +++++ .../tests/unit/c/test-print-to_dynamic_raw.h | 41 ++ .../unit/c/test-print-to_dynamic_raw_safely.c | 93 +++++ .../unit/c/test-print-to_dynamic_raw_safely.h | 41 ++ .../tests/unit/c/test-print-to_dynamic_safely.c | 93 +++++ .../tests/unit/c/test-print-to_dynamic_safely.h | 41 ++ .../f_print/tests/unit/c/test-print-to_except.c | 135 ++++++ .../f_print/tests/unit/c/test-print-to_except.h | 41 ++ .../tests/unit/c/test-print-to_except_dynamic.c | 111 +++++ .../tests/unit/c/test-print-to_except_dynamic.h | 41 ++ .../unit/c/test-print-to_except_dynamic_partial.c | 115 ++++++ .../unit/c/test-print-to_except_dynamic_partial.h | 41 ++ .../c/test-print-to_except_dynamic_partial_raw.c | 115 ++++++ .../c/test-print-to_except_dynamic_partial_raw.h | 41 ++ ...st-print-to_except_dynamic_partial_raw_safely.c | 115 ++++++ ...st-print-to_except_dynamic_partial_raw_safely.h | 41 ++ .../test-print-to_except_dynamic_partial_safely.c | 115 ++++++ .../test-print-to_except_dynamic_partial_safely.h | 41 ++ .../unit/c/test-print-to_except_dynamic_raw.c | 111 +++++ .../unit/c/test-print-to_except_dynamic_raw.h | 41 ++ .../c/test-print-to_except_dynamic_raw_safely.c | 111 +++++ .../c/test-print-to_except_dynamic_raw_safely.h | 41 ++ .../unit/c/test-print-to_except_dynamic_safely.c | 111 +++++ .../unit/c/test-print-to_except_dynamic_safely.h | 41 ++ .../f_print/tests/unit/c/test-print-to_except_in.c | 144 +++++++ .../f_print/tests/unit/c/test-print-to_except_in.h | 41 ++ .../tests/unit/c/test-print-to_except_in_dynamic.c | 119 ++++++ .../tests/unit/c/test-print-to_except_in_dynamic.h | 41 ++ .../c/test-print-to_except_in_dynamic_partial.c | 123 ++++++ .../c/test-print-to_except_in_dynamic_partial.h | 41 ++ .../test-print-to_except_in_dynamic_partial_raw.c | 123 ++++++ .../test-print-to_except_in_dynamic_partial_raw.h | 41 ++ ...print-to_except_in_dynamic_partial_raw_safely.c | 123 ++++++ ...print-to_except_in_dynamic_partial_raw_safely.h | 41 ++ ...est-print-to_except_in_dynamic_partial_safely.c | 123 ++++++ ...est-print-to_except_in_dynamic_partial_safely.h | 41 ++ .../unit/c/test-print-to_except_in_dynamic_raw.c | 119 ++++++ .../unit/c/test-print-to_except_in_dynamic_raw.h | 41 ++ .../c/test-print-to_except_in_dynamic_raw_safely.c | 119 ++++++ .../c/test-print-to_except_in_dynamic_raw_safely.h | 41 ++ .../c/test-print-to_except_in_dynamic_safely.c | 119 ++++++ .../c/test-print-to_except_in_dynamic_safely.h | 41 ++ .../tests/unit/c/test-print-to_except_in_raw.c | 144 +++++++ .../tests/unit/c/test-print-to_except_in_raw.h | 41 ++ .../unit/c/test-print-to_except_in_raw_safely.c | 144 +++++++ .../unit/c/test-print-to_except_in_raw_safely.h | 41 ++ .../tests/unit/c/test-print-to_except_in_safely.c | 144 +++++++ .../tests/unit/c/test-print-to_except_in_safely.h | 41 ++ .../tests/unit/c/test-print-to_except_raw.c | 135 ++++++ .../tests/unit/c/test-print-to_except_raw.h | 41 ++ .../tests/unit/c/test-print-to_except_raw_safely.c | 135 ++++++ .../tests/unit/c/test-print-to_except_raw_safely.h | 41 ++ .../tests/unit/c/test-print-to_except_safely.c | 135 ++++++ .../tests/unit/c/test-print-to_except_safely.h | 41 ++ level_0/f_print/tests/unit/c/test-print-to_raw.c | 110 +++++ level_0/f_print/tests/unit/c/test-print-to_raw.h | 41 ++ .../tests/unit/c/test-print-to_raw_safely.c | 107 +++++ .../tests/unit/c/test-print-to_raw_safely.h | 41 ++ .../tests/unit/c/test-print-to_raw_terminated.c | 93 +++++ .../tests/unit/c/test-print-to_raw_terminated.h | 41 ++ .../f_print/tests/unit/c/test-print-to_safely.c | 107 +++++ .../f_print/tests/unit/c/test-print-to_safely.h | 41 ++ .../tests/unit/c/test-print-to_safely_terminated.c | 93 +++++ .../tests/unit/c/test-print-to_safely_terminated.h | 41 ++ .../tests/unit/c/test-print-to_terminated.c | 93 +++++ .../tests/unit/c/test-print-to_terminated.h | 41 ++ level_0/f_print/tests/unit/c/test-print.c | 451 +++++++++++++++++++++ level_0/f_print/tests/unit/c/test-print.h | 155 +++++++ 176 files changed, 12401 insertions(+) create mode 100644 level_0/f_print/data/build/dependencies-tests create mode 100644 level_0/f_print/data/build/settings-mocks create mode 100644 level_0/f_print/data/build/settings-tests create mode 100644 level_0/f_print/data/build/testfile create mode 100644 level_0/f_print/tests/unit/c/mock-print.c create mode 100644 level_0/f_print/tests/unit/c/mock-print.h create mode 100644 level_0/f_print/tests/unit/c/test-print-.c create mode 100644 level_0/f_print/tests/unit/c/test-print-.h create mode 100644 level_0/f_print/tests/unit/c/test-print-character.c create mode 100644 level_0/f_print/tests/unit/c/test-print-character.h create mode 100644 level_0/f_print/tests/unit/c/test-print-character_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-character_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-character_safely_get.c create mode 100644 level_0/f_print/tests/unit/c/test-print-character_safely_get.h create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic.c create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic.h create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_partial.c create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_partial.h create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_partial_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_partial_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-dynamic_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_partial.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_partial.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_dynamic_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_dynamic_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_in_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-except_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-except_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-raw_terminated.c create mode 100644 level_0/f_print/tests/unit/c/test-print-raw_terminated.h create mode 100644 level_0/f_print/tests/unit/c/test-print-safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-safely_get.c create mode 100644 level_0/f_print/tests/unit/c/test-print-safely_get.h create mode 100644 level_0/f_print/tests/unit/c/test-print-safely_terminated.c create mode 100644 level_0/f_print/tests/unit/c/test-print-safely_terminated.h create mode 100644 level_0/f_print/tests/unit/c/test-print-terminated.c create mode 100644 level_0/f_print/tests/unit/c/test-print-terminated.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_character.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_character.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_character_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_character_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_partial.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_partial.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_dynamic_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_dynamic_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_in_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_except_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_raw.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_raw.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_raw_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_raw_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_raw_terminated.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_raw_terminated.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_safely.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_safely.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_safely_terminated.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_safely_terminated.h create mode 100644 level_0/f_print/tests/unit/c/test-print-to_terminated.c create mode 100644 level_0/f_print/tests/unit/c/test-print-to_terminated.h create mode 100644 level_0/f_print/tests/unit/c/test-print.c create mode 100644 level_0/f_print/tests/unit/c/test-print.h diff --git a/level_0/f_print/data/build/dependencies-tests b/level_0/f_print/data/build/dependencies-tests new file mode 100644 index 0000000..dea3179 --- /dev/null +++ b/level_0/f_print/data/build/dependencies-tests @@ -0,0 +1,3 @@ +# fss-0001 + +cmocka 1.* diff --git a/level_0/f_print/data/build/settings-mocks b/level_0/f_print/data/build/settings-mocks new file mode 100644 index 0000000..f52d1a5 --- /dev/null +++ b/level_0/f_print/data/build/settings-mocks @@ -0,0 +1,64 @@ +# 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_print + +version_major 0 +version_minor 5 +version_micro 9 +version_file micro +version_target minor + +modes individual clang test coverage +modes_default individual + +build_compiler gcc +build_compiler-clang clang +build_indexer ar +build_indexer_arguments rcs +build_language c + +build_libraries -lc +build_libraries-individual -lf_memory -lf_string -lf_utf + +build_sources_library print.c private-print.c print/common.c print/to.c print/private-to.c ../../tests/unit/c/mock-print.c + +build_sources_headers print.h print/common.h print/to.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 + +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=clearerr_unlocked +flags -Wl,--wrap=ferror_unlocked +flags -Wl,--wrap=fwrite_unlocked +flags -Wl,--wrap=write diff --git a/level_0/f_print/data/build/settings-tests b/level_0/f_print/data/build/settings-tests new file mode 100644 index 0000000..3a01c8c --- /dev/null +++ b/level_0/f_print/data/build/settings-tests @@ -0,0 +1,73 @@ +# 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_print + +version_major 0 +version_minor 5 +version_micro 9 +version_file major +version_target major + +modes individual clang test coverage +modes_default individual + +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_type_array -lf_print -lf_utf + +build_sources_program test-print-.c +build_sources_program test-print-character.c test-print-character_safely.c test-print-character_safely_get.c +build_sources_program test-print-dynamic.c test-print-dynamic_partial.c test-print-dynamic_partial_raw.c test-print-dynamic_partial_raw_safely.c test-print-dynamic_partial_safely.c test-print-dynamic_raw.c test-print-dynamic_raw_safely.c test-print-dynamic_safely.c +build_sources_program test-print-except_dynamic.c test-print-except_dynamic_partial.c test-print-except_dynamic_partial_raw.c test-print-except_dynamic_partial_raw_safely.c test-print-except_dynamic_partial_safely.c test-print-except_dynamic_raw.c test-print-except_dynamic_raw_safely.c test-print-except_dynamic_safely.c +build_sources_program test-print-except_in_dynamic.c test-print-except_in_dynamic_partial.c test-print-except_in_dynamic_partial_raw.c test-print-except_in_dynamic_partial_raw_safely.c test-print-except_in_dynamic_partial_safely.c test-print-except_in_dynamic_raw.c test-print-except_in_dynamic_raw_safely.c test-print-except_in_dynamic_safely.c +build_sources_program test-print-except.c test-print-except_in.c test-print-except_in_raw.c test-print-except_in_raw_safely.c test-print-except_in_safely.c +build_sources_program test-print-except_raw.c test-print-except_raw_safely.c test-print-except_safely.c +build_sources_program test-print-raw.c test-print-raw_safely.c test-print-raw_terminated.c +build_sources_program test-print-safely.c test-print-safely_get.c test-print-safely_terminated.c +build_sources_program test-print-terminated.c +build_sources_program test-print-to.c +build_sources_program test-print-to_character.c test-print-to_character_safely.c +build_sources_program test-print-to_dynamic.c test-print-to_dynamic_partial.c test-print-to_dynamic_partial_raw.c test-print-to_dynamic_partial_raw_safely.c test-print-to_dynamic_partial_safely.c test-print-to_dynamic_raw.c test-print-to_dynamic_raw_safely.c test-print-to_dynamic_safely.c +build_sources_program test-print-to_except_dynamic.c test-print-to_except_dynamic_partial.c test-print-to_except_dynamic_partial_raw.c test-print-to_except_dynamic_partial_raw_safely.c test-print-to_except_dynamic_partial_safely.c test-print-to_except_dynamic_raw.c test-print-to_except_dynamic_raw_safely.c test-print-to_except_dynamic_safely.c +build_sources_program test-print-to_except_in_dynamic.c test-print-to_except_in_dynamic_partial.c test-print-to_except_in_dynamic_partial_raw.c test-print-to_except_in_dynamic_partial_raw_safely.c test-print-to_except_in_dynamic_partial_safely.c test-print-to_except_in_dynamic_raw.c test-print-to_except_in_dynamic_raw_safely.c test-print-to_except_in_dynamic_safely.c +build_sources_program test-print-to_except.c test-print-to_except_in.c test-print-to_except_in_raw.c test-print-to_except_in_raw_safely.c test-print-to_except_in_safely.c +build_sources_program test-print-to_except_raw.c test-print-to_except_raw_safely.c test-print-to_except_safely.c +build_sources_program test-print-to_raw.c test-print-to_raw_safely.c test-print-to_raw_terminated.c +build_sources_program test-print-to_safely.c test-print-to_safely_terminated.c +build_sources_program test-print-to_terminated.c +build_sources_program test-print.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 -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_print/data/build/testfile b/level_0/f_print/data/build/testfile new file mode 100644 index 0000000..080e7a8 --- /dev/null +++ b/level_0/f_print/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 + build settings-tests + + operate ld_library_path + + if exists build/programs/shared/test-f_print + shell build/programs/shared/test-f_print + + if exists build/programs/static/test-f_print + shell build/programs/static/test-f_print + + if not exists build/programs/shared/test-f_print + and not exists build/programs/static/test-f_print + 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_print/tests/unit/c/mock-print.c b/level_0/f_print/tests/unit/c/mock-print.c new file mode 100644 index 0000000..0092af6 --- /dev/null +++ b/level_0/f_print/tests/unit/c/mock-print.c @@ -0,0 +1,35 @@ +#include "mock-print.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void __wrap_clearerr_unlocked(FILE *stream) { +} + +int __wrap_ferror_unlocked(FILE *stream) { + + return mock_type(int); +} + +size_t __wrap_fwrite_unlocked(const void *ptr, size_t size, size_t n, FILE *stream) { + + return mock_type(size_t); +} + +ssize_t __wrap_write(int fd, const void *buf, size_t count) { + + const bool failure = mock_type(bool); + + if (failure) { + errno = mock_type(int); + + return -1; + } + + return mock_type(ssize_t); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/mock-print.h b/level_0/f_print/tests/unit/c/mock-print.h new file mode 100644 index 0000000..e25c331 --- /dev/null +++ b/level_0/f_print/tests/unit/c/mock-print.h @@ -0,0 +1,40 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _MOCK__print_h +#define _MOCK__print_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 void __wrap_clearerr_unlocked(FILE *stream); +extern int __wrap_ferror_unlocked(FILE *stream); +extern size_t __wrap_fwrite_unlocked(const void *ptr, size_t size, size_t n, FILE *stream); +extern ssize_t __wrap_write(int fd, const void *buf, size_t count); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _MOCK__print_h diff --git a/level_0/f_print/tests/unit/c/test-print-.c b/level_0/f_print/tests/unit/c/test-print-.c new file mode 100644 index 0000000..c122949 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-.c @@ -0,0 +1,72 @@ +#include "test-print.h" +#include "test-print-.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print(test.string, test.used, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print(test.string, test.used, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print(f_string_empty_s.string, f_string_empty_s.used, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print(test.string, f_string_empty_s.used, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print(0, test.used, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print(test.string, test.used, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-.h b/level_0/f_print/tests/unit/c/test-print-.h new file mode 100644 index 0000000..395cdf8 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print__h +#define _TEST__F_print__h + +/** + * Test that function fails. + * + * @see f_print() + */ +extern void test__f_print__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print() + */ +extern void test__f_print__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print() + */ +extern void test__f_print__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print() + */ +extern void test__f_print__works(void **state); + +#endif // _TEST__F_print__h diff --git a/level_0/f_print/tests/unit/c/test-print-character.c b/level_0/f_print/tests/unit/c/test-print-character.c new file mode 100644 index 0000000..9334f70 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-character.c @@ -0,0 +1,47 @@ +#include "test-print.h" +#include "test-print-character.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_character__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + + const f_status_t status = f_print_character(test.string[0], stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_character__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_character(test.string[0], 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_character__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 1); + + const f_status_t status = f_print_character(test.string[0], stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-character.h b/level_0/f_print/tests/unit/c/test-print-character.h new file mode 100644 index 0000000..8bf9b93 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-character.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_character_h +#define _TEST__F_print_character_h + +/** + * Test that function fails. + * + * @see f_print_character() + */ +extern void test__f_print_character__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_character() + */ +extern void test__f_print_character__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_print_character() + */ +extern void test__f_print_character__works(void **state); + +#endif // _TEST__F_print_character_h diff --git a/level_0/f_print/tests/unit/c/test-print-character_safely.c b/level_0/f_print/tests/unit/c/test-print-character_safely.c new file mode 100644 index 0000000..d96db2d --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-character_safely.c @@ -0,0 +1,110 @@ +#include "test-print.h" +#include "test-print-character_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_character_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + + const f_status_t status = f_print_character_safely(test.string[0], stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } + + { + will_return(__wrap_fwrite_unlocked, 0); + + const f_status_t status = f_print_character_safely((f_char_t) 0x7f, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } + + { + will_return(__wrap_fwrite_unlocked, 0); + + const f_status_t status = f_print_character_safely((f_char_t) F_utf_byte_1_d, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } + + { + const f_string_static_t alternate = macro_f_string_static_t_initialize("蠇", 0, 2); + + will_return(__wrap_fwrite_unlocked, 0); + + const f_status_t status = f_print_character_safely(alternate.string[0], stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } + + { + will_return(__wrap_fwrite_unlocked, 0); + + const f_status_t status = f_print_character_safely(test.string[0], stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_character_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_character_safely(test.string[0], 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_character_safely__returns_utf(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("蠇", 0, 2); + + { + will_return(__wrap_fwrite_unlocked, 1); + + const f_status_t status = f_print_character_safely(test.string[0], stdout); + + assert_int_equal(status, F_utf); + } +} + +void test__f_print_character_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, f_print_sequence_delete_s.used); + + const f_status_t status = f_print_character_safely((f_char_t) 0x7f, stdout); + + assert_int_equal(status, F_none); + } + + { + will_return(__wrap_fwrite_unlocked, f_print_sequence_unknown_s.used); + + const f_status_t status = f_print_character_safely((f_char_t) F_utf_byte_1_d, stdout); + + assert_int_equal(status, F_none); + } + + { + will_return(__wrap_fwrite_unlocked, 1); + + const f_status_t status = f_print_character_safely(test.string[0], stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-character_safely.h b/level_0/f_print/tests/unit/c/test-print-character_safely.h new file mode 100644 index 0000000..70f70e6 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-character_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_character_safely_h +#define _TEST__F_print_character_safely_h + +/** + * Test that function fails. + * + * @see f_print_character_safely() + */ +extern void test__f_print_character_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_character_safely() + */ +extern void test__f_print_character_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_utf. + * + * @see f_print_character_safely() + */ +extern void test__f_print_character_safely__returns_utf(void **state); + +/** + * Test that function works. + * + * @see f_print_character_safely() + */ +extern void test__f_print_character_safely__works(void **state); + +#endif // _TEST__F_print_character_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-character_safely_get.c b/level_0/f_print/tests/unit/c/test-print-character_safely_get.c new file mode 100644 index 0000000..e3d6545 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-character_safely_get.c @@ -0,0 +1,68 @@ +#include "test-print.h" +#include "test-print-character_safely_get.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_character_safely_get__returns_character_control(void **state) { + + for (uint8_t i = 0; i < 32 ; ++i) { + + const f_char_t character = (f_char_t) i; + + const f_string_static_t safe = f_print_character_safely_get(character); + + assert_int_equal(safe.used, f_print_sequence_set_control_s[i].used); + assert_string_equal(safe.string, f_print_sequence_set_control_s[i].string); + } // for +} + +void test__f_print_character_safely_get__returns_character_delete(void **state) { + + const f_char_t character = (f_char_t) 0x7f; + + { + const f_string_static_t safe = f_print_character_safely_get(character); + + assert_int_equal(safe.used, f_print_sequence_delete_s.used); + assert_string_equal(safe.string, f_print_sequence_delete_s.string); + } +} + +void test__f_print_character_safely_get__returns_character_unknown(void **state) { + + const f_char_t character = (f_char_t) F_utf_byte_1_d; + + { + const f_string_static_t safe = f_print_character_safely_get(character); + + assert_int_equal(safe.used, f_print_sequence_unknown_s.used); + assert_string_equal(safe.string, f_print_sequence_unknown_s.string); + } +} + +void test__f_print_character_safely_get__returns_empty(void **state) { + + { + const f_char_t character = 'a'; + + const f_string_static_t safe = f_print_character_safely_get(character); + + assert_int_equal(safe.used, f_string_empty_s.used); + assert_string_equal(safe.string, f_string_empty_s.string); + } + + { + const f_string_t string = "蠇"; + + const f_string_static_t safe = f_print_character_safely_get(string[0]); + + assert_int_equal(safe.used, f_string_empty_s.used); + assert_string_equal(safe.string, f_string_empty_s.string); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-character_safely_get.h b/level_0/f_print/tests/unit/c/test-print-character_safely_get.h new file mode 100644 index 0000000..cfca344 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-character_safely_get.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_character_safely_get_h +#define _TEST__F_print_character_safely_get_h + +/** + * Test that function works but returns a control character safe alternative. + * + * @see f_print_character_safely_get() + */ +extern void test__f_print_character_safely_get__returns_character_control(void **state); + +/** + * Test that function works but returns a delete character safe alternative. + * + * @see f_print_character_safely_get() + */ +extern void test__f_print_character_safely_get__returns_character_delete(void **state); + +/** + * Test that function works but returns a unknown character safe alternative. + * + * @see f_print_character_safely_get() + */ +extern void test__f_print_character_safely_get__returns_character_unknown(void **state); + +/** + * Test that function works but returns an empty string. + * + * @see f_print_character_safely_get() + */ +extern void test__f_print_character_safely_get__returns_empty(void **state); + +#endif // _TEST__F_print_character_safely_get_h diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic.c b/level_0/f_print/tests/unit/c/test-print-dynamic.c new file mode 100644 index 0000000..21a684a --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic.c @@ -0,0 +1,58 @@ +#include "test-print.h" +#include "test-print-dynamic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_dynamic__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_dynamic(test, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_dynamic__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_dynamic(test, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_dynamic__returns_data_not(void **state) { + + { + const f_status_t status = f_print_dynamic(f_string_empty_s, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_dynamic__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_dynamic(test, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic.h b/level_0/f_print/tests/unit/c/test-print-dynamic.h new file mode 100644 index 0000000..90969d7 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_dynamic_h +#define _TEST__F_print_dynamic_h + +/** + * Test that function fails. + * + * @see f_print_dynamic() + */ +extern void test__f_print_dynamic__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_dynamic() + */ +extern void test__f_print_dynamic__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_dynamic() + */ +extern void test__f_print_dynamic__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_dynamic() + */ +extern void test__f_print_dynamic__works(void **state); + +#endif // _TEST__F_print_dynamic_h diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_partial.c b/level_0/f_print/tests/unit/c/test-print-dynamic_partial.c new file mode 100644 index 0000000..3b0c6ef --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_partial.c @@ -0,0 +1,63 @@ +#include "test-print.h" +#include "test-print-dynamic_partial.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_dynamic_partial__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_dynamic_partial(test, partial, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_dynamic_partial__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_dynamic_partial(test, partial, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_dynamic_partial__returns_data_not(void **state) { + + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_dynamic_partial(f_string_empty_s, partial, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_dynamic_partial__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_dynamic_partial(test, partial, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_partial.h b/level_0/f_print/tests/unit/c/test-print-dynamic_partial.h new file mode 100644 index 0000000..0cfb6d5 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_partial.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_dynamic_partial_h +#define _TEST__F_print_dynamic_partial_h + +/** + * Test that function fails. + * + * @see f_print_dynamic_partial() + */ +extern void test__f_print_dynamic_partial__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_dynamic_partial() + */ +extern void test__f_print_dynamic_partial__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_dynamic_partial() + */ +extern void test__f_print_dynamic_partial__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_dynamic_partial() + */ +extern void test__f_print_dynamic_partial__works(void **state); + +#endif // _TEST__F_print_dynamic_partial_h diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw.c b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw.c new file mode 100644 index 0000000..3e221e9 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw.c @@ -0,0 +1,63 @@ +#include "test-print.h" +#include "test-print-dynamic_partial_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_dynamic_partial_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_dynamic_partial_raw(test, partial, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_dynamic_partial_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_dynamic_partial_raw(test, partial, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_dynamic_partial_raw__returns_data_not(void **state) { + + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_dynamic_partial_raw(f_string_empty_s, partial, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_dynamic_partial_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_dynamic_partial_raw(test, partial, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw.h b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw.h new file mode 100644 index 0000000..e81f1d1 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_dynamic_partial_raw_h +#define _TEST__F_print_dynamic_partial_raw_h + +/** + * Test that function fails. + * + * @see f_print_dynamic_partial_raw() + */ +extern void test__f_print_dynamic_partial_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_dynamic_partial_raw() + */ +extern void test__f_print_dynamic_partial_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_dynamic_partial_raw() + */ +extern void test__f_print_dynamic_partial_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_dynamic_partial_raw() + */ +extern void test__f_print_dynamic_partial_raw__works(void **state); + +#endif // _TEST__F_print_dynamic_partial_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw_safely.c new file mode 100644 index 0000000..c6a8fd4 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw_safely.c @@ -0,0 +1,63 @@ +#include "test-print.h" +#include "test-print-dynamic_partial_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_dynamic_partial_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_dynamic_partial_raw_safely(test, partial, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_dynamic_partial_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_dynamic_partial_raw_safely(test, partial, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_dynamic_partial_raw_safely__returns_data_not(void **state) { + + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_dynamic_partial_raw_safely(f_string_empty_s, partial, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_dynamic_partial_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_dynamic_partial_raw_safely(test, partial, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw_safely.h new file mode 100644 index 0000000..c82bd56 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_dynamic_partial_raw_safely_h +#define _TEST__F_print_dynamic_partial_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_dynamic_partial_raw_safely() + */ +extern void test__f_print_dynamic_partial_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_dynamic_partial_raw_safely() + */ +extern void test__f_print_dynamic_partial_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_dynamic_partial_raw_safely() + */ +extern void test__f_print_dynamic_partial_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_dynamic_partial_raw_safely() + */ +extern void test__f_print_dynamic_partial_raw_safely__works(void **state); + +#endif // _TEST__F_print_dynamic_partial_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_partial_safely.c b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_safely.c new file mode 100644 index 0000000..57820a8 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_safely.c @@ -0,0 +1,63 @@ +#include "test-print.h" +#include "test-print-dynamic_partial_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_dynamic_partial_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_dynamic_partial_safely(test, partial, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_dynamic_partial_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_dynamic_partial_safely(test, partial, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_dynamic_partial_safely__returns_data_not(void **state) { + + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_dynamic_partial_safely(f_string_empty_s, partial, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_dynamic_partial_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_dynamic_partial_safely(test, partial, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_partial_safely.h b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_safely.h new file mode 100644 index 0000000..2796199 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_partial_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_dynamic_partial_safely_h +#define _TEST__F_print_dynamic_partial_safely_h + +/** + * Test that function fails. + * + * @see f_print_dynamic_partial_safely() + */ +extern void test__f_print_dynamic_partial_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_dynamic_partial_safely() + */ +extern void test__f_print_dynamic_partial_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_dynamic_partial_safely() + */ +extern void test__f_print_dynamic_partial_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_dynamic_partial_safely() + */ +extern void test__f_print_dynamic_partial_safely__works(void **state); + +#endif // _TEST__F_print_dynamic_partial_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_raw.c b/level_0/f_print/tests/unit/c/test-print-dynamic_raw.c new file mode 100644 index 0000000..94852e1 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_raw.c @@ -0,0 +1,58 @@ +#include "test-print.h" +#include "test-print-dynamic_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_dynamic_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_dynamic_raw(test, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_dynamic_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_dynamic_raw(test, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_dynamic_raw__returns_data_not(void **state) { + + { + const f_status_t status = f_print_dynamic_raw(f_string_empty_s, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_dynamic_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_dynamic_raw(test, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_raw.h b/level_0/f_print/tests/unit/c/test-print-dynamic_raw.h new file mode 100644 index 0000000..770f04e --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_dynamic_raw_h +#define _TEST__F_print_dynamic_raw_h + +/** + * Test that function fails. + * + * @see f_print_dynamic_raw() + */ +extern void test__f_print_dynamic_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_dynamic_raw() + */ +extern void test__f_print_dynamic_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_dynamic_raw() + */ +extern void test__f_print_dynamic_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_dynamic_raw() + */ +extern void test__f_print_dynamic_raw__works(void **state); + +#endif // _TEST__F_print_dynamic_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-dynamic_raw_safely.c new file mode 100644 index 0000000..4e9f664 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_raw_safely.c @@ -0,0 +1,58 @@ +#include "test-print.h" +#include "test-print-dynamic_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_dynamic_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_dynamic_raw_safely(test, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_dynamic_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_dynamic_raw_safely(test, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_dynamic_raw_safely__returns_data_not(void **state) { + + { + const f_status_t status = f_print_dynamic_raw_safely(f_string_empty_s, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_dynamic_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_dynamic_raw_safely(test, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-dynamic_raw_safely.h new file mode 100644 index 0000000..6b19232 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_dynamic_raw_safely_h +#define _TEST__F_print_dynamic_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_dynamic_raw_safely() + */ +extern void test__f_print_dynamic_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_dynamic_raw_safely() + */ +extern void test__f_print_dynamic_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_dynamic_raw_safely() + */ +extern void test__f_print_dynamic_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_dynamic_raw_safely() + */ +extern void test__f_print_dynamic_raw_safely__works(void **state); + +#endif // _TEST__F_print_dynamic_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_safely.c b/level_0/f_print/tests/unit/c/test-print-dynamic_safely.c new file mode 100644 index 0000000..c9c52c8 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_safely.c @@ -0,0 +1,58 @@ +#include "test-print.h" +#include "test-print-dynamic_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_dynamic_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_dynamic_safely(test, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_dynamic_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_dynamic_safely(test, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_dynamic_safely__returns_data_not(void **state) { + + { + const f_status_t status = f_print_dynamic_safely(f_string_empty_s, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_dynamic_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_dynamic_safely(test, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-dynamic_safely.h b/level_0/f_print/tests/unit/c/test-print-dynamic_safely.h new file mode 100644 index 0000000..99d4801 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-dynamic_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_dynamic_safely_h +#define _TEST__F_print_dynamic_safely_h + +/** + * Test that function fails. + * + * @see f_print_dynamic_safely() + */ +extern void test__f_print_dynamic_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_dynamic_safely() + */ +extern void test__f_print_dynamic_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_dynamic_safely() + */ +extern void test__f_print_dynamic_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_dynamic_safely() + */ +extern void test__f_print_dynamic_safely__works(void **state); + +#endif // _TEST__F_print_dynamic_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except.c b/level_0/f_print/tests/unit/c/test-print-except.c new file mode 100644 index 0000000..78d5ca4 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except.c @@ -0,0 +1,100 @@ +#include "test-print.h" +#include "test-print-except.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except(test.string, 0, test.used, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except(test.string, 0, test.used, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except(f_string_empty_s.string, 0, f_string_empty_s.used, except, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except(test.string, 0, f_string_empty_s.used, except, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except(0, 0, test.used, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except(test.string, 0, test.used, except, stdout); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except(test.string, 2, test.used, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except(test.string, 1, test.used, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except.h b/level_0/f_print/tests/unit/c/test-print-except.h new file mode 100644 index 0000000..611dede --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_h +#define _TEST__F_print_except_h + +/** + * Test that function fails. + * + * @see f_print_except() + */ +extern void test__f_print_except__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except() + */ +extern void test__f_print_except__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except() + */ +extern void test__f_print_except__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except() + */ +extern void test__f_print_except__works(void **state); + +#endif // _TEST__F_print_except_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic.c b/level_0/f_print/tests/unit/c/test-print-except_dynamic.c new file mode 100644 index 0000000..f5cae0a --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic.c @@ -0,0 +1,76 @@ +#include "test-print.h" +#include "test-print-except_dynamic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_dynamic__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_dynamic(test, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_dynamic__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_dynamic(test, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_dynamic__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_dynamic(f_string_empty_s, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_dynamic__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic(test, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic(test, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic.h b/level_0/f_print/tests/unit/c/test-print-except_dynamic.h new file mode 100644 index 0000000..3e50850 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_dynamic_h +#define _TEST__F_print_except_dynamic_h + +/** + * Test that function fails. + * + * @see f_print_except_dynamic() + */ +extern void test__f_print_except_dynamic__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_dynamic() + */ +extern void test__f_print_except_dynamic__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_dynamic() + */ +extern void test__f_print_except_dynamic__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_dynamic() + */ +extern void test__f_print_except_dynamic__works(void **state); + +#endif // _TEST__F_print_except_dynamic_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial.c b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial.c new file mode 100644 index 0000000..74cc53d --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial.c @@ -0,0 +1,80 @@ +#include "test-print.h" +#include "test-print-except_dynamic_partial.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_dynamic_partial__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_dynamic_partial(test, partial, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_dynamic_partial__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_dynamic_partial(test, partial, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_dynamic_partial__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_dynamic_partial(f_string_empty_s, partial, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_dynamic_partial__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_partial(test, partial, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_partial(test, partial, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial.h b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial.h new file mode 100644 index 0000000..65aa12e --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_dynamic_partial_h +#define _TEST__F_print_except_dynamic_partial_h + +/** + * Test that function fails. + * + * @see f_print_except_dynamic_partial() + */ +extern void test__f_print_except_dynamic_partial__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_dynamic_partial() + */ +extern void test__f_print_except_dynamic_partial__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_dynamic_partial() + */ +extern void test__f_print_except_dynamic_partial__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_dynamic_partial() + */ +extern void test__f_print_except_dynamic_partial__works(void **state); + +#endif // _TEST__F_print_except_dynamic_partial_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw.c b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw.c new file mode 100644 index 0000000..d90fb8a --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw.c @@ -0,0 +1,80 @@ +#include "test-print.h" +#include "test-print-except_dynamic_partial_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_dynamic_partial_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_dynamic_partial_raw(test, partial, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_dynamic_partial_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_dynamic_partial_raw(test, partial, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_dynamic_partial_raw__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_dynamic_partial_raw(f_string_empty_s, partial, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_dynamic_partial_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_partial_raw(test, partial, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_partial_raw(test, partial, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw.h b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw.h new file mode 100644 index 0000000..dd31511 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_dynamic_partial_raw_h +#define _TEST__F_print_except_dynamic_partial_raw_h + +/** + * Test that function fails. + * + * @see f_print_except_dynamic_partial_raw() + */ +extern void test__f_print_except_dynamic_partial_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_dynamic_partial_raw() + */ +extern void test__f_print_except_dynamic_partial_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_dynamic_partial_raw() + */ +extern void test__f_print_except_dynamic_partial_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_dynamic_partial_raw() + */ +extern void test__f_print_except_dynamic_partial_raw__works(void **state); + +#endif // _TEST__F_print_except_dynamic_partial_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw_safely.c new file mode 100644 index 0000000..b70bd7d --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw_safely.c @@ -0,0 +1,80 @@ +#include "test-print.h" +#include "test-print-except_dynamic_partial_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_dynamic_partial_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_dynamic_partial_raw_safely(test, partial, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_dynamic_partial_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_dynamic_partial_raw_safely(test, partial, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_dynamic_partial_raw_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_dynamic_partial_raw_safely(f_string_empty_s, partial, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_dynamic_partial_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_partial_raw_safely(test, partial, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_partial_raw_safely(test, partial, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw_safely.h new file mode 100644 index 0000000..5962a80 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_dynamic_partial_raw_safely_h +#define _TEST__F_print_except_dynamic_partial_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_dynamic_partial_raw_safely() + */ +extern void test__f_print_except_dynamic_partial_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_dynamic_partial_raw_safely() + */ +extern void test__f_print_except_dynamic_partial_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_dynamic_partial_raw_safely() + */ +extern void test__f_print_except_dynamic_partial_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_dynamic_partial_raw_safely() + */ +extern void test__f_print_except_dynamic_partial_raw_safely__works(void **state); + +#endif // _TEST__F_print_except_dynamic_partial_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_safely.c b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_safely.c new file mode 100644 index 0000000..761c050 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_safely.c @@ -0,0 +1,80 @@ +#include "test-print.h" +#include "test-print-except_dynamic_partial_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_dynamic_partial_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_dynamic_partial_safely(test, partial, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_dynamic_partial_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_dynamic_partial_safely(test, partial, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_dynamic_partial_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_dynamic_partial_safely(f_string_empty_s, partial, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_dynamic_partial_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_partial_safely(test, partial, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_partial_safely(test, partial, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_safely.h b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_safely.h new file mode 100644 index 0000000..dd0d136 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_partial_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_dynamic_partial_safely_h +#define _TEST__F_print_except_dynamic_partial_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_dynamic_partial_safely() + */ +extern void test__f_print_except_dynamic_partial_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_dynamic_partial_safely() + */ +extern void test__f_print_except_dynamic_partial_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_dynamic_partial_safely() + */ +extern void test__f_print_except_dynamic_partial_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_dynamic_partial_safely() + */ +extern void test__f_print_except_dynamic_partial_safely__works(void **state); + +#endif // _TEST__F_print_except_dynamic_partial_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw.c b/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw.c new file mode 100644 index 0000000..8b84476 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw.c @@ -0,0 +1,76 @@ +#include "test-print.h" +#include "test-print-except_dynamic_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_dynamic_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_dynamic_raw(test, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_dynamic_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_dynamic_raw(test, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_dynamic_raw__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_dynamic_raw(f_string_empty_s, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_dynamic_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_raw(test, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_raw(test, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw.h b/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw.h new file mode 100644 index 0000000..1422090 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_dynamic_raw_h +#define _TEST__F_print_except_dynamic_raw_h + +/** + * Test that function fails. + * + * @see f_print_except_dynamic_raw() + */ +extern void test__f_print_except_dynamic_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_dynamic_raw() + */ +extern void test__f_print_except_dynamic_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_dynamic_raw() + */ +extern void test__f_print_except_dynamic_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_dynamic_raw() + */ +extern void test__f_print_except_dynamic_raw__works(void **state); + +#endif // _TEST__F_print_except_dynamic_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw_safely.c new file mode 100644 index 0000000..1bdd7b4 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw_safely.c @@ -0,0 +1,76 @@ +#include "test-print.h" +#include "test-print-except_dynamic_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_dynamic_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_dynamic_raw_safely(test, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_dynamic_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_dynamic_raw_safely(test, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_dynamic_raw_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_dynamic_raw_safely(f_string_empty_s, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_dynamic_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_raw_safely(test, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_raw_safely(test, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw_safely.h new file mode 100644 index 0000000..5a4de21 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_dynamic_raw_safely_h +#define _TEST__F_print_except_dynamic_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_dynamic_raw_safely() + */ +extern void test__f_print_except_dynamic_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_dynamic_raw_safely() + */ +extern void test__f_print_except_dynamic_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_dynamic_raw_safely() + */ +extern void test__f_print_except_dynamic_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_dynamic_raw_safely() + */ +extern void test__f_print_except_dynamic_raw_safely__works(void **state); + +#endif // _TEST__F_print_except_dynamic_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_safely.c b/level_0/f_print/tests/unit/c/test-print-except_dynamic_safely.c new file mode 100644 index 0000000..4a5f91f --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_safely.c @@ -0,0 +1,76 @@ +#include "test-print.h" +#include "test-print-except_dynamic_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_dynamic_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_dynamic_safely(test, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_dynamic_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_dynamic_safely(test, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_dynamic_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_dynamic_safely(f_string_empty_s, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_dynamic_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_safely(test, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_dynamic_safely(test, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_dynamic_safely.h b/level_0/f_print/tests/unit/c/test-print-except_dynamic_safely.h new file mode 100644 index 0000000..c9450a2 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_dynamic_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_dynamic_safely_h +#define _TEST__F_print_except_dynamic_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_dynamic_safely() + */ +extern void test__f_print_except_dynamic_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_dynamic_safely() + */ +extern void test__f_print_except_dynamic_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_dynamic_safely() + */ +extern void test__f_print_except_dynamic_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_dynamic_safely() + */ +extern void test__f_print_except_dynamic_safely__works(void **state); + +#endif // _TEST__F_print_except_dynamic_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in.c b/level_0/f_print/tests/unit/c/test-print-except_in.c new file mode 100644 index 0000000..46e86a6 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in.c @@ -0,0 +1,109 @@ +#include "test-print.h" +#include "test-print-except_in.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in(test.string, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in(test.string, 0, test.used, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in(f_string_empty_s.string, 0, f_string_empty_s.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_in(test.string, 0, f_string_empty_s.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_in(0, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in(test.string, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in(test.string, 2, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in(test.string, 1, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in.h b/level_0/f_print/tests/unit/c/test-print-except_in.h new file mode 100644 index 0000000..af70aa5 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_h +#define _TEST__F_print_except_in_h + +/** + * Test that function fails. + * + * @see f_print_except_in() + */ +extern void test__f_print_except_in__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in() + */ +extern void test__f_print_except_in__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in() + */ +extern void test__f_print_except_in__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in() + */ +extern void test__f_print_except_in__works(void **state); + +#endif // _TEST__F_print_except_in_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic.c b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic.c new file mode 100644 index 0000000..d162468 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic.c @@ -0,0 +1,84 @@ +#include "test-print.h" +#include "test-print-except_in_dynamic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in_dynamic__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in_dynamic(test, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in_dynamic__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_dynamic(test, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in_dynamic__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_dynamic(f_string_empty_s, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in_dynamic__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic(test, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic(test, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic.h b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic.h new file mode 100644 index 0000000..27cd440 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_dynamic_h +#define _TEST__F_print_except_in_dynamic_h + +/** + * Test that function fails. + * + * @see f_print_except_in_dynamic() + */ +extern void test__f_print_except_in_dynamic__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in_dynamic() + */ +extern void test__f_print_except_in_dynamic__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in_dynamic() + */ +extern void test__f_print_except_in_dynamic__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in_dynamic() + */ +extern void test__f_print_except_in_dynamic__works(void **state); + +#endif // _TEST__F_print_except_in_dynamic_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial.c b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial.c new file mode 100644 index 0000000..5bc646e --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial.c @@ -0,0 +1,88 @@ +#include "test-print.h" +#include "test-print-except_in_dynamic_partial.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in_dynamic_partial__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in_dynamic_partial(test, partial, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in_dynamic_partial__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_in_dynamic_partial(test, partial, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in_dynamic_partial__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_in_dynamic_partial(f_string_empty_s, partial, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in_dynamic_partial__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_partial(test, partial, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_partial(test, partial, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial.h b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial.h new file mode 100644 index 0000000..e0cb56c --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_dynamic_partial_h +#define _TEST__F_print_except_in_dynamic_partial_h + +/** + * Test that function fails. + * + * @see f_print_except_in_dynamic_partial() + */ +extern void test__f_print_except_in_dynamic_partial__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in_dynamic_partial() + */ +extern void test__f_print_except_in_dynamic_partial__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in_dynamic_partial() + */ +extern void test__f_print_except_in_dynamic_partial__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in_dynamic_partial() + */ +extern void test__f_print_except_in_dynamic_partial__works(void **state); + +#endif // _TEST__F_print_except_in_dynamic_partial_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw.c b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw.c new file mode 100644 index 0000000..bb27c65 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw.c @@ -0,0 +1,88 @@ +#include "test-print.h" +#include "test-print-except_in_dynamic_partial_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in_dynamic_partial_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in_dynamic_partial_raw(test, partial, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in_dynamic_partial_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_in_dynamic_partial_raw(test, partial, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in_dynamic_partial_raw__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_in_dynamic_partial_raw(f_string_empty_s, partial, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in_dynamic_partial_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_partial_raw(test, partial, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_partial_raw(test, partial, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw.h b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw.h new file mode 100644 index 0000000..5cff049 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_dynamic_partial_raw_h +#define _TEST__F_print_except_in_dynamic_partial_raw_h + +/** + * Test that function fails. + * + * @see f_print_except_in_dynamic_partial_raw() + */ +extern void test__f_print_except_in_dynamic_partial_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in_dynamic_partial_raw() + */ +extern void test__f_print_except_in_dynamic_partial_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in_dynamic_partial_raw() + */ +extern void test__f_print_except_in_dynamic_partial_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in_dynamic_partial_raw() + */ +extern void test__f_print_except_in_dynamic_partial_raw__works(void **state); + +#endif // _TEST__F_print_except_in_dynamic_partial_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw_safely.c new file mode 100644 index 0000000..893b4df --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw_safely.c @@ -0,0 +1,88 @@ +#include "test-print.h" +#include "test-print-except_in_dynamic_partial_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in_dynamic_partial_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in_dynamic_partial_raw_safely(test, partial, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in_dynamic_partial_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_in_dynamic_partial_raw_safely(test, partial, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in_dynamic_partial_raw_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_in_dynamic_partial_raw_safely(f_string_empty_s, partial, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in_dynamic_partial_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_partial_raw_safely(test, partial, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_partial_raw_safely(test, partial, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw_safely.h new file mode 100644 index 0000000..bfc03f5 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_dynamic_partial_raw_safely_h +#define _TEST__F_print_except_in_dynamic_partial_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_in_dynamic_partial_raw_safely() + */ +extern void test__f_print_except_in_dynamic_partial_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in_dynamic_partial_raw_safely() + */ +extern void test__f_print_except_in_dynamic_partial_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in_dynamic_partial_raw_safely() + */ +extern void test__f_print_except_in_dynamic_partial_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in_dynamic_partial_raw_safely() + */ +extern void test__f_print_except_in_dynamic_partial_raw_safely__works(void **state); + +#endif // _TEST__F_print_except_in_dynamic_partial_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_safely.c b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_safely.c new file mode 100644 index 0000000..57386b3 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_safely.c @@ -0,0 +1,88 @@ +#include "test-print.h" +#include "test-print-except_in_dynamic_partial_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in_dynamic_partial_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in_dynamic_partial_safely(test, partial, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in_dynamic_partial_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_in_dynamic_partial_safely(test, partial, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in_dynamic_partial_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_except_in_dynamic_partial_safely(f_string_empty_s, partial, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in_dynamic_partial_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_partial_safely(test, partial, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_partial_safely(test, partial, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_safely.h b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_safely.h new file mode 100644 index 0000000..420feac --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_partial_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_dynamic_partial_safely_h +#define _TEST__F_print_except_in_dynamic_partial_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_in_dynamic_partial_safely() + */ +extern void test__f_print_except_in_dynamic_partial_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in_dynamic_partial_safely() + */ +extern void test__f_print_except_in_dynamic_partial_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in_dynamic_partial_safely() + */ +extern void test__f_print_except_in_dynamic_partial_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in_dynamic_partial_safely() + */ +extern void test__f_print_except_in_dynamic_partial_safely__works(void **state); + +#endif // _TEST__F_print_except_in_dynamic_partial_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw.c b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw.c new file mode 100644 index 0000000..8faf1f0 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw.c @@ -0,0 +1,84 @@ +#include "test-print.h" +#include "test-print-except_in_dynamic_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in_dynamic_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in_dynamic_raw(test, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in_dynamic_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_dynamic_raw(test, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in_dynamic_raw__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_dynamic_raw(f_string_empty_s, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in_dynamic_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_raw(test, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_raw(test, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw.h b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw.h new file mode 100644 index 0000000..0923c66 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_dynamic_raw_h +#define _TEST__F_print_except_in_dynamic_raw_h + +/** + * Test that function fails. + * + * @see f_print_except_in_dynamic_raw() + */ +extern void test__f_print_except_in_dynamic_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in_dynamic_raw() + */ +extern void test__f_print_except_in_dynamic_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in_dynamic_raw() + */ +extern void test__f_print_except_in_dynamic_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in_dynamic_raw() + */ +extern void test__f_print_except_in_dynamic_raw__works(void **state); + +#endif // _TEST__F_print_except_in_dynamic_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw_safely.c new file mode 100644 index 0000000..ba13e3f --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw_safely.c @@ -0,0 +1,84 @@ +#include "test-print.h" +#include "test-print-except_in_dynamic_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in_dynamic_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in_dynamic_raw_safely(test, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in_dynamic_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_dynamic_raw_safely(test, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in_dynamic_raw_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_dynamic_raw_safely(f_string_empty_s, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in_dynamic_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_raw_safely(test, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_raw_safely(test, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw_safely.h new file mode 100644 index 0000000..14fbbc3 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_dynamic_raw_safely_h +#define _TEST__F_print_except_in_dynamic_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_in_dynamic_raw_safely() + */ +extern void test__f_print_except_in_dynamic_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in_dynamic_raw_safely() + */ +extern void test__f_print_except_in_dynamic_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in_dynamic_raw_safely() + */ +extern void test__f_print_except_in_dynamic_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in_dynamic_raw_safely() + */ +extern void test__f_print_except_in_dynamic_raw_safely__works(void **state); + +#endif // _TEST__F_print_except_in_dynamic_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_safely.c b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_safely.c new file mode 100644 index 0000000..d7a377d --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_safely.c @@ -0,0 +1,84 @@ +#include "test-print.h" +#include "test-print-except_in_dynamic_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in_dynamic_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in_dynamic_safely(test, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in_dynamic_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_dynamic_safely(test, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in_dynamic_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_dynamic_safely(f_string_empty_s, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in_dynamic_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_safely(test, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_dynamic_safely(test, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_safely.h b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_safely.h new file mode 100644 index 0000000..6fb0ee8 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_dynamic_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_dynamic_safely_h +#define _TEST__F_print_except_in_dynamic_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_in_dynamic_safely() + */ +extern void test__f_print_except_in_dynamic_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in_dynamic_safely() + */ +extern void test__f_print_except_in_dynamic_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in_dynamic_safely() + */ +extern void test__f_print_except_in_dynamic_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in_dynamic_safely() + */ +extern void test__f_print_except_in_dynamic_safely__works(void **state); + +#endif // _TEST__F_print_except_in_dynamic_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_raw.c b/level_0/f_print/tests/unit/c/test-print-except_in_raw.c new file mode 100644 index 0000000..71a1d34 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_raw.c @@ -0,0 +1,109 @@ +#include "test-print.h" +#include "test-print-except_in_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in_raw(test.string, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_raw(test.string, 0, test.used, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in_raw__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_raw(f_string_empty_s.string, 0, f_string_empty_s.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_in_raw(test.string, 0, f_string_empty_s.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_in_raw(0, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_raw(test.string, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_raw(test.string, 2, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_raw(test.string, 1, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_raw.h b/level_0/f_print/tests/unit/c/test-print-except_in_raw.h new file mode 100644 index 0000000..7ce0af2 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_raw_h +#define _TEST__F_print_except_in_raw_h + +/** + * Test that function fails. + * + * @see f_print_except_in_raw() + */ +extern void test__f_print_except_in_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in_raw() + */ +extern void test__f_print_except_in_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in_raw() + */ +extern void test__f_print_except_in_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in_raw() + */ +extern void test__f_print_except_in_raw__works(void **state); + +#endif // _TEST__F_print_except_in_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-except_in_raw_safely.c new file mode 100644 index 0000000..c884d81 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_raw_safely.c @@ -0,0 +1,109 @@ +#include "test-print.h" +#include "test-print-except_in_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in_raw_safely(test.string, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_raw_safely(test.string, 0, test.used, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in_raw_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_raw_safely(f_string_empty_s.string, 0, f_string_empty_s.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_in_raw_safely(test.string, 0, f_string_empty_s.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_in_raw_safely(0, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_raw_safely(test.string, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_raw_safely(test.string, 2, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_raw_safely(test.string, 1, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-except_in_raw_safely.h new file mode 100644 index 0000000..4bc62a8 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_raw_safely_h +#define _TEST__F_print_except_in_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_in_raw_safely() + */ +extern void test__f_print_except_in_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in_raw_safely() + */ +extern void test__f_print_except_in_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in_raw_safely() + */ +extern void test__f_print_except_in_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in_raw_safely() + */ +extern void test__f_print_except_in_raw_safely__works(void **state); + +#endif // _TEST__F_print_except_in_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_safely.c b/level_0/f_print/tests/unit/c/test-print-except_in_safely.c new file mode 100644 index 0000000..33695f8 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_safely.c @@ -0,0 +1,109 @@ +#include "test-print.h" +#include "test-print-except_in_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_in_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_in_safely(test.string, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_in_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_safely(test.string, 0, test.used, except, range, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_in_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_except_in_safely(f_string_empty_s.string, 0, f_string_empty_s.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_in_safely(test.string, 0, f_string_empty_s.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_in_safely(0, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_in_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_safely(test.string, 0, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_safely(test.string, 2, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_in_safely(test.string, 1, test.used, except, range, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_in_safely.h b/level_0/f_print/tests/unit/c/test-print-except_in_safely.h new file mode 100644 index 0000000..07975df --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_in_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_in_safely_h +#define _TEST__F_print_except_in_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_in_safely() + */ +extern void test__f_print_except_in_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_in_safely() + */ +extern void test__f_print_except_in_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_in_safely() + */ +extern void test__f_print_except_in_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_in_safely() + */ +extern void test__f_print_except_in_safely__works(void **state); + +#endif // _TEST__F_print_except_in_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_raw.c b/level_0/f_print/tests/unit/c/test-print-except_raw.c new file mode 100644 index 0000000..bef76c6 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_raw.c @@ -0,0 +1,100 @@ +#include "test-print.h" +#include "test-print-except_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_raw(test.string, 0, test.used, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_raw(test.string, 0, test.used, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_raw__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_raw(f_string_empty_s.string, 0, f_string_empty_s.used, except, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_raw(test.string, 0, f_string_empty_s.used, except, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_raw(0, 0, test.used, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_raw(test.string, 0, test.used, except, stdout); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_raw(test.string, 2, test.used, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_raw(test.string, 1, test.used, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_raw.h b/level_0/f_print/tests/unit/c/test-print-except_raw.h new file mode 100644 index 0000000..28ad687 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_raw_h +#define _TEST__F_print_except_raw_h + +/** + * Test that function fails. + * + * @see f_print_except_raw() + */ +extern void test__f_print_except_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_raw() + */ +extern void test__f_print_except_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_raw() + */ +extern void test__f_print_except_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_raw() + */ +extern void test__f_print_except_raw__works(void **state); + +#endif // _TEST__F_print_except_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-except_raw_safely.c new file mode 100644 index 0000000..1d19f4e --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_raw_safely.c @@ -0,0 +1,100 @@ +#include "test-print.h" +#include "test-print-except_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_raw_safely(test.string, 0, test.used, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_raw_safely(test.string, 0, test.used, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_raw_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_raw_safely(f_string_empty_s.string, 0, f_string_empty_s.used, except, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_raw_safely(test.string, 0, f_string_empty_s.used, except, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_raw_safely(0, 0, test.used, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_raw_safely(test.string, 0, test.used, except, stdout); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_raw_safely(test.string, 2, test.used, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_raw_safely(test.string, 1, test.used, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-except_raw_safely.h new file mode 100644 index 0000000..2700b4d --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_raw_safely_h +#define _TEST__F_print_except_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_raw_safely() + */ +extern void test__f_print_except_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_raw_safely() + */ +extern void test__f_print_except_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_raw_safely() + */ +extern void test__f_print_except_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_raw_safely() + */ +extern void test__f_print_except_raw_safely__works(void **state); + +#endif // _TEST__F_print_except_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-except_safely.c b/level_0/f_print/tests/unit/c/test-print-except_safely.c new file mode 100644 index 0000000..e9f6a0f --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_safely.c @@ -0,0 +1,100 @@ +#include "test-print.h" +#include "test-print-except_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_except_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_except_safely(test.string, 0, test.used, except, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_except_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_safely(test.string, 0, test.used, except, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_except_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_except_safely(f_string_empty_s.string, 0, f_string_empty_s.used, except, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_safely(test.string, 0, f_string_empty_s.used, except, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_except_safely(0, 0, test.used, except, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_except_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_safely(test.string, 0, test.used, except, stdout); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_safely(test.string, 2, test.used, except, stdout); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_except_safely(test.string, 1, test.used, except, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-except_safely.h b/level_0/f_print/tests/unit/c/test-print-except_safely.h new file mode 100644 index 0000000..069deef --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-except_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_except_safely_h +#define _TEST__F_print_except_safely_h + +/** + * Test that function fails. + * + * @see f_print_except_safely() + */ +extern void test__f_print_except_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_except_safely() + */ +extern void test__f_print_except_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_except_safely() + */ +extern void test__f_print_except_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_except_safely() + */ +extern void test__f_print_except_safely__works(void **state); + +#endif // _TEST__F_print_except_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-raw.c b/level_0/f_print/tests/unit/c/test-print-raw.c new file mode 100644 index 0000000..0a8988c --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-raw.c @@ -0,0 +1,72 @@ +#include "test-print.h" +#include "test-print-raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_raw(test.string, test.used, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_raw(test.string, test.used, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_raw__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_raw(f_string_empty_s.string, f_string_empty_s.used, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_raw(test.string, f_string_empty_s.used, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_raw(0, test.used, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_raw(test.string, test.used, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-raw.h b/level_0/f_print/tests/unit/c/test-print-raw.h new file mode 100644 index 0000000..d3cbf86 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_raw_h +#define _TEST__F_print_raw_h + +/** + * Test that function fails. + * + * @see f_print_raw() + */ +extern void test__f_print_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_raw() + */ +extern void test__f_print_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_raw() + */ +extern void test__f_print_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_raw() + */ +extern void test__f_print_raw__works(void **state); + +#endif // _TEST__F_print_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-raw_safely.c b/level_0/f_print/tests/unit/c/test-print-raw_safely.c new file mode 100644 index 0000000..0bd375c --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-raw_safely.c @@ -0,0 +1,72 @@ +#include "test-print.h" +#include "test-print-raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_raw_safely(test.string, test.used, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_raw_safely(test.string, test.used, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_raw_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_raw_safely(f_string_empty_s.string, f_string_empty_s.used, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_raw_safely(test.string, f_string_empty_s.used, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_raw_safely(0, test.used, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_raw_safely(test.string, test.used, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-raw_safely.h b/level_0/f_print/tests/unit/c/test-print-raw_safely.h new file mode 100644 index 0000000..44ca35a --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_raw_safely_h +#define _TEST__F_print_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_raw_safely() + */ +extern void test__f_print_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_raw_safely() + */ +extern void test__f_print_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_raw_safely() + */ +extern void test__f_print_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_raw_safely() + */ +extern void test__f_print_raw_safely__works(void **state); + +#endif // _TEST__F_print_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-raw_terminated.c b/level_0/f_print/tests/unit/c/test-print-raw_terminated.c new file mode 100644 index 0000000..525f7a1 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-raw_terminated.c @@ -0,0 +1,58 @@ +#include "test-print.h" +#include "test-print-raw_terminated.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_raw_terminated__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_raw_terminated(test.string, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_raw_terminated__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_raw_terminated(test.string, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_raw_terminated__returns_data_not(void **state) { + + { + const f_status_t status = f_print_raw_terminated(0, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_raw_terminated__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_raw_terminated(test.string, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-raw_terminated.h b/level_0/f_print/tests/unit/c/test-print-raw_terminated.h new file mode 100644 index 0000000..f2242e0 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-raw_terminated.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_raw_terminated_h +#define _TEST__F_print_raw_terminated_h + +/** + * Test that function fails. + * + * @see f_print_raw_terminated() + */ +extern void test__f_print_raw_terminated__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_raw_terminated() + */ +extern void test__f_print_raw_terminated__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_raw_terminated() + */ +extern void test__f_print_raw_terminated__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_raw_terminated() + */ +extern void test__f_print_raw_terminated__works(void **state); + +#endif // _TEST__F_print_raw_terminated_h diff --git a/level_0/f_print/tests/unit/c/test-print-safely.c b/level_0/f_print/tests/unit/c/test-print-safely.c new file mode 100644 index 0000000..5d7141f --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-safely.c @@ -0,0 +1,72 @@ +#include "test-print.h" +#include "test-print-safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_safely(test.string, test.used, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_safely(test.string, test.used, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_safely(f_string_empty_s.string, f_string_empty_s.used, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_safely(test.string, f_string_empty_s.used, stdout); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_safely(0, test.used, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_safely(test.string, test.used, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-safely.h b/level_0/f_print/tests/unit/c/test-print-safely.h new file mode 100644 index 0000000..705de4c --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_safely_h +#define _TEST__F_print_safely_h + +/** + * Test that function fails. + * + * @see f_print_safely() + */ +extern void test__f_print_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_safely() + */ +extern void test__f_print_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_safely() + */ +extern void test__f_print_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_safely() + */ +extern void test__f_print_safely__works(void **state); + +#endif // _TEST__F_print_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-safely_get.c b/level_0/f_print/tests/unit/c/test-print-safely_get.c new file mode 100644 index 0000000..4d16763 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-safely_get.c @@ -0,0 +1,72 @@ +#include "test-print.h" +#include "test-print-safely_get.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_safely_get__returns_character_control(void **state) { + + for (uint8_t i = 0; i < 32 ; ++i) { + + char string[2] = ""; + string[0] = (f_char_t) i; + + const f_string_static_t safe = f_print_safely_get(string, 1); + + assert_int_equal(safe.used, f_print_sequence_set_control_s[i].used); + assert_string_equal(safe.string, f_print_sequence_set_control_s[i].string); + } // for +} + +void test__f_print_safely_get__returns_character_delete(void **state) { + + char string[2] = ""; + string[0] = (f_char_t) 0x7f; + + { + const f_string_static_t safe = f_print_safely_get(string, 1); + + assert_int_equal(safe.used, f_print_sequence_delete_s.used); + assert_string_equal(safe.string, f_print_sequence_delete_s.string); + } +} + +void test__f_print_safely_get__returns_character_unknown(void **state) { + + char string[2] = ""; + string[0] = (f_char_t) F_utf_byte_1_d; + + { + const f_string_static_t safe = f_print_safely_get(string, 1); + + assert_int_equal(safe.used, f_print_sequence_unknown_s.used); + assert_string_equal(safe.string, f_print_sequence_unknown_s.string); + } +} + +void test__f_print_safely_get__returns_empty(void **state) { + + { + char string[2] = ""; + string[0] = 'a'; + + const f_string_static_t safe = f_print_safely_get(string, 1); + + assert_int_equal(safe.used, f_string_empty_s.used); + assert_string_equal(safe.string, f_string_empty_s.string); + } + + { + char string[3] = "蠇"; + + const f_string_static_t safe = f_print_safely_get(string, 3); + + assert_int_equal(safe.used, f_string_empty_s.used); + assert_string_equal(safe.string, f_string_empty_s.string); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-safely_get.h b/level_0/f_print/tests/unit/c/test-print-safely_get.h new file mode 100644 index 0000000..80a539e --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-safely_get.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_safely_get_h +#define _TEST__F_print_safely_get_h + +/** + * Test that function works but returns a control character safe alternative. + * + * @see f_print_safely_get() + */ +extern void test__f_print_safely_get__returns_character_control(void **state); + +/** + * Test that function works but returns a delete character safe alternative. + * + * @see f_print_safely_get() + */ +extern void test__f_print_safely_get__returns_character_delete(void **state); + +/** + * Test that function works but returns a unknown character safe alternative. + * + * @see f_print_safely_get() + */ +extern void test__f_print_safely_get__returns_character_unknown(void **state); + +/** + * Test that function works but returns an empty string. + * + * @see f_print_safely_get() + */ +extern void test__f_print_safely_get__returns_empty(void **state); + +#endif // _TEST__F_print_safely_get_h diff --git a/level_0/f_print/tests/unit/c/test-print-safely_terminated.c b/level_0/f_print/tests/unit/c/test-print-safely_terminated.c new file mode 100644 index 0000000..49a0670 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-safely_terminated.c @@ -0,0 +1,58 @@ +#include "test-print.h" +#include "test-print-safely_terminated.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_safely_terminated__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_safely_terminated(test.string, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_safely_terminated__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_safely_terminated(test.string, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_safely_terminated__returns_data_not(void **state) { + + { + const f_status_t status = f_print_safely_terminated(0, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_safely_terminated__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_safely_terminated(test.string, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-safely_terminated.h b/level_0/f_print/tests/unit/c/test-print-safely_terminated.h new file mode 100644 index 0000000..e365725 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-safely_terminated.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_safely_terminated_h +#define _TEST__F_print_safely_terminated_h + +/** + * Test that function fails. + * + * @see f_print_safely_terminated() + */ +extern void test__f_print_safely_terminated__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_safely_terminated() + */ +extern void test__f_print_safely_terminated__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_safely_terminated() + */ +extern void test__f_print_safely_terminated__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_safely_terminated() + */ +extern void test__f_print_safely_terminated__works(void **state); + +#endif // _TEST__F_print_safely_terminated_h diff --git a/level_0/f_print/tests/unit/c/test-print-terminated.c b/level_0/f_print/tests/unit/c/test-print-terminated.c new file mode 100644 index 0000000..cb4a2a9 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-terminated.c @@ -0,0 +1,58 @@ +#include "test-print.h" +#include "test-print-terminated.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_terminated__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, 0); + will_return(__wrap_ferror_unlocked, 1); + + const f_status_t status = f_print_terminated(test.string, stdout); + + assert_int_equal(status, F_status_set_error(F_output)); + } +} + +void test__f_print_terminated__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_terminated(test.string, 0); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_terminated__returns_data_not(void **state) { + + { + const f_status_t status = f_print_terminated(0, stdout); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_terminated__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_fwrite_unlocked, test.used); + will_return(__wrap_ferror_unlocked, 0); + + const f_status_t status = f_print_terminated(test.string, stdout); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-terminated.h b/level_0/f_print/tests/unit/c/test-print-terminated.h new file mode 100644 index 0000000..2a2960e --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-terminated.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_terminated_h +#define _TEST__F_print_terminated_h + +/** + * Test that function fails. + * + * @see f_print_terminated() + */ +extern void test__f_print_terminated__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_terminated() + */ +extern void test__f_print_terminated__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_terminated() + */ +extern void test__f_print_terminated__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_terminated() + */ +extern void test__f_print_terminated__works(void **state); + +#endif // _TEST__F_print_terminated_h diff --git a/level_0/f_print/tests/unit/c/test-print-to.c b/level_0/f_print/tests/unit/c/test-print-to.c new file mode 100644 index 0000000..eff054b --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to.c @@ -0,0 +1,107 @@ +#include "test-print.h" +#include "test-print-to.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to(test.string, test.used, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to(test.string, test.used, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to(f_string_empty_s.string, f_string_empty_s.used, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to(test.string, f_string_empty_s.used, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to(0, test.used, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to(test.string, test.used, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to.h b/level_0/f_print/tests/unit/c/test-print-to.h new file mode 100644 index 0000000..32049c2 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_h +#define _TEST__F_print_to_h + +/** + * Test that function fails. + * + * @see f_print_to() + */ +extern void test__f_print_to__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to() + */ +extern void test__f_print_to__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to() + */ +extern void test__f_print_to__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to() + */ +extern void test__f_print_to__works(void **state); + +#endif // _TEST__F_print_to_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_character.c b/level_0/f_print/tests/unit/c/test-print-to_character.c new file mode 100644 index 0000000..4b710d7 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_character.c @@ -0,0 +1,84 @@ +#include "test-print.h" +#include "test-print-to_character.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_character__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_character(test.string[0], 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_character__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_character(test.string[0], -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_character__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, 1); + + const f_status_t status = f_print_to_character(test.string[0], 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_character.h b/level_0/f_print/tests/unit/c/test-print-to_character.h new file mode 100644 index 0000000..61f9a46 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_character.h @@ -0,0 +1,34 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_character_h +#define _TEST__F_print_to_character_h + +/** + * Test that function fails. + * + * @see f_print_to_character() + */ +extern void test__f_print_to_character__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_character() + */ +extern void test__f_print_to_character__parameter_checking(void **state); + +/** + * Test that function works. + * + * @see f_print_to_character() + */ +extern void test__f_print_to_character__works(void **state); + +#endif // _TEST__F_print_to_character_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_character_safely.c b/level_0/f_print/tests/unit/c/test-print-to_character_safely.c new file mode 100644 index 0000000..cb105de --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_character_safely.c @@ -0,0 +1,158 @@ +#include "test-print.h" +#include "test-print-to_character_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_character_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_character_safely(test.string[0], 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_character_safely((f_char_t) 0x7f, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_character_safely((f_char_t) F_utf_byte_1_d, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for + + for (int i = 0; i < 14; ++i) { + + const f_string_static_t alternate = macro_f_string_static_t_initialize("蠇", 0, 2); + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_character_safely(alternate.string[0], 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_character_safely(test.string[0], 0);; + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_character_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_character_safely(test.string[0], -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_character_safely__returns_utf(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("蠇", 0, 2); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, 1); + + const f_status_t status = f_print_to_character_safely(test.string[0], 0); + + assert_int_equal(status, F_utf); + } +} + +void test__f_print_to_character_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, f_print_sequence_delete_s.used); + + const f_status_t status = f_print_to_character_safely((f_char_t) 0x7f, 0); + + assert_int_equal(status, F_none); + } + + { + will_return(__wrap_write, false); + will_return(__wrap_write, f_print_sequence_unknown_s.used); + + const f_status_t status = f_print_to_character_safely((f_char_t) F_utf_byte_1_d, 0); + + assert_int_equal(status, F_none); + } + + { + will_return(__wrap_write, false); + will_return(__wrap_write, 1); + + const f_status_t status = f_print_to_character_safely(test.string[0], 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_character_safely.h b/level_0/f_print/tests/unit/c/test-print-to_character_safely.h new file mode 100644 index 0000000..01adf40 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_character_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_character_safely_h +#define _TEST__F_print_to_character_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_character_safely() + */ +extern void test__f_print_to_character_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_character_safely() + */ +extern void test__f_print_to_character_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_utf. + * + * @see f_print_to_character_safely() + */ +extern void test__f_print_to_character_safely__returns_utf(void **state); + +/** + * Test that function works. + * + * @see f_print_to_character_safely() + */ +extern void test__f_print_to_character_safely__works(void **state); + +#endif // _TEST__F_print_to_character_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic.c b/level_0/f_print/tests/unit/c/test-print-to_dynamic.c new file mode 100644 index 0000000..71aebae --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic.c @@ -0,0 +1,93 @@ +#include "test-print.h" +#include "test-print-to_dynamic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_dynamic__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_dynamic(test, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_dynamic__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_dynamic(test, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_dynamic__returns_data_not(void **state) { + + { + const f_status_t status = f_print_to_dynamic(f_string_empty_s, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_dynamic__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_dynamic(test, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic.h b/level_0/f_print/tests/unit/c/test-print-to_dynamic.h new file mode 100644 index 0000000..e514be7 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_dynamic_h +#define _TEST__F_print_to_dynamic_h + +/** + * Test that function fails. + * + * @see f_print_to_dynamic() + */ +extern void test__f_print_to_dynamic__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_dynamic() + */ +extern void test__f_print_to_dynamic__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_dynamic() + */ +extern void test__f_print_to_dynamic__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_dynamic() + */ +extern void test__f_print_to_dynamic__works(void **state); + +#endif // _TEST__F_print_to_dynamic_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial.c b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial.c new file mode 100644 index 0000000..a41d9f1 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial.c @@ -0,0 +1,98 @@ +#include "test-print.h" +#include "test-print-to_dynamic_partial.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_dynamic_partial__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_dynamic_partial(test, partial, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_dynamic_partial__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_dynamic_partial(test, partial, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_dynamic_partial__returns_data_not(void **state) { + + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_dynamic_partial(f_string_empty_s, partial, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_dynamic_partial__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_dynamic_partial(test, partial, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial.h b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial.h new file mode 100644 index 0000000..a6e5482 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_dynamic_partial_h +#define _TEST__F_print_to_dynamic_partial_h + +/** + * Test that function fails. + * + * @see f_print_to_dynamic_partial() + */ +extern void test__f_print_to_dynamic_partial__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_dynamic_partial() + */ +extern void test__f_print_to_dynamic_partial__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_dynamic_partial() + */ +extern void test__f_print_to_dynamic_partial__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_dynamic_partial() + */ +extern void test__f_print_to_dynamic_partial__works(void **state); + +#endif // _TEST__F_print_to_dynamic_partial_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw.c b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw.c new file mode 100644 index 0000000..04d5b4f --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw.c @@ -0,0 +1,98 @@ +#include "test-print.h" +#include "test-print-to_dynamic_partial_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_dynamic_partial_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_dynamic_partial_raw(test, partial, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_dynamic_partial_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_dynamic_partial_raw(test, partial, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_dynamic_partial_raw__returns_data_not(void **state) { + + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_dynamic_partial_raw(f_string_empty_s, partial, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_dynamic_partial_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_dynamic_partial_raw(test, partial, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw.h b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw.h new file mode 100644 index 0000000..7deec2e --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_dynamic_partial_raw_h +#define _TEST__F_print_to_dynamic_partial_raw_h + +/** + * Test that function fails. + * + * @see f_print_to_dynamic_partial_raw() + */ +extern void test__f_print_to_dynamic_partial_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_dynamic_partial_raw() + */ +extern void test__f_print_to_dynamic_partial_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_dynamic_partial_raw() + */ +extern void test__f_print_to_dynamic_partial_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_dynamic_partial_raw() + */ +extern void test__f_print_to_dynamic_partial_raw__works(void **state); + +#endif // _TEST__F_print_to_dynamic_partial_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw_safely.c new file mode 100644 index 0000000..3b62dd8 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw_safely.c @@ -0,0 +1,98 @@ +#include "test-print.h" +#include "test-print-to_dynamic_partial_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_dynamic_partial_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_dynamic_partial_raw_safely(test, partial, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_dynamic_partial_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_dynamic_partial_raw_safely(test, partial, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_dynamic_partial_raw_safely__returns_data_not(void **state) { + + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_dynamic_partial_raw_safely(f_string_empty_s, partial, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_dynamic_partial_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_dynamic_partial_raw_safely(test, partial, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw_safely.h new file mode 100644 index 0000000..0168002 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_dynamic_partial_raw_safely_h +#define _TEST__F_print_to_dynamic_partial_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_dynamic_partial_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_dynamic_partial_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_dynamic_partial_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_dynamic_partial_raw_safely__works(void **state); + +#endif // _TEST__F_print_to_dynamic_partial_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_safely.c b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_safely.c new file mode 100644 index 0000000..1c58504 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_safely.c @@ -0,0 +1,98 @@ +#include "test-print.h" +#include "test-print-to_dynamic_partial_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_dynamic_partial_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_dynamic_partial_safely(test, partial, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_dynamic_partial_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_dynamic_partial_safely(test, partial, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_dynamic_partial_safely__returns_data_not(void **state) { + + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_dynamic_partial_safely(f_string_empty_s, partial, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_dynamic_partial_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_dynamic_partial_safely(test, partial, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_safely.h b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_safely.h new file mode 100644 index 0000000..b7d267b --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_partial_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_dynamic_partial_safely_h +#define _TEST__F_print_to_dynamic_partial_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_dynamic_partial_safely() + */ +extern void test__f_print_to_dynamic_partial_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_dynamic_partial_safely() + */ +extern void test__f_print_to_dynamic_partial_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_dynamic_partial_safely() + */ +extern void test__f_print_to_dynamic_partial_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_dynamic_partial_safely() + */ +extern void test__f_print_to_dynamic_partial_safely__works(void **state); + +#endif // _TEST__F_print_to_dynamic_partial_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw.c b/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw.c new file mode 100644 index 0000000..a6b2b12 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw.c @@ -0,0 +1,93 @@ +#include "test-print.h" +#include "test-print-to_dynamic_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_dynamic_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_dynamic_raw(test, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_dynamic_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_dynamic_raw(test, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_dynamic_raw__returns_data_not(void **state) { + + { + const f_status_t status = f_print_to_dynamic_raw(f_string_empty_s, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_dynamic_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_dynamic_raw(test, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw.h b/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw.h new file mode 100644 index 0000000..9c1f63a --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_dynamic_raw_h +#define _TEST__F_print_to_dynamic_raw_h + +/** + * Test that function fails. + * + * @see f_print_to_dynamic_raw() + */ +extern void test__f_print_to_dynamic_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_dynamic_raw() + */ +extern void test__f_print_to_dynamic_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_dynamic_raw() + */ +extern void test__f_print_to_dynamic_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_dynamic_raw() + */ +extern void test__f_print_to_dynamic_raw__works(void **state); + +#endif // _TEST__F_print_to_dynamic_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw_safely.c new file mode 100644 index 0000000..3351968 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw_safely.c @@ -0,0 +1,93 @@ +#include "test-print.h" +#include "test-print-to_dynamic_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_dynamic_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_dynamic_raw_safely(test, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_dynamic_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_dynamic_raw_safely(test, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_dynamic_raw_safely__returns_data_not(void **state) { + + { + const f_status_t status = f_print_to_dynamic_raw_safely(f_string_empty_s, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_dynamic_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_dynamic_raw_safely(test, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw_safely.h new file mode 100644 index 0000000..98b94e1 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_dynamic_raw_safely_h +#define _TEST__F_print_to_dynamic_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_dynamic_raw_safely() + */ +extern void test__f_print_to_dynamic_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_dynamic_raw_safely() + */ +extern void test__f_print_to_dynamic_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_dynamic_raw_safely() + */ +extern void test__f_print_to_dynamic_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_dynamic_raw_safely() + */ +extern void test__f_print_to_dynamic_raw_safely__works(void **state); + +#endif // _TEST__F_print_to_dynamic_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_safely.c b/level_0/f_print/tests/unit/c/test-print-to_dynamic_safely.c new file mode 100644 index 0000000..df31a79 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_safely.c @@ -0,0 +1,93 @@ +#include "test-print.h" +#include "test-print-to_dynamic_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_dynamic_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_dynamic_safely(test, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_dynamic_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_dynamic_safely(test, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_dynamic_safely__returns_data_not(void **state) { + + { + const f_status_t status = f_print_to_dynamic_safely(f_string_empty_s, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_dynamic_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_dynamic_safely(test, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_dynamic_safely.h b/level_0/f_print/tests/unit/c/test-print-to_dynamic_safely.h new file mode 100644 index 0000000..c731b8b --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_dynamic_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_dynamic_safely_h +#define _TEST__F_print_to_dynamic_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_dynamic_safely() + */ +extern void test__f_print_to_dynamic_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_dynamic_safely() + */ +extern void test__f_print_to_dynamic_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_dynamic_safely() + */ +extern void test__f_print_to_dynamic_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_dynamic_safely() + */ +extern void test__f_print_to_dynamic_safely__works(void **state); + +#endif // _TEST__F_print_to_dynamic_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except.c b/level_0/f_print/tests/unit/c/test-print-to_except.c new file mode 100644 index 0000000..8786b6e --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except.c @@ -0,0 +1,135 @@ +#include "test-print.h" +#include "test-print-to_except.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except(test.string, 0, test.used, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except(test.string, 0, test.used, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except(f_string_empty_s.string, 0, f_string_empty_s.used, except, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except(test.string, 0, f_string_empty_s.used, except, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except(0, 0, test.used, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except(test.string, 0, test.used, except, 0); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except(test.string, 2, test.used, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except(test.string, 1, test.used, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except.h b/level_0/f_print/tests/unit/c/test-print-to_except.h new file mode 100644 index 0000000..1695b39 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_h +#define _TEST__F_print_to_except_h + +/** + * Test that function fails. + * + * @see f_print_to_except() + */ +extern void test__f_print_to_except__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except() + */ +extern void test__f_print_to_except__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except() + */ +extern void test__f_print_to_except__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except() + */ +extern void test__f_print_to_except__works(void **state); + +#endif // _TEST__F_print_to_except_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic.c b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic.c new file mode 100644 index 0000000..a017dd1 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic.c @@ -0,0 +1,111 @@ +#include "test-print.h" +#include "test-print-to_except_dynamic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_dynamic__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_dynamic(test, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_dynamic__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_dynamic(test, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_dynamic__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_dynamic(f_string_empty_s, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_dynamic__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic(test, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic(test, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic.h b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic.h new file mode 100644 index 0000000..cbd9efe --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_dynamic_h +#define _TEST__F_print_to_except_dynamic_h + +/** + * Test that function fails. + * + * @see f_print_to_except_dynamic() + */ +extern void test__f_print_to_except_dynamic__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_dynamic() + */ +extern void test__f_print_to_except_dynamic__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_dynamic() + */ +extern void test__f_print_to_except_dynamic__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_dynamic() + */ +extern void test__f_print_to_except_dynamic__works(void **state); + +#endif // _TEST__F_print_to_except_dynamic_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial.c b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial.c new file mode 100644 index 0000000..b8bcc4f --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial.c @@ -0,0 +1,115 @@ +#include "test-print.h" +#include "test-print-to_except_dynamic_partial.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_dynamic_partial__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_dynamic_partial(test, partial, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_dynamic_partial__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_dynamic_partial(test, partial, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_dynamic_partial__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_dynamic_partial(f_string_empty_s, partial, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_dynamic_partial__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_partial(test, partial, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_partial(test, partial, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial.h b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial.h new file mode 100644 index 0000000..c0232b5 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_dynamic_partial_h +#define _TEST__F_print_to_except_dynamic_partial_h + +/** + * Test that function fails. + * + * @see f_print_to_except_dynamic_partial() + */ +extern void test__f_print_to_except_dynamic_partial__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_dynamic_partial() + */ +extern void test__f_print_to_except_dynamic_partial__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_dynamic_partial() + */ +extern void test__f_print_to_except_dynamic_partial__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_dynamic_partial() + */ +extern void test__f_print_to_except_dynamic_partial__works(void **state); + +#endif // _TEST__F_print_to_except_dynamic_partial_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw.c b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw.c new file mode 100644 index 0000000..de00b23 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw.c @@ -0,0 +1,115 @@ +#include "test-print.h" +#include "test-print-to_except_dynamic_partial_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_dynamic_partial_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_dynamic_partial_raw(test, partial, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_dynamic_partial_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_dynamic_partial_raw(test, partial, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_dynamic_partial_raw__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_dynamic_partial_raw(f_string_empty_s, partial, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_dynamic_partial_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_partial_raw(test, partial, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_partial_raw(test, partial, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw.h b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw.h new file mode 100644 index 0000000..587ea61 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_dynamic_partial_raw_h +#define _TEST__F_print_to_except_dynamic_partial_raw_h + +/** + * Test that function fails. + * + * @see f_print_to_except_dynamic_partial_raw() + */ +extern void test__f_print_to_except_dynamic_partial_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_dynamic_partial_raw() + */ +extern void test__f_print_to_except_dynamic_partial_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_dynamic_partial_raw() + */ +extern void test__f_print_to_except_dynamic_partial_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_dynamic_partial_raw() + */ +extern void test__f_print_to_except_dynamic_partial_raw__works(void **state); + +#endif // _TEST__F_print_to_except_dynamic_partial_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw_safely.c new file mode 100644 index 0000000..cbf0d16 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw_safely.c @@ -0,0 +1,115 @@ +#include "test-print.h" +#include "test-print-to_except_dynamic_partial_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_dynamic_partial_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_dynamic_partial_raw_safely(test, partial, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_dynamic_partial_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_dynamic_partial_raw_safely(test, partial, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_dynamic_partial_raw_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_dynamic_partial_raw_safely(f_string_empty_s, partial, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_dynamic_partial_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_partial_raw_safely(test, partial, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_partial_raw_safely(test, partial, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw_safely.h new file mode 100644 index 0000000..ff032a3 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_dynamic_partial_raw_safely_h +#define _TEST__F_print_to_except_dynamic_partial_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_except_dynamic_partial_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_except_dynamic_partial_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_except_dynamic_partial_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_except_dynamic_partial_raw_safely__works(void **state); + +#endif // _TEST__F_print_to_except_dynamic_partial_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_safely.c new file mode 100644 index 0000000..07d0b24 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_safely.c @@ -0,0 +1,115 @@ +#include "test-print.h" +#include "test-print-to_except_dynamic_partial_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_dynamic_partial_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_dynamic_partial_safely(test, partial, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_dynamic_partial_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_dynamic_partial_safely(test, partial, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_dynamic_partial_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_dynamic_partial_safely(f_string_empty_s, partial, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_dynamic_partial_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_partial_safely(test, partial, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_partial_safely(test, partial, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_safely.h new file mode 100644 index 0000000..dd0584a --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_partial_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_dynamic_partial_safely_h +#define _TEST__F_print_to_except_dynamic_partial_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_dynamic_partial_safely() + */ +extern void test__f_print_to_except_dynamic_partial_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_dynamic_partial_safely() + */ +extern void test__f_print_to_except_dynamic_partial_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_dynamic_partial_safely() + */ +extern void test__f_print_to_except_dynamic_partial_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_dynamic_partial_safely() + */ +extern void test__f_print_to_except_dynamic_partial_safely__works(void **state); + +#endif // _TEST__F_print_to_except_dynamic_partial_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw.c b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw.c new file mode 100644 index 0000000..ba6f561 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw.c @@ -0,0 +1,111 @@ +#include "test-print.h" +#include "test-print-to_except_dynamic_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_dynamic_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_dynamic_raw(test, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_dynamic_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_dynamic_raw(test, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_dynamic_raw__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_dynamic_raw(f_string_empty_s, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_dynamic_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_raw(test, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_raw(test, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw.h b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw.h new file mode 100644 index 0000000..7142159 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_dynamic_raw_h +#define _TEST__F_print_to_except_dynamic_raw_h + +/** + * Test that function fails. + * + * @see f_print_to_except_dynamic_raw() + */ +extern void test__f_print_to_except_dynamic_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_dynamic_raw() + */ +extern void test__f_print_to_except_dynamic_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_dynamic_raw() + */ +extern void test__f_print_to_except_dynamic_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_dynamic_raw() + */ +extern void test__f_print_to_except_dynamic_raw__works(void **state); + +#endif // _TEST__F_print_to_except_dynamic_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw_safely.c new file mode 100644 index 0000000..d1b8a5e --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw_safely.c @@ -0,0 +1,111 @@ +#include "test-print.h" +#include "test-print-to_except_dynamic_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_dynamic_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_dynamic_raw_safely(test, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_dynamic_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_dynamic_raw_safely(test, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_dynamic_raw_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_dynamic_raw_safely(f_string_empty_s, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_dynamic_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_raw_safely(test, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_raw_safely(test, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw_safely.h new file mode 100644 index 0000000..d89f38f --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_dynamic_raw_safely_h +#define _TEST__F_print_to_except_dynamic_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_dynamic_raw_safely() + */ +extern void test__f_print_to_except_dynamic_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_dynamic_raw_safely() + */ +extern void test__f_print_to_except_dynamic_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_dynamic_raw_safely() + */ +extern void test__f_print_to_except_dynamic_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_dynamic_raw_safely() + */ +extern void test__f_print_to_except_dynamic_raw_safely__works(void **state); + +#endif // _TEST__F_print_to_except_dynamic_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_safely.c new file mode 100644 index 0000000..b644c55 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_safely.c @@ -0,0 +1,111 @@ +#include "test-print.h" +#include "test-print-to_except_dynamic_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_dynamic_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_dynamic_safely(test, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_dynamic_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_dynamic_safely(test, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_dynamic_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_dynamic_safely(f_string_empty_s, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_dynamic_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_safely(test, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_dynamic_safely(test, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_safely.h new file mode 100644 index 0000000..cf25d2a --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_dynamic_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_dynamic_safely_h +#define _TEST__F_print_to_except_dynamic_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_dynamic_safely() + */ +extern void test__f_print_to_except_dynamic_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_dynamic_safely() + */ +extern void test__f_print_to_except_dynamic_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_dynamic_safely() + */ +extern void test__f_print_to_except_dynamic_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_dynamic_safely() + */ +extern void test__f_print_to_except_dynamic_safely__works(void **state); + +#endif // _TEST__F_print_to_except_dynamic_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in.c b/level_0/f_print/tests/unit/c/test-print-to_except_in.c new file mode 100644 index 0000000..4e5f31a --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in.c @@ -0,0 +1,144 @@ +#include "test-print.h" +#include "test-print-to_except_in.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in(test.string, 0, test.used, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in(test.string, 0, test.used, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in(f_string_empty_s.string, 0, f_string_empty_s.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_in(test.string, 0, f_string_empty_s.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_in(0, 0, test.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in(test.string, 0, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in(test.string, 2, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in(test.string, 1, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in.h b/level_0/f_print/tests/unit/c/test-print-to_except_in.h new file mode 100644 index 0000000..9ca84a5 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_h +#define _TEST__F_print_to_except_in_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in() + */ +extern void test__f_print_to_except_in__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in() + */ +extern void test__f_print_to_except_in__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in() + */ +extern void test__f_print_to_except_in__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in() + */ +extern void test__f_print_to_except_in__works(void **state); + +#endif // _TEST__F_print_to_except_in_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic.c b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic.c new file mode 100644 index 0000000..1235b23 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic.c @@ -0,0 +1,119 @@ +#include "test-print.h" +#include "test-print-to_except_in_dynamic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in_dynamic__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in_dynamic(test, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in_dynamic__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_dynamic(test, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in_dynamic__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_dynamic(f_string_empty_s, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in_dynamic__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic(test, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic(test, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic.h b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic.h new file mode 100644 index 0000000..c511f14 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_dynamic_h +#define _TEST__F_print_to_except_in_dynamic_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in_dynamic() + */ +extern void test__f_print_to_except_in_dynamic__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in_dynamic() + */ +extern void test__f_print_to_except_in_dynamic__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in_dynamic() + */ +extern void test__f_print_to_except_in_dynamic__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in_dynamic() + */ +extern void test__f_print_to_except_in_dynamic__works(void **state); + +#endif // _TEST__F_print_to_except_in_dynamic_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial.c b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial.c new file mode 100644 index 0000000..d61fa29 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial.c @@ -0,0 +1,123 @@ +#include "test-print.h" +#include "test-print-to_except_in_dynamic_partial.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in_dynamic_partial__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in_dynamic_partial(test, partial, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in_dynamic_partial__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_in_dynamic_partial(test, partial, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in_dynamic_partial__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_in_dynamic_partial(f_string_empty_s, partial, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in_dynamic_partial__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_partial(test, partial, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_partial(test, partial, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial.h b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial.h new file mode 100644 index 0000000..38ad648 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_dynamic_partial_h +#define _TEST__F_print_to_except_in_dynamic_partial_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in_dynamic_partial() + */ +extern void test__f_print_to_except_in_dynamic_partial__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in_dynamic_partial() + */ +extern void test__f_print_to_except_in_dynamic_partial__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in_dynamic_partial() + */ +extern void test__f_print_to_except_in_dynamic_partial__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in_dynamic_partial() + */ +extern void test__f_print_to_except_in_dynamic_partial__works(void **state); + +#endif // _TEST__F_print_to_except_in_dynamic_partial_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw.c b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw.c new file mode 100644 index 0000000..19621b4 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw.c @@ -0,0 +1,123 @@ +#include "test-print.h" +#include "test-print-to_except_in_dynamic_partial_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in_dynamic_partial_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in_dynamic_partial_raw(test, partial, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in_dynamic_partial_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_in_dynamic_partial_raw(test, partial, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in_dynamic_partial_raw__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_in_dynamic_partial_raw(f_string_empty_s, partial, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in_dynamic_partial_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_partial_raw(test, partial, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_partial_raw(test, partial, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw.h b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw.h new file mode 100644 index 0000000..8cbb7fa --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_dynamic_partial_raw_h +#define _TEST__F_print_to_except_in_dynamic_partial_raw_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in_dynamic_partial_raw() + */ +extern void test__f_print_to_except_in_dynamic_partial_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in_dynamic_partial_raw() + */ +extern void test__f_print_to_except_in_dynamic_partial_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in_dynamic_partial_raw() + */ +extern void test__f_print_to_except_in_dynamic_partial_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in_dynamic_partial_raw() + */ +extern void test__f_print_to_except_in_dynamic_partial_raw__works(void **state); + +#endif // _TEST__F_print_to_except_in_dynamic_partial_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw_safely.c new file mode 100644 index 0000000..b4cd65a --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw_safely.c @@ -0,0 +1,123 @@ +#include "test-print.h" +#include "test-print-to_except_in_dynamic_partial_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in_dynamic_partial_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in_dynamic_partial_raw_safely(test, partial, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in_dynamic_partial_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_in_dynamic_partial_raw_safely(test, partial, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in_dynamic_partial_raw_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_in_dynamic_partial_raw_safely(f_string_empty_s, partial, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in_dynamic_partial_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_partial_raw_safely(test, partial, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_partial_raw_safely(test, partial, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw_safely.h new file mode 100644 index 0000000..932f3db --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_dynamic_partial_raw_safely_h +#define _TEST__F_print_to_except_in_dynamic_partial_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_except_in_dynamic_partial_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_except_in_dynamic_partial_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_except_in_dynamic_partial_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in_dynamic_partial_raw_safely() + */ +extern void test__f_print_to_except_in_dynamic_partial_raw_safely__works(void **state); + +#endif // _TEST__F_print_to_except_in_dynamic_partial_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_safely.c new file mode 100644 index 0000000..215dabb --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_safely.c @@ -0,0 +1,123 @@ +#include "test-print.h" +#include "test-print-to_except_in_dynamic_partial_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in_dynamic_partial_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in_dynamic_partial_safely(test, partial, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in_dynamic_partial_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_in_dynamic_partial_safely(test, partial, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in_dynamic_partial_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_status_t status = f_print_to_except_in_dynamic_partial_safely(f_string_empty_s, partial, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in_dynamic_partial_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_string_range_t partial = macro_f_string_range_t_initialize(0, 2); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_partial_safely(test, partial, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_partial_safely(test, partial, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_safely.h new file mode 100644 index 0000000..e20cfb7 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_partial_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_dynamic_partial_safely_h +#define _TEST__F_print_to_except_in_dynamic_partial_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in_dynamic_partial_safely() + */ +extern void test__f_print_to_except_in_dynamic_partial_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in_dynamic_partial_safely() + */ +extern void test__f_print_to_except_in_dynamic_partial_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in_dynamic_partial_safely() + */ +extern void test__f_print_to_except_in_dynamic_partial_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in_dynamic_partial_safely() + */ +extern void test__f_print_to_except_in_dynamic_partial_safely__works(void **state); + +#endif // _TEST__F_print_to_except_in_dynamic_partial_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw.c b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw.c new file mode 100644 index 0000000..03814a5 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw.c @@ -0,0 +1,119 @@ +#include "test-print.h" +#include "test-print-to_except_in_dynamic_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in_dynamic_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in_dynamic_raw(test, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in_dynamic_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_dynamic_raw(test, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in_dynamic_raw__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_dynamic_raw(f_string_empty_s, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in_dynamic_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_raw(test, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_raw(test, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw.h b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw.h new file mode 100644 index 0000000..ab08e37 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_dynamic_raw_h +#define _TEST__F_print_to_except_in_dynamic_raw_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in_dynamic_raw() + */ +extern void test__f_print_to_except_in_dynamic_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in_dynamic_raw() + */ +extern void test__f_print_to_except_in_dynamic_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in_dynamic_raw() + */ +extern void test__f_print_to_except_in_dynamic_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in_dynamic_raw() + */ +extern void test__f_print_to_except_in_dynamic_raw__works(void **state); + +#endif // _TEST__F_print_to_except_in_dynamic_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw_safely.c new file mode 100644 index 0000000..112efcd --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw_safely.c @@ -0,0 +1,119 @@ +#include "test-print.h" +#include "test-print-to_except_in_dynamic_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in_dynamic_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in_dynamic_raw_safely(test, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in_dynamic_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_dynamic_raw_safely(test, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in_dynamic_raw_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_dynamic_raw_safely(f_string_empty_s, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in_dynamic_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_raw_safely(test, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_raw_safely(test, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw_safely.h new file mode 100644 index 0000000..ac19e44 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_dynamic_raw_safely_h +#define _TEST__F_print_to_except_in_dynamic_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in_dynamic_raw_safely() + */ +extern void test__f_print_to_except_in_dynamic_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in_dynamic_raw_safely() + */ +extern void test__f_print_to_except_in_dynamic_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in_dynamic_raw_safely() + */ +extern void test__f_print_to_except_in_dynamic_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in_dynamic_raw_safely() + */ +extern void test__f_print_to_except_in_dynamic_raw_safely__works(void **state); + +#endif // _TEST__F_print_to_except_in_dynamic_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_safely.c new file mode 100644 index 0000000..c662c2b --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_safely.c @@ -0,0 +1,119 @@ +#include "test-print.h" +#include "test-print-to_except_in_dynamic_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in_dynamic_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in_dynamic_safely(test, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in_dynamic_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_dynamic_safely(test, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in_dynamic_safely__returns_data_not(void **state) { + + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_dynamic_safely(f_string_empty_s, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in_dynamic_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_safely(test, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_dynamic_safely(test, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_safely.h new file mode 100644 index 0000000..5772550 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_dynamic_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_dynamic_safely_h +#define _TEST__F_print_to_except_in_dynamic_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in_dynamic_safely() + */ +extern void test__f_print_to_except_in_dynamic_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in_dynamic_safely() + */ +extern void test__f_print_to_except_in_dynamic_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in_dynamic_safely() + */ +extern void test__f_print_to_except_in_dynamic_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in_dynamic_safely() + */ +extern void test__f_print_to_except_in_dynamic_safely__works(void **state); + +#endif // _TEST__F_print_to_except_in_dynamic_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_raw.c b/level_0/f_print/tests/unit/c/test-print-to_except_in_raw.c new file mode 100644 index 0000000..91d236b --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_raw.c @@ -0,0 +1,144 @@ +#include "test-print.h" +#include "test-print-to_except_in_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in_raw(test.string, 0, test.used, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_raw(test.string, 0, test.used, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in_raw__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_raw(f_string_empty_s.string, 0, f_string_empty_s.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_in_raw(test.string, 0, f_string_empty_s.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_in_raw(0, 0, test.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_raw(test.string, 0, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_raw(test.string, 2, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_raw(test.string, 1, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_raw.h b/level_0/f_print/tests/unit/c/test-print-to_except_in_raw.h new file mode 100644 index 0000000..8aab3ab --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_raw_h +#define _TEST__F_print_to_except_in_raw_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in_raw() + */ +extern void test__f_print_to_except_in_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in_raw() + */ +extern void test__f_print_to_except_in_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in_raw() + */ +extern void test__f_print_to_except_in_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in_raw() + */ +extern void test__f_print_to_except_in_raw__works(void **state); + +#endif // _TEST__F_print_to_except_in_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_in_raw_safely.c new file mode 100644 index 0000000..9642311 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_raw_safely.c @@ -0,0 +1,144 @@ +#include "test-print.h" +#include "test-print-to_except_in_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in_raw_safely(test.string, 0, test.used, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_raw_safely(test.string, 0, test.used, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in_raw_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_raw_safely(f_string_empty_s.string, 0, f_string_empty_s.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_in_raw_safely(test.string, 0, f_string_empty_s.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_in_raw_safely(0, 0, test.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_raw_safely(test.string, 0, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_raw_safely(test.string, 2, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_raw_safely(test.string, 1, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_in_raw_safely.h new file mode 100644 index 0000000..c97adf0 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_raw_safely_h +#define _TEST__F_print_to_except_in_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in_raw_safely() + */ +extern void test__f_print_to_except_in_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in_raw_safely() + */ +extern void test__f_print_to_except_in_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in_raw_safely() + */ +extern void test__f_print_to_except_in_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in_raw_safely() + */ +extern void test__f_print_to_except_in_raw_safely__works(void **state); + +#endif // _TEST__F_print_to_except_in_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_in_safely.c new file mode 100644 index 0000000..ddc339f --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_safely.c @@ -0,0 +1,144 @@ +#include "test-print.h" +#include "test-print-to_except_in_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_in_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_in_safely(test.string, 0, test.used, except, range, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_in_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_safely(test.string, 0, test.used, except, range, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_in_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + { + const f_status_t status = f_print_to_except_in_safely(f_string_empty_s.string, 0, f_string_empty_s.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_in_safely(test.string, 0, f_string_empty_s.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_in_safely(0, 0, test.used, except, range, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_in_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_safely(test.string, 0, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + const f_string_ranges_t range = f_string_ranges_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_safely(test.string, 2, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + f_string_range_t ranges[] = { + macro_f_string_range_t_initialize(0, 1), + }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + const f_string_ranges_t range = macro_f_string_ranges_t_initialize(ranges, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_in_safely(test.string, 1, test.used, except, range, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_in_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_in_safely.h new file mode 100644 index 0000000..ba78eab --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_in_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_in_safely_h +#define _TEST__F_print_to_except_in_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_in_safely() + */ +extern void test__f_print_to_except_in_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_in_safely() + */ +extern void test__f_print_to_except_in_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_in_safely() + */ +extern void test__f_print_to_except_in_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_in_safely() + */ +extern void test__f_print_to_except_in_safely__works(void **state); + +#endif // _TEST__F_print_to_except_in_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_raw.c b/level_0/f_print/tests/unit/c/test-print-to_except_raw.c new file mode 100644 index 0000000..5e1d853 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_raw.c @@ -0,0 +1,135 @@ +#include "test-print.h" +#include "test-print-to_except_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_raw(test.string, 0, test.used, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_raw(test.string, 0, test.used, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_raw__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_raw(f_string_empty_s.string, 0, f_string_empty_s.used, except, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_raw(test.string, 0, f_string_empty_s.used, except, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_raw(0, 0, test.used, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_raw(test.string, 0, test.used, except, 0); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_raw(test.string, 2, test.used, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_raw(test.string, 1, test.used, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_raw.h b/level_0/f_print/tests/unit/c/test-print-to_except_raw.h new file mode 100644 index 0000000..d8cbba9 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_raw_h +#define _TEST__F_print_to_except_raw_h + +/** + * Test that function fails. + * + * @see f_print_to_except_raw() + */ +extern void test__f_print_to_except_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_raw() + */ +extern void test__f_print_to_except_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_raw() + */ +extern void test__f_print_to_except_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_raw() + */ +extern void test__f_print_to_except_raw__works(void **state); + +#endif // _TEST__F_print_to_except_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_raw_safely.c new file mode 100644 index 0000000..aac2f1f --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_raw_safely.c @@ -0,0 +1,135 @@ +#include "test-print.h" +#include "test-print-to_except_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_raw_safely(test.string, 0, test.used, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_raw_safely(test.string, 0, test.used, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_raw_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_raw_safely(f_string_empty_s.string, 0, f_string_empty_s.used, except, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_raw_safely(test.string, 0, f_string_empty_s.used, except, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_raw_safely(0, 0, test.used, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_raw_safely(test.string, 0, test.used, except, 0); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_raw_safely(test.string, 2, test.used, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_raw_safely(test.string, 1, test.used, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_raw_safely.h new file mode 100644 index 0000000..f598f6b --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_raw_safely_h +#define _TEST__F_print_to_except_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_raw_safely() + */ +extern void test__f_print_to_except_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_raw_safely() + */ +extern void test__f_print_to_except_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_raw_safely() + */ +extern void test__f_print_to_except_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_raw_safely() + */ +extern void test__f_print_to_except_raw_safely__works(void **state); + +#endif // _TEST__F_print_to_except_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_safely.c b/level_0/f_print/tests/unit/c/test-print-to_except_safely.c new file mode 100644 index 0000000..72f581d --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_safely.c @@ -0,0 +1,135 @@ +#include "test-print.h" +#include "test-print-to_except_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_except_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_except_safely(test.string, 0, test.used, except, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_except_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_safely(test.string, 0, test.used, except, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_except_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + const f_array_lengths_t except = f_array_lengths_t_initialize; + + { + const f_status_t status = f_print_to_except_safely(f_string_empty_s.string, 0, f_string_empty_s.used, except, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_safely(test.string, 0, f_string_empty_s.used, except, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_except_safely(0, 0, test.used, except, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_except_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_safely(test.string, 0, test.used, except, 0); + + assert_int_equal(status, F_none); + } + + { + const f_array_lengths_t except = f_array_lengths_t_initialize; + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_safely(test.string, 2, test.used, except, 0); + + assert_int_equal(status, F_none); + } + + { + f_array_length_t lengths[] = { 3 }; + const f_array_lengths_t except = macro_f_array_lengths_t_initialize(lengths, 0, 1); + + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_except_safely(test.string, 1, test.used, except, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_except_safely.h b/level_0/f_print/tests/unit/c/test-print-to_except_safely.h new file mode 100644 index 0000000..711cdb7 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_except_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_except_safely_h +#define _TEST__F_print_to_except_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_except_safely() + */ +extern void test__f_print_to_except_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_except_safely() + */ +extern void test__f_print_to_except_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_except_safely() + */ +extern void test__f_print_to_except_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_except_safely() + */ +extern void test__f_print_to_except_safely__works(void **state); + +#endif // _TEST__F_print_to_except_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_raw.c b/level_0/f_print/tests/unit/c/test-print-to_raw.c new file mode 100644 index 0000000..47b61f0 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_raw.c @@ -0,0 +1,110 @@ +#include "test-print.h" +#include "test-print-to_raw.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_raw__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_raw(test.string, test.used, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_raw__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_raw(test.string, test.used, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_raw__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_raw(f_string_empty_s.string, f_string_empty_s.used, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_raw(test.string, f_string_empty_s.used, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_raw(0, test.used, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_raw__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + /*will_return(__wrap_write, false); + will_return(__wrap_write, 1);*/ + + const f_status_t status = f_print_to_raw(test.string, test.used, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_raw.h b/level_0/f_print/tests/unit/c/test-print-to_raw.h new file mode 100644 index 0000000..fae3644 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_raw.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_raw_h +#define _TEST__F_print_to_raw_h + +/** + * Test that function fails. + * + * @see f_print_to_raw() + */ +extern void test__f_print_to_raw__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_raw() + */ +extern void test__f_print_to_raw__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_raw() + */ +extern void test__f_print_to_raw__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_raw() + */ +extern void test__f_print_to_raw__works(void **state); + +#endif // _TEST__F_print_to_raw_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_raw_safely.c b/level_0/f_print/tests/unit/c/test-print-to_raw_safely.c new file mode 100644 index 0000000..d539b3c --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_raw_safely.c @@ -0,0 +1,107 @@ +#include "test-print.h" +#include "test-print-to_raw_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_raw_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_raw_safely(test.string, test.used, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_raw_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_raw_safely(test.string, test.used, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_raw_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_raw_safely(f_string_empty_s.string, f_string_empty_s.used, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_raw_safely(test.string, f_string_empty_s.used, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_raw_safely(0, test.used, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_raw_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_raw_safely(test.string, test.used, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_raw_safely.h b/level_0/f_print/tests/unit/c/test-print-to_raw_safely.h new file mode 100644 index 0000000..831492d --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_raw_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_raw_safely_h +#define _TEST__F_print_to_raw_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_raw_safely() + */ +extern void test__f_print_to_raw_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_raw_safely() + */ +extern void test__f_print_to_raw_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_raw_safely() + */ +extern void test__f_print_to_raw_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_raw_safely() + */ +extern void test__f_print_to_raw_safely__works(void **state); + +#endif // _TEST__F_print_to_raw_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_raw_terminated.c b/level_0/f_print/tests/unit/c/test-print-to_raw_terminated.c new file mode 100644 index 0000000..3f92569 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_raw_terminated.c @@ -0,0 +1,93 @@ +#include "test-print.h" +#include "test-print-to_raw_terminated.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_raw_terminated__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_raw_terminated(test.string, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_raw_terminated__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_raw_terminated(test.string, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_raw_terminated__returns_data_not(void **state) { + + { + const f_status_t status = f_print_to_raw_terminated(0, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_raw_terminated__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_raw_terminated(test.string, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_raw_terminated.h b/level_0/f_print/tests/unit/c/test-print-to_raw_terminated.h new file mode 100644 index 0000000..5344ae6 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_raw_terminated.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_raw_terminated_h +#define _TEST__F_print_to_raw_terminated_h + +/** + * Test that function fails. + * + * @see f_print_to_raw_terminated() + */ +extern void test__f_print_to_raw_terminated__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_raw_terminated() + */ +extern void test__f_print_to_raw_terminated__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_raw_terminated() + */ +extern void test__f_print_to_raw_terminated__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_raw_terminated() + */ +extern void test__f_print_to_raw_terminated__works(void **state); + +#endif // _TEST__F_print_to_raw_terminated_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_safely.c b/level_0/f_print/tests/unit/c/test-print-to_safely.c new file mode 100644 index 0000000..5a6bc12 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_safely.c @@ -0,0 +1,107 @@ +#include "test-print.h" +#include "test-print-to_safely.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_safely__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_safely(test.string, test.used, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_safely__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_safely(test.string, test.used, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_safely__returns_data_not(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_safely(f_string_empty_s.string, f_string_empty_s.used, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_safely(test.string, f_string_empty_s.used, 0); + + assert_int_equal(status, F_data_not); + } + + { + const f_status_t status = f_print_to_safely(0, test.used, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_safely__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_safely(test.string, test.used, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_safely.h b/level_0/f_print/tests/unit/c/test-print-to_safely.h new file mode 100644 index 0000000..7423899 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_safely.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_safely_h +#define _TEST__F_print_to_safely_h + +/** + * Test that function fails. + * + * @see f_print_to_safely() + */ +extern void test__f_print_to_safely__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_safely() + */ +extern void test__f_print_to_safely__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_safely() + */ +extern void test__f_print_to_safely__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_safely() + */ +extern void test__f_print_to_safely__works(void **state); + +#endif // _TEST__F_print_to_safely_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_safely_terminated.c b/level_0/f_print/tests/unit/c/test-print-to_safely_terminated.c new file mode 100644 index 0000000..f13c0b8 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_safely_terminated.c @@ -0,0 +1,93 @@ +#include "test-print.h" +#include "test-print-to_safely_terminated.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_safely_terminated__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_safely_terminated(test.string, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_safely_terminated__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_safely_terminated(test.string, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_safely_terminated__returns_data_not(void **state) { + + { + const f_status_t status = f_print_to_safely_terminated(0, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_safely_terminated__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_safely_terminated(test.string, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_safely_terminated.h b/level_0/f_print/tests/unit/c/test-print-to_safely_terminated.h new file mode 100644 index 0000000..8e5358d --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_safely_terminated.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_safely_terminated_h +#define _TEST__F_print_to_safely_terminated_h + +/** + * Test that function fails. + * + * @see f_print_to_safely_terminated() + */ +extern void test__f_print_to_safely_terminated__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_safely_terminated() + */ +extern void test__f_print_to_safely_terminated__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_safely_terminated() + */ +extern void test__f_print_to_safely_terminated__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_safely_terminated() + */ +extern void test__f_print_to_safely_terminated__works(void **state); + +#endif // _TEST__F_print_to_safely_terminated_h diff --git a/level_0/f_print/tests/unit/c/test-print-to_terminated.c b/level_0/f_print/tests/unit/c/test-print-to_terminated.c new file mode 100644 index 0000000..2ae1344 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_terminated.c @@ -0,0 +1,93 @@ +#include "test-print.h" +#include "test-print-to_terminated.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_print_to_terminated__fails(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + int errnos[] = { + EAGAIN, + EBADF, + EDESTADDRREQ, + EDQUOT, + EFBIG, + EFAULT, + EINTR, + EINVAL, + EIO, + EISDIR, + ENOSPC, + EPIPE, + EWOULDBLOCK, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_block, + F_file_descriptor, + F_socket_not, + F_filesystem_quota_block, + F_number_overflow, + F_buffer, + F_interrupt, + F_parameter, + F_input_output, + F_file_type_directory, + F_space_not, + F_pipe, + F_block, + F_output, + }; + + for (int i = 0; i < 14; ++i) { + + will_return(__wrap_write, true); + will_return(__wrap_write, errnos[i]); + + const f_status_t status = f_print_to_terminated(test.string, 0); + + assert_int_equal(status, F_status_set_error(statuss[i])); + } // for +} + +void test__f_print_to_terminated__parameter_checking(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + const f_status_t status = f_print_to_terminated(test.string, -1); + + assert_int_equal(F_status_set_fine(status), F_parameter); + } +} + +void test__f_print_to_terminated__returns_data_not(void **state) { + + { + const f_status_t status = f_print_to_terminated(0, 0); + + assert_int_equal(status, F_data_not); + } +} + +void test__f_print_to_terminated__works(void **state) { + + const f_string_static_t test = macro_f_string_static_t_initialize("test", 0, 4); + + { + will_return(__wrap_write, false); + will_return(__wrap_write, test.used); + + const f_status_t status = f_print_to_terminated(test.string, 0); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print-to_terminated.h b/level_0/f_print/tests/unit/c/test-print-to_terminated.h new file mode 100644 index 0000000..3bb2b0b --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print-to_terminated.h @@ -0,0 +1,41 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_to_terminated_h +#define _TEST__F_print_to_terminated_h + +/** + * Test that function fails. + * + * @see f_print_to_terminated() + */ +extern void test__f_print_to_terminated__fails(void **state); + +/** + * Test that parameter checking works as expected. + * + * @see f_print_to_terminated() + */ +extern void test__f_print_to_terminated__parameter_checking(void **state); + +/** + * Test that function works but returns F_data_not. + * + * @see f_print_to_terminated() + */ +extern void test__f_print_to_terminated__returns_data_not(void **state); + +/** + * Test that function works. + * + * @see f_print_to_terminated() + */ +extern void test__f_print_to_terminated__works(void **state); + +#endif // _TEST__F_print_to_terminated_h diff --git a/level_0/f_print/tests/unit/c/test-print.c b/level_0/f_print/tests/unit/c/test-print.c new file mode 100644 index 0000000..95e8ebb --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print.c @@ -0,0 +1,451 @@ +#include "test-print.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_print__fails), + cmocka_unit_test(test__f_print__returns_data_not), + cmocka_unit_test(test__f_print__works), + + cmocka_unit_test(test__f_print_character__fails), + cmocka_unit_test(test__f_print_character__works), + + cmocka_unit_test(test__f_print_character_safely__fails), + cmocka_unit_test(test__f_print_character_safely__returns_utf), + cmocka_unit_test(test__f_print_character_safely__works), + + cmocka_unit_test(test__f_print_character_safely_get__returns_character_control), + cmocka_unit_test(test__f_print_character_safely_get__returns_character_delete), + cmocka_unit_test(test__f_print_character_safely_get__returns_character_unknown), + cmocka_unit_test(test__f_print_character_safely_get__returns_empty), + + cmocka_unit_test(test__f_print_dynamic__fails), + cmocka_unit_test(test__f_print_dynamic__returns_data_not), + cmocka_unit_test(test__f_print_dynamic__works), + + cmocka_unit_test(test__f_print_dynamic_partial__fails), + cmocka_unit_test(test__f_print_dynamic_partial__returns_data_not), + cmocka_unit_test(test__f_print_dynamic_partial__works), + + cmocka_unit_test(test__f_print_dynamic_partial_raw__fails), + cmocka_unit_test(test__f_print_dynamic_partial_raw__returns_data_not), + cmocka_unit_test(test__f_print_dynamic_partial_raw__works), + + cmocka_unit_test(test__f_print_dynamic_partial_raw_safely__fails), + cmocka_unit_test(test__f_print_dynamic_partial_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_dynamic_partial_raw_safely__works), + + cmocka_unit_test(test__f_print_dynamic_partial_safely__fails), + cmocka_unit_test(test__f_print_dynamic_partial_safely__returns_data_not), + cmocka_unit_test(test__f_print_dynamic_partial_safely__works), + + cmocka_unit_test(test__f_print_dynamic_raw__fails), + cmocka_unit_test(test__f_print_dynamic_raw__returns_data_not), + cmocka_unit_test(test__f_print_dynamic_raw__works), + + cmocka_unit_test(test__f_print_dynamic_raw_safely__fails), + cmocka_unit_test(test__f_print_dynamic_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_dynamic_raw_safely__works), + + cmocka_unit_test(test__f_print_dynamic_safely__fails), + cmocka_unit_test(test__f_print_dynamic_safely__returns_data_not), + cmocka_unit_test(test__f_print_dynamic_safely__works), + + cmocka_unit_test(test__f_print_except__fails), + cmocka_unit_test(test__f_print_except__returns_data_not), + cmocka_unit_test(test__f_print_except__works), + + cmocka_unit_test(test__f_print_except_dynamic__fails), + cmocka_unit_test(test__f_print_except_dynamic__returns_data_not), + cmocka_unit_test(test__f_print_except_dynamic__works), + + cmocka_unit_test(test__f_print_except_dynamic_partial__fails), + cmocka_unit_test(test__f_print_except_dynamic_partial__returns_data_not), + cmocka_unit_test(test__f_print_except_dynamic_partial__works), + + cmocka_unit_test(test__f_print_except_dynamic_partial_raw__fails), + cmocka_unit_test(test__f_print_except_dynamic_partial_raw__returns_data_not), + cmocka_unit_test(test__f_print_except_dynamic_partial_raw__works), + + cmocka_unit_test(test__f_print_except_dynamic_partial_raw_safely__fails), + cmocka_unit_test(test__f_print_except_dynamic_partial_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_dynamic_partial_raw_safely__works), + + cmocka_unit_test(test__f_print_except_dynamic_partial_safely__fails), + cmocka_unit_test(test__f_print_except_dynamic_partial_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_dynamic_partial_safely__works), + + cmocka_unit_test(test__f_print_except_dynamic_raw__fails), + cmocka_unit_test(test__f_print_except_dynamic_raw__returns_data_not), + cmocka_unit_test(test__f_print_except_dynamic_raw__works), + + cmocka_unit_test(test__f_print_except_dynamic_raw_safely__fails), + cmocka_unit_test(test__f_print_except_dynamic_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_dynamic_raw_safely__works), + + cmocka_unit_test(test__f_print_except_dynamic_safely__fails), + cmocka_unit_test(test__f_print_except_dynamic_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_dynamic_safely__works), + + cmocka_unit_test(test__f_print_except_in__fails), + cmocka_unit_test(test__f_print_except_in__returns_data_not), + cmocka_unit_test(test__f_print_except_in__works), + + cmocka_unit_test(test__f_print_except_in_dynamic__fails), + cmocka_unit_test(test__f_print_except_in_dynamic__returns_data_not), + cmocka_unit_test(test__f_print_except_in_dynamic__works), + + cmocka_unit_test(test__f_print_except_in_dynamic_partial__fails), + cmocka_unit_test(test__f_print_except_in_dynamic_partial__returns_data_not), + cmocka_unit_test(test__f_print_except_in_dynamic_partial__works), + + cmocka_unit_test(test__f_print_except_in_dynamic_partial_raw__fails), + cmocka_unit_test(test__f_print_except_in_dynamic_partial_raw__returns_data_not), + cmocka_unit_test(test__f_print_except_in_dynamic_partial_raw__works), + + cmocka_unit_test(test__f_print_except_in_dynamic_partial_raw_safely__fails), + cmocka_unit_test(test__f_print_except_in_dynamic_partial_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_in_dynamic_partial_raw_safely__works), + + cmocka_unit_test(test__f_print_except_in_dynamic_partial_safely__fails), + cmocka_unit_test(test__f_print_except_in_dynamic_partial_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_in_dynamic_partial_safely__works), + + cmocka_unit_test(test__f_print_except_in_dynamic_raw__fails), + cmocka_unit_test(test__f_print_except_in_dynamic_raw__returns_data_not), + cmocka_unit_test(test__f_print_except_in_dynamic_raw__works), + + cmocka_unit_test(test__f_print_except_in_dynamic_raw_safely__fails), + cmocka_unit_test(test__f_print_except_in_dynamic_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_in_dynamic_raw_safely__works), + + cmocka_unit_test(test__f_print_except_in_dynamic_safely__fails), + cmocka_unit_test(test__f_print_except_in_dynamic_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_in_dynamic_safely__works), + + cmocka_unit_test(test__f_print_except_in_raw__fails), + cmocka_unit_test(test__f_print_except_in_raw__returns_data_not), + cmocka_unit_test(test__f_print_except_in_raw__works), + + cmocka_unit_test(test__f_print_except_in_raw_safely__fails), + cmocka_unit_test(test__f_print_except_in_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_in_raw_safely__works), + + cmocka_unit_test(test__f_print_except_in_safely__fails), + cmocka_unit_test(test__f_print_except_in_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_in_safely__works), + + cmocka_unit_test(test__f_print_except_raw__fails), + cmocka_unit_test(test__f_print_except_raw__returns_data_not), + cmocka_unit_test(test__f_print_except_raw__works), + + cmocka_unit_test(test__f_print_except_raw_safely__fails), + cmocka_unit_test(test__f_print_except_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_raw_safely__works), + + cmocka_unit_test(test__f_print_except_safely__fails), + cmocka_unit_test(test__f_print_except_safely__returns_data_not), + cmocka_unit_test(test__f_print_except_safely__works), + + cmocka_unit_test(test__f_print_raw__fails), + cmocka_unit_test(test__f_print_raw__returns_data_not), + cmocka_unit_test(test__f_print_raw__works), + + cmocka_unit_test(test__f_print_raw_safely__fails), + cmocka_unit_test(test__f_print_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_raw_safely__works), + + cmocka_unit_test(test__f_print_raw_terminated__fails), + cmocka_unit_test(test__f_print_raw_terminated__returns_data_not), + cmocka_unit_test(test__f_print_raw_terminated__works), + + cmocka_unit_test(test__f_print_safely__fails), + cmocka_unit_test(test__f_print_safely__returns_data_not), + cmocka_unit_test(test__f_print_safely__works), + + cmocka_unit_test(test__f_print_safely_get__returns_character_control), + cmocka_unit_test(test__f_print_safely_get__returns_character_delete), + cmocka_unit_test(test__f_print_safely_get__returns_character_unknown), + cmocka_unit_test(test__f_print_safely_get__returns_empty), + + cmocka_unit_test(test__f_print_safely_terminated__fails), + cmocka_unit_test(test__f_print_safely_terminated__returns_data_not), + cmocka_unit_test(test__f_print_safely_terminated__works), + + cmocka_unit_test(test__f_print_terminated__fails), + cmocka_unit_test(test__f_print_terminated__returns_data_not), + cmocka_unit_test(test__f_print_terminated__works), + + cmocka_unit_test(test__f_print_to__fails), + cmocka_unit_test(test__f_print_to__returns_data_not), + cmocka_unit_test(test__f_print_to__works), + + cmocka_unit_test(test__f_print_to_character__fails), + cmocka_unit_test(test__f_print_to_character__works), + + cmocka_unit_test(test__f_print_to_character_safely__fails), + cmocka_unit_test(test__f_print_to_character_safely__returns_utf), + cmocka_unit_test(test__f_print_to_character_safely__works), + + cmocka_unit_test(test__f_print_to_dynamic__fails), + cmocka_unit_test(test__f_print_to_dynamic__returns_data_not), + cmocka_unit_test(test__f_print_to_dynamic__works), + + cmocka_unit_test(test__f_print_to_dynamic_partial__fails), + cmocka_unit_test(test__f_print_to_dynamic_partial__returns_data_not), + cmocka_unit_test(test__f_print_to_dynamic_partial__works), + + cmocka_unit_test(test__f_print_to_dynamic_partial_raw__fails), + cmocka_unit_test(test__f_print_to_dynamic_partial_raw__returns_data_not), + cmocka_unit_test(test__f_print_to_dynamic_partial_raw__works), + + cmocka_unit_test(test__f_print_to_dynamic_partial_raw_safely__fails), + cmocka_unit_test(test__f_print_to_dynamic_partial_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_dynamic_partial_raw_safely__works), + + cmocka_unit_test(test__f_print_to_dynamic_partial_safely__fails), + cmocka_unit_test(test__f_print_to_dynamic_partial_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_dynamic_partial_safely__works), + + cmocka_unit_test(test__f_print_to_dynamic_raw__fails), + cmocka_unit_test(test__f_print_to_dynamic_raw__returns_data_not), + cmocka_unit_test(test__f_print_to_dynamic_raw__works), + + cmocka_unit_test(test__f_print_to_dynamic_raw_safely__fails), + cmocka_unit_test(test__f_print_to_dynamic_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_dynamic_raw_safely__works), + + cmocka_unit_test(test__f_print_to_dynamic_safely__fails), + cmocka_unit_test(test__f_print_to_dynamic_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_dynamic_safely__works), + + cmocka_unit_test(test__f_print_to_except__fails), + cmocka_unit_test(test__f_print_to_except__returns_data_not), + cmocka_unit_test(test__f_print_to_except__works), + + cmocka_unit_test(test__f_print_to_except_dynamic__fails), + cmocka_unit_test(test__f_print_to_except_dynamic__returns_data_not), + cmocka_unit_test(test__f_print_to_except_dynamic__works), + + cmocka_unit_test(test__f_print_to_except_dynamic_partial__fails), + cmocka_unit_test(test__f_print_to_except_dynamic_partial__returns_data_not), + cmocka_unit_test(test__f_print_to_except_dynamic_partial__works), + + cmocka_unit_test(test__f_print_to_except_dynamic_partial_raw__fails), + cmocka_unit_test(test__f_print_to_except_dynamic_partial_raw__returns_data_not), + cmocka_unit_test(test__f_print_to_except_dynamic_partial_raw__works), + + cmocka_unit_test(test__f_print_to_except_dynamic_partial_raw_safely__fails), + cmocka_unit_test(test__f_print_to_except_dynamic_partial_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_dynamic_partial_raw_safely__works), + + cmocka_unit_test(test__f_print_to_except_dynamic_partial_safely__fails), + cmocka_unit_test(test__f_print_to_except_dynamic_partial_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_dynamic_partial_safely__works), + + cmocka_unit_test(test__f_print_to_except_dynamic_raw__fails), + cmocka_unit_test(test__f_print_to_except_dynamic_raw__returns_data_not), + cmocka_unit_test(test__f_print_to_except_dynamic_raw__works), + + cmocka_unit_test(test__f_print_to_except_dynamic_raw_safely__fails), + cmocka_unit_test(test__f_print_to_except_dynamic_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_dynamic_raw_safely__works), + + cmocka_unit_test(test__f_print_to_except_dynamic_safely__fails), + cmocka_unit_test(test__f_print_to_except_dynamic_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_dynamic_safely__works), + + cmocka_unit_test(test__f_print_to_except_in__fails), + cmocka_unit_test(test__f_print_to_except_in__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in__works), + + cmocka_unit_test(test__f_print_to_except_in_dynamic__fails), + cmocka_unit_test(test__f_print_to_except_in_dynamic__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in_dynamic__works), + + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial__fails), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial__works), + + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_raw__fails), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_raw__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_raw__works), + + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_raw_safely__fails), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_raw_safely__works), + + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_safely__fails), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_safely__works), + + cmocka_unit_test(test__f_print_to_except_in_dynamic_raw__fails), + cmocka_unit_test(test__f_print_to_except_in_dynamic_raw__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in_dynamic_raw__works), + + cmocka_unit_test(test__f_print_to_except_in_dynamic_raw_safely__fails), + cmocka_unit_test(test__f_print_to_except_in_dynamic_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in_dynamic_raw_safely__works), + + cmocka_unit_test(test__f_print_to_except_in_dynamic_safely__fails), + cmocka_unit_test(test__f_print_to_except_in_dynamic_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in_dynamic_safely__works), + + cmocka_unit_test(test__f_print_to_except_in_raw__fails), + cmocka_unit_test(test__f_print_to_except_in_raw__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in_raw__works), + + cmocka_unit_test(test__f_print_to_except_in_raw_safely__fails), + cmocka_unit_test(test__f_print_to_except_in_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in_raw_safely__works), + + cmocka_unit_test(test__f_print_to_except_in_safely__fails), + cmocka_unit_test(test__f_print_to_except_in_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_in_safely__works), + + cmocka_unit_test(test__f_print_to_except_raw__fails), + cmocka_unit_test(test__f_print_to_except_raw__returns_data_not), + cmocka_unit_test(test__f_print_to_except_raw__works), + + cmocka_unit_test(test__f_print_to_except_raw_safely__fails), + cmocka_unit_test(test__f_print_to_except_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_raw_safely__works), + + cmocka_unit_test(test__f_print_to_except_safely__fails), + cmocka_unit_test(test__f_print_to_except_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_except_safely__works), + + cmocka_unit_test(test__f_print_to_raw__fails), + cmocka_unit_test(test__f_print_to_raw__returns_data_not), + cmocka_unit_test(test__f_print_to_raw__works), + + cmocka_unit_test(test__f_print_to_raw_safely__fails), + cmocka_unit_test(test__f_print_to_raw_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_raw_safely__works), + + cmocka_unit_test(test__f_print_to_raw_terminated__fails), + cmocka_unit_test(test__f_print_to_raw_terminated__returns_data_not), + cmocka_unit_test(test__f_print_to_raw_terminated__works), + + cmocka_unit_test(test__f_print_to_safely__fails), + cmocka_unit_test(test__f_print_to_safely__returns_data_not), + cmocka_unit_test(test__f_print_to_safely__works), + + cmocka_unit_test(test__f_print_to_safely_terminated__fails), + cmocka_unit_test(test__f_print_to_safely_terminated__returns_data_not), + cmocka_unit_test(test__f_print_to_safely_terminated__works), + + cmocka_unit_test(test__f_print_to_terminated__fails), + cmocka_unit_test(test__f_print_to_terminated__returns_data_not), + cmocka_unit_test(test__f_print_to_terminated__works), + + #ifndef _di_level_0_parameter_checking_ + cmocka_unit_test(test__f_print__parameter_checking), + cmocka_unit_test(test__f_print_character__parameter_checking), + cmocka_unit_test(test__f_print_character_safely__parameter_checking), + // f_print_character_safely_get() doesn't use parameter checking. + cmocka_unit_test(test__f_print_dynamic__parameter_checking), + cmocka_unit_test(test__f_print_dynamic_partial__parameter_checking), + cmocka_unit_test(test__f_print_dynamic_partial_raw__parameter_checking), + cmocka_unit_test(test__f_print_dynamic_partial_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_dynamic_partial_safely__parameter_checking), + cmocka_unit_test(test__f_print_dynamic_raw__parameter_checking), + cmocka_unit_test(test__f_print_dynamic_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_dynamic_safely__parameter_checking), + cmocka_unit_test(test__f_print_except__parameter_checking), + cmocka_unit_test(test__f_print_except_dynamic__parameter_checking), + cmocka_unit_test(test__f_print_except_dynamic_partial__parameter_checking), + cmocka_unit_test(test__f_print_except_dynamic_partial_raw__parameter_checking), + cmocka_unit_test(test__f_print_except_dynamic_partial_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_except_dynamic_partial_safely__parameter_checking), + cmocka_unit_test(test__f_print_except_dynamic_raw__parameter_checking), + cmocka_unit_test(test__f_print_except_dynamic_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_except_dynamic_safely__parameter_checking), + cmocka_unit_test(test__f_print_except_in__parameter_checking), + cmocka_unit_test(test__f_print_except_in_dynamic__parameter_checking), + cmocka_unit_test(test__f_print_except_in_dynamic_partial__parameter_checking), + cmocka_unit_test(test__f_print_except_in_dynamic_partial_raw__parameter_checking), + cmocka_unit_test(test__f_print_except_in_dynamic_partial_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_except_in_dynamic_partial_safely__parameter_checking), + cmocka_unit_test(test__f_print_except_in_dynamic_raw__parameter_checking), + cmocka_unit_test(test__f_print_except_in_dynamic_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_except_in_dynamic_safely__parameter_checking), + cmocka_unit_test(test__f_print_except_in_raw__parameter_checking), + cmocka_unit_test(test__f_print_except_in_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_except_in_safely__parameter_checking), + cmocka_unit_test(test__f_print_except_raw__parameter_checking), + cmocka_unit_test(test__f_print_except_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_except_safely__parameter_checking), + cmocka_unit_test(test__f_print_raw__parameter_checking), + cmocka_unit_test(test__f_print_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_raw_terminated__parameter_checking), + cmocka_unit_test(test__f_print_safely__parameter_checking), + // f_print_safely_get() doesn't use parameter checking. + cmocka_unit_test(test__f_print_safely_terminated__parameter_checking), + cmocka_unit_test(test__f_print_terminated__parameter_checking), + cmocka_unit_test(test__f_print_to__parameter_checking), + cmocka_unit_test(test__f_print_to_character__parameter_checking), + cmocka_unit_test(test__f_print_to_character_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_dynamic__parameter_checking), + cmocka_unit_test(test__f_print_to_dynamic_partial__parameter_checking), + cmocka_unit_test(test__f_print_to_dynamic_partial_raw__parameter_checking), + cmocka_unit_test(test__f_print_to_dynamic_partial_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_dynamic_partial_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_dynamic_raw__parameter_checking), + cmocka_unit_test(test__f_print_to_dynamic_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_dynamic_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except__parameter_checking), + cmocka_unit_test(test__f_print_to_except_dynamic__parameter_checking), + cmocka_unit_test(test__f_print_to_except_dynamic_partial__parameter_checking), + cmocka_unit_test(test__f_print_to_except_dynamic_partial_raw__parameter_checking), + cmocka_unit_test(test__f_print_to_except_dynamic_partial_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except_dynamic_partial_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except_dynamic_raw__parameter_checking), + cmocka_unit_test(test__f_print_to_except_dynamic_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except_dynamic_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in_dynamic__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_raw__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in_dynamic_partial_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in_dynamic_raw__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in_dynamic_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in_dynamic_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in_raw__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except_in_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except_raw__parameter_checking), + cmocka_unit_test(test__f_print_to_except_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_except_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_raw__parameter_checking), + cmocka_unit_test(test__f_print_to_raw_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_raw_terminated__parameter_checking), + cmocka_unit_test(test__f_print_to_safely__parameter_checking), + cmocka_unit_test(test__f_print_to_safely_terminated__parameter_checking), + cmocka_unit_test(test__f_print_to_terminated__parameter_checking), + #endif // _di_level_0_parameter_checking_ + }; + + return cmocka_run_group_tests(tests, setup, setdown); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_print/tests/unit/c/test-print.h b/level_0/f_print/tests/unit/c/test-print.h new file mode 100644 index 0000000..db93398 --- /dev/null +++ b/level_0/f_print/tests/unit/c/test-print.h @@ -0,0 +1,155 @@ +/** + * FLL - Level 0 + * + * Project: Print + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the print project. + */ +#ifndef _TEST__F_print_h +#define _TEST__F_print_h + +// Libc includes. +#include +#include +#include +#include + +// cmocka includes. +#include + +// FLL-0 includes. +#include + +// Mock includes. +#include "mock-print.h" + +// Test includes. +#include "test-print-.h" +#include "test-print-character.h" +#include "test-print-character_safely.h" +#include "test-print-character_safely_get.h" +#include "test-print-dynamic.h" +#include "test-print-dynamic_partial.h" +#include "test-print-dynamic_partial_raw.h" +#include "test-print-dynamic_partial_raw_safely.h" +#include "test-print-dynamic_partial_safely.h" +#include "test-print-dynamic_raw.h" +#include "test-print-dynamic_raw_safely.h" +#include "test-print-dynamic_safely.h" +#include "test-print-except.h" +#include "test-print-except_dynamic.h" +#include "test-print-except_dynamic_partial.h" +#include "test-print-except_dynamic_partial_raw.h" +#include "test-print-except_dynamic_partial_raw_safely.h" +#include "test-print-except_dynamic_partial_safely.h" +#include "test-print-except_dynamic_raw.h" +#include "test-print-except_dynamic_raw_safely.h" +#include "test-print-except_dynamic_safely.h" +#include "test-print-except_in.h" +#include "test-print-except_in_dynamic.h" +#include "test-print-except_in_dynamic_partial.h" +#include "test-print-except_in_dynamic_partial_raw.h" +#include "test-print-except_in_dynamic_partial_raw_safely.h" +#include "test-print-except_in_dynamic_partial_safely.h" +#include "test-print-except_in_dynamic_raw.h" +#include "test-print-except_in_dynamic_raw_safely.h" +#include "test-print-except_in_dynamic_safely.h" +#include "test-print-except_in_raw.h" +#include "test-print-except_in_raw_safely.h" +#include "test-print-except_in_safely.h" +#include "test-print-except_raw.h" +#include "test-print-except_raw_safely.h" +#include "test-print-except_safely.h" +#include "test-print-raw.h" +#include "test-print-raw_safely.h" +#include "test-print-raw_terminated.h" +#include "test-print-safely.h" +#include "test-print-safely_get.h" +#include "test-print-safely_terminated.h" +#include "test-print-terminated.h" +#include "test-print-to.h" +#include "test-print-to_character.h" +#include "test-print-to_character_safely.h" +#include "test-print-to_dynamic.h" +#include "test-print-to_dynamic_partial.h" +#include "test-print-to_dynamic_partial_raw.h" +#include "test-print-to_dynamic_partial_raw_safely.h" +#include "test-print-to_dynamic_partial_safely.h" +#include "test-print-to_dynamic_raw.h" +#include "test-print-to_dynamic_raw_safely.h" +#include "test-print-to_dynamic_safely.h" +#include "test-print-to_except.h" +#include "test-print-to_except_dynamic.h" +#include "test-print-to_except_dynamic_partial.h" +#include "test-print-to_except_dynamic_partial_raw.h" +#include "test-print-to_except_dynamic_partial_raw_safely.h" +#include "test-print-to_except_dynamic_partial_safely.h" +#include "test-print-to_except_dynamic_raw.h" +#include "test-print-to_except_dynamic_raw_safely.h" +#include "test-print-to_except_dynamic_safely.h" +#include "test-print-to_except_in.h" +#include "test-print-to_except_in_dynamic.h" +#include "test-print-to_except_in_dynamic_partial.h" +#include "test-print-to_except_in_dynamic_partial_raw.h" +#include "test-print-to_except_in_dynamic_partial_raw_safely.h" +#include "test-print-to_except_in_dynamic_partial_safely.h" +#include "test-print-to_except_in_dynamic_raw.h" +#include "test-print-to_except_in_dynamic_raw_safely.h" +#include "test-print-to_except_in_dynamic_safely.h" +#include "test-print-to_except_in_raw.h" +#include "test-print-to_except_in_raw_safely.h" +#include "test-print-to_except_in_safely.h" +#include "test-print-to_except_raw.h" +#include "test-print-to_except_raw_safely.h" +#include "test-print-to_except_safely.h" +#include "test-print-to_raw.h" +#include "test-print-to_raw_safely.h" +#include "test-print-to_raw_terminated.h" +#include "test-print-to_safely.h" +#include "test-print-to_safely_terminated.h" +#include "test-print-to_terminated.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_print_h -- 1.8.3.1