From b0a2fc40fb8f4e93646b103d9e8f04033332236c Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding@users.noreply.github.com> Date: Sat, 19 Jul 2025 11:30:33 -0600 Subject: [PATCH 01/13] Update test.c --- code/logic/test.c | 1 - 1 file changed, 1 deletion(-) diff --git a/code/logic/test.c b/code/logic/test.c index 5b467888..03e17ed7 100644 --- a/code/logic/test.c +++ b/code/logic/test.c @@ -503,7 +503,6 @@ void fossil_pizza_run_test(const fossil_pizza_engine_t* engine, fossil_pizza_cas } else { test_case->result = FOSSIL_PIZZA_CASE_FAIL; if (engine->pallet.run.fail_fast) { - fossil_pizza_show_cases(suite, engine); return; // Exit immediately if --fail-fast is enabled } } From 57d4366b143009e9423d423f371538845119a889 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding@users.noreply.github.com> Date: Sat, 19 Jul 2025 11:45:36 -0600 Subject: [PATCH 02/13] Update Dockerfile.debian --- .github/ciimage/Dockerfile.debian | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/ciimage/Dockerfile.debian b/.github/ciimage/Dockerfile.debian index f114ade3..2e8a063e 100644 --- a/.github/ciimage/Dockerfile.debian +++ b/.github/ciimage/Dockerfile.debian @@ -1,5 +1,5 @@ -# Use a specific Debian base image -FROM debian:buster +# Use a specific Debian Bookworm base image +FROM debian:bookworm # Set environment variables to avoid interaction ENV DEBIAN_FRONTEND=noninteractive \ @@ -7,28 +7,30 @@ ENV DEBIAN_FRONTEND=noninteractive \ # Install system dependencies and clean up RUN apt-get update && \ - apt-get install -y \ + apt-get install -y --no-install-recommends \ build-essential \ clang \ gcc \ g++ \ gdb \ llvm \ - libstdc++-8-dev \ + libstdc++-12-dev \ wget \ python3 \ + python3-full \ python3-pip \ - git && \ + git \ + ca-certificates && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -# Install Meson and Ninja -RUN python3 -m pip install --no-cache-dir meson ninja==1.10.2 +# Install Meson and Ninja using pip +RUN python3 -m pip install --no-cache-dir meson==1.3.0 ninja==1.10.2 --break-system-packages # Set environment variables -ENV CC=/usr/bin/clang -ENV CXX=/usr/bin/clang++ -ENV LD_LIBRARY_PATH=/usr/local/lib +ENV CC=clang \ + CXX=clang++ \ + LD_LIBRARY_PATH=/usr/local/lib # Set working directory WORKDIR /workspace From 71baea25a79ab7f1b04b9ea098e03265b7e06081 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" <55331536+dreamer-coding@users.noreply.github.com> Date: Sat, 19 Jul 2025 12:03:07 -0600 Subject: [PATCH 03/13] Update test.c --- code/logic/test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/code/logic/test.c b/code/logic/test.c index 03e17ed7..3848173a 100644 --- a/code/logic/test.c +++ b/code/logic/test.c @@ -21,6 +21,7 @@ #include #include + jmp_buf test_jump_buffer; // This will hold the jump buffer for longjmp static int _ASSERT_COUNT = 0; // Counter for the number of assertions From 91fa15e5e246b31288e6c650f925a89de1b705af Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" Date: Sat, 19 Jul 2025 12:29:30 -0600 Subject: [PATCH 04/13] add test cases for new bitwise assumptions --- code/tests/cases/test_tdd.c | 90 +++++++++++++++++++++++++++++++++++ code/tests/cases/test_tdd.cpp | 90 +++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) diff --git a/code/tests/cases/test_tdd.c b/code/tests/cases/test_tdd.c index b280d3e9..c6b1dec2 100644 --- a/code/tests/cases/test_tdd.c +++ b/code/tests/cases/test_tdd.c @@ -948,6 +948,87 @@ FOSSIL_TEST(c_assume_run_of_not_soap_tone_detected) { ASSUME_NOT_SOAP_TONE_DETECTED(text, expected_tone); } // end case +FOSSIL_TEST(c_assume_run_of_bitwise_true) { + uint8_t a = 0b10101010; + uint8_t b = 0b01010101; + uint8_t c = a | b; // 0b11111111 + uint8_t d = a & b; // 0b00000000 + + ASSUME_ITS_BITWISE_TRUE(a & 0b10000000); + ASSUME_ITS_BITWISE_TRUE(b & 0b00000001); + ASSUME_ITS_BITWISE_TRUE(c == 0xFF); + ASSUME_ITS_BITWISE_TRUE(~d == 0xFF); +} + +FOSSIL_TEST(c_assume_run_of_bitwise_false) { + uint8_t a = 0b10101010; + uint8_t b = 0b01010101; + uint8_t d = a & b; // 0b00000000 + + ASSUME_ITS_BITWISE_FALSE(d & 0b00000001); + ASSUME_ITS_BITWISE_FALSE(a & 0b00000001); + ASSUME_ITS_BITWISE_FALSE(b & 0b10000000); + ASSUME_ITS_BITWISE_FALSE(a == b); +} + +FOSSIL_TEST(c_assume_run_of_not_bitwise_true) { + uint8_t a = 0b10101010; + uint8_t b = 0b01010101; + + ASSUME_NOT_BITWISE_TRUE(a == b); + ASSUME_NOT_BITWISE_TRUE(a & 0b00000001); + ASSUME_NOT_BITWISE_TRUE(b & 0b10000000); +} + +FOSSIL_TEST(c_assume_run_of_not_bitwise_false) { + uint8_t a = 0b10101010; + uint8_t b = 0b01010101; + uint8_t c = a | b; // 0b11111111 + + ASSUME_NOT_BITWISE_FALSE(c == 0xFF); + ASSUME_NOT_BITWISE_FALSE(a & 0b10000000); + ASSUME_NOT_BITWISE_FALSE(b & 0b00000001); +} + +FOSSIL_TEST(c_assume_run_of_less_than_bitwise) { + uint8_t a = 0b00001111; // 15 + uint8_t b = 0b11110000; // 240 + + ASSUME_ITS_LESS_THAN_BITWISE(a, b); + ASSUME_ITS_LESS_THAN_BITWISE(a & b, a | b); +} + +FOSSIL_TEST(c_assume_run_of_more_than_bitwise) { + uint8_t a = 0b11110000; // 240 + uint8_t b = 0b00001111; // 15 + + ASSUME_ITS_MORE_THAN_BITWISE(a, b); + ASSUME_ITS_MORE_THAN_BITWISE(a | b, a & b); +} + +FOSSIL_TEST(c_assume_run_of_equal_bitwise) { + uint8_t a = 0b10101010; + uint8_t b = 0b10101010; + + ASSUME_ITS_EQUAL_BITWISE(a, b); + ASSUME_ITS_EQUAL_BITWISE(a ^ b, 0); +} + +FOSSIL_TEST(c_assume_run_of_more_or_equal_bitwise) { + uint8_t a = 0b10101010; + uint8_t b = 0b01010101; + + ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, b); + ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, a); +} + +FOSSIL_TEST(c_assume_run_of_less_or_equal_bitwise) { + uint8_t a = 0b01010101; + uint8_t b = 0b10101010; + + ASSUME_ITS_LESS_OR_EQUAL_BITWISE(a, b); + ASSUME_ITS_LESS_OR_EQUAL_BITWISE(b, b); +} // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool @@ -1040,6 +1121,15 @@ FOSSIL_TEST_GROUP(c_tdd_test_cases) { FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_its_soap_rot_brain); FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_its_soap_tone_detected); FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_not_soap_tone_detected); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_bitwise_true); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_bitwise_false); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_not_bitwise_true); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_not_bitwise_false); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_less_than_bitwise); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_more_than_bitwise); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_equal_bitwise); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_more_or_equal_bitwise); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_less_or_equal_bitwise); FOSSIL_TEST_REGISTER(c_tdd_suite); } // end of group diff --git a/code/tests/cases/test_tdd.cpp b/code/tests/cases/test_tdd.cpp index b2b10198..6b4c2240 100644 --- a/code/tests/cases/test_tdd.cpp +++ b/code/tests/cases/test_tdd.cpp @@ -944,6 +944,87 @@ FOSSIL_TEST(cpp_assume_run_of_not_soap_tone_detected) { ASSUME_NOT_SOAP_TONE_DETECTED(text, expected_tone); } // end case +FOSSIL_TEST(cpp_assume_run_of_bitwise_true) { + uint8_t a = 0b10101010; + uint8_t b = 0b01010101; + uint8_t c = a | b; // 0b11111111 + uint8_t d = a & b; // 0b00000000 + + ASSUME_ITS_BITWISE_TRUE(a & 0b10000000); + ASSUME_ITS_BITWISE_TRUE(b & 0b00000001); + ASSUME_ITS_BITWISE_TRUE(c == 0xFF); + ASSUME_ITS_BITWISE_TRUE(~d == 0xFF); +} + +FOSSIL_TEST(cpp_assume_run_of_bitwise_false) { + uint8_t a = 0b10101010; + uint8_t b = 0b01010101; + uint8_t d = a & b; // 0b00000000 + + ASSUME_ITS_BITWISE_FALSE(d & 0b00000001); + ASSUME_ITS_BITWISE_FALSE(a & 0b00000001); + ASSUME_ITS_BITWISE_FALSE(b & 0b10000000); + ASSUME_ITS_BITWISE_FALSE(a == b); +} + +FOSSIL_TEST(cpp_assume_run_of_not_bitwise_true) { + uint8_t a = 0b10101010; + uint8_t b = 0b01010101; + + ASSUME_NOT_BITWISE_TRUE(a == b); + ASSUME_NOT_BITWISE_TRUE(a & 0b00000001); + ASSUME_NOT_BITWISE_TRUE(b & 0b10000000); +} + +FOSSIL_TEST(cpp_assume_run_of_not_bitwise_false) { + uint8_t a = 0b10101010; + uint8_t b = 0b01010101; + uint8_t c = a | b; // 0b11111111 + + ASSUME_NOT_BITWISE_FALSE(c == 0xFF); + ASSUME_NOT_BITWISE_FALSE(a & 0b10000000); + ASSUME_NOT_BITWISE_FALSE(b & 0b00000001); +} + +FOSSIL_TEST(cpp_assume_run_of_less_than_bitwise) { + uint8_t a = 0b00001111; // 15 + uint8_t b = 0b11110000; // 240 + + ASSUME_ITS_LESS_THAN_BITWISE(a, b); + ASSUME_ITS_LESS_THAN_BITWISE(a & b, a | b); +} + +FOSSIL_TEST(cpp_assume_run_of_more_than_bitwise) { + uint8_t a = 0b11110000; // 240 + uint8_t b = 0b00001111; // 15 + + ASSUME_ITS_MORE_THAN_BITWISE(a, b); + ASSUME_ITS_MORE_THAN_BITWISE(a | b, a & b); +} + +FOSSIL_TEST(cpp_assume_run_of_equal_bitwise) { + uint8_t a = 0b10101010; + uint8_t b = 0b10101010; + + ASSUME_ITS_EQUAL_BITWISE(a, b); + ASSUME_ITS_EQUAL_BITWISE(a ^ b, 0); +} + +FOSSIL_TEST(cpp_assume_run_of_more_or_equal_bitwise) { + uint8_t a = 0b10101010; + uint8_t b = 0b01010101; + + ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, b); + ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, a); +} + +FOSSIL_TEST(cpp_assume_run_of_less_or_equal_bitwise) { + uint8_t a = 0b01010101; + uint8_t b = 0b10101010; + + ASSUME_ITS_LESS_OR_EQUAL_BITWISE(a, b); + ASSUME_ITS_LESS_OR_EQUAL_BITWISE(b, b); +} // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool @@ -1036,6 +1117,15 @@ FOSSIL_TEST_GROUP(cpp_tdd_test_cases) { FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_its_soap_rot_brain); FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_its_soap_tone_detected); FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_not_soap_tone_detected); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_bitwise_true); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_bitwise_false); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_not_bitwise_true); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_not_bitwise_false); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_less_than_bitwise); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_more_than_bitwise); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_equal_bitwise); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_more_or_equal_bitwise); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_less_or_equal_bitwise); FOSSIL_TEST_REGISTER(cpp_tdd_suite); } // end of group From 5cf325060486520bb67ff499b19e9eec5dfbbd14 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" Date: Sat, 19 Jul 2025 12:30:01 -0600 Subject: [PATCH 05/13] add new assumptions for bitwise --- code/logic/fossil/pizza/assume.h | 83 ++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/code/logic/fossil/pizza/assume.h b/code/logic/fossil/pizza/assume.h index 6e4ca896..3ffae450 100644 --- a/code/logic/fossil/pizza/assume.h +++ b/code/logic/fossil/pizza/assume.h @@ -70,6 +70,89 @@ extern "C" { #define ASSUME_NOT_FALSE(actual) \ FOSSIL_TEST_ASSUME((actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %s to not be false", (actual) ? "true" : "false")) +// ************************************************** +// +// Bitwise assumptions +// +// ************************************************** + +/** + * @brief Assumes that the given bitwise expression is true. + * + * @param actual The bitwise expression to be evaluated. + */ +#define ASSUME_ITS_BITWISE_TRUE(actual) \ + FOSSIL_TEST_ASSUME((actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %s to be true", (actual) ? "true" : "false")) + +/** + * @brief Assumes that the given bitwise expression is false. + * + * @param actual The bitwise expression to be evaluated. + */ +#define ASSUME_ITS_BITWISE_FALSE(actual) \ + FOSSIL_TEST_ASSUME(!(actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %s to be false", (actual) ? "true" : "false")) + +/** + * @brief Assumes that the given bitwise expression is not true. + * + * @param actual The bitwise expression to be evaluated. + */ +#define ASSUME_NOT_BITWISE_TRUE(actual) \ + FOSSIL_TEST_ASSUME(!(actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %s to not be true", (actual) ? "true" : "false")) + +/** + * @brief Assumes that the given bitwise expression is not false. + * + * @param actual The bitwise expression to be evaluated. + */ +#define ASSUME_NOT_BITWISE_FALSE(actual) \ + FOSSIL_TEST_ASSUME((actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %s to not be false", (actual) ? "true" : "false")) + +/** + * @brief Assumes that the given value is less than the expected value (bitwise). + * + * @param actual The actual value. + * @param expected The expected value. + */ +#define ASSUME_ITS_LESS_THAN_BITWISE(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) < (expected), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %u to be less than " #expected " of value %u (bitwise)", (actual), (expected))) + +/** + * @brief Assumes that the given value is more than the expected value (bitwise). + * + * @param actual The actual value. + * @param expected The expected value. + */ +#define ASSUME_ITS_MORE_THAN_BITWISE(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) > (expected), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %u to be more than " #expected " of value %u (bitwise)", (actual), (expected))) + +/** + * @brief Assumes that the given value is equal to the expected value (bitwise). + * + * @param actual The actual value. + * @param expected The expected value. + */ +#define ASSUME_ITS_EQUAL_BITWISE(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) == (expected), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %u to be equal to " #expected " of value %u (bitwise)", (actual), (expected))) + +/** + * @brief Assumes that the given value is more than or equal to the expected value (bitwise). + * + * @param actual The actual value. + * @param expected The expected value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_BITWISE(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) >= (expected), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %u to be more than or equal to " #expected " of value %u (bitwise)", (actual), (expected))) + +/** + * @brief Assumes that the given value is less than or equal to the expected value (bitwise). + * + * @param actual The actual value. + * @param expected The expected value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_BITWISE(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) <= (expected), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %u to be less than or equal to " #expected " of value %u (bitwise)", (actual), (expected))) + // ************************************************** // // Floating point assumtions From 9702d8cb3e2b27c059fc4ef7c702936074f88318 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" Date: Sat, 19 Jul 2025 12:30:13 -0600 Subject: [PATCH 06/13] add new sanity checks for directory --- code/logic/fossil/pizza/sanity.h | 86 ++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/code/logic/fossil/pizza/sanity.h b/code/logic/fossil/pizza/sanity.h index 6e84f1e2..f7ec5e56 100644 --- a/code/logic/fossil/pizza/sanity.h +++ b/code/logic/fossil/pizza/sanity.h @@ -87,6 +87,36 @@ int fossil_sanity_sys_create_file(const char* filename); */ int fossil_sanity_sys_file_exists(const char* filename); +/** + * @brief Creates an empty directory at the specified location. + * + * This function attempts to create an empty directory with the given name. If the directory + * already exists, the function may return an error or success depending on the system's + * behavior. The function returns a status code indicating success or failure. + * + * @param dirname A null-terminated string representing the path to the directory to be created. + * The path can be relative or absolute. + * @return int Returns 0 on successful creation of the directory. Returns a negative value if + * the directory could not be created due to errors such as insufficient permissions + * or invalid paths. + */ +int fossil_sanity_sys_create_dir(const char* dirname); + +/** + * @brief Checks whether a directory exists at the specified location. + * + * This function determines if a directory exists at the given path. It can be used to verify + * the presence of a directory before performing operations such as reading or writing. The + * function does not differentiate between regular directories and other file types. + * + * @param dirname A null-terminated string representing the path to the directory to check. + * The path can be relative or absolute. + * @return int Returns 1 if the directory exists, and 0 if it does not exist. Note that this + * function does not check for directory accessibility or permissions. + */ +int fossil_sanity_sys_dir_exists(const char* dirname); + + #ifdef __cplusplus } #endif @@ -166,6 +196,35 @@ int fossil_sanity_sys_file_exists(const char* filename); #define _FOSSIL_SANITY_SYS_FILE_EXISTS(filename) \ fossil_sanity_sys_file_exists(filename) +/** + * @brief Creates an empty directory at the specified location. + * This function attempts to create an empty directory with the given name. If the directory + * already exists, the function may return an error or success depending on the system's + * behavior. + * + * @param dirname A null-terminated string representing the path to the directory to be created. + * The path can be relative or absolute. + * @return int Returns 0 on successful creation of the directory. Returns a negative value if + * the directory could not be created due to errors such as insufficient permissions + * or invalid paths. + */ +#define _FOSSIL_SANITY_SYS_CREATE_DIR(dirname) \ + fossil_sanity_sys_create_dir(dirname) + +/** + * @brief Checks whether a directory exists at the specified location. + * This function determines if a directory exists at the given path. It can be used to verify + * the presence of a directory before performing operations such as reading or writing. The + * function does not differentiate between regular files, directories, or other file types. + * + * @param dirname A null-terminated string representing the path to the directory to check. + * The path can be relative or absolute. + * @return int Returns 1 if the directory exists, and 0 if it does not exist. Note that this + * function does not check for directory accessibility or permissions. + */ +#define _FOSSIL_SANITY_SYS_DIR_EXISTS(dirname) \ + fossil_sanity_sys_dir_exists(dirname) + // ***************************************************************************** // Public API Macros // ***************************************************************************** @@ -237,4 +296,31 @@ int fossil_sanity_sys_file_exists(const char* filename); #define FOSSIL_SANITY_SYS_FILE_EXISTS(filename) \ _FOSSIL_SANITY_SYS_FILE_EXISTS(filename) +/** + * @brief Creates an empty directory at the specified location. + * This macro is a wrapper around the _FOSSIL_SANITY_SYS_CREATE_DIR function. + * It is used to create an empty directory with the given name. + * + * @param dirname A null-terminated string representing the path to the directory to be created. + * The path can be relative or absolute. + * @return int Returns 0 on successful creation of the directory. Returns a negative value if + * the directory could not be created due to errors such as insufficient permissions + * or invalid paths. + */ +#define FOSSIL_SANITY_SYS_CREATE_DIR(dirname) \ + _FOSSIL_SANITY_SYS_CREATE_DIR(dirname) + +/** + * @brief Checks whether a directory exists at the specified location. + * This macro is a wrapper around the _FOSSIL_SANITY_SYS_DIR_EXISTS function. + * It is used to check if a directory exists at the given path. + * + * @param dirname A null-terminated string representing the path to the directory to check. + * The path can be relative or absolute. + * @return int Returns 1 if the directory exists, and 0 if it does not exist. Note that this + * function does not check for directory accessibility or permissions. + */ +#define FOSSIL_SANITY_SYS_DIR_EXISTS(dirname) \ + _FOSSIL_SANITY_SYS_DIR_EXISTS(dirname) + #endif // FOSSIL_SANITY_H From a2e256c959de66312a4bfbd5f7f72b681302b952 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" Date: Sat, 19 Jul 2025 12:30:33 -0600 Subject: [PATCH 07/13] add new test for the new sanity checks --- code/tests/cases/test_sanity.c | 29 +++++++++++++++++++++++++++++ code/tests/cases/test_sanity.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/code/tests/cases/test_sanity.c b/code/tests/cases/test_sanity.c index be4749d5..9ea4184d 100644 --- a/code/tests/cases/test_sanity.c +++ b/code/tests/cases/test_sanity.c @@ -87,7 +87,34 @@ FOSSIL_TEST(c_sanity_sys_file_exists) { remove(filename); } // end case +FOSSIL_TEST(c_sanity_sys_create_dir) { + const char *dirname = "test_dir"; + int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname); + // Test cases + ASSUME_ITS_EQUAL_I32(result, 0); // Directory creation should succeed + ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1); // Directory should exist + + // Cleanup + rmdir(dirname); +} // end case + +FOSSIL_TEST(c_sanity_sys_dir_exists) { + const char *dirname = "test_dir_exists"; + + // Ensure directory does not exist initially + ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 0); + + // Create the directory + int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname); + ASSUME_ITS_EQUAL_I32(result, 0); + + // Test cases + ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1); + + // Cleanup + rmdir(dirname); +} // end case // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool @@ -97,6 +124,8 @@ FOSSIL_TEST_GROUP(c_sanity_test_cases) { FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_getpid); FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_create_file); FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_file_exists); + FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_create_dir); + FOSSIL_TEST_ADD(c_sanity_suite, c_sanity_sys_dir_exists); FOSSIL_TEST_REGISTER(c_sanity_suite); } // end of group diff --git a/code/tests/cases/test_sanity.cpp b/code/tests/cases/test_sanity.cpp index 0a1d3d0e..05a52c5a 100644 --- a/code/tests/cases/test_sanity.cpp +++ b/code/tests/cases/test_sanity.cpp @@ -87,7 +87,34 @@ FOSSIL_TEST(cpp_sanity_sys_file_exists) { remove(filename); } // end case +FOSSIL_TEST(cpp_sanity_sys_create_dir) { + const char *dirname = "test_dir"; + int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname); + // Test cases + ASSUME_ITS_EQUAL_I32(result, 0); // Directory creation should succeed + ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1); // Directory should exist + + // Cleanup + rmdir(dirname); +} // end case + +FOSSIL_TEST(cpp_sanity_sys_dir_exists) { + const char *dirname = "test_dir_exists"; + + // Ensure directory does not exist initially + ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 0); + + // Create the directory + int result = FOSSIL_SANITY_SYS_CREATE_DIR(dirname); + ASSUME_ITS_EQUAL_I32(result, 0); + + // Test cases + ASSUME_ITS_EQUAL_I32(FOSSIL_SANITY_SYS_DIR_EXISTS(dirname), 1); + + // Cleanup + rmdir(dirname); +} // end case // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool @@ -97,6 +124,8 @@ FOSSIL_TEST_GROUP(cpp_sanity_test_cases) { FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_getpid); FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_create_file); FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_file_exists); + FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_create_dir); + FOSSIL_TEST_ADD(cpp_sanity_suite, cpp_sanity_sys_dir_exists); FOSSIL_TEST_REGISTER(cpp_sanity_suite); } // end of group From eb8ae527b470de50a3f6bfe860eba3804657be21 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" Date: Sat, 19 Jul 2025 12:31:20 -0600 Subject: [PATCH 08/13] flip to v1.2.5 --- README.md | 2 +- code/logic/common.c | 2 +- meson.build | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 261a8bd2..0a59b477 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ To get started with Pizza Test, ensure you have the following installed: # ====================== [wrap-git] url = https://github.com/fossillogic/fossil-test.git - revision = v1.2.4 + revision = v1.2.5 [provide] fossil-test = fossil_test_dep diff --git a/code/logic/common.c b/code/logic/common.c index c293050b..7fc2ff6b 100644 --- a/code/logic/common.c +++ b/code/logic/common.c @@ -19,7 +19,7 @@ // macro definitions // ***************************************************************************** -#define FOSSIL_PIZZA_VERSION "1.2.4" +#define FOSSIL_PIZZA_VERSION "1.2.5" #define FOSSIL_PIZZA_AUTHOR "Fossil Logic" #define FOSSIL_PIZZA_WEBSITE "https://fossillogic.com" diff --git a/meson.build b/meson.build index 19717948..cd2386a2 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('Pizza Test', 'c', 'cpp', meson_version: '>=1.3.0', license: 'MPL-2.0', - version: '1.2.4', + version: '1.2.5', default_options: ['c_std=c11,c18', 'cpp_std=c++20']) subdir('code') From dfbbe0023cc2666a38dce36cb11fbbdba37b768b Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" Date: Sat, 19 Jul 2025 12:55:43 -0600 Subject: [PATCH 09/13] update the bitwise cases --- code/tests/cases/test_tdd.c | 62 +++++++++++++++++------------------ code/tests/cases/test_tdd.cpp | 62 +++++++++++++++++------------------ 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/code/tests/cases/test_tdd.c b/code/tests/cases/test_tdd.c index c6b1dec2..5b850c27 100644 --- a/code/tests/cases/test_tdd.c +++ b/code/tests/cases/test_tdd.c @@ -949,82 +949,82 @@ FOSSIL_TEST(c_assume_run_of_not_soap_tone_detected) { } // end case FOSSIL_TEST(c_assume_run_of_bitwise_true) { - uint8_t a = 0b10101010; - uint8_t b = 0b01010101; - uint8_t c = a | b; // 0b11111111 - uint8_t d = a & b; // 0b00000000 + uint8_t a = 0xAA; + uint8_t b = 0x55; + uint8_t c = a | b; // 0xFF + uint8_t d = a & b; // 0x00 - ASSUME_ITS_BITWISE_TRUE(a & 0b10000000); - ASSUME_ITS_BITWISE_TRUE(b & 0b00000001); + ASSUME_ITS_BITWISE_TRUE(a & 0x80); + ASSUME_ITS_BITWISE_TRUE(b & 0x01); ASSUME_ITS_BITWISE_TRUE(c == 0xFF); ASSUME_ITS_BITWISE_TRUE(~d == 0xFF); } FOSSIL_TEST(c_assume_run_of_bitwise_false) { - uint8_t a = 0b10101010; - uint8_t b = 0b01010101; - uint8_t d = a & b; // 0b00000000 + uint8_t a = 0xAA; + uint8_t b = 0x55; + uint8_t d = a & b; // 0x00 - ASSUME_ITS_BITWISE_FALSE(d & 0b00000001); - ASSUME_ITS_BITWISE_FALSE(a & 0b00000001); - ASSUME_ITS_BITWISE_FALSE(b & 0b10000000); + ASSUME_ITS_BITWISE_FALSE(d & 0x01); + ASSUME_ITS_BITWISE_FALSE(a & 0x01); + ASSUME_ITS_BITWISE_FALSE(b & 0x80); ASSUME_ITS_BITWISE_FALSE(a == b); } FOSSIL_TEST(c_assume_run_of_not_bitwise_true) { - uint8_t a = 0b10101010; - uint8_t b = 0b01010101; + uint8_t a = 0xAA; + uint8_t b = 0x55; ASSUME_NOT_BITWISE_TRUE(a == b); - ASSUME_NOT_BITWISE_TRUE(a & 0b00000001); - ASSUME_NOT_BITWISE_TRUE(b & 0b10000000); + ASSUME_NOT_BITWISE_TRUE(a & 0x01); + ASSUME_NOT_BITWISE_TRUE(b & 0x80); } FOSSIL_TEST(c_assume_run_of_not_bitwise_false) { - uint8_t a = 0b10101010; - uint8_t b = 0b01010101; - uint8_t c = a | b; // 0b11111111 + uint8_t a = 0xAA; + uint8_t b = 0x55; + uint8_t c = a | b; // 0xFF ASSUME_NOT_BITWISE_FALSE(c == 0xFF); - ASSUME_NOT_BITWISE_FALSE(a & 0b10000000); - ASSUME_NOT_BITWISE_FALSE(b & 0b00000001); + ASSUME_NOT_BITWISE_FALSE(a & 0x80); + ASSUME_NOT_BITWISE_FALSE(b & 0x01); } FOSSIL_TEST(c_assume_run_of_less_than_bitwise) { - uint8_t a = 0b00001111; // 15 - uint8_t b = 0b11110000; // 240 + uint8_t a = 0x0F; // 15 + uint8_t b = 0xF0; // 240 ASSUME_ITS_LESS_THAN_BITWISE(a, b); ASSUME_ITS_LESS_THAN_BITWISE(a & b, a | b); } FOSSIL_TEST(c_assume_run_of_more_than_bitwise) { - uint8_t a = 0b11110000; // 240 - uint8_t b = 0b00001111; // 15 + uint8_t a = 0xF0; // 240 + uint8_t b = 0x0F; // 15 ASSUME_ITS_MORE_THAN_BITWISE(a, b); ASSUME_ITS_MORE_THAN_BITWISE(a | b, a & b); } FOSSIL_TEST(c_assume_run_of_equal_bitwise) { - uint8_t a = 0b10101010; - uint8_t b = 0b10101010; + uint8_t a = 0xAA; + uint8_t b = 0xAA; ASSUME_ITS_EQUAL_BITWISE(a, b); ASSUME_ITS_EQUAL_BITWISE(a ^ b, 0); } FOSSIL_TEST(c_assume_run_of_more_or_equal_bitwise) { - uint8_t a = 0b10101010; - uint8_t b = 0b01010101; + uint8_t a = 0xAA; + uint8_t b = 0x55; ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, b); ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, a); } FOSSIL_TEST(c_assume_run_of_less_or_equal_bitwise) { - uint8_t a = 0b01010101; - uint8_t b = 0b10101010; + uint8_t a = 0x55; + uint8_t b = 0xAA; ASSUME_ITS_LESS_OR_EQUAL_BITWISE(a, b); ASSUME_ITS_LESS_OR_EQUAL_BITWISE(b, b); diff --git a/code/tests/cases/test_tdd.cpp b/code/tests/cases/test_tdd.cpp index 6b4c2240..2aa5cf5d 100644 --- a/code/tests/cases/test_tdd.cpp +++ b/code/tests/cases/test_tdd.cpp @@ -945,82 +945,82 @@ FOSSIL_TEST(cpp_assume_run_of_not_soap_tone_detected) { } // end case FOSSIL_TEST(cpp_assume_run_of_bitwise_true) { - uint8_t a = 0b10101010; - uint8_t b = 0b01010101; - uint8_t c = a | b; // 0b11111111 - uint8_t d = a & b; // 0b00000000 + uint8_t a = 0xAA; // 0b10101010 + uint8_t b = 0x55; // 0b01010101 + uint8_t c = a | b; // 0xFF + uint8_t d = a & b; // 0x00 - ASSUME_ITS_BITWISE_TRUE(a & 0b10000000); - ASSUME_ITS_BITWISE_TRUE(b & 0b00000001); + ASSUME_ITS_BITWISE_TRUE(a & 0x80); // 0b10000000 + ASSUME_ITS_BITWISE_TRUE(b & 0x01); // 0b00000001 ASSUME_ITS_BITWISE_TRUE(c == 0xFF); ASSUME_ITS_BITWISE_TRUE(~d == 0xFF); } FOSSIL_TEST(cpp_assume_run_of_bitwise_false) { - uint8_t a = 0b10101010; - uint8_t b = 0b01010101; - uint8_t d = a & b; // 0b00000000 + uint8_t a = 0xAA; // 0b10101010 + uint8_t b = 0x55; // 0b01010101 + uint8_t d = a & b; // 0x00 - ASSUME_ITS_BITWISE_FALSE(d & 0b00000001); - ASSUME_ITS_BITWISE_FALSE(a & 0b00000001); - ASSUME_ITS_BITWISE_FALSE(b & 0b10000000); + ASSUME_ITS_BITWISE_FALSE(d & 0x01); // 0b00000001 + ASSUME_ITS_BITWISE_FALSE(a & 0x01); // 0b00000001 + ASSUME_ITS_BITWISE_FALSE(b & 0x80); // 0b10000000 ASSUME_ITS_BITWISE_FALSE(a == b); } FOSSIL_TEST(cpp_assume_run_of_not_bitwise_true) { - uint8_t a = 0b10101010; - uint8_t b = 0b01010101; + uint8_t a = 0xAA; // 0b10101010 + uint8_t b = 0x55; // 0b01010101 ASSUME_NOT_BITWISE_TRUE(a == b); - ASSUME_NOT_BITWISE_TRUE(a & 0b00000001); - ASSUME_NOT_BITWISE_TRUE(b & 0b10000000); + ASSUME_NOT_BITWISE_TRUE(a & 0x01); // 0b00000001 + ASSUME_NOT_BITWISE_TRUE(b & 0x80); // 0b10000000 } FOSSIL_TEST(cpp_assume_run_of_not_bitwise_false) { - uint8_t a = 0b10101010; - uint8_t b = 0b01010101; - uint8_t c = a | b; // 0b11111111 + uint8_t a = 0xAA; // 0b10101010 + uint8_t b = 0x55; // 0b01010101 + uint8_t c = a | b; // 0xFF ASSUME_NOT_BITWISE_FALSE(c == 0xFF); - ASSUME_NOT_BITWISE_FALSE(a & 0b10000000); - ASSUME_NOT_BITWISE_FALSE(b & 0b00000001); + ASSUME_NOT_BITWISE_FALSE(a & 0x80); // 0b10000000 + ASSUME_NOT_BITWISE_FALSE(b & 0x01); // 0b00000001 } FOSSIL_TEST(cpp_assume_run_of_less_than_bitwise) { - uint8_t a = 0b00001111; // 15 - uint8_t b = 0b11110000; // 240 + uint8_t a = 0x0F; // 15 + uint8_t b = 0xF0; // 240 ASSUME_ITS_LESS_THAN_BITWISE(a, b); ASSUME_ITS_LESS_THAN_BITWISE(a & b, a | b); } FOSSIL_TEST(cpp_assume_run_of_more_than_bitwise) { - uint8_t a = 0b11110000; // 240 - uint8_t b = 0b00001111; // 15 + uint8_t a = 0xF0; // 240 + uint8_t b = 0x0F; // 15 ASSUME_ITS_MORE_THAN_BITWISE(a, b); ASSUME_ITS_MORE_THAN_BITWISE(a | b, a & b); } FOSSIL_TEST(cpp_assume_run_of_equal_bitwise) { - uint8_t a = 0b10101010; - uint8_t b = 0b10101010; + uint8_t a = 0xAA; // 0b10101010 + uint8_t b = 0xAA; // 0b10101010 ASSUME_ITS_EQUAL_BITWISE(a, b); ASSUME_ITS_EQUAL_BITWISE(a ^ b, 0); } FOSSIL_TEST(cpp_assume_run_of_more_or_equal_bitwise) { - uint8_t a = 0b10101010; - uint8_t b = 0b01010101; + uint8_t a = 0xAA; // 0b10101010 + uint8_t b = 0x55; // 0b01010101 ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, b); ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, a); } FOSSIL_TEST(cpp_assume_run_of_less_or_equal_bitwise) { - uint8_t a = 0b01010101; - uint8_t b = 0b10101010; + uint8_t a = 0x55; // 0b01010101 + uint8_t b = 0xAA; // 0b10101010 ASSUME_ITS_LESS_OR_EQUAL_BITWISE(a, b); ASSUME_ITS_LESS_OR_EQUAL_BITWISE(b, b); From b24440a01c34edc92b84ef0b7efb8346d06bf67d Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" Date: Sat, 19 Jul 2025 13:00:14 -0600 Subject: [PATCH 10/13] small change to the bitwise assumtions --- code/logic/fossil/pizza/assume.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/logic/fossil/pizza/assume.h b/code/logic/fossil/pizza/assume.h index 3ffae450..250ee329 100644 --- a/code/logic/fossil/pizza/assume.h +++ b/code/logic/fossil/pizza/assume.h @@ -82,7 +82,7 @@ extern "C" { * @param actual The bitwise expression to be evaluated. */ #define ASSUME_ITS_BITWISE_TRUE(actual) \ - FOSSIL_TEST_ASSUME((actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %s to be true", (actual) ? "true" : "false")) + FOSSIL_TEST_ASSUME((actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %d to be true", (actual) ? 1 : 0)) /** * @brief Assumes that the given bitwise expression is false. @@ -90,7 +90,7 @@ extern "C" { * @param actual The bitwise expression to be evaluated. */ #define ASSUME_ITS_BITWISE_FALSE(actual) \ - FOSSIL_TEST_ASSUME(!(actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %s to be false", (actual) ? "true" : "false")) + FOSSIL_TEST_ASSUME(!(actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %d to be false", (actual) ? 1 : 0)) /** * @brief Assumes that the given bitwise expression is not true. @@ -98,7 +98,7 @@ extern "C" { * @param actual The bitwise expression to be evaluated. */ #define ASSUME_NOT_BITWISE_TRUE(actual) \ - FOSSIL_TEST_ASSUME(!(actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %s to not be true", (actual) ? "true" : "false")) + FOSSIL_TEST_ASSUME(!(actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %d to not be true", (actual) ? 1 : 0)) /** * @brief Assumes that the given bitwise expression is not false. @@ -106,7 +106,7 @@ extern "C" { * @param actual The bitwise expression to be evaluated. */ #define ASSUME_NOT_BITWISE_FALSE(actual) \ - FOSSIL_TEST_ASSUME((actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %s to not be false", (actual) ? "true" : "false")) + FOSSIL_TEST_ASSUME((actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %d to not be false", (actual) ? 1 : 0)) /** * @brief Assumes that the given value is less than the expected value (bitwise). From fedbffd278364f98760b3650ec8b03af15238cff Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" Date: Sat, 19 Jul 2025 14:30:06 -0600 Subject: [PATCH 11/13] add missing impl for sanity --- code/logic/sanity.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/code/logic/sanity.c b/code/logic/sanity.c index 24a227c1..b81a1eca 100644 --- a/code/logic/sanity.c +++ b/code/logic/sanity.c @@ -85,3 +85,21 @@ int fossil_sanity_sys_file_exists(const char* filename) { return (stat(filename, &buffer) == 0); // On Unix-like systems, use the stat function to check if the file exists. #endif } + +int fossil_sanity_sys_create_dir(const char* dirname) { +#ifdef _WIN32 + return CreateDirectoryA(dirname, NULL) ? 0 : -1; // On Windows, use the CreateDirectoryA function to create the directory. +#else + return mkdir(dirname, 0755); // On Unix-like systems, use the mkdir function to create the directory. +#endif +} + +int fossil_sanity_sys_dir_exists(const char* dirname) { +#ifdef _WIN32 + struct _stat buffer; + return (_stat(dirname, &buffer) == 0 && (buffer.st_mode & _S_IFDIR)); // On Windows, use the _stat function to check if the directory exists. +#else + struct stat buffer; + return (stat(dirname, &buffer) == 0 && S_ISDIR(buffer.st_mode)); // On Unix-like systems, use the stat function to check if the directory exists. +#endif +} From b3914470649450fcaac61f16725fd23fe8a42398 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" Date: Sat, 19 Jul 2025 14:31:51 -0600 Subject: [PATCH 12/13] fix for windows sake --- code/tests/cases/test_tdd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/tests/cases/test_tdd.c b/code/tests/cases/test_tdd.c index 5b850c27..f4200d74 100644 --- a/code/tests/cases/test_tdd.c +++ b/code/tests/cases/test_tdd.c @@ -957,7 +957,7 @@ FOSSIL_TEST(c_assume_run_of_bitwise_true) { ASSUME_ITS_BITWISE_TRUE(a & 0x80); ASSUME_ITS_BITWISE_TRUE(b & 0x01); ASSUME_ITS_BITWISE_TRUE(c == 0xFF); - ASSUME_ITS_BITWISE_TRUE(~d == 0xFF); + ASSUME_ITS_BITWISE_TRUE((uint8_t)(~d) == 0xFF); } FOSSIL_TEST(c_assume_run_of_bitwise_false) { From 3f199c6f3ccf955bd291e95502fedc196090d618 Mon Sep 17 00:00:00 2001 From: "Michael Gene Brockus (Dreamer)" Date: Sat, 19 Jul 2025 14:36:46 -0600 Subject: [PATCH 13/13] remove bitwise --- code/logic/fossil/pizza/assume.h | 83 ----------------------------- code/tests/cases/test_tdd.c | 91 -------------------------------- code/tests/cases/test_tdd.cpp | 91 -------------------------------- 3 files changed, 265 deletions(-) diff --git a/code/logic/fossil/pizza/assume.h b/code/logic/fossil/pizza/assume.h index 250ee329..6e4ca896 100644 --- a/code/logic/fossil/pizza/assume.h +++ b/code/logic/fossil/pizza/assume.h @@ -70,89 +70,6 @@ extern "C" { #define ASSUME_NOT_FALSE(actual) \ FOSSIL_TEST_ASSUME((actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %s to not be false", (actual) ? "true" : "false")) -// ************************************************** -// -// Bitwise assumptions -// -// ************************************************** - -/** - * @brief Assumes that the given bitwise expression is true. - * - * @param actual The bitwise expression to be evaluated. - */ -#define ASSUME_ITS_BITWISE_TRUE(actual) \ - FOSSIL_TEST_ASSUME((actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %d to be true", (actual) ? 1 : 0)) - -/** - * @brief Assumes that the given bitwise expression is false. - * - * @param actual The bitwise expression to be evaluated. - */ -#define ASSUME_ITS_BITWISE_FALSE(actual) \ - FOSSIL_TEST_ASSUME(!(actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %d to be false", (actual) ? 1 : 0)) - -/** - * @brief Assumes that the given bitwise expression is not true. - * - * @param actual The bitwise expression to be evaluated. - */ -#define ASSUME_NOT_BITWISE_TRUE(actual) \ - FOSSIL_TEST_ASSUME(!(actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %d to not be true", (actual) ? 1 : 0)) - -/** - * @brief Assumes that the given bitwise expression is not false. - * - * @param actual The bitwise expression to be evaluated. - */ -#define ASSUME_NOT_BITWISE_FALSE(actual) \ - FOSSIL_TEST_ASSUME((actual), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %d to not be false", (actual) ? 1 : 0)) - -/** - * @brief Assumes that the given value is less than the expected value (bitwise). - * - * @param actual The actual value. - * @param expected The expected value. - */ -#define ASSUME_ITS_LESS_THAN_BITWISE(actual, expected) \ - FOSSIL_TEST_ASSUME((actual) < (expected), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %u to be less than " #expected " of value %u (bitwise)", (actual), (expected))) - -/** - * @brief Assumes that the given value is more than the expected value (bitwise). - * - * @param actual The actual value. - * @param expected The expected value. - */ -#define ASSUME_ITS_MORE_THAN_BITWISE(actual, expected) \ - FOSSIL_TEST_ASSUME((actual) > (expected), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %u to be more than " #expected " of value %u (bitwise)", (actual), (expected))) - -/** - * @brief Assumes that the given value is equal to the expected value (bitwise). - * - * @param actual The actual value. - * @param expected The expected value. - */ -#define ASSUME_ITS_EQUAL_BITWISE(actual, expected) \ - FOSSIL_TEST_ASSUME((actual) == (expected), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %u to be equal to " #expected " of value %u (bitwise)", (actual), (expected))) - -/** - * @brief Assumes that the given value is more than or equal to the expected value (bitwise). - * - * @param actual The actual value. - * @param expected The expected value. - */ -#define ASSUME_ITS_MORE_OR_EQUAL_BITWISE(actual, expected) \ - FOSSIL_TEST_ASSUME((actual) >= (expected), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %u to be more than or equal to " #expected " of value %u (bitwise)", (actual), (expected))) - -/** - * @brief Assumes that the given value is less than or equal to the expected value (bitwise). - * - * @param actual The actual value. - * @param expected The expected value. - */ -#define ASSUME_ITS_LESS_OR_EQUAL_BITWISE(actual, expected) \ - FOSSIL_TEST_ASSUME((actual) <= (expected), _FOSSIL_TEST_ASSUME_MESSAGE("Expected " #actual " of value %u to be less than or equal to " #expected " of value %u (bitwise)", (actual), (expected))) - // ************************************************** // // Floating point assumtions diff --git a/code/tests/cases/test_tdd.c b/code/tests/cases/test_tdd.c index f4200d74..4ba991ca 100644 --- a/code/tests/cases/test_tdd.c +++ b/code/tests/cases/test_tdd.c @@ -948,88 +948,6 @@ FOSSIL_TEST(c_assume_run_of_not_soap_tone_detected) { ASSUME_NOT_SOAP_TONE_DETECTED(text, expected_tone); } // end case -FOSSIL_TEST(c_assume_run_of_bitwise_true) { - uint8_t a = 0xAA; - uint8_t b = 0x55; - uint8_t c = a | b; // 0xFF - uint8_t d = a & b; // 0x00 - - ASSUME_ITS_BITWISE_TRUE(a & 0x80); - ASSUME_ITS_BITWISE_TRUE(b & 0x01); - ASSUME_ITS_BITWISE_TRUE(c == 0xFF); - ASSUME_ITS_BITWISE_TRUE((uint8_t)(~d) == 0xFF); -} - -FOSSIL_TEST(c_assume_run_of_bitwise_false) { - uint8_t a = 0xAA; - uint8_t b = 0x55; - uint8_t d = a & b; // 0x00 - - ASSUME_ITS_BITWISE_FALSE(d & 0x01); - ASSUME_ITS_BITWISE_FALSE(a & 0x01); - ASSUME_ITS_BITWISE_FALSE(b & 0x80); - ASSUME_ITS_BITWISE_FALSE(a == b); -} - -FOSSIL_TEST(c_assume_run_of_not_bitwise_true) { - uint8_t a = 0xAA; - uint8_t b = 0x55; - - ASSUME_NOT_BITWISE_TRUE(a == b); - ASSUME_NOT_BITWISE_TRUE(a & 0x01); - ASSUME_NOT_BITWISE_TRUE(b & 0x80); -} - -FOSSIL_TEST(c_assume_run_of_not_bitwise_false) { - uint8_t a = 0xAA; - uint8_t b = 0x55; - uint8_t c = a | b; // 0xFF - - ASSUME_NOT_BITWISE_FALSE(c == 0xFF); - ASSUME_NOT_BITWISE_FALSE(a & 0x80); - ASSUME_NOT_BITWISE_FALSE(b & 0x01); -} - -FOSSIL_TEST(c_assume_run_of_less_than_bitwise) { - uint8_t a = 0x0F; // 15 - uint8_t b = 0xF0; // 240 - - ASSUME_ITS_LESS_THAN_BITWISE(a, b); - ASSUME_ITS_LESS_THAN_BITWISE(a & b, a | b); -} - -FOSSIL_TEST(c_assume_run_of_more_than_bitwise) { - uint8_t a = 0xF0; // 240 - uint8_t b = 0x0F; // 15 - - ASSUME_ITS_MORE_THAN_BITWISE(a, b); - ASSUME_ITS_MORE_THAN_BITWISE(a | b, a & b); -} - -FOSSIL_TEST(c_assume_run_of_equal_bitwise) { - uint8_t a = 0xAA; - uint8_t b = 0xAA; - - ASSUME_ITS_EQUAL_BITWISE(a, b); - ASSUME_ITS_EQUAL_BITWISE(a ^ b, 0); -} - -FOSSIL_TEST(c_assume_run_of_more_or_equal_bitwise) { - uint8_t a = 0xAA; - uint8_t b = 0x55; - - ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, b); - ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, a); -} - -FOSSIL_TEST(c_assume_run_of_less_or_equal_bitwise) { - uint8_t a = 0x55; - uint8_t b = 0xAA; - - ASSUME_ITS_LESS_OR_EQUAL_BITWISE(a, b); - ASSUME_ITS_LESS_OR_EQUAL_BITWISE(b, b); -} - // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -1121,15 +1039,6 @@ FOSSIL_TEST_GROUP(c_tdd_test_cases) { FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_its_soap_rot_brain); FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_its_soap_tone_detected); FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_not_soap_tone_detected); - FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_bitwise_true); - FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_bitwise_false); - FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_not_bitwise_true); - FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_not_bitwise_false); - FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_less_than_bitwise); - FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_more_than_bitwise); - FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_equal_bitwise); - FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_more_or_equal_bitwise); - FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_less_or_equal_bitwise); FOSSIL_TEST_REGISTER(c_tdd_suite); } // end of group diff --git a/code/tests/cases/test_tdd.cpp b/code/tests/cases/test_tdd.cpp index 2aa5cf5d..478dc297 100644 --- a/code/tests/cases/test_tdd.cpp +++ b/code/tests/cases/test_tdd.cpp @@ -944,88 +944,6 @@ FOSSIL_TEST(cpp_assume_run_of_not_soap_tone_detected) { ASSUME_NOT_SOAP_TONE_DETECTED(text, expected_tone); } // end case -FOSSIL_TEST(cpp_assume_run_of_bitwise_true) { - uint8_t a = 0xAA; // 0b10101010 - uint8_t b = 0x55; // 0b01010101 - uint8_t c = a | b; // 0xFF - uint8_t d = a & b; // 0x00 - - ASSUME_ITS_BITWISE_TRUE(a & 0x80); // 0b10000000 - ASSUME_ITS_BITWISE_TRUE(b & 0x01); // 0b00000001 - ASSUME_ITS_BITWISE_TRUE(c == 0xFF); - ASSUME_ITS_BITWISE_TRUE(~d == 0xFF); -} - -FOSSIL_TEST(cpp_assume_run_of_bitwise_false) { - uint8_t a = 0xAA; // 0b10101010 - uint8_t b = 0x55; // 0b01010101 - uint8_t d = a & b; // 0x00 - - ASSUME_ITS_BITWISE_FALSE(d & 0x01); // 0b00000001 - ASSUME_ITS_BITWISE_FALSE(a & 0x01); // 0b00000001 - ASSUME_ITS_BITWISE_FALSE(b & 0x80); // 0b10000000 - ASSUME_ITS_BITWISE_FALSE(a == b); -} - -FOSSIL_TEST(cpp_assume_run_of_not_bitwise_true) { - uint8_t a = 0xAA; // 0b10101010 - uint8_t b = 0x55; // 0b01010101 - - ASSUME_NOT_BITWISE_TRUE(a == b); - ASSUME_NOT_BITWISE_TRUE(a & 0x01); // 0b00000001 - ASSUME_NOT_BITWISE_TRUE(b & 0x80); // 0b10000000 -} - -FOSSIL_TEST(cpp_assume_run_of_not_bitwise_false) { - uint8_t a = 0xAA; // 0b10101010 - uint8_t b = 0x55; // 0b01010101 - uint8_t c = a | b; // 0xFF - - ASSUME_NOT_BITWISE_FALSE(c == 0xFF); - ASSUME_NOT_BITWISE_FALSE(a & 0x80); // 0b10000000 - ASSUME_NOT_BITWISE_FALSE(b & 0x01); // 0b00000001 -} - -FOSSIL_TEST(cpp_assume_run_of_less_than_bitwise) { - uint8_t a = 0x0F; // 15 - uint8_t b = 0xF0; // 240 - - ASSUME_ITS_LESS_THAN_BITWISE(a, b); - ASSUME_ITS_LESS_THAN_BITWISE(a & b, a | b); -} - -FOSSIL_TEST(cpp_assume_run_of_more_than_bitwise) { - uint8_t a = 0xF0; // 240 - uint8_t b = 0x0F; // 15 - - ASSUME_ITS_MORE_THAN_BITWISE(a, b); - ASSUME_ITS_MORE_THAN_BITWISE(a | b, a & b); -} - -FOSSIL_TEST(cpp_assume_run_of_equal_bitwise) { - uint8_t a = 0xAA; // 0b10101010 - uint8_t b = 0xAA; // 0b10101010 - - ASSUME_ITS_EQUAL_BITWISE(a, b); - ASSUME_ITS_EQUAL_BITWISE(a ^ b, 0); -} - -FOSSIL_TEST(cpp_assume_run_of_more_or_equal_bitwise) { - uint8_t a = 0xAA; // 0b10101010 - uint8_t b = 0x55; // 0b01010101 - - ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, b); - ASSUME_ITS_MORE_OR_EQUAL_BITWISE(a, a); -} - -FOSSIL_TEST(cpp_assume_run_of_less_or_equal_bitwise) { - uint8_t a = 0x55; // 0b01010101 - uint8_t b = 0xAA; // 0b10101010 - - ASSUME_ITS_LESS_OR_EQUAL_BITWISE(a, b); - ASSUME_ITS_LESS_OR_EQUAL_BITWISE(b, b); -} - // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * @@ -1117,15 +1035,6 @@ FOSSIL_TEST_GROUP(cpp_tdd_test_cases) { FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_its_soap_rot_brain); FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_its_soap_tone_detected); FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_not_soap_tone_detected); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_bitwise_true); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_bitwise_false); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_not_bitwise_true); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_not_bitwise_false); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_less_than_bitwise); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_more_than_bitwise); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_equal_bitwise); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_more_or_equal_bitwise); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_less_or_equal_bitwise); FOSSIL_TEST_REGISTER(cpp_tdd_suite); } // end of group