diff --git a/.github/workflows/meson_ci.yml b/.github/workflows/meson_ci.yml index 8ccc7787..2bd197aa 100644 --- a/.github/workflows/meson_ci.yml +++ b/.github/workflows/meson_ci.yml @@ -243,7 +243,7 @@ jobs: -w /workspace \ ${GITHUB_REPOSITORY}:${{ matrix.distro }} \ /bin/bash -c " - meson setup builddir --fatal-meson-warnings -Dwerror=true -Dwith_test=enabled -Dwarning_level=3 -Dc_std=c17 + meson setup builddir --fatal-meson-warnings -Dwerror=true -Dwith_test=enabled -Dwarning_level=3 meson compile -C builddir meson test -C builddir -v" diff --git a/README.md b/README.md index 6ccfc250..c11cb96c 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,50 @@ -# ***Fossil Test: Unit Testing/Mocking Framework*** - `C, C++` +# ***Fossil Test by Fossil Logic*** -**Overview:** -Fossil Test is a robust unit testing and mocking framework developed by Fossil Logic. It is designed to facilitate the creation of high-quality test cases across any C and C++ project. The framework supports Behavior-Driven Development (BDD), Domain Driven Development (DDD), and Test-Driven Development (TDD) styles, providing a flexible and comprehensive solution for ensuring software reliability and correctness. +**Fossil Test** is a comprehensive unit testing, mocking, and benchmarking suite created by Fossil Logic, designed to ensure the reliability and performance of C and C++ projects. With support for multiple development methodologies, including Behavior-Driven Development (BDD), Domain-Driven Design (DDD), and Test-Driven Development (TDD), Fossil Test provides a versatile foundation for crafting high-quality test cases across various workflows. -In addition to Fossil Test, Fossil Logic also offers two additional frameworks: Fossil Mark and Fossil Mock. Fossil Mark is a powerful benchmarking framework that allows developers to measure the performance of their code and identify areas for optimization. With built-in timing information and detailed reporting, developers can easily track the execution time of each test case and make informed decisions to improve the efficiency of their software. +The Fossil suite consists of three complementary frameworks to streamline the development and testing process: -Fossil Mock, on the other hand, provides powerful mocking capabilities that enable developers to simulate the behavior of complex dependencies. This ensures focused and reliable unit tests, as developers can create mock objects that mimic the behavior of real dependencies, allowing for thorough testing of different scenarios. +- **Fossil Test**: The core unit testing framework that enables developers to create, manage, and execute unit tests effectively, ensuring each component functions as expected. +- **Fossil Mock**: A dedicated mocking library that simulates complex dependencies. Using mock objects, developers can isolate and thoroughly test individual components, improving the precision and reliability of test coverage. +- **Fossil Mark**: A benchmarking tool that provides detailed performance insights by measuring execution time, identifying bottlenecks, and offering in-depth reporting to optimize code efficiency. -By combining the features of Fossil Test, Fossil Mark, and Fossil Mock, developers can create robust and performant code, ensuring the quality and reliability of their software projects. +Together, **Fossil Test**, **Fossil Mock**, and **Fossil Mark** offer a powerful, integrated toolkit for developing, testing, and optimizing robust software, making them an essential asset for developers committed to quality and performance. + +--- **Key Features:** | Feature | Description | |--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **BDD and TDD Support** | Allows developers to write tests in both BDD and TDD styles, catering to various development and testing preferences. | -| **Unit Testing** | Provides a complete suite of tools for writing and executing unit tests, ensuring that individual units of code perform as expected. | -| **Mocking Capabilities** | Includes powerful mocking features that enable developers to simulate the behavior of complex dependencies, ensuring focused and reliable unit tests. | -| **Test Case Management** | Supports organizing and managing test cases efficiently, with features for categorizing, prioritizing, and tagging tests. | -| **Detailed Reporting** | Generates detailed reports on test execution, including information on passed, failed, skipped, and timed-out tests, helping developers quickly address issues. | -| **Performance Tracking** | Tracks the performance of each test case with built-in timing information, allowing developers to monitor and optimize test execution time. | -| **Assertion Detection** | Detects whether assertions are used within the code, ensuring that critical conditions are enforced and identifying areas that may lack proper validation. | -| **Command-Line Interface (CLI)** | Includes a powerful CLI for running tests, generating reports, and managing the test suite from the command line, enhancing automation and integration. | -| **Extensible and Configurable** | Designed to be extensible and configurable, allowing developers to tailor the framework to their specific needs, from reporting formats to tool integration.| +| **BDD, DDD, and TDD Support** | Supports Behavior-Driven, Domain-Driven, and Test-Driven Development styles, catering to various project methodologies. | +| **Comprehensive Unit Testing** | A full suite of tools for creating, managing, and executing unit tests, ensuring that individual units of code behave as expected. | +| **Mocking Capabilities** | Powerful mocking features allow developers to simulate complex dependencies, ensuring focused and reliable unit tests. | +| **Performance Tracking** | Measures and reports the performance of each test case, helping developers optimize test execution time and performance. | +| **Command-Line Interface (CLI)** | A powerful CLI for running tests, generating reports, and managing the test suite, supporting automation and integration workflows. | + +--- ## ***Prerequisites*** -Before getting started, make sure you have the following installed: +To get started with Fossil Test, ensure you have the following installed: + +- **Meson Build System**: Fossil Test requires Meson. If you don’t have Meson installed, follow the installation instructions on the official [Meson website](https://mesonbuild.com/Getting-meson.html). -- **Meson Build System**: This project relies on Meson. If you don't have Meson installed, visit the official [Meson website](https://mesonbuild.com/Getting-meson.html) for installation instructions. +--- -## Adding Dependency +### Adding Fossil Test Dependency -1. **Install Meson Build System**: Before integrating the dependency, ensure you have Meson `1.3` or newer installed on your host system. You can install it with this command. +To integrate Fossil Test into your project, follow these steps: +1. **Install Meson Build System**: + Install Meson version `1.3` or newer: ```sh - python -m pip install meson # to install Meson - python -m pip install --upgrade meson # to upgrade Meson + python -m pip install meson # To install Meson + python -m pip install --upgrade meson # To upgrade Meson ``` -2. **Adding Wrap File**: You can add a `.wrap` file by first navigating to the `subprojects` directory and creating `fossil-test.wrap`. Next, copy the definition into the file: +2. **Create a `.wrap` File**: + Add the `fossil-test.wrap` file in your `subprojects` directory and include the following content: ```ini # ====================== @@ -46,119 +52,72 @@ Before getting started, make sure you have the following installed: # ====================== [wrap-git] url = https://github.com/fossillogic/fossil-test.git - revision = v1.0.6 + revision = v1.0.7 [provide] fossil-test = fossil_test_dep - fossil-mock = fossil_mock_dep - fossil-mark = fossil_mark_dep ``` -3. **Integrate the New Dependency**: After creating the dependency `.wrap` file, you need to integrate it into your Meson project. This typically involves adding the dependency to your `meson.build` file. Here's an example of how you might do that: - +3. **Integrate the Dependency**: + In your `meson.build` file, integrate Fossil Test by adding the following line: ```ini dep = dependency('fossil-test') ``` - This line retrieves the `fossil-test` dependency, allowing you to use it in your project. **Releases Page**: Head over to the [Fossil Test Releases](https://github.com/fossillogic/fossil-test/releases) to find any preferred version of the framework. For the best experience with Fossil Test, it is recommended to always use the latest release. + **Note**: For the best experience, always use the latest release of Fossil Test. Visit the [Fossil Test Releases](https://github.com/fossillogic/fossil-test/releases) page for the latest versions. + +--- ## Fossil Test CLI Usage -The Fossil Test CLI is a command-line tool designed to help you run and manage your test suite efficiently. Below are the available commands and options: +The Fossil Test CLI provides an efficient way to run and manage tests directly from the terminal. Here are the available commands and options: ### Commands and Options | Command | Description | -|---------------------------------|-----------------------------------------------------------------------------------------------| -| `--version` | Displays the version of the Fossil Test CLI. | -| `--help` | Shows the help message with usage instructions. | -| `--tip` | Provides a tip or hint about using the Fossil Test CLI. | -| `--info` | Displays information about the test runner. | -| `--author` | Shows information about the author of the test runner. | -| `only=` or `only=` | Runs only the tests tagged with the specified tag(s). Tags should be comma-separated for multiple tags. | -| `reverse [enable/disable]` | Enables or disables the reverse order of test execution. | -| `repeat=` | Repeats the test suite for the specified number of times. | -| `shuffle [enable/disable]` | Enables or disables the shuffling of test execution order. | -| `verbose [cutback/normal/verbose]` | Sets the verbosity level of the output. Options are `cutback`, `normal`, and `verbose`. | -| `list` | Lists all available tests. | -| `summary [enable/disable]` | Enables or disables the summary of test results after execution. | -| `color [enable/disable]` | Enables or disables colored output in the terminal. | -| `sanity [enable/disable]` | Enables or disables sanity checks before running the tests. | - -### Examples - -- Display version information: - - ```sh - fossil_cli --version - ``` +|----------------------------------|-----------------------------------------------------------------------------------------------| +| `--version` | Displays the current version of Fossil Test. | +| `--help` | Shows help message with usage instructions. | +| `--info` | Displays detailed information about the test run. | +| `reverse [enable/disable]` | Enables or disables reverse order of test execution. | +| `repeat=` | Repeats the test suite a specified number of times. | +| `shuffle [enable/disable]` | Enables or disables shuffling of test execution order. | -- Show help message: +### Example Usage +- Display the version: ```sh - fossil_cli --help - ``` - -- Run only tests tagged with "unit" and "integration": - - ```sh - fossil_cli only=unit,integration + fossil_cli --version ``` - Enable reverse order of test execution: - ```sh fossil_cli reverse enable ``` - Repeat the test suite 5 times: - ```sh fossil_cli repeat=5 ``` -- Enable verbose output: - - ```sh - fossil_cli verbose verbose - ``` - -- List all available tests: - - ```sh - fossil_cli list - ``` - -- Enable test result summary: - - ```sh - fossil_cli summary enable - ``` - -- Enable colored output: - - ```sh - fossil_cli color enable - ``` - -Feel free to explore and use the various commands and options to tailor the test runner to your needs. For further assistance, refer to the `--help` command. +--- -## Configure Options +## Configure Build Options -You have options when configuring the build, each serving a different purpose: - -- **Running Tests**: To enable running tests, use `-Dwith_test=enabled` when configuring the build. - -Example: +To configure the build system with testing enabled, use the following command: ```sh meson setup builddir -Dwith_test=enabled ``` +--- + ## ***Contributing and Support*** -If you're interested in contributing to this project, encounter any issues, have questions, or would like to provide feedback, don't hesitate to open an issue or visit the [Fossil Logic Docs](https://fossillogic.com/docs) for more information. +If you would like to contribute, have questions, or need help, feel free to open an issue on the [Fossil Test GitHub repository](https://github.com/fossillogic/fossil-test) or consult the [Fossil Logic Docs](https://fossillogic.com/docs). + +--- -## ***Conclusion:*** +## ***Conclusion*** -Fossil Test is a comprehensive solution for C and C++ developers aiming to ensure the quality and reliability of their code. By supporting both BDD and TDD, along with powerful mocking, assertion detection, detailed reporting, and a robust CLI, Fossil Test empowers developers to create robust and maintainable test suites. Its flexibility and extensibility make it a valuable tool for projects of any size and complexity, fostering a culture of quality and continuous improvement. +Fossil Test is a powerful and flexible framework for C and C++ developers, designed to support a wide range of testing methodologies such as BDD, DDD, and TDD. With features like mocking, detailed reporting, and performance tracking, Fossil Test empowers developers to create high-quality software and maintainable test suites. Combined with Fossil Mark and Fossil Mock, it provides a complete suite for testing, optimization, and dependency management. Whether you're building small projects or large-scale applications, Fossil Test is an essential tool to ensure the reliability and performance of your code. diff --git a/code/logic/benchmark/benchmark.c b/code/logic/benchmark.c similarity index 76% rename from code/logic/benchmark/benchmark.c rename to code/logic/benchmark.c index 0abff793..d4aa9cc5 100644 --- a/code/logic/benchmark/benchmark.c +++ b/code/logic/benchmark.c @@ -14,70 +14,79 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include "fossil/benchmark/benchmark.h" +#include "fossil/test/benchmark.h" #include +#include +#include #include #include #include -// -// local types -// -static uint64_t start_time; - #if defined(_WIN32) -static double frequency; // Variable to store the frequency for Windows +#include +static LARGE_INTEGER frequency; +static LARGE_INTEGER start_time; +#elif defined(__APPLE__) +#include +clock_t start_time; +#else +#include +#include +clock_t start_time; +#endif + +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199309L +#endif + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE #endif void fossil_test_start_benchmark(void) { #if defined(_WIN32) - LARGE_INTEGER freq; - if (!QueryPerformanceFrequency(&freq)) { - // Handle error - fprintf(stderr, "Error: QueryPerformanceFrequency failed\n"); - exit(EXIT_FAILURE); - } - frequency = (double)freq.QuadPart; - if (!QueryPerformanceCounter((LARGE_INTEGER*)&start_time)) { - // Handle error - fprintf(stderr, "Error: QueryPerformanceCounter failed\n"); - exit(EXIT_FAILURE); - } -#else + QueryPerformanceFrequency(&frequency); + QueryPerformanceCounter(&start_time); +#elif defined(__APPLE__) + start_time = mach_absolute_time(); +#elif defined(_POSIX_VERSION) struct timespec ts; - if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) { - // Handle error - perror("Error: clock_gettime failed"); - exit(EXIT_FAILURE); - } + clock_gettime(CLOCK_MONOTONIC, &ts); start_time = ts.tv_sec * 1e9 + ts.tv_nsec; +#else + struct timeval tv; + gettimeofday(&tv, NULL); + start_time = (uint64_t)tv.tv_sec * 1e6 + tv.tv_usec; #endif } uint64_t fossil_test_stop_benchmark(void) { #if defined(_WIN32) LARGE_INTEGER end_time; - if (!QueryPerformanceCounter(&end_time)) { - // Handle error - fprintf(stderr, "Error: QueryPerformanceCounter failed\n"); - exit(EXIT_FAILURE); - } - return (uint64_t)((end_time.QuadPart - start_time) * 1e9 / frequency); -#else + QueryPerformanceCounter(&end_time); + return (uint64_t)((end_time.QuadPart - start_time.QuadPart) * 1e9 / frequency.QuadPart); +#elif defined(__APPLE__) + uint64_t end_time = mach_absolute_time(); + mach_timebase_info_data_t timebase; + mach_timebase_info(&timebase); + return (end_time - start_time) * timebase.numer / timebase.denom; +#elif defined(_POSIX_VERSION) struct timespec ts; - if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) { - // Handle error - perror("Error: clock_gettime failed"); - exit(EXIT_FAILURE); - } - return (uint64_t)((ts.tv_sec * 1e9 + ts.tv_nsec) - start_time); + clock_gettime(CLOCK_MONOTONIC, &ts); + return (ts.tv_sec * 1e9 + ts.tv_nsec) - start_time; +#else + struct timeval tv; + gettimeofday(&tv, NULL); + uint64_t end_time = (uint64_t)tv.tv_sec * 1e6 + tv.tv_usec; + return (end_time - start_time) * 1e3; #endif } void assume_duration(double expected, double actual, double unit) { - clock_t end_time = clock(); - double elapsed_time = (double)(end_time - start_time) / ((double)CLOCKS_PER_SEC / unit); - if (elapsed_time < expected) { + uint64_t elapsed_time = fossil_test_stop_benchmark(); + double elapsed_seconds = elapsed_time / (1e9 / unit); // Convert to the desired time unit + + if (elapsed_seconds < expected) { printf("Benchmark failed: expected %f, got %f\n", expected, actual); } } diff --git a/code/logic/benchmark/meson.build b/code/logic/benchmark/meson.build deleted file mode 100644 index ea9ee0b0..00000000 --- a/code/logic/benchmark/meson.build +++ /dev/null @@ -1,10 +0,0 @@ -mark_code = ['benchmark.c'] - -fossil_mark_lib = library('fossil-mark', - mark_code, - install: true, - include_directories: dir) - -fossil_mark_dep = declare_dependency( - link_with: fossil_mark_lib, - include_directories: dir) \ No newline at end of file diff --git a/code/logic/fossil/_common/common.h b/code/logic/fossil/_common/common.h deleted file mode 100644 index 071fde80..00000000 --- a/code/logic/fossil/_common/common.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_TEST_COMMON_H -#define FOSSIL_TEST_COMMON_H - -#ifdef _WIN32 -#include -#else -#define _GNU_SOURCE // Define _GNU_SOURCE for C code -#endif - -#ifdef _WIN32 -#include -#else -#include -#include -#ifdef __APPLE__ -#include -#include -#include -#else -#include -#endif -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// becuase Microsoft had to be diffrent -#ifdef _WIN32 -#define wcsncasecmp _wcsnicmp -#endif - -// Used in floating-point asserts -#define FOSSIL_TEST_FLOAT_EPSILON 1e-6 -#define FOSSIL_TEST_DOUBLE_EPSILON 1e-9 - -#if __cplusplus >= 201103L || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) -/** - * @brief Definition for xnull pointers in C++11 and later or C23 and later. - * - * In C++11 or later, `xnullptr` is a keyword representing a xnull pointer constant. - * In C23 or later, `_xnullptr` is recognized in the same way as C++. - */ - #define xnull nullptr - #define xnullptr nullptr - #define xterm '\0' -#else - #if defined(_WIN64) || defined(_WIN32) -/** - * @brief Definition for xnull pointers on Windows systems. - * - * For Windows (both 32-bit and 64-bit), we define `xnull` and `xnullptr` as 0. - */ - #define xnull 0 - #define xnullptr 0 - #define xterm '\0' - #else -/** - * @brief Definition for xnull pointers on POSIX systems, macOS, and embedded systems. - * - * For POSIX, macOS, and embedded systems, we define `xnull` and `xnullptr` as a void pointer to 0. - */ - #define xnull (void *)(0) - #define xnullptr (void *)(0) - #define xterm '\0' - #endif -#endif - -// Custom implementation of strdup -static inline char* _custom_fossil_test_strdup(const char* str) { - if (!str) return xnull; // Handle NULL pointer gracefully - - size_t len = 0; - while (str[len] != '\0') len++; // Calculate the length of the string - - char* dup = (char*)malloc((len + 1) * sizeof(char)); // Allocate memory for the duplicate string - if (!dup) return xnull; // Check if malloc failed - - for (size_t i = 0; i < len; i++) { - dup[i] = str[i]; // Copy each character from the original string to the duplicate - } - dup[len] = '\0'; // Add null terminator to the end of the duplicate string - - return dup; -} - -#endif diff --git a/code/logic/fossil/_common/platform.h b/code/logic/fossil/_common/platform.h deleted file mode 100644 index 5e3feccd..00000000 --- a/code/logic/fossil/_common/platform.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_TEST_PLATFORM_H -#define FOSSIL_TEST_PLATFORM_H - -#include "common.h" // for introspection data - -#ifdef __cplusplus -extern "C" { -#endif - -// Utility function to get the architecture -static inline char* _fossil_test_get_architecture(void) { - char* arch = (char*)malloc(10 * sizeof(char)); // Explicit cast for C++ - if (arch == NULL) { - return NULL; - } -#ifdef _WIN32 - SYSTEM_INFO sysinfo; - GetSystemInfo(&sysinfo); - switch (sysinfo.wProcessorArchitecture) { - case PROCESSOR_ARCHITECTURE_AMD64: - strncpy(arch, "x86_64", 9); - break; - case PROCESSOR_ARCHITECTURE_ARM: - strncpy(arch, "ARM", 9); - break; - case PROCESSOR_ARCHITECTURE_ARM64: - strncpy(arch, "ARM64", 9); - break; - case PROCESSOR_ARCHITECTURE_INTEL: - strncpy(arch, "x86", 9); - break; - default: - strncpy(arch, "unknown", 9); - } - arch[9] = '\0'; -#else - struct utsname buffer; - if (uname(&buffer) == 0) { - strncpy(arch, buffer.machine, 9); - } else { - strncpy(arch, "unknown", 9); - } - arch[9] = '\0'; -#endif - return arch; -} - -// Utility function to get the OS name -static inline char* _fossil_test_get_os_name(void) { - char* os_name = (char*)malloc(20 * sizeof(char)); // Explicit cast for C++ - if (os_name == NULL) { - return NULL; - } -#ifdef _WIN32 - strncpy(os_name, "Windows", 19); -#else - struct utsname buffer; - if (uname(&buffer) == 0) { - strncpy(os_name, buffer.sysname, 19); - } else { - strncpy(os_name, "unknown", 19); - } -#endif - os_name[19] = '\0'; - return os_name; -} - -// Utility function to check if the system is big endian -static inline bool _fossil_test_assert_is_big_endian(void) { - uint16_t num = 0x1; - return (*(uint8_t *)&num == 0); -} - -// Utility function to get the number of CPUs -static inline int _fossil_test_get_num_cpus(void) { -#ifdef _WIN32 - SYSTEM_INFO sysinfo; - GetSystemInfo(&sysinfo); - return sysinfo.dwNumberOfProcessors; -#elif defined(__APPLE__) - int num_cpus; - size_t size = sizeof(num_cpus); - if (sysctlbyname("hw.ncpu", &num_cpus, &size, NULL, 0) == 0) { - return num_cpus; - } else { - return 1; // Default to 1 if unable to get the number of CPUs - } -#else - return sysconf(_SC_NPROCESSORS_ONLN); -#endif -} - -// Utility function to get the total memory size in MB -static inline int _fossil_test_get_memory_size(void) { -#ifdef _WIN32 - MEMORYSTATUSEX status; - status.dwLength = sizeof(status); - if (GlobalMemoryStatusEx(&status)) { - return (int)(status.ullTotalPhys / (1024 * 1024)); - } else { - fprintf(stderr, "Failed to get memory status on Windows\n"); - return 0; - } -#elif defined(__APPLE__) - int64_t mem_size; - size_t size = sizeof(mem_size); - if (sysctlbyname("hw.memsize", &mem_size, &size, NULL, 0) == 0) { - return (int)(mem_size / (1024 * 1024)); - } else { - fprintf(stderr, "Failed to get memory size on macOS\n"); - return 0; - } -#elif defined(__linux__) - struct sysinfo info; - if (sysinfo(&info) == 0) { - return (int)(info.totalram * info.mem_unit / (1024 * 1024)); - } else { - fprintf(stderr, "Failed to get memory size on Linux\n"); - return 0; - } -#else - fprintf(stderr, "Unsupported platform\n"); - return 0; -#endif -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/code/logic/fossil/benchmark/framework.h b/code/logic/fossil/benchmark/framework.h deleted file mode 100644 index fc3975a6..00000000 --- a/code/logic/fossil/benchmark/framework.h +++ /dev/null @@ -1,234 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * File: framework.hpp - * Project: Fossil Logic - * Description: This file implments the framework for benchmarking. - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_MARK_FRAMEWORK_HPP -#define FOSSIL_MARK_FRAMEWORK_HPP - -#include "benchmark.h" - -// Macros for benchmarking -/** - * @brief Define macro for marking a benchmark. - * - * This macro is used to mark a benchmark with a given name. It initializes - * the benchmark structure and sets the name of the benchmark. - * - * @param name The name of the benchmark. - */ -#define MARK_BENCHMARK(name) \ - fossil_benchmark_t benchmark_##name; \ - fossil_benchmark_init(&benchmark_##name, #name) - -/** - * @brief Define macro for starting a benchmark. - * - * This macro is used to start a benchmark with a given name. It starts the - * timer for the benchmark. - * - * @param name The name of the benchmark. - */ -#define MARK_START(name) \ - fossil_benchmark_start(&benchmark_##name) - -/** - * @brief Define macro for stopping a benchmark. - * - * This macro is used to stop a benchmark with a given name. It stops the - * timer for the benchmark. - * - * @param name The name of the benchmark. - */ -#define MARK_STOP(name) \ - fossil_benchmark_stop(&benchmark_##name) - -/** - * @brief Define macro for reporting a benchmark. - * - * This macro is used to report the results of a benchmark with a given name. - * It prints the benchmark name and the elapsed time. - * - * @param name The name of the benchmark. - */ -#define MARK_REPORT(name) \ - fossil_benchmark_report(&benchmark_##name) - -/** - * @brief Define macro for scoped benchmarking. - * - * This macro is used to create a scoped benchmark with a given name. It - * initializes the scoped benchmark structure and sets the benchmark to be - * used. - * - * @param name The name of the benchmark. - */ -#define MARK_SCOPED(name) \ - scoped_benchmark_t scoped_benchmark_##name; \ - fossil_scoped_benchmark_init(&scoped_benchmark_##name, &benchmark_##name) - -// ================================================================= -// Bench specific commands -// ================================================================= - -/** - * @brief Define macro for starting a benchmark. - * - * This macro is used to mark the start of a benchmark. It typically initializes - * any necessary resources or variables required for benchmarking. - */ -#define TEST_BENCHMARK() fossil_test_start_benchmark() - -/** - * @brief Define macro for getting the current time. - * - * This macro is used to retrieve the current time, which is typically used - * in conjunction with TEST_BENCHMARK to calculate the elapsed time for a benchmark. - */ -#define TEST_CURRENT_TIME() fossil_test_stop_benchmark() - -/** - * @brief Define macro for reporting test duration with a given timeout. - * - * This macro is used to report the duration of a test with a given timeout. - * It takes the timeout duration, elapsed time, and actual duration as arguments - * and reports the results, typically in the form of logs or console output. - * - * @param duration The duration unit (e.g., "minutes", "seconds"). - * @param elapsed The elapsed time since the benchmark started. - * @param actual The actual duration of the test. - */ -#define TEST_DURATION(duration, elapsed, actual) fossil_test_benchmark((char*)duration, elapsed, actual) - -/** - * @brief Define macro for reporting test duration in minutes. - * - * This macro is a shorthand for reporting test duration in minutes using TEST_DURATION. - * It takes the elapsed time and actual duration as arguments and reports the results - * in minutes. - * - * @param elapsed The elapsed time since the benchmark started. - * @param actual The actual duration of the test. - */ -#define TEST_DURATION_MIN(elapsed, actual) TEST_DURATION((char*)"minutes", elapsed, actual) - -/** - * @brief Define macro for reporting test duration in seconds. - * - * This macro is a shorthand for reporting test duration in seconds using TEST_DURATION. - * It takes the elapsed time and actual duration as arguments and reports the results - * in seconds. - * - * @param elapsed The elapsed time since the benchmark started. - * @param actual The actual duration of the test. - */ -#define TEST_DURATION_SEC(elapsed, actual) TEST_DURATION((char*)"seconds", elapsed, actual) - -/** - * @brief Define macro for reporting test duration in milliseconds. - * - * This macro is a shorthand for reporting test duration in milliseconds using TEST_DURATION. - * It takes the elapsed time and actual duration as arguments and reports the results - * in milliseconds. - * - * @param elapsed The elapsed time since the benchmark started. - * @param actual The actual duration of the test. - */ -#define TEST_DURATION_MIL(elapsed, actual) TEST_DURATION((char*)"milliseconds", elapsed, actual) - -/** - * @brief Define macro for reporting test duration in microseconds. - * - * This macro is a shorthand for reporting test duration in microseconds using TEST_DURATION. - * It takes the elapsed time and actual duration as arguments and reports the results - * in microseconds. - * - * @param elapsed The elapsed time since the benchmark started. - * @param actual The actual duration of the test. - */ -#define TEST_DURATION_MIC(elapsed, actual) TEST_DURATION((char*)"microseconds", elapsed, actual) - -/** - * @brief Define macro for reporting test duration in nanoseconds. - * - * This macro is a shorthand for reporting test duration in nanoseconds using TEST_DURATION. - * It takes the elapsed time and actual duration as arguments and reports the results - * in nanoseconds. - * - * @param elapsed The elapsed time since the benchmark started. - * @param actual The actual duration of the test. - */ -#define TEST_DURATION_NAN(elapsed, actual) TEST_DURATION((char*)"nanoseconds", elapsed, actual) - -/** - * @brief Define macro for reporting test duration in picoseconds. - * - * This macro is a shorthand for reporting test duration in picoseconds using TEST_DURATION. - * It takes the elapsed time and actual duration as arguments and reports the results - * in picoseconds. - * - * @param elapsed The elapsed time since the benchmark started. - * @param actual The actual duration of the test. - */ -#define TEST_DURATION_PIC(elapsed, actual) TEST_DURATION((char*)"picoseconds", elapsed, actual) - -/** - * @brief Define macro for reporting test duration in femtoseconds. - * - * This macro is a shorthand for reporting test duration in femtoseconds using TEST_DURATION. - * It takes the elapsed time and actual duration as arguments and reports the results - * in femtoseconds. - * - * @param elapsed The elapsed time since the benchmark started. - * @param actual The actual duration of the test. - */ -#define TEST_DURATION_FEM(elapsed, actual) TEST_DURATION((char*)"femtoseconds", elapsed, actual) - -/** - * @brief Define macro for reporting test duration in attoseconds. - * - * This macro is a shorthand for reporting test duration in attoseconds using TEST_DURATION. - * It takes the elapsed time and actual duration as arguments and reports the results - * in attoseconds. - * - * @param elapsed The elapsed time since the benchmark started. - * @param actual The actual duration of the test. - */ -#define TEST_DURATION_ATT(elapsed, actual) TEST_DURATION((char*)"attoseconds", elapsed, actual) - -/** - * @brief Define macro for reporting test duration in zeptoseconds. - * - * This macro is a shorthand for reporting test duration in zeptoseconds using TEST_DURATION. - * It takes the elapsed time and actual duration as arguments and reports the results - * in zeptoseconds. - * - * @param elapsed The elapsed time since the benchmark started. - * @param actual The actual duration of the test. - */ -#define TEST_DURATION_ZEP(elapsed, actual) TEST_DURATION((char*)"zeptoseconds", elapsed, actual) - -/** - * @brief Define macro for reporting test duration in yoctoseconds. - * - * This macro is a shorthand for reporting test duration in yoctoseconds using TEST_DURATION. - * It takes the elapsed time and actual duration as arguments and reports the results - * in yoctoseconds. - * - * @param elapsed The elapsed time since the benchmark started. - * @param actual The actual duration of the test. - */ -#define TEST_DURATION_YOC(elapsed, actual) TEST_DURATION((char*)"yoctoseconds", elapsed, actual) - -#endif // FOSSIL_MARK_FRAMEWORK_HPP diff --git a/code/logic/fossil/meson.build b/code/logic/fossil/meson.build deleted file mode 100644 index ff5b77c4..00000000 --- a/code/logic/fossil/meson.build +++ /dev/null @@ -1 +0,0 @@ -dir = include_directories('.') diff --git a/code/logic/fossil/mockup/framework.h b/code/logic/fossil/mockup/framework.h deleted file mode 100644 index b7a86bc6..00000000 --- a/code/logic/fossil/mockup/framework.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * File: framework.hpp - * Project: Fossil Logic - * Description: This file implments the framework for mockup testing. - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_MOCK_FRAMEWORK_H -#define FOSSIL_MOCK_FRAMEWORK_H - -#include "mockup.h" - -/** - * @brief Macro for initializing the mock list. - * - * This macro initializes the mock list by calling the fossil_mock_init function. - * - * @param list The mock list to initialize. - */ -#define MOCK_INIT(list) _MOCK_INIT(list) - -/** - * @brief Macro for destroying the mock list. - * - * This macro destroys the mock list by calling the fossil_mock_destroy function. - * - * @param list The mock list to destroy. - */ -#define MOCK_DESTROY(list) _MOCK_DESTROY(list) - -/** - * @brief Macro for adding a mock function call to the mock list. - * - * This macro adds a mock function call to the mock list by calling the fossil_mock_add_call function. - * - * @param list The mock list to add the call to. - * @param func The mock function to add the call for. - * @param args The arguments of the mock function call. - * @param num_args The number of arguments in the mock function call. - */ -#define MOCK_ADD_CALL(list, func, args, num_args) _MOCK_ADD_CALL(list, func, args, num_args) - -/** - * @brief Macro for printing the mock list. - * - * This macro prints the mock list by calling the fossil_mock_print function. - * - * @param list The mock list to print. - */ -#define MOCK_PRINT(list) _MOCK_PRINT(list) -/** - * @def FOSSIL_MOCK_FUNC - * @brief Macro for creating a mock function with the specified return type, name, and parameters. - * - * This macro simplifies the creation of mock functions by defining a function with the given return - * type, name, and parameters. The function name will be prefixed with "fossil_mockup_" to clearly indicate - * that it is a mock function. - * - * @param return_type The return type of the mock function. - * @param name The name of the mock function. - * @param ... The parameters of the mock function in the format: (type1 param1, type2 param2, ...). - * @return The return type specified for the mock function. - */ -#define FOSSIL_MOCK_FUNC(return_type, name, ...) _FOSSIL_MOCK_FUNC(return_type, name, __VA_ARGS__) - -/** - * @def FOSSIL_MOCK_ALIAS - * @brief Macro for creating a type alias based on an existing type. - * - * This macro creates a type alias for a given existing type. - * - * @param new_type The name of the new type alias. - * @param existing_type The existing type to create an alias for. - */ -#define FOSSIL_MOCK_ALIAS(new_type, existing_type) _FOSSIL_MOCK_ALIAS(new_type, existing_type) - -/** - * @def FOSSIL_MOCK_STRUCT - * @brief Macro for creating a mock struct with the specified name and members. - * - * This macro simplifies the creation of mock structs by defining a struct with the given name - * and members. The struct name will be prefixed with "fossil_mockup_" to clearly indicate that it is a mock struct. - * - * @param name The name of the mock struct. - * @param ... The members of the mock struct in the format: (type1 member1, type2 member2, ...). - */ -#define FOSSIL_MOCK_STRUCT(name, ...) _FOSSIL_MOCK_STRUCT(name, __VA_ARGS__) - -#endif // FOSSIL_MOCK_FRAMEWORK_H diff --git a/code/logic/fossil/test/assume.h b/code/logic/fossil/test/assume.h new file mode 100644 index 00000000..f699c264 --- /dev/null +++ b/code/logic/fossil/test/assume.h @@ -0,0 +1,2297 @@ +/* + * ----------------------------------------------------------------------------- + * Project: Fossil Logic + * + * This file is part of the Fossil Logic project, which aims to develop high- + * performance, cross-platform applications and libraries. The code contained + * herein is subject to the terms and conditions defined in the project license. + * + * Author: Michael Gene Brockus (Dreamer) + * Date: 07/01/2024 + * + * Copyright (C) 2024 Fossil Logic. All rights reserved. + * ----------------------------------------------------------------------------- + */ +#ifndef FOSSIL_TEST_ASSUME_TYPE_H +#define FOSSIL_TEST_ASSUME_TYPE_H + +#include "framework.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// becuase Microsoft had to be diffrent +#ifdef _WIN32 +#define wcsncasecmp _wcsnicmp +#endif + +// Used in floating-point asserts +#define FOSSIL_TEST_FLOAT_EPSILON 1e-6 +#define FOSSIL_TEST_DOUBLE_EPSILON 1e-9 + +// ************************************************** +// +// Boolean ASSUMEions +// +// ************************************************** + +/** + * @brief Assumes that the given boolean expression is true. + * + * @param actual The boolean expression to be evaluated. + */ +#define ASSUME_ITS_TRUE(actual) \ + FOSSIL_TEST_ASSUME((actual), "Expected " #actual " to be true") + +/** + * @brief Assumes that the given boolean expression is false. + * + * @param actual The boolean expression to be evaluated. + */ +#define ASSUME_ITS_FALSE(actual) \ + FOSSIL_TEST_ASSUME(!(actual), "Expected " #actual " to be false") + +/** + * @brief Assumes that the given boolean expression is not true. + * + * @param actual The boolean expression to be evaluated. + */ +#define ASSUME_NOT_TRUE(actual) \ + FOSSIL_TEST_ASSUME(!(actual), "Expected " #actual " to not be true") + +/** + * @brief Assumes that the given boolean expression is not false. + * + * @param actual The boolean expression to be evaluated. + */ +#define ASSUME_NOT_FALSE(actual) \ + FOSSIL_TEST_ASSUME((actual), "Expected " #actual " to not be false") + +// ************************************************** +// +// Floating point ASSUMEions +// +// ************************************************** + +// Double equality check with tolerance +/** + * @brief Assumes that the given double values are equal within a specified tolerance. + * + * @param actual The actual double value. + * @param expected The expected double value. + * @param tol The tolerance within which the values should be considered equal. + */ +#define ASSUME_ITS_EQUAL_F64(actual, expected, tol) \ + FOSSIL_TEST_ASSUME(fabs((actual) - (expected)) <= (tol), "Expected " #actual " to be equal to " #expected " within tolerance " #tol) + +/** + * @brief Assumes that the given double value is less than the expected value. + * + * @param actual The actual double value. + * @param expected The expected double value. + */ +#define ASSUME_ITS_LESS_THAN_F64(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) < (expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given double value is more than the expected value. + * + * @param actual The actual double value. + * @param expected The expected double value. + */ +#define ASSUME_ITS_MORE_THAN_F64(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) > (expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given double value is less than or equal to the expected value. + * + * @param actual The actual double value. + * @param expected The expected double value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_F64(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) <= (expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given double value is more than or equal to the expected value. + * + * @param actual The actual double value. + * @param expected The expected double value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_F64(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) >= (expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given double values are not equal within a specified tolerance. + * + * @param actual The actual double value. + * @param expected The expected double value. + * @param tol The tolerance within which the values should not be considered equal. + */ +#define ASSUME_NOT_EQUAL_F64(actual, expected, tol) \ + FOSSIL_TEST_ASSUME(fabs((actual) - (expected)) > (tol), "Expected " #actual " to not be equal to " #expected " within tolerance " #tol) + +/** + * @brief Assumes that the given double value is not less than the expected value. + * + * @param actual The actual double value. + * @param expected The expected double value. + */ +#define ASSUME_NOT_LESS_THAN_F64(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) >= (expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given double value is not more than the expected value. + * + * @param actual The actual double value. + * @param expected The expected double value. + */ +#define ASSUME_NOT_MORE_THAN_F64(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) <= (expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given double value is not less than or equal to the expected value. + * + * @param actual The actual double value. + * @param expected The expected double value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_F64(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) > (expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given double value is not more than or equal to the expected value. + * + * @param actual The actual double value. + * @param expected The expected double value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_F64(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) < (expected), "Expected " #actual " to not be more than or equal to " #expected) + +// Float equality check with tolerance +/** + * @brief Assumes that the given float values are equal within a specified tolerance. + * + * @param actual The actual float value. + * @param expected The expected float value. + * @param tol The tolerance within which the values should be considered equal. + */ +#define ASSUME_ITS_EQUAL_F32(actual, expected, tol) \ + FOSSIL_TEST_ASSUME(fabsf((actual) - (expected)) <= (tol), "Expected " #actual " to be equal to " #expected " within tolerance " #tol) + +/** + * @brief Assumes that the given float value is less than the expected value. + * + * @param actual The actual float value. + * @param expected The expected float value. + */ +#define ASSUME_ITS_LESS_THAN_F32(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) < (expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given float value is more than the expected value. + * + * @param actual The actual float value. + * @param expected The expected float value. + */ +#define ASSUME_ITS_MORE_THAN_F32(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) > (expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given float value is less than or equal to the expected value. + * + * @param actual The actual float value. + * @param expected The expected float value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_F32(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) <= (expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given float value is more than or equal to the expected value. + * + * @param actual The actual float value. + * @param expected The expected float value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_F32(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) >= (expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given float values are not equal within a specified tolerance. + * + * @param actual The actual float value. + * @param expected The expected float value. + * @param tol The tolerance within which the values should not be considered equal. + */ +#define ASSUME_NOT_EQUAL_F32(actual, expected, tol) \ + FOSSIL_TEST_ASSUME(fabsf((actual) - (expected)) > (tol), "Expected " #actual " to not be equal to " #expected " within tolerance " #tol) + +/** + * @brief Assumes that the given float value is not less than the expected value. + * + * @param actual The actual float value. + * @param expected The expected float value. + */ +#define ASSUME_NOT_LESS_THAN_F32(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) >= (expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given float value is not more than the expected value. + * + * @param actual The actual float value. + * @param expected The expected float value. + */ +#define ASSUME_NOT_MORE_THAN_F32(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) <= (expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given float value is not less than or equal to the expected value. + * + * @param actual The actual float value. + * @param expected The expected float value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_F32(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) > (expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given float value is not more than or equal to the expected value. + * + * @param actual The actual float value. + * @param expected The expected float value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_F32(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) < (expected), "Expected " #actual " to not be more than or equal to " #expected) + +// Float NaN and Infinity checks +/** + * @brief Assumes that the given float value is NaN (Not a Number). + * + * @param actual The actual float value. + */ +#define ASSUME_ITS_NAN_F32(actual) \ + FOSSIL_TEST_ASSUME(isnan(actual), "Expected " #actual " to be NaN") + +/** + * @brief Assumes that the given float value is infinity. + * + * @param actual The actual float value. + */ +#define ASSUME_ITS_INF_F32(actual) \ + FOSSIL_TEST_ASSUME(isinf(actual), "Expected " #actual " to be infinity") + +// Double NaN and Infinity checks +/** + * @brief Assumes that the given double value is NaN (Not a Number). + * + * @param actual The actual double value. + */ +#define ASSUME_ITS_NAN_F64(actual) \ + FOSSIL_TEST_ASSUME(isnan(actual), "Expected " #actual " to be NaN") + +/** + * @brief Assumes that the given double value is infinity. + * + * @param actual The actual double value. + */ +#define ASSUME_ITS_INF_F64(actual) \ + FOSSIL_TEST_ASSUME(isinf(actual), "Expected " #actual " to be infinity") + +// ************************************************** +// +// Numaric ASSUMEions +// +// ************************************************** + +/** + * @brief Assumes that the given 8-bit octal values are equal. + * + * @param actual The actual 8-bit octal value. + * @param expected The expected 8-bit octal value. + */ +#define ASSUME_ITS_EQUAL_O8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 8-bit octal value is less than the expected value. + * + * @param actual The actual 8-bit octal value. + * @param expected The expected 8-bit octal value. + */ +#define ASSUME_ITS_LESS_THAN_O8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 8-bit octal value is more than the expected value. + * + * @param actual The actual 8-bit octal value. + * @param expected The expected 8-bit octal value. + */ +#define ASSUME_ITS_MORE_THAN_O8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 8-bit octal value is less than or equal to the expected value. + * + * @param actual The actual 8-bit octal value. + * @param expected The expected 8-bit octal value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_O8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit octal value is more than or equal to the expected value. + * + * @param actual The actual 8-bit octal value. + * @param expected The expected 8-bit octal value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_O8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit octal values are not equal. + * + * @param actual The actual 8-bit octal value. + * @param expected The expected 8-bit octal value. + */ +#define ASSUME_NOT_EQUAL_O8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 8-bit octal value is not less than the expected value. + * + * @param actual The actual 8-bit octal value. + * @param expected The expected 8-bit octal value. + */ +#define ASSUME_NOT_LESS_THAN_O8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 8-bit octal value is not more than the expected value. + * + * @param actual The actual 8-bit octal value. + * @param expected The expected 8-bit octal value. + */ +#define ASSUME_NOT_MORE_THAN_O8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 8-bit octal value is not less than or equal to the expected value. + * + * @param actual The actual 8-bit octal value. + * @param expected The expected 8-bit octal value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_O8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit octal value is not more than or equal to the expected value. + * + * @param actual The actual 8-bit octal value. + * @param expected The expected 8-bit octal value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_O8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit octal values are equal. + * + * @param actual The actual 16-bit octal value. + * @param expected The expected 16-bit octal value. + */ +#define ASSUME_ITS_EQUAL_O16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 16-bit octal value is less than the expected value. + * + * @param actual The actual 16-bit octal value. + * @param expected The expected 16-bit octal value. + */ +#define ASSUME_ITS_LESS_THAN_O16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 16-bit octal value is more than the expected value. + * + * @param actual The actual 16-bit octal value. + * @param expected The expected 16-bit octal value. + */ +#define ASSUME_ITS_MORE_THAN_O16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 16-bit octal value is less than or equal to the expected value. + * + * @param actual The actual 16-bit octal value. + * @param expected The expected 16-bit octal value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_O16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit octal value is more than or equal to the expected value. + * + * @param actual The actual 16-bit octal value. + * @param expected The expected 16-bit octal value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_O16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit octal values are not equal. + * + * @param actual The actual 16-bit octal value. + * @param expected The expected 16-bit octal value. + */ +#define ASSUME_NOT_EQUAL_O16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 16-bit octal value is not less than the expected value. + * + * @param actual The actual 16-bit octal value. + * @param expected The expected 16-bit octal value. + */ +#define ASSUME_NOT_LESS_THAN_O16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 16-bit octal value is not more than the expected value. + * + * @param actual The actual 16-bit octal value. + * @param expected The expected 16-bit octal value. + */ +#define ASSUME_NOT_MORE_THAN_O16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 16-bit octal value is not less than or equal to the expected value. + * + * @param actual The actual 16-bit octal value. + * @param expected The expected 16-bit octal value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_O16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit octal value is not more than or equal to the expected value. + * + * @param actual The actual 16-bit octal value. + * @param expected The expected 16-bit octal value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_O16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit octal values are equal. + * + * @param actual The actual 32-bit octal value. + * @param expected The expected 32-bit octal value. + */ +#define ASSUME_ITS_EQUAL_O32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 32-bit octal value is less than the expected value. + * + * @param actual The actual 32-bit octal value. + * @param expected The expected 32-bit octal value. + */ +#define ASSUME_ITS_LESS_THAN_O32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 32-bit octal value is more than the expected value. + * + * @param actual The actual 32-bit octal value. + * @param expected The expected 32-bit octal value. + */ +#define ASSUME_ITS_MORE_THAN_O32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 32-bit octal value is less than or equal to the expected value. + * + * @param actual The actual 32-bit octal value. + * @param expected The expected 32-bit octal value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_O32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit octal value is more than or equal to the expected value. + * + * @param actual The actual 32-bit octal value. + * @param expected The expected 32-bit octal value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_O32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit octal values are not equal. + * + * @param actual The actual 32-bit octal value. + * @param expected The expected 32-bit octal value. + */ +#define ASSUME_NOT_EQUAL_O32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 32-bit octal value is not less than the expected value. + * + * @param actual The actual 32-bit octal value. + * @param expected The expected 32-bit octal value. + */ +#define ASSUME_NOT_LESS_THAN_O32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 32-bit octal value is not more than the expected value. + * + * @param actual The actual 32-bit octal value. + * @param expected The expected 32-bit octal value. + */ +#define ASSUME_NOT_MORE_THAN_O32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 32-bit octal value is not less than or equal to the expected value. + * + * @param actual The actual 32-bit octal value. + * @param expected The expected 32-bit octal value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_O32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit octal value is not more than or equal to the expected value. + * + * @param actual The actual 32-bit octal value. + * @param expected The expected 32-bit octal value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_O32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit octal values are equal. + * + * @param actual The actual 64-bit octal value. + * @param expected The expected 64-bit octal value. + */ +#define ASSUME_ITS_EQUAL_O64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 64-bit octal value is less than the expected value. + * + * @param actual The actual 64-bit octal value. + * @param expected The expected 64-bit octal value. + */ +#define ASSUME_ITS_LESS_THAN_O64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 64-bit octal value is more than the expected value. + * + * @param actual The actual 64-bit octal value. + * @param expected The expected 64-bit octal value. + */ +#define ASSUME_ITS_MORE_THAN_O64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 64-bit octal value is less than or equal to the expected value. + * + * @param actual The actual 64-bit octal value. + * @param expected The expected 64-bit octal value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_O64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit octal value is more than or equal to the expected value. + * + * @param actual The actual 64-bit octal value. + * @param expected The expected 64-bit octal value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_O64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit octal values are not equal. + * + * @param actual The actual 64-bit octal value. + * @param expected The expected 64-bit octal value. + */ +#define ASSUME_NOT_EQUAL_O64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 64-bit octal value is not less than the expected value. + * + * @param actual The actual 64-bit octal value. + * @param expected The expected 64-bit octal value. + */ +#define ASSUME_NOT_LESS_THAN_O64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 64-bit octal value is not more than the expected value. + * + * @param actual The actual 64-bit octal value. + * @param expected The expected 64-bit octal value. + */ +#define ASSUME_NOT_MORE_THAN_O64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 64-bit octal value is not less than or equal to the expected value. + * + * @param actual The actual 64-bit octal value. + * @param expected The expected 64-bit octal value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_O64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit octal value is not more than or equal to the expected value. + * + * @param actual The actual 64-bit octal value. + * @param expected The expected 64-bit octal value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_O64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +// Hexadecimal ASSUMEions + +/** + * @brief Assumes that the given 8-bit hexadecimal values are equal. + * + * @param actual The actual 8-bit hexadecimal value. + * @param expected The expected 8-bit hexadecimal value. + */ +#define ASSUME_ITS_EQUAL_H8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 8-bit hexadecimal value is less than the expected value. + * + * @param actual The actual 8-bit hexadecimal value. + * @param expected The expected 8-bit hexadecimal value. + */ +#define ASSUME_ITS_LESS_THAN_H8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 8-bit hexadecimal value is more than the expected value. + * + * @param actual The actual 8-bit hexadecimal value. + * @param expected The expected 8-bit hexadecimal value. + */ +#define ASSUME_ITS_MORE_THAN_H8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 8-bit hexadecimal value is less than or equal to the expected value. + * + * @param actual The actual 8-bit hexadecimal value. + * @param expected The expected 8-bit hexadecimal value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_H8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit hexadecimal value is more than or equal to the expected value. + * + * @param actual The actual 8-bit hexadecimal value. + * @param expected The expected 8-bit hexadecimal value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_H8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit hexadecimal values are not equal. + * + * @param actual The actual 8-bit hexadecimal value. + * @param expected The expected 8-bit hexadecimal value. + */ +#define ASSUME_NOT_EQUAL_H8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 8-bit hexadecimal value is not less than the expected value. + * + * @param actual The actual 8-bit hexadecimal value. + * @param expected The expected 8-bit hexadecimal value. + */ +#define ASSUME_NOT_LESS_THAN_H8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 8-bit hexadecimal value is not more than the expected value. + * + * @param actual The actual 8-bit hexadecimal value. + * @param expected The expected 8-bit hexadecimal value. + */ +#define ASSUME_NOT_MORE_THAN_H8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 8-bit hexadecimal value is not less than or equal to the expected value. + * + * @param actual The actual 8-bit hexadecimal value. + * @param expected The expected 8-bit hexadecimal value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_H8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit hexadecimal value is not more than or equal to the expected value. + * + * @param actual The actual 8-bit hexadecimal value. + * @param expected The expected 8-bit hexadecimal value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_H8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit hexadecimal values are equal. + * + * @param actual The actual 16-bit hexadecimal value. + * @param expected The expected 16-bit hexadecimal value. + */ +#define ASSUME_ITS_EQUAL_H16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 16-bit hexadecimal value is less than the expected value. + * + * @param actual The actual 16-bit hexadecimal value. + * @param expected The expected 16-bit hexadecimal value. + */ +#define ASSUME_ITS_LESS_THAN_H16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 16-bit hexadecimal value is more than the expected value. + * + * @param actual The actual 16-bit hexadecimal value. + * @param expected The expected 16-bit hexadecimal value. + */ +#define ASSUME_ITS_MORE_THAN_H16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 16-bit hexadecimal value is less than or equal to the expected value. + * + * @param actual The actual 16-bit hexadecimal value. + * @param expected The expected 16-bit hexadecimal value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_H16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit hexadecimal value is more than or equal to the expected value. + * + * @param actual The actual 16-bit hexadecimal value. + * @param expected The expected 16-bit hexadecimal value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_H16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit hexadecimal values are not equal. + * + * @param actual The actual 16-bit hexadecimal value. + * @param expected The expected 16-bit hexadecimal value. + */ +#define ASSUME_NOT_EQUAL_H16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 16-bit hexadecimal value is not less than the expected value. + * + * @param actual The actual 16-bit hexadecimal value. + * @param expected The expected 16-bit hexadecimal value. + */ +#define ASSUME_NOT_LESS_THAN_H16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 16-bit hexadecimal value is not more than the expected value. + * + * @param actual The actual 16-bit hexadecimal value. + * @param expected The expected 16-bit hexadecimal value. + */ +#define ASSUME_NOT_MORE_THAN_H16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 16-bit hexadecimal value is not less than or equal to the expected value. + * + * @param actual The actual 16-bit hexadecimal value. + * @param expected The expected 16-bit hexadecimal value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_H16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit hexadecimal value is not more than or equal to the expected value. + * + * @param actual The actual 16-bit hexadecimal value. + * @param expected The expected 16-bit hexadecimal value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_H16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit hexadecimal values are equal. + * + * @param actual The actual 32-bit hexadecimal value. + * @param expected The expected 32-bit hexadecimal value. + */ +#define ASSUME_ITS_EQUAL_H32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 32-bit hexadecimal value is less than the expected value. + * + * @param actual The actual 32-bit hexadecimal value. + * @param expected The expected 32-bit hexadecimal value. + */ +#define ASSUME_ITS_LESS_THAN_H32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 32-bit hexadecimal value is more than the expected value. + * + * @param actual The actual 32-bit hexadecimal value. + * @param expected The expected 32-bit hexadecimal value. + */ +#define ASSUME_ITS_MORE_THAN_H32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 32-bit hexadecimal value is less than or equal to the expected value. + * + * @param actual The actual 32-bit hexadecimal value. + * @param expected The expected 32-bit hexadecimal value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_H32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit hexadecimal value is more than or equal to the expected value. + * + * @param actual The actual 32-bit hexadecimal value. + * @param expected The expected 32-bit hexadecimal value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_H32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit hexadecimal values are not equal. + * + * @param actual The actual 32-bit hexadecimal value. + * @param expected The expected 32-bit hexadecimal value. + */ +#define ASSUME_NOT_EQUAL_H32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 32-bit hexadecimal value is not less than the expected value. + * + * @param actual The actual 32-bit hexadecimal value. + * @param expected The expected 32-bit hexadecimal value. + */ +#define ASSUME_NOT_LESS_THAN_H32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 32-bit hexadecimal value is not more than the expected value. + * + * @param actual The actual 32-bit hexadecimal value. + * @param expected The expected 32-bit hexadecimal value. + */ +#define ASSUME_NOT_MORE_THAN_H32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 32-bit hexadecimal value is not less than or equal to the expected value. + * + * @param actual The actual 32-bit hexadecimal value. + * @param expected The expected 32-bit hexadecimal value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_H32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit hexadecimal value is not more than or equal to the expected value. + * + * @param actual The actual 32-bit hexadecimal value. + * @param expected The expected 32-bit hexadecimal value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_H32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit hexadecimal values are equal. + * + * @param actual The actual 64-bit hexadecimal value. + * @param expected The expected 64-bit hexadecimal value. + */ +#define ASSUME_ITS_EQUAL_H64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 64-bit hexadecimal value is less than the expected value. + * + * @param actual The actual 64-bit hexadecimal value. + * @param expected The expected 64-bit hexadecimal value. + */ +#define ASSUME_ITS_LESS_THAN_H64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 64-bit hexadecimal value is more than the expected value. + * + * @param actual The actual 64-bit hexadecimal value. + * @param expected The expected 64-bit hexadecimal value. + */ +#define ASSUME_ITS_MORE_THAN_H64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 64-bit hexadecimal value is less than or equal to the expected value. + * + * @param actual The actual 64-bit hexadecimal value. + * @param expected The expected 64-bit hexadecimal value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_H64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit hexadecimal value is more than or equal to the expected value. + * + * @param actual The actual 64-bit hexadecimal value. + * @param expected The expected 64-bit hexadecimal value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_H64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit hexadecimal values are not equal. + * + * @param actual The actual 64-bit hexadecimal value. + * @param expected The expected 64-bit hexadecimal value. + */ +#define ASSUME_NOT_EQUAL_H64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 64-bit hexadecimal value is not less than the expected value. + * + * @param actual The actual 64-bit hexadecimal value. + * @param expected The expected 64-bit hexadecimal value. + */ +#define ASSUME_NOT_LESS_THAN_H64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 64-bit hexadecimal value is not more than the expected value. + * + * @param actual The actual 64-bit hexadecimal value. + * @param expected The expected 64-bit hexadecimal value. + */ +#define ASSUME_NOT_MORE_THAN_H64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 64-bit hexadecimal value is not less than or equal to the expected value. + * + * @param actual The actual 64-bit hexadecimal value. + * @param expected The expected 64-bit hexadecimal value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_H64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit hexadecimal value is not more than or equal to the expected value. + * + * @param actual The actual 64-bit hexadecimal value. + * @param expected The expected 64-bit hexadecimal value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_H64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit integer values are equal. + * + * @param actual The actual 8-bit integer value. + * @param expected The expected 8-bit integer value. + */ +#define ASSUME_ITS_EQUAL_I8(actual, expected) \ + FOSSIL_TEST_ASSUME((int8_t)(actual) == (int8_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 8-bit integer value is less than the expected value. + * + * @param actual The actual 8-bit integer value. + * @param expected The expected 8-bit integer value. + */ +#define ASSUME_ITS_LESS_THAN_I8(actual, expected) \ + FOSSIL_TEST_ASSUME((int8_t)(actual) < (int8_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 8-bit integer value is more than the expected value. + * + * @param actual The actual 8-bit integer value. + * @param expected The expected 8-bit integer value. + */ +#define ASSUME_ITS_MORE_THAN_I8(actual, expected) \ + FOSSIL_TEST_ASSUME((int8_t)(actual) > (int8_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 8-bit integer value is less than or equal to the expected value. + * + * @param actual The actual 8-bit integer value. + * @param expected The expected 8-bit integer value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_I8(actual, expected) \ + FOSSIL_TEST_ASSUME((int8_t)(actual) <= (int8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit integer value is more than or equal to the expected value. + * + * @param actual The actual 8-bit integer value. + * @param expected The expected 8-bit integer value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_I8(actual, expected) \ + FOSSIL_TEST_ASSUME((int8_t)(actual) >= (int8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit integer values are not equal. + * + * @param actual The actual 8-bit integer value. + * @param expected The expected 8-bit integer value. + */ +#define ASSUME_NOT_EQUAL_I8(actual, expected) \ + FOSSIL_TEST_ASSUME((int8_t)(actual) != (int8_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 8-bit integer value is not less than the expected value. + * + * @param actual The actual 8-bit integer value. + * @param expected The expected 8-bit integer value. + */ +#define ASSUME_NOT_LESS_THAN_I8(actual, expected) \ + FOSSIL_TEST_ASSUME((int8_t)(actual) >= (int8_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 8-bit integer value is not more than the expected value. + * + * @param actual The actual 8-bit integer value. + * @param expected The expected 8-bit integer value. + */ +#define ASSUME_NOT_MORE_THAN_I8(actual, expected) \ + FOSSIL_TEST_ASSUME((int8_t)(actual) <= (int8_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 8-bit integer value is not less than or equal to the expected value. + * + * @param actual The actual 8-bit integer value. + * @param expected The expected 8-bit integer value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_I8(actual, expected) \ + FOSSIL_TEST_ASSUME((int8_t)(actual) > (int8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit integer value is not more than or equal to the expected value. + * + * @param actual The actual 8-bit integer value. + * @param expected The expected 8-bit integer value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_I8(actual, expected) \ + FOSSIL_TEST_ASSUME((int8_t)(actual) < (int8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit integer values are equal. + * + * @param actual The actual 16-bit integer value. + * @param expected The expected 16-bit integer value. + */ +#define ASSUME_ITS_EQUAL_I16(actual, expected) \ + FOSSIL_TEST_ASSUME((int16_t)(actual) == (int16_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 16-bit integer value is less than the expected value. + * + * @param actual The actual 16-bit integer value. + * @param expected The expected 16-bit integer value. + */ +#define ASSUME_ITS_LESS_THAN_I16(actual, expected) \ + FOSSIL_TEST_ASSUME((int16_t)(actual) < (int16_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 16-bit integer value is more than the expected value. + * + * @param actual The actual 16-bit integer value. + * @param expected The expected 16-bit integer value. + */ +#define ASSUME_ITS_MORE_THAN_I16(actual, expected) \ + FOSSIL_TEST_ASSUME((int16_t)(actual) > (int16_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 16-bit integer value is less than or equal to the expected value. + * + * @param actual The actual 16-bit integer value. + * @param expected The expected 16-bit integer value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_I16(actual, expected) \ + FOSSIL_TEST_ASSUME((int16_t)(actual) <= (int16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit integer value is more than or equal to the expected value. + * + * @param actual The actual 16-bit integer value. + * @param expected The expected 16-bit integer value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_I16(actual, expected) \ + FOSSIL_TEST_ASSUME((int16_t)(actual) >= (int16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit integer values are not equal. + * + * @param actual The actual 16-bit integer value. + * @param expected The expected 16-bit integer value. + */ +#define ASSUME_NOT_EQUAL_I16(actual, expected) \ + FOSSIL_TEST_ASSUME((int16_t)(actual) != (int16_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 16-bit integer value is not less than the expected value. + * + * @param actual The actual 16-bit integer value. + * @param expected The expected 16-bit integer value. + */ +#define ASSUME_NOT_LESS_THAN_I16(actual, expected) \ + FOSSIL_TEST_ASSUME((int16_t)(actual) >= (int16_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 16-bit integer value is not more than the expected value. + * + * @param actual The actual 16-bit integer value. + * @param expected The expected 16-bit integer value. + */ +#define ASSUME_NOT_MORE_THAN_I16(actual, expected) \ + FOSSIL_TEST_ASSUME((int16_t)(actual) <= (int16_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 16-bit integer value is not less than or equal to the expected value. + * + * @param actual The actual 16-bit integer value. + * @param expected The expected 16-bit integer value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_I16(actual, expected) \ + FOSSIL_TEST_ASSUME((int16_t)(actual) > (int16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit integer value is not more than or equal to the expected value. + * + * @param actual The actual 16-bit integer value. + * @param expected The expected 16-bit integer value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_I16(actual, expected) \ + FOSSIL_TEST_ASSUME((int16_t)(actual) < (int16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit integer values are equal. + * + * @param actual The actual 32-bit integer value. + * @param expected The expected 32-bit integer value. + */ +#define ASSUME_ITS_EQUAL_I32(actual, expected) \ + FOSSIL_TEST_ASSUME((int32_t)(actual) == (int32_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 32-bit integer value is less than the expected value. + * + * @param actual The actual 32-bit integer value. + * @param expected The expected 32-bit integer value. + */ +#define ASSUME_ITS_LESS_THAN_I32(actual, expected) \ + FOSSIL_TEST_ASSUME((int32_t)(actual) < (int32_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 32-bit integer value is more than the expected value. + * + * @param actual The actual 32-bit integer value. + * @param expected The expected 32-bit integer value. + */ +#define ASSUME_ITS_MORE_THAN_I32(actual, expected) \ + FOSSIL_TEST_ASSUME((int32_t)(actual) > (int32_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 32-bit integer value is less than or equal to the expected value. + * + * @param actual The actual 32-bit integer value. + * @param expected The expected 32-bit integer value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_I32(actual, expected) \ + FOSSIL_TEST_ASSUME((int32_t)(actual) <= (int32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit integer value is more than or equal to the expected value. + * + * @param actual The actual 32-bit integer value. + * @param expected The expected 32-bit integer value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_I32(actual, expected) \ + FOSSIL_TEST_ASSUME((int32_t)(actual) >= (int32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit integer values are not equal. + * + * @param actual The actual 32-bit integer value. + * @param expected The expected 32-bit integer value. + */ +#define ASSUME_NOT_EQUAL_I32(actual, expected) \ + FOSSIL_TEST_ASSUME((int32_t)(actual) != (int32_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 32-bit integer value is not less than the expected value. + * + * @param actual The actual 32-bit integer value. + * @param expected The expected 32-bit integer value. + */ +#define ASSUME_NOT_LESS_THAN_I32(actual, expected) \ + FOSSIL_TEST_ASSUME((int32_t)(actual) >= (int32_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 32-bit integer value is not more than the expected value. + * + * @param actual The actual 32-bit integer value. + * @param expected The expected 32-bit integer value. + */ +#define ASSUME_NOT_MORE_THAN_I32(actual, expected) \ + FOSSIL_TEST_ASSUME((int32_t)(actual) <= (int32_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 32-bit integer value is not less than or equal to the expected value. + * + * @param actual The actual 32-bit integer value. + * @param expected The expected 32-bit integer value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_I32(actual, expected) \ + FOSSIL_TEST_ASSUME((int32_t)(actual) > (int32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit integer value is not more than or equal to the expected value. + * + * @param actual The actual 32-bit integer value. + * @param expected The expected 32-bit integer value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_I32(actual, expected) \ + FOSSIL_TEST_ASSUME((int32_t)(actual) < (int32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit integer values are equal. + * + * @param actual The actual 64-bit integer value. + * @param expected The expected 64-bit integer value. + */ +#define ASSUME_ITS_EQUAL_I64(actual, expected) \ + FOSSIL_TEST_ASSUME((int64_t)(actual) == (int64_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 64-bit integer value is less than the expected value. + * + * @param actual The actual 64-bit integer value. + * @param expected The expected 64-bit integer value. + */ +#define ASSUME_ITS_LESS_THAN_I64(actual, expected) \ + FOSSIL_TEST_ASSUME((int64_t)(actual) < (int64_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 64-bit integer value is more than the expected value. + * + * @param actual The actual 64-bit integer value. + * @param expected The expected 64-bit integer value. + */ +#define ASSUME_ITS_MORE_THAN_I64(actual, expected) \ + FOSSIL_TEST_ASSUME((int64_t)(actual) > (int64_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 64-bit integer value is less than or equal to the expected value. + * + * @param actual The actual 64-bit integer value. + * @param expected The expected 64-bit integer value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_I64(actual, expected) \ + FOSSIL_TEST_ASSUME((int64_t)(actual) <= (int64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit integer value is more than or equal to the expected value. + * + * @param actual The actual 64-bit integer value. + * @param expected The expected 64-bit integer value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_I64(actual, expected) \ + FOSSIL_TEST_ASSUME((int64_t)(actual) >= (int64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit integer values are not equal. + * + * @param actual The actual 64-bit integer value. + * @param expected The expected 64-bit integer value. + */ +#define ASSUME_NOT_EQUAL_I64(actual, expected) \ + FOSSIL_TEST_ASSUME((int64_t)(actual) != (int64_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 64-bit integer value is not less than the expected value. + * + * @param actual The actual 64-bit integer value. + * @param expected The expected 64-bit integer value. + */ +#define ASSUME_NOT_LESS_THAN_I64(actual, expected) \ + FOSSIL_TEST_ASSUME((int64_t)(actual) >= (int64_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 64-bit integer value is not more than the expected value. + * + * @param actual The actual 64-bit integer value. + * @param expected The expected 64-bit integer value. + */ +#define ASSUME_NOT_MORE_THAN_I64(actual, expected) \ + FOSSIL_TEST_ASSUME((int64_t)(actual) <= (int64_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 64-bit integer value is not less than or equal to the expected value. + * + * @param actual The actual 64-bit integer value. + * @param expected The expected 64-bit integer value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_I64(actual, expected) \ + FOSSIL_TEST_ASSUME((int64_t)(actual) > (int64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit integer value is not more than or equal to the expected value. + * + * @param actual The actual 64-bit integer value. + * @param expected The expected 64-bit integer value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_I64(actual, expected) \ + FOSSIL_TEST_ASSUME((int64_t)(actual) < (int64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit unsigned integer values are equal. + * + * @param actual The actual 8-bit unsigned integer value. + * @param expected The expected 8-bit unsigned integer value. + */ +#define ASSUME_ITS_EQUAL_U8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 8-bit unsigned integer value is less than the expected value. + * + * @param actual The actual 8-bit unsigned integer value. + * @param expected The expected 8-bit unsigned integer value. + */ +#define ASSUME_ITS_LESS_THAN_U8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 8-bit unsigned integer value is more than the expected value. + * + * @param actual The actual 8-bit unsigned integer value. + * @param expected The expected 8-bit unsigned integer value. + */ +#define ASSUME_ITS_MORE_THAN_U8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 8-bit unsigned integer value is less than or equal to the expected value. + * + * @param actual The actual 8-bit unsigned integer value. + * @param expected The expected 8-bit unsigned integer value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_U8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit unsigned integer value is more than or equal to the expected value. + * + * @param actual The actual 8-bit unsigned integer value. + * @param expected The expected 8-bit unsigned integer value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_U8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit unsigned integer values are not equal. + * + * @param actual The actual 8-bit unsigned integer value. + * @param expected The expected 8-bit unsigned integer value. + */ +#define ASSUME_NOT_EQUAL_U8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 8-bit unsigned integer value is not less than the expected value. + * + * @param actual The actual 8-bit unsigned integer value. + * @param expected The expected 8-bit unsigned integer value. + */ +#define ASSUME_NOT_LESS_THAN_U8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 8-bit unsigned integer value is not more than the expected value. + * + * @param actual The actual 8-bit unsigned integer value. + * @param expected The expected 8-bit unsigned integer value. + */ +#define ASSUME_NOT_MORE_THAN_U8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 8-bit unsigned integer value is not less than or equal to the expected value. + * + * @param actual The actual 8-bit unsigned integer value. + * @param expected The expected 8-bit unsigned integer value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_U8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 8-bit unsigned integer value is not more than or equal to the expected value. + * + * @param actual The actual 8-bit unsigned integer value. + * @param expected The expected 8-bit unsigned integer value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_U8(actual, expected) \ + FOSSIL_TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit unsigned integer values are equal. + * + * @param actual The actual 16-bit unsigned integer value. + * @param expected The expected 16-bit unsigned integer value. + */ +#define ASSUME_ITS_EQUAL_U16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 16-bit unsigned integer value is less than the expected value. + * + * @param actual The actual 16-bit unsigned integer value. + * @param expected The expected 16-bit unsigned integer value. + */ +#define ASSUME_ITS_LESS_THAN_U16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 16-bit unsigned integer value is more than the expected value. + * + * @param actual The actual 16-bit unsigned integer value. + * @param expected The expected 16-bit unsigned integer value. + */ +#define ASSUME_ITS_MORE_THAN_U16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 16-bit unsigned integer value is less than or equal to the expected value. + * + * @param actual The actual 16-bit unsigned integer value. + * @param expected The expected 16-bit unsigned integer value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_U16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit unsigned integer value is more than or equal to the expected value. + * + * @param actual The actual 16-bit unsigned integer value. + * @param expected The expected 16-bit unsigned integer value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_U16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit unsigned integer values are not equal. + * + * @param actual The actual 16-bit unsigned integer value. + * @param expected The expected 16-bit unsigned integer value. + */ +#define ASSUME_NOT_EQUAL_U16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 16-bit unsigned integer value is not less than the expected value. + * + * @param actual The actual 16-bit unsigned integer value. + * @param expected The expected 16-bit unsigned integer value. + */ +#define ASSUME_NOT_LESS_THAN_U16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 16-bit unsigned integer value is not more than the expected value. + * + * @param actual The actual 16-bit unsigned integer value. + * @param expected The expected 16-bit unsigned integer value. + */ +#define ASSUME_NOT_MORE_THAN_U16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 16-bit unsigned integer value is not less than or equal to the expected value. + * + * @param actual The actual 16-bit unsigned integer value. + * @param expected The expected 16-bit unsigned integer value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_U16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 16-bit unsigned integer value is not more than or equal to the expected value. + * + * @param actual The actual 16-bit unsigned integer value. + * @param expected The expected 16-bit unsigned integer value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_U16(actual, expected) \ + FOSSIL_TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit unsigned integer values are equal. + * + * @param actual The actual 32-bit unsigned integer value. + * @param expected The expected 32-bit unsigned integer value. + */ +#define ASSUME_ITS_EQUAL_U32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 32-bit unsigned integer value is less than the expected value. + * + * @param actual The actual 32-bit unsigned integer value. + * @param expected The expected 32-bit unsigned integer value. + */ +#define ASSUME_ITS_LESS_THAN_U32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 32-bit unsigned integer value is more than the expected value. + * + * @param actual The actual 32-bit unsigned integer value. + * @param expected The expected 32-bit unsigned integer value. + */ +#define ASSUME_ITS_MORE_THAN_U32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 32-bit unsigned integer value is less than or equal to the expected value. + * + * @param actual The actual 32-bit unsigned integer value. + * @param expected The expected 32-bit unsigned integer value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_U32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit unsigned integer value is more than or equal to the expected value. + * + * @param actual The actual 32-bit unsigned integer value. + * @param expected The expected 32-bit unsigned integer value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_U32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit unsigned integer values are not equal. + * + * @param actual The actual 32-bit unsigned integer value. + * @param expected The expected 32-bit unsigned integer value. + */ +#define ASSUME_NOT_EQUAL_U32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 32-bit unsigned integer value is not less than the expected value. + * + * @param actual The actual 32-bit unsigned integer value. + * @param expected The expected 32-bit unsigned integer value. + */ +#define ASSUME_NOT_LESS_THAN_U32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 32-bit unsigned integer value is not more than the expected value. + * + * @param actual The actual 32-bit unsigned integer value. + * @param expected The expected 32-bit unsigned integer value. + */ +#define ASSUME_NOT_MORE_THAN_U32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 32-bit unsigned integer value is not less than or equal to the expected value. + * + * @param actual The actual 32-bit unsigned integer value. + * @param expected The expected 32-bit unsigned integer value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_U32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 32-bit unsigned integer value is not more than or equal to the expected value. + * + * @param actual The actual 32-bit unsigned integer value. + * @param expected The expected 32-bit unsigned integer value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_U32(actual, expected) \ + FOSSIL_TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit unsigned integer values are equal. + * + * @param actual The actual 64-bit unsigned integer value. + * @param expected The expected 64-bit unsigned integer value. + */ +#define ASSUME_ITS_EQUAL_U64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given 64-bit unsigned integer value is less than the expected value. + * + * @param actual The actual 64-bit unsigned integer value. + * @param expected The expected 64-bit unsigned integer value. + */ +#define ASSUME_ITS_LESS_THAN_U64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given 64-bit unsigned integer value is more than the expected value. + * + * @param actual The actual 64-bit unsigned integer value. + * @param expected The expected 64-bit unsigned integer value. + */ +#define ASSUME_ITS_MORE_THAN_U64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given 64-bit unsigned integer value is less than or equal to the expected value. + * + * @param actual The actual 64-bit unsigned integer value. + * @param expected The expected 64-bit unsigned integer value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_U64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit unsigned integer value is more than or equal to the expected value. + * + * @param actual The actual 64-bit unsigned integer value. + * @param expected The expected 64-bit unsigned integer value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_U64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit unsigned integer values are not equal. + * + * @param actual The actual 64-bit unsigned integer value. + * @param expected The expected 64-bit unsigned integer value. + */ +#define ASSUME_NOT_EQUAL_U64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the given 64-bit unsigned integer value is not less than the expected value. + * + * @param actual The actual 64-bit unsigned integer value. + * @param expected The expected 64-bit unsigned integer value. + */ +#define ASSUME_NOT_LESS_THAN_U64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) + +/** + * @brief Assumes that the given 64-bit unsigned integer value is not more than the expected value. + * + * @param actual The actual 64-bit unsigned integer value. + * @param expected The expected 64-bit unsigned integer value. + */ +#define ASSUME_NOT_MORE_THAN_U64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) + +/** + * @brief Assumes that the given 64-bit unsigned integer value is not less than or equal to the expected value. + * + * @param actual The actual 64-bit unsigned integer value. + * @param expected The expected 64-bit unsigned integer value. + */ +#define ASSUME_NOT_LESS_OR_EQUAL_U64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) + +/** + * @brief Assumes that the given 64-bit unsigned integer value is not more than or equal to the expected value. + * + * @param actual The actual 64-bit unsigned integer value. + * @param expected The expected 64-bit unsigned integer value. + */ +#define ASSUME_NOT_MORE_OR_EQUAL_U64(actual, expected) \ + FOSSIL_TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) + +// ************************************************** +// +// Null pointer ASSUMEions (_CNULL) +// +// ************************************************** + +/** + * @brief Assumes that the given pointer is NULL. + * + * @param actual The pointer to be evaluated. + */ +#define ASSUME_ITS_CNULL(actual) \ + FOSSIL_TEST_ASSUME((actual) == NULL, "Expected " #actual " to be NULL") + +/** + * @brief Assumes that the given pointer is not NULL. + * + * @param actual The pointer to be evaluated. + */ +#define ASSUME_NOT_CNULL(actual) \ + FOSSIL_TEST_ASSUME((actual) != NULL, "Expected " #actual " to not be NULL") + +/** + * @brief Assumes that the given pointers are equal. + * + * @param actual The actual pointer. + * @param expected The expected pointer. + */ +#define ASSUME_ITS_EQUAL_PTR(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) == (expected), "Expected pointer " #actual " to be equal to pointer " #expected " ") + +/** + * @brief Assumes that the given pointers are not equal. + * + * @param actual The actual pointer. + * @param expected The expected pointer. + */ +#define ASSUME_NOT_EQUAL_PTR(actual, expected) \ + FOSSIL_TEST_ASSUME((actual) != (expected), "Expected pointer " #actual " to not be equal to pointer " #expected " ") + +/** + * @brief Assumes that the given size_t values are equal. + * + * @param actual The actual size_t value. + * @param expected The expected size_t value. + */ +#define ASSUME_ITS_EQUAL_SIZE(actual, expected) \ + FOSSIL_TEST_ASSUME((size_t)(actual) == (size_t)(expected), "Expected " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given size_t value is less than the expected value. + * + * @param actual The actual size_t value. + * @param expected The expected size_t value. + */ +#define ASSUME_ITS_LESS_THAN_SIZE(actual, expected) \ + FOSSIL_TEST_ASSUME((size_t)(actual) < (size_t)(expected), "Expected " #actual " to be less than " #expected) + +/** + * @brief Assumes that the given size_t value is more than the expected value. + * + * @param actual The actual size_t value. + * @param expected The expected size_t value. + */ +#define ASSUME_ITS_MORE_THAN_SIZE(actual, expected) \ + FOSSIL_TEST_ASSUME((size_t)(actual) > (size_t)(expected), "Expected " #actual " to be more than " #expected) + +/** + * @brief Assumes that the given size_t value is less than or equal to the expected value. + * + * @param actual The actual size_t value. + * @param expected The expected size_t value. + */ +#define ASSUME_ITS_LESS_OR_EQUAL_SIZE(actual, expected) \ + FOSSIL_TEST_ASSUME((size_t)(actual) <= (size_t)(expected), "Expected " #actual " to be less than or equal to " #expected) + +/** + * @brief Assumes that the given size_t value is more than or equal to the expected value. + * + * @param actual The actual size_t value. + * @param expected The expected size_t value. + */ +#define ASSUME_ITS_MORE_OR_EQUAL_SIZE(actual, expected) \ + FOSSIL_TEST_ASSUME((size_t)(actual) >= (size_t)(expected), "Expected " #actual " to be more than or equal to " #expected) + +/** + * @brief Assumes that the given size_t values are not equal. + * + * @param actual The actual size_t value. + * @param expected The expected size_t value. + */ +#define ASSUME_NOT_EQUAL_SIZE(actual, expected) \ + FOSSIL_TEST_ASSUME((size_t)(actual) != (size_t)(expected), "Expected " #actual " to not be equal to " #expected) + +// ************************************************** +// +// Range ASSUMEions +// +// ************************************************** + +/** + * @brief Assumes that the given value is within the specified range. + * + * @param value The value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE(value, min, max) \ + FOSSIL_TEST_ASSUME((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given value is not within the specified range. + * + * @param value The value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE(value, min, max) \ + FOSSIL_TEST_ASSUME((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") + +// Unsigned integer type assumptions + +/** + * @brief Assumes that the given 8-bit unsigned integer value is within the specified range. + * + * @param value The 8-bit unsigned integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_U8(value, min, max) \ + FOSSIL_TEST_ASSUME((uint8_t)(value) >= (uint8_t)(min) && (uint8_t)(value) <= (uint8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 8-bit unsigned integer value is not within the specified range. + * + * @param value The 8-bit unsigned integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_U8(value, min, max) \ + FOSSIL_TEST_ASSUME((uint8_t)(value) < (uint8_t)(min) || (uint8_t)(value) > (uint8_t)(max), "Value " #value " is within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 16-bit unsigned integer value is within the specified range. + * + * @param value The 16-bit unsigned integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_U16(value, min, max) \ + FOSSIL_TEST_ASSUME((uint16_t)(value) >= (uint16_t)(min) && (uint16_t)(value) <= (uint16_t)(max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 16-bit unsigned integer value is not within the specified range. + * + * @param value The 16-bit unsigned integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_U16(value, min, max) \ + FOSSIL_TEST_ASSUME((uint16_t)(value) < (uint16_t)(min) || (uint16_t)(value) > (uint16_t)(max), "Value " #value " is within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 32-bit unsigned integer value is within the specified range. + * + * @param value The 32-bit unsigned integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_U32(value, min, max) \ + FOSSIL_TEST_ASSUME((uint32_t)(value) >= (uint32_t)(min) && (uint32_t)(value) <= (uint32_t)(max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 32-bit unsigned integer value is not within the specified range. + * + * @param value The 32-bit unsigned integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_U32(value, min, max) \ + FOSSIL_TEST_ASSUME((uint32_t)(value) < (uint32_t)(min) || (uint32_t)(value) > (uint32_t)(max), "Value " #value " is within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 64-bit unsigned integer value is within the specified range. + * + * @param value The 64-bit unsigned integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_U64(value, min, max) \ + FOSSIL_TEST_ASSUME((uint64_t)(value) >= (uint64_t)(min) && (uint64_t)(value) <= (uint64_t)(max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 64-bit unsigned integer value is not within the specified range. + * + * @param value The 64-bit unsigned integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_U64(value, min, max) \ + FOSSIL_TEST_ASSUME((uint64_t)(value) < (uint64_t)(min) || (uint64_t)(value) > (uint64_t)(max), "Value " #value " is within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 8-bit integer value is within the specified range. + * + * @param value The 8-bit integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_I8(value, min, max) \ + FOSSIL_TEST_ASSUME((int8_t)(value) >= (int8_t)(min) && (int8_t)(value) <= (int8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 8-bit integer value is not within the specified range. + * + * @param value The 8-bit integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_I8(value, min, max) \ + FOSSIL_TEST_ASSUME((int8_t)(value) < (int8_t)(min) || (int8_t)(value) > (int8_t)(max), "Value " #value " is within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 16-bit integer value is within the specified range. + * + * @param value The 16-bit integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_I16(value, min, max) \ + FOSSIL_TEST_ASSUME((int16_t)(value) >= (int16_t)(min) && (int16_t)(value) <= (int16_t)(max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 16-bit integer value is not within the specified range. + * + * @param value The 16-bit integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_I16(value, min, max) \ + FOSSIL_TEST_ASSUME((int16_t)(value) < (int16_t)(min) || (int16_t)(value) > (int16_t)(max), "Value " #value " is within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 32-bit integer value is within the specified range. + * + * @param value The 32-bit integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_I32(value, min, max) \ + FOSSIL_TEST_ASSUME((int32_t)(value) >= (int32_t)(min) && (int32_t)(value) <= (int32_t)(max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 32-bit integer value is not within the specified range. + * + * @param value The 32-bit integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_I32(value, min, max) \ + FOSSIL_TEST_ASSUME((int32_t)(value) < (int32_t)(min) || (int32_t)(value) > (int32_t)(max), "Value " #value " is within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 64-bit integer value is within the specified range. + * + * @param value The 64-bit integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_I64(value, min, max) \ + FOSSIL_TEST_ASSUME((int64_t)(value) >= (int64_t)(min) && (int64_t)(value) <= (int64_t)(max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given 64-bit integer value is not within the specified range. + * + * @param value The 64-bit integer value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_I64(value, min, max) \ + FOSSIL_TEST_ASSUME((int64_t)(value) < (int64_t)(min) || (int64_t)(value) > (int64_t)(max), "Value " #value " is within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given float value is within the specified range. + * + * @param value The float value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_F32(value, min, max) \ + FOSSIL_TEST_ASSUME((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given float value is not within the specified range. + * + * @param value The float value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_F32(value, min, max) \ + FOSSIL_TEST_ASSUME((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given double value is within the specified range. + * + * @param value The double value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_F64(value, min, max) \ + FOSSIL_TEST_ASSUME((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given double value is not within the specified range. + * + * @param value The double value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_F64(value, min, max) \ + FOSSIL_TEST_ASSUME((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") + +// Byte char type ASSUMEions (uint8_t) + +/** + * @brief Assumes that the given byte char value is within the specified range. + * + * @param value The byte char value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_BCHAR(value, min, max) \ + FOSSIL_TEST_ASSUME((uint8_t)(value) >= (uint8_t)(min) && (uint8_t)(value) <= (uint8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given byte char value is not within the specified range. + * + * @param value The byte char value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_BCHAR(value, min, max) \ + FOSSIL_TEST_ASSUME((uint8_t)(value) < (uint8_t)(min) || (uint8_t)(value) > (uint8_t)(max), "Value " #value " is within range [" #min ", " #max "]") + +// Char type ASSUMEions (char) + +/** + * @brief Assumes that the given char value is within the specified range. + * + * @param value The char value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_CCHAR(value, min, max) \ + FOSSIL_TEST_ASSUME((char)(value) >= (char)(min) && (char)(value) <= (char)(max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given char value is not within the specified range. + * + * @param value The char value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_CCHAR(value, min, max) \ + FOSSIL_TEST_ASSUME((char)(value) < (char)(min) || (char)(value) > (char)(max), "Value " #value " is within range [" #min ", " #max "]") + +// Wide char type ASSUMEions (wchar_t) + +/** + * @brief Assumes that the given wide char value is within the specified range. + * + * @param value The wide char value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_ITS_WITHIN_RANGE_WCHAR(value, min, max) \ + FOSSIL_TEST_ASSUME((wchar_t)(value) >= (wchar_t)(min) && (wchar_t)(value) <= (wchar_t)(max), "Value " #value " is not within range [" #min ", " #max "]") + +/** + * @brief Assumes that the given wide char value is not within the specified range. + * + * @param value The wide char value to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + */ +#define ASSUME_NOT_WITHIN_RANGE_WCHAR(value, min, max) \ + FOSSIL_TEST_ASSUME((wchar_t)(value) < (wchar_t)(min) || (wchar_t)(value) > (wchar_t)(max), "Value " #value " is within range [" #min ", " #max "]") + +// ************************************************** +// +// String ASSUMEions +// +// ************************************************** + +/** + * @brief Assumes that the given wide char strings are equal. + * + * @param actual The actual wide char string. + * @param expected The expected wide char string. + */ +#define ASSUME_ITS_EQUAL_WSTR(actual, expected) \ + FOSSIL_TEST_ASSUME(wcscmp((actual), (expected)) == 0, "Expected wide string " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given wide char strings are not equal. + * + * @param actual The actual wide char string. + * @param expected The expected wide char string. + */ +#define ASSUME_NOT_EQUAL_WSTR(actual, expected) \ + FOSSIL_TEST_ASSUME(wcscmp((actual), (expected)) != 0, "Expected wide string " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the length of the given wide char string is equal to the expected length. + * + * @param actual The actual wide char string. + * @param expected_len The expected length of the wide char string. + */ +#define ASSUME_ITS_LENGTH_EQUAL_WSTR(actual, expected_len) \ + FOSSIL_TEST_ASSUME(wcslen((actual)) == (expected_len), "Expected length of wide string " #actual " to be equal to " #expected_len) + +/** + * @brief Assumes that the given byte strings are equal. + * + * @param actual The actual byte string. + * @param expected The expected byte string. + */ +#define ASSUME_ITS_EQUAL_BSTR(actual, expected) \ + FOSSIL_TEST_ASSUME(strcmp((const char*)(actual), (const char*)(expected)) == 0, "Expected byte string " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given byte strings are not equal. + * + * @param actual The actual byte string. + * @param expected The expected byte string. + */ +#define ASSUME_NOT_EQUAL_BSTR(actual, expected) \ + FOSSIL_TEST_ASSUME(strcmp((const char*)(actual), (const char*)(expected)) != 0, "Expected byte string " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the length of the given byte string is equal to the expected length. + * + * @param actual The actual byte string. + * @param expected_len The expected length of the byte string. + */ +#define ASSUME_ITS_LENGTH_EQUAL_BSTR(actual, expected_len) \ + FOSSIL_TEST_ASSUME(strlen((const char*)(actual)) == (expected_len), "Expected length of byte string " #actual " to be equal to " #expected_len) + +/** + * @brief Assumes that the given C strings are equal. + * + * @param actual The actual C string. + * @param expected The expected C string. + */ +#define ASSUME_ITS_EQUAL_CSTR(actual, expected) \ + FOSSIL_TEST_ASSUME(strcmp((actual), (expected)) == 0, "Expected C string " #actual " to be equal to " #expected) + +/** + * @brief Assumes that the given C strings are not equal. + * + * @param actual The actual C string. + * @param expected The expected C string. + */ +#define ASSUME_NOT_EQUAL_CSTR(actual, expected) \ + FOSSIL_TEST_ASSUME(strcmp((actual), (expected)) != 0, "Expected C string " #actual " to not be equal to " #expected) + +/** + * @brief Assumes that the length of the given C string is equal to the expected length. + * + * @param actual The actual C string. + * @param expected_len The expected length of the C string. + */ +#define ASSUME_ITS_LENGTH_EQUAL_CSTR(actual, expected_len) \ + FOSSIL_TEST_ASSUME(strlen((actual)) == (expected_len), "Expected length of C string " #actual " to be equal to " #expected_len) + +// ************************************************** +// +// Array ASSUMEions +// +// ************************************************** + +/** + * @brief Assumes that the given arrays are equal. + * + * @param actual The actual array. + * @param expected The expected array. + * @param length The length of the arrays. + */ +#define ASSUME_ITS_EQUAL_ARRAY(actual, expected, length) \ + for (size_t i = 0; i < (length); i++) { \ + FOSSIL_TEST_ASSUME((actual)[i] == (expected)[i], "Expected array element " #actual " to be equal to " #expected); \ + } + +/** + * @brief Assumes that the given arrays are not equal. + * + * @param actual The actual array. + * @param expected The expected array. + * @param length The length of the arrays. + */ +#define ASSUME_NOT_EQUAL_ARRAY(actual, expected, length) \ + for (size_t i = 0; i < (length); i++) { \ + FOSSIL_TEST_ASSUME((actual)[i] != (expected)[i], "Expected array element " #actual " to not be equal to " #expected); \ + } + +/** + * @brief Assumes that the length of the given arrays are equal. + * + * @param actual_length The actual length of the array. + * @param expected_length The expected length of the array. + */ +#define ASSUME_ITS_LENGTH_EQUAL_ARRAY(actual_length, expected_length) \ + FOSSIL_TEST_ASSUME((actual_length) == (expected_length), "Expected array length " #actual_length " to be equal to " #expected_length) + +/** + * @brief Assumes that the elements of the given array are within the specified range. + * + * @param array The array to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + * @param length The length of the array. + */ +#define ASSUME_ITS_WITHIN_RANGE_ARRAY(array, min, max, length) \ + for (size_t i = 0; i < (length); i++) { \ + FOSSIL_TEST_ASSUME((array)[i] >= (min) && (array)[i] <= (max), "Expected array element " #array " to be within range [" #min ", " #max "]"); \ + } + +/** + * @brief Assumes that the elements of the given array are not within the specified range. + * + * @param array The array to be evaluated. + * @param min The minimum value of the range. + * @param max The maximum value of the range. + * @param length The length of the array. + */ +#define ASSUME_NOT_WITHIN_RANGE_ARRAY(array, min, max, length) \ + for (size_t i = 0; i < (length); i++) { \ + FOSSIL_TEST_ASSUME((array)[i] < (min) || (array)[i] > (max), "Expected array element " #array " to not be within range [" #min ", " #max "]"); \ + } + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/code/logic/fossil/benchmark/benchmark.h b/code/logic/fossil/test/benchmark.h similarity index 96% rename from code/logic/fossil/benchmark/benchmark.h rename to code/logic/fossil/test/benchmark.h index 91071e3f..5ac8b8a9 100644 --- a/code/logic/fossil/benchmark/benchmark.h +++ b/code/logic/fossil/test/benchmark.h @@ -15,13 +15,15 @@ #ifndef FOSSIL_MARK_BENCHMARK_H #define FOSSIL_MARK_BENCHMARK_H -#include "fossil/_common/common.h" - #include #include #include #include +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { const char* name; clock_t start_time; @@ -130,4 +132,17 @@ void fossil_test_start_benchmark(void); */ uint64_t fossil_test_stop_benchmark(void); +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +#include +#include + +namespace fossil { + +} +#endif + #endif // FOSSIL_MARK_FRAMEWORK_H diff --git a/code/logic/fossil/test/framework.h b/code/logic/fossil/test/framework.h new file mode 100644 index 00000000..4c2d5d32 --- /dev/null +++ b/code/logic/fossil/test/framework.h @@ -0,0 +1,489 @@ +/* + * ----------------------------------------------------------------------------- + * Project: Fossil Logic + * + * This file is part of the Fossil Logic project, which aims to develop high- + * performance, cross-platform applications and libraries. The code contained + * herein is subject to the terms and conditions defined in the project license. + * + * Author: Michael Gene Brockus (Dreamer) + * Date: 07/01/2024 + * + * Copyright (C) 2024 Fossil Logic. All rights reserved. + * ----------------------------------------------------------------------------- + */ +#ifndef FOSSIL_TEST_FRAMEWORK_H +#define FOSSIL_TEST_FRAMEWORK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "benchmark.h" +#include "unittest.h" +#include "mockup.h" +#include "assume.h" + +/** + * Macro to define a given step in a test case. + * This macro is used to define a given step in a test case. The given step + * should contain the setup logic required to prepare the environment for the + * test case. + */ +#define GIVEN(description) _GIVEN(description) + +/** + * Macro to define a when step in a test case. + * This macro is used to define a when step in a test case. The when step should + * contain the logic to execute the functionality that is being tested. + */ +#define WHEN(description) _WHEN(description) + +/** + * Macro to define a then step in a test case. + * This macro is used to define a then step in a test case. The then step should + * contain the logic to verify the correctness of the functionality that was + * tested. + */ +#define THEN(description) _THEN(description) + +/** + * Macro to define a test group. + * This macro is used to define a test group, which is a collection of test + * cases that are related to each other. The test group can be executed as a + * whole to verify the correctness of a group of functionalities. + */ +#define FOSSIL_TEST_GROUP(name) \ + _FOSSIL_TEST_GROUP(name) + +/** + * Macro to export a test group. + * This macro is used to export a test group from a test file. The test group + * will be available to other test files that import it. + */ +#define FOSSIL_TEST_EXPORT(name) \ + _FOSSIL_TEST_EXPORT(name) + +/** + * Macro to import a test group. + * This macro is used to import a test group into the test runner. The test group + * will be executed when the test runner is run. + */ +#define FOSSIL_TEST_IMPORT(name) \ + _FOSSIL_TEST_IMPORT(name) + +/** + * Macro to start the test runner. + * This macro is used to start the test runner, which will initialize the test + * framework and prepare to run all test cases in the test suite. + */ +#define FOSSIL_TEST_START(argc, argv) \ + _FOSSIL_TEST_START(argc, argv) + +/** + * Macro to run all test cases in the test suite. + * This macro is used to run all test cases in the test suite. The test cases + * will be executed in sequence, and the results will be output to the console. + */ +#define FOSSIL_TEST_RUN() \ + _FOSSIL_TEST_RUN() + +/** + * Macro to print a summary of the test results. + * This macro is used to print a summary of the test results after all test + * cases have been executed. The summary will include the number of test cases + * that passed, failed, and were skipped. + */ +#define FOSSIL_TEST_SUMMARY() \ + _FOSSIL_TEST_SUMMARY() + +/** + * Macro to end the test runner. + * This macro is used to end the test runner, which will clean up the test + * framework and return the appropriate exit code based on the test results. + */ +#define FOSSIL_TEST_END() \ + _FOSSIL_TEST_END() + +/** + * Macro to define a test case. + * This macro is used to declare a test case function that will be executed + * as part of the test suite. The test case function should contain the logic + * to verify the correctness of a specific functionality. + */ +#define FOSSIL_TEST_ADD(suite, test_case) \ + _FOSSIL_TEST_ADD(suite, test_case) + +/** + * Macro to define a test suite. + * This macro is used to declare a test suite, which is a collection of test + * cases that are related to each other. The test suite can be executed as a + * whole to verify the correctness of a group of functionalities. + */ +#define FOSSIL_TEST_SUITE(suite_name) \ + _FOSSIL_TEST_SUITE(suite_name) + +/** + * Macro to register a test suite with the test framework. + * This macro is used to register a test suite with the test framework. The test + * suite will be added to the list of test suites that will be executed by the + * test runner. + */ +#define FOSSIL_TEST_REGISTER(suite) \ + _FOSSIL_TEST_REGISTER(suite) + +/** + * Macro to define a setup function for a test. + * This macro is used to declare a setup function that will be executed before + * each test case in a test suite. The setup function should contain the logic + * to initialize the environment or state required for the test cases. + */ +#define FOSSIL_SETUP(name) \ + _FOSSIL_TEST_SETUP(name) + +/** + * Macro to define a teardown function for a test. + * This macro is used to declare a teardown function that will be executed after + * each test case in a test suite. The teardown function should contain the logic + * to clean up the environment or state after the test cases have been executed. + */ +#define FOSSIL_TEARDOWN(name) \ + _FOSSIL_TEST_TEARDOWN(name) + +/** + * Macro to define test data. + * This macro is used to declare a structure that contains the data required + * for a test case. The test data structure can be used to pass input parameters + * to the test case and store the expected output values. + */ +#define FOSSIL_TEST_DATA(name) \ + _FOSSIL_TEST_DATA(name) + +/** + * Macro to define a test case. + * This macro is used to declare a test case function that will be executed + * as part of the test suite. The test case function should contain the logic + * to verify the correctness of a specific functionality. + */ +#define FOSSIL_TEST_CASE(name) \ + _FOSSIL_TEST_CASE(name) + +/** + * Macro to assume a condition in a test runner. + * This macro is used to assert that a specific condition is true within a test + * runner. If the condition is false, the test runner will output the specified + * message and may abort the execution of the test case or test suite. + */ +#define FOSSIL_TEST_ASSUME(condition, message) \ + _FOSSIL_TEST_ASSUME(condition, message) + +/** + * Macro to assert a condition in a test runner. + * This macro is used to assert that a specific condition is true within a test + * runner. If the condition is false, the test runner will output the specified + * message and abort the execution of the test case or test suite. + */ +#define FOSSIL_TEST_ASSERT(condition, message) \ + _FOSSIL_TEST_ASSUME(condition, message) + + +// ***************************************************************************** +// Mocking framework +// ***************************************************************************** + +/** + * @brief Macro for initializing the mock list. + * + * This macro initializes the mock list by calling the fossil_mock_init function. + * + * @param list The mock list to initialize. + */ +#define MOCK_INIT(list) _MOCK_INIT(list) + +/** + * @brief Macro for destroying the mock list. + * + * This macro destroys the mock list by calling the fossil_mock_destroy function. + * + * @param list The mock list to destroy. + */ +#define MOCK_DESTROY(list) _MOCK_DESTROY(list) + +/** + * @brief Macro for adding a mock function call to the mock list. + * + * This macro adds a mock function call to the mock list by calling the fossil_mock_add_call function. + * + * @param list The mock list to add the call to. + * @param func The mock function to add the call for. + * @param args The arguments of the mock function call. + * @param num_args The number of arguments in the mock function call. + */ +#define MOCK_ADD_CALL(list, func, args, num_args) _MOCK_ADD_CALL(list, func, args, num_args) + +/** + * @brief Macro for printing the mock list. + * + * This macro prints the mock list by calling the fossil_mock_print function. + * + * @param list The mock list to print. + */ +#define MOCK_PRINT(list) _MOCK_PRINT(list) +/** + * @def FOSSIL_MOCK_FUNC + * @brief Macro for creating a mock function with the specified return type, name, and parameters. + * + * This macro simplifies the creation of mock functions by defining a function with the given return + * type, name, and parameters. The function name will be prefixed with "fossil_mockup_" to clearly indicate + * that it is a mock function. + * + * @param return_type The return type of the mock function. + * @param name The name of the mock function. + * @param ... The parameters of the mock function in the format: (type1 param1, type2 param2, ...). + * @return The return type specified for the mock function. + */ +#define FOSSIL_MOCK_FUNC(return_type, name, ...) _FOSSIL_MOCK_FUNC(return_type, name, __VA_ARGS__) + +/** + * @def FOSSIL_MOCK_ALIAS + * @brief Macro for creating a type alias based on an existing type. + * + * This macro creates a type alias for a given existing type. + * + * @param new_type The name of the new type alias. + * @param existing_type The existing type to create an alias for. + */ +#define FOSSIL_MOCK_ALIAS(new_type, existing_type) _FOSSIL_MOCK_ALIAS(new_type, existing_type) + +/** + * @def FOSSIL_MOCK_STRUCT + * @brief Macro for creating a mock struct with the specified name and members. + * + * This macro simplifies the creation of mock structs by defining a struct with the given name + * and members. The struct name will be prefixed with "fossil_mockup_" to clearly indicate that it is a mock struct. + * + * @param name The name of the mock struct. + * @param ... The members of the mock struct in the format: (type1 member1, type2 member2, ...). + */ +#define FOSSIL_MOCK_STRUCT(name, ...) _FOSSIL_MOCK_STRUCT(name, __VA_ARGS__) + +// ***************************************************************************** +// Benchmark framework +// ***************************************************************************** + +/** + * @brief Define macro for marking a benchmark. + * + * This macro is used to mark a benchmark with a given name. It initializes + * the benchmark structure and sets the name of the benchmark. + * + * @param name The name of the benchmark. + */ +#define MARK_BENCHMARK(name) \ + fossil_benchmark_t benchmark_##name; \ + fossil_benchmark_init(&benchmark_##name, #name) + +/** + * @brief Define macro for starting a benchmark. + * + * This macro is used to start a benchmark with a given name. It starts the + * timer for the benchmark. + * + * @param name The name of the benchmark. + */ +#define MARK_START(name) \ + fossil_benchmark_start(&benchmark_##name) + +/** + * @brief Define macro for stopping a benchmark. + * + * This macro is used to stop a benchmark with a given name. It stops the + * timer for the benchmark. + * + * @param name The name of the benchmark. + */ +#define MARK_STOP(name) \ + fossil_benchmark_stop(&benchmark_##name) + +/** + * @brief Define macro for reporting a benchmark. + * + * This macro is used to report the results of a benchmark with a given name. + * It prints the benchmark name and the elapsed time. + * + * @param name The name of the benchmark. + */ +#define MARK_REPORT(name) \ + fossil_benchmark_report(&benchmark_##name) + +/** + * @brief Define macro for scoped benchmarking. + * + * This macro is used to create a scoped benchmark with a given name. It + * initializes the scoped benchmark structure and sets the benchmark to be + * used. + * + * @param name The name of the benchmark. + */ +#define MARK_SCOPED(name) \ + scoped_benchmark_t scoped_benchmark_##name; \ + fossil_scoped_benchmark_init(&scoped_benchmark_##name, &benchmark_##name) + +// ================================================================= +// Bench specific commands +// ================================================================= + +/** + * @brief Define macro for starting a benchmark. + * + * This macro is used to mark the start of a benchmark. It typically initializes + * any necessary resources or variables required for benchmarking. + */ +#define TEST_BENCHMARK() fossil_test_start_benchmark() + +/** + * @brief Define macro for getting the current time. + * + * This macro is used to retrieve the current time, which is typically used + * in conjunction with TEST_BENCHMARK to calculate the elapsed time for a benchmark. + */ +#define TEST_CURRENT_TIME() fossil_test_stop_benchmark() + +/** + * @brief Define macro for reporting test duration with a given timeout. + * + * This macro is used to report the duration of a test with a given timeout. + * It takes the timeout duration, elapsed time, and actual duration as arguments + * and reports the results, typically in the form of logs or console output. + * + * @param duration The duration unit (e.g., "minutes", "seconds"). + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define TEST_DURATION(duration, elapsed, actual) fossil_test_benchmark((char*)duration, elapsed, actual) + +/** + * @brief Define macro for reporting test duration in minutes. + * + * This macro is a shorthand for reporting test duration in minutes using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in minutes. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define TEST_DURATION_MIN(elapsed, actual) TEST_DURATION((char*)"minutes", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in seconds. + * + * This macro is a shorthand for reporting test duration in seconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in seconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define TEST_DURATION_SEC(elapsed, actual) TEST_DURATION((char*)"seconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in milliseconds. + * + * This macro is a shorthand for reporting test duration in milliseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in milliseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define TEST_DURATION_MIL(elapsed, actual) TEST_DURATION((char*)"milliseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in microseconds. + * + * This macro is a shorthand for reporting test duration in microseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in microseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define TEST_DURATION_MIC(elapsed, actual) TEST_DURATION((char*)"microseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in nanoseconds. + * + * This macro is a shorthand for reporting test duration in nanoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in nanoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define TEST_DURATION_NAN(elapsed, actual) TEST_DURATION((char*)"nanoseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in picoseconds. + * + * This macro is a shorthand for reporting test duration in picoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in picoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define TEST_DURATION_PIC(elapsed, actual) TEST_DURATION((char*)"picoseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in femtoseconds. + * + * This macro is a shorthand for reporting test duration in femtoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in femtoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define TEST_DURATION_FEM(elapsed, actual) TEST_DURATION((char*)"femtoseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in attoseconds. + * + * This macro is a shorthand for reporting test duration in attoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in attoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define TEST_DURATION_ATT(elapsed, actual) TEST_DURATION((char*)"attoseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in zeptoseconds. + * + * This macro is a shorthand for reporting test duration in zeptoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in zeptoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define TEST_DURATION_ZEP(elapsed, actual) TEST_DURATION((char*)"zeptoseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in yoctoseconds. + * + * This macro is a shorthand for reporting test duration in yoctoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in yoctoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define TEST_DURATION_YOC(elapsed, actual) TEST_DURATION((char*)"yoctoseconds", elapsed, actual) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/code/logic/fossil/mockup/mockup.h b/code/logic/fossil/test/mockup.h similarity index 98% rename from code/logic/fossil/mockup/mockup.h rename to code/logic/fossil/test/mockup.h index 76b47f36..ddb884d7 100644 --- a/code/logic/fossil/mockup/mockup.h +++ b/code/logic/fossil/test/mockup.h @@ -20,7 +20,6 @@ #include #include #include -#include "fossil/_common/common.h" /** * @brief Macro for initializing the mock list. @@ -159,4 +158,13 @@ void fossil_mock_print(MockCallList *list); } #endif +#ifdef __cplusplus +#include +#include + +namespace fossil { + +} +#endif + #endif // FOSSIL_MOCK_FRAMEWORK_H diff --git a/code/logic/fossil/test/unittest.h b/code/logic/fossil/test/unittest.h new file mode 100644 index 00000000..ce6faea8 --- /dev/null +++ b/code/logic/fossil/test/unittest.h @@ -0,0 +1,326 @@ +/* + * ----------------------------------------------------------------------------- + * Project: Fossil Logic + * + * This file is part of the Fossil Logic project, which aims to develop high- + * performance, cross-platform applications and libraries. The code contained + * herein is subject to the terms and conditions defined in the project license. + * + * Author: Michael Gene Brockus (Dreamer) + * Date: 07/01/2024 + * + * Copyright (C) 2024 Fossil Logic. All rights reserved. + * ----------------------------------------------------------------------------- + */ +#ifndef FOSSIL_TEST_CORE_H +#define FOSSIL_TEST_CORE_H + +#define MAX_NAME_LENGTH 256 + +// Color codes +#define COLOR_RESET "\033[0m" +#define COLOR_PASS "\033[32m" // Green +#define COLOR_FAIL "\033[31m" // Red +#define COLOR_SKIP "\033[33m" // Yellow +#define COLOR_INFO "\033[34m" // Blue +#define COLOR_BDD "\033[35m" // Magenta +#define COLOR_CYAN "\033[36m" // Cyan + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// Define the structure to hold parsed options +typedef struct { + bool show_version; + bool show_help; + bool show_info; + bool reverse; + bool repeat_enabled; + int repeat_count; + bool shuffle_enabled; +} fossil_options_t; + +typedef enum { + TEST_STATUS_PASS, + TEST_STATUS_FAIL, + TEST_STATUS_SKIP +} test_status_t; + +// Stack frame structure for tracking function call details during failures +typedef struct stack_frame { + const char *func; + const char *file; + int line; + struct stack_frame *next; +} stack_frame_t; + +// Test case structure +typedef struct test_case { + const char *name; // Test case name + void (*test_func)(void); // Pointer to test function + void (*setup_func)(void); // Pointer to setup function (optional) + void (*teardown_func)(void); // Pointer to teardown function (optional) + test_status_t status; // Test status (pass, fail, skip) + const char *failure_message; // Failure message (if any) + stack_frame_t *stack_trace; // Stack trace for failures + double execution_time; // Execution time of the test + struct test_case *next; // Pointer to next test case in the list +} test_case_t; + +// Test suite structure +typedef struct test_suite { + const char *name; // Suite name + void (*suite_setup_func)(void); // Suite setup function (optional) + void (*suite_teardown_func)(void); // Suite teardown function (optional) + double total_execution_time; // Total execution time of all test cases + test_case_t *tests; // List of test cases + struct test_suite *next; // Pointer to next suite in the list +} test_suite_t; + +typedef struct fossil_test_env { + fossil_options_t options; + jmp_buf env; + int total_tests; + int pass_count; + int fail_count; + int skip_count; + int unexpected_count; + double total_execution_time; + test_suite_t *test_suites; +} fossil_test_env_t; + +// ***************************************************************************** +// Function declarations +// ***************************************************************************** + +/** + * @brief Creates a new test suite. + * + * @param name The name of the test suite. + * @return A pointer to the created test suite. + */ +test_suite_t* fossil_test_create_suite(const char *name); + +/** + * @brief Registers a test suite with the test environment. + * + * @param env The test environment. + * @param suite The test suite to register. + */ +void fossil_test_register_suite(fossil_test_env_t *env, test_suite_t *suite); + +/** + * @brief Adds a test case to a test suite. + * + * @param suite The test suite. + * @param test_case The test case to add. + */ +void fossil_test_add_case(test_suite_t *suite, test_case_t *test_case); + +/** + * @brief Removes a test case from a test suite. + * + * @param suite The test suite. + * @param test_case The test case to remove. + */ +void fossil_test_remove_case(test_suite_t *suite, test_case_t *test_case); + +/** + * @brief Sets up a test case. + * + * @param test_case The test case to set up. + */ +void fossil_test_case_setup(test_case_t *test_case); + +/** + * @brief Tears down a test case. + * + * @param test_case The test case to tear down. + */ +void fossil_test_case_teardown(test_case_t *test_case); + +/** + * @brief Runs a test case. + * + * @param test_case The test case to run. + * @param env The test environment. + */ +void fossil_test_run_case(test_case_t *test_case, fossil_test_env_t *env); + +/** + * @brief Runs all test cases in a test suite. + * + * @param suite The test suite to run. + * @param env The test environment. + */ +void fossil_test_run_suite(test_suite_t *suite, fossil_test_env_t *env); + +/** + * @brief Asserts a condition and prints a message if the assertion fails. + * + * @param condition The condition to assert. + * @param message The message to print if the assertion fails. + * @param file The file where the assertion failed. + * @param line The line number where the assertion failed. + * @param func The function where the assertion failed. + */ +void fossil_test_assert_internal(bool condition, const char *message, const char *file, int line, const char *func); + +/** + * @brief Initializes the test environment. + * + * @param env The test environment to initialize. + */ +void fossil_test_init(fossil_test_env_t *env, int argc, char **argv); + +/** + * @brief Prints a summary of the test results. + * + * @param env The test environment. + */ +void fossil_test_summary(fossil_test_env_t *env); + +/** + * @brief Runs all test suites and test cases in the test environment. + * + * @param env The test environment. + */ +void fossil_test_run_all(fossil_test_env_t *env); + +/** + * @brief Prints the stack trace. + * + * @param stack_trace The stack trace to print. + */ +void fossil_test_print_stack_trace(stack_frame_t *stack_trace); + +// ***************************************************************************** +// Macro definitions +// ***************************************************************************** + +// Assertion macro to assume a condition is true +#define _FOSSIL_TEST_ASSUME(condition, message) \ + fossil_test_assert_internal((condition), (message), __FILE__, __LINE__, __func__) + +// Macro for defining a test case +#define _FOSSIL_TEST_CASE(test_name) \ + void test_name##_test_func(void); \ + test_case_t test_name##_test_case = { \ + .name = #test_name, \ + .test_func = test_name##_test_func, \ + .setup_func = NULL, \ + .teardown_func = NULL, \ + .status = TEST_STATUS_PASS, \ + .failure_message = NULL, \ + .execution_time = 0.0, \ + .stack_trace = NULL, \ + .next = NULL \ + }; \ + void test_name##_test_func(void) + +// Macro for defining test data structures +#define _FOSSIL_TEST_DATA(name) \ + typedef struct name + +// Macro for setting up a test case +#define _FOSSIL_TEST_SETUP(name) \ + void name##_setup_func(void) + +// Macro for tearing down a test case +#define _FOSSIL_TEST_TEARDOWN(name) \ + void name##_teardown_func(void) + +// Macro to create a test suite with setup and teardown hooks +#define _FOSSIL_TEST_SUITE(suite_name) \ + void suite_name##_setup_func(void); \ + void suite_name##_teardown_func(void); \ + test_suite_t suite_name = { \ + .name = #suite_name, \ + .tests = NULL, \ + .total_execution_time = 0.0, \ + .suite_setup_func = suite_name##_setup_func, \ + .suite_teardown_func = suite_name##_teardown_func, \ + .next = NULL \ + } + +// Macro to register a suite with the test environment +#define _FOSSIL_TEST_REGISTER(suite) \ + fossil_test_register_suite(_env, &suite) + +// Macro to add a test case to a suite +#define _FOSSIL_TEST_ADD(suite, test) \ + fossil_test_add_case(&suite, &(test##_test_case)) + +// Macro to define a test group, grouping tests under a common environment +#define _FOSSIL_TEST_GROUP(name) \ + void name##_test_group(fossil_test_env_t *_env) + +// Macro to export a test group +#define _FOSSIL_TEST_EXPORT(name) \ + void name##_test_group(fossil_test_env_t *_env) + +// Macro to import a test group into the environment +#define _FOSSIL_TEST_IMPORT(name) \ + name##_test_group(&_env) + +// Main runner management macros + +// Macro to initialize the test environment and handle command-line args +#define _FOSSIL_TEST_START(argc, argv) \ + fossil_test_env_t _env; \ + fossil_test_init(&_env, argc, argv) + +// Macro to run all tests in the environment +#define _FOSSIL_TEST_RUN() \ + fossil_test_run_all(&_env) + +// Macro to output a summary of the test results +#define _FOSSIL_TEST_SUMMARY() \ + fossil_test_summary(&_env) + +// Macro to clean up after all tests and exit with appropriate status code +#define _FOSSIL_TEST_END() \ + int fail_count = _env.fail_count; \ + return fail_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS + +// Behavior-driven development macros for Given, When, Then structure + +#define _GIVEN(description) \ + if (0) { \ + printf(COLOR_BDD "Given %s\n" COLOR_RESET, description); \ + } + +#define _WHEN(description) \ + if (0) { \ + printf(COLOR_BDD "When %s\n" COLOR_RESET, description); \ + } + +#define _THEN(description) \ + if (0) { \ + printf(COLOR_BDD "Then %s\n" COLOR_RESET, description); \ + } + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +#include +#include + +namespace fossil { + +} +#endif + +#endif diff --git a/code/logic/fossil/unittest/assert.h b/code/logic/fossil/unittest/assert.h deleted file mode 100644 index 1b0e67db..00000000 --- a/code/logic/fossil/unittest/assert.h +++ /dev/null @@ -1,868 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_TEST_ASSERT_TYPE_H -#define FOSSIL_TEST_ASSERT_TYPE_H - -#include // using assurt rules from Fossil Test - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// ************************************************** -// -// Boolean assertions -// -// ************************************************** - -// Boolean ITS assertions -#define ASSERT_ITS_TRUE(actual) \ - TEST_ASSERT((actual), "Expected " #actual " to be true") - -#define ASSERT_ITS_FALSE(actual) \ - TEST_ASSERT(!(actual), "Expected " #actual " to be false") - -// Boolean NOT assertions -#define ASSERT_NOT_TRUE(actual) \ - TEST_ASSERT(!(actual), "Expected " #actual " to not be true") - -#define ASSERT_NOT_FALSE(actual) \ - TEST_ASSERT((actual), "Expected " #actual " to not be false") - -// ************************************************** -// -// Floating point assertions -// -// ************************************************** - -// Double equality check with tolerance -#define ASSERT_ITS_EQUAL_F64(actual, expected, tol) \ - TEST_ASSERT(fabs((actual) - (expected)) <= (tol), "Expected " #actual " to be equal to " #expected " within tolerance " #tol) - -#define ASSERT_ITS_LESS_THAN_F64(actual, expected) \ - TEST_ASSERT((actual) < (expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_F64(actual, expected) \ - TEST_ASSERT((actual) > (expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_F64(actual, expected) \ - TEST_ASSERT((actual) <= (expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_F64(actual, expected) \ - TEST_ASSERT((actual) >= (expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_F64(actual, expected, tol) \ - TEST_ASSERT(fabs((actual) - (expected)) > (tol), "Expected " #actual " to not be equal to " #expected " within tolerance " #tol) - -#define ASSERT_NOT_LESS_THAN_F64(actual, expected) \ - TEST_ASSERT((actual) >= (expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_F64(actual, expected) \ - TEST_ASSERT((actual) <= (expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_F64(actual, expected) \ - TEST_ASSERT((actual) > (expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_F64(actual, expected) \ - TEST_ASSERT((actual) < (expected), "Expected " #actual " to not be more than or equal to " #expected) - -// Float equality check with tolerance -#define ASSERT_ITS_EQUAL_F32(actual, expected, tol) \ - TEST_ASSERT(fabsf((actual) - (expected)) <= (tol), "Expected " #actual " to be equal to " #expected " within tolerance " #tol) - -#define ASSERT_ITS_LESS_THAN_F32(actual, expected) \ - TEST_ASSERT((actual) < (expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_F32(actual, expected) \ - TEST_ASSERT((actual) > (expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_F32(actual, expected) \ - TEST_ASSERT((actual) <= (expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_F32(actual, expected) \ - TEST_ASSERT((actual) >= (expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_F32(actual, expected, tol) \ - TEST_ASSERT(fabsf((actual) - (expected)) > (tol), "Expected " #actual " to not be equal to " #expected " within tolerance " #tol) - -#define ASSERT_NOT_LESS_THAN_F32(actual, expected) \ - TEST_ASSERT((actual) >= (expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_F32(actual, expected) \ - TEST_ASSERT((actual) <= (expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_F32(actual, expected) \ - TEST_ASSERT((actual) > (expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_F32(actual, expected) \ - TEST_ASSERT((actual) < (expected), "Expected " #actual " to not be more than or equal to " #expected) - -// Float NaN and Infinity checks -#define ASSERT_ITS_NAN_F32(actual) \ - TEST_ASSERT(isnan(actual), "Expected " #actual " to be NaN") - -#define ASSERT_ITS_INF_F32(actual) \ - TEST_ASSERT(isinf(actual), "Expected " #actual " to be infinity") - -// Double NaN and Infinity checks -#define ASSERT_ITS_NAN_F64(actual) \ - TEST_ASSERT(isnan(actual), "Expected " #actual " to be NaN") - -#define ASSERT_ITS_INF_F64(actual) \ - TEST_ASSERT(isinf(actual), "Expected " #actual " to be infinity") - -// ************************************************** -// -// Numaric assertions -// -// ************************************************** - -// Octal assertions - -// O8 Assertions -#define ASSERT_ITS_EQUAL_O8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_O8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_O8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_O8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_O8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_O8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_O8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_O8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_O8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_O8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// O16 Assertions -#define ASSERT_ITS_EQUAL_O16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_O16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_O16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_O16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_O16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_O16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_O16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_O16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_O16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_O16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// O32 Assertions -#define ASSERT_ITS_EQUAL_O32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_O32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_O32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_O32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_O32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_O32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_O32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_O32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_O32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_O32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// OI64 Assertions -#define ASSERT_ITS_EQUAL_O64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_O64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_O64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_O64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_O64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_O64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_O64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_O64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_O64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_O64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// Hexadecimal assertions - -// H8 Assertions -#define ASSERT_ITS_EQUAL_H8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_H8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_H8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_H8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_H8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_H8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_H8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_H8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_H8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_H8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// H16 Assertions -#define ASSERT_ITS_EQUAL_H16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_H16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_H16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_H16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_H16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_H16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_H16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_H16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_H16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_H16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// H32 Assertions -#define ASSERT_ITS_EQUAL_H32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_H32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_H32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_H32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_H32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_H32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_H32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_H32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_H32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_H32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// H64 Assertions -#define ASSERT_ITS_EQUAL_H64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_H64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_H64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_H64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_H64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_H64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_H64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_H64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_H64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_H64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I8 Assertions -#define ASSERT_ITS_EQUAL_I8(actual, expected) \ - TEST_ASSERT((int8_t)(actual) == (int8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_I8(actual, expected) \ - TEST_ASSERT((int8_t)(actual) < (int8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_I8(actual, expected) \ - TEST_ASSERT((int8_t)(actual) > (int8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_I8(actual, expected) \ - TEST_ASSERT((int8_t)(actual) <= (int8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_I8(actual, expected) \ - TEST_ASSERT((int8_t)(actual) >= (int8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_I8(actual, expected) \ - TEST_ASSERT((int8_t)(actual) != (int8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_I8(actual, expected) \ - TEST_ASSERT((int8_t)(actual) >= (int8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_I8(actual, expected) \ - TEST_ASSERT((int8_t)(actual) <= (int8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_I8(actual, expected) \ - TEST_ASSERT((int8_t)(actual) > (int8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_I8(actual, expected) \ - TEST_ASSERT((int8_t)(actual) < (int8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I16 Assertions -#define ASSERT_ITS_EQUAL_I16(actual, expected) \ - TEST_ASSERT((int16_t)(actual) == (int16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_I16(actual, expected) \ - TEST_ASSERT((int16_t)(actual) < (int16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_I16(actual, expected) \ - TEST_ASSERT((int16_t)(actual) > (int16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_I16(actual, expected) \ - TEST_ASSERT((int16_t)(actual) <= (int16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_I16(actual, expected) \ - TEST_ASSERT((int16_t)(actual) >= (int16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_I16(actual, expected) \ - TEST_ASSERT((int16_t)(actual) != (int16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_I16(actual, expected) \ - TEST_ASSERT((int16_t)(actual) >= (int16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_I16(actual, expected) \ - TEST_ASSERT((int16_t)(actual) <= (int16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_I16(actual, expected) \ - TEST_ASSERT((int16_t)(actual) > (int16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_I16(actual, expected) \ - TEST_ASSERT((int16_t)(actual) < (int16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I32 Assertions -#define ASSERT_ITS_EQUAL_I32(actual, expected) \ - TEST_ASSERT((int32_t)(actual) == (int32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_I32(actual, expected) \ - TEST_ASSERT((int32_t)(actual) < (int32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_I32(actual, expected) \ - TEST_ASSERT((int32_t)(actual) > (int32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_I32(actual, expected) \ - TEST_ASSERT((int32_t)(actual) <= (int32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_I32(actual, expected) \ - TEST_ASSERT((int32_t)(actual) >= (int32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_I32(actual, expected) \ - TEST_ASSERT((int32_t)(actual) != (int32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_I32(actual, expected) \ - TEST_ASSERT((int32_t)(actual) >= (int32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_I32(actual, expected) \ - TEST_ASSERT((int32_t)(actual) <= (int32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_I32(actual, expected) \ - TEST_ASSERT((int32_t)(actual) > (int32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_I32(actual, expected) \ - TEST_ASSERT((int32_t)(actual) < (int32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I64 Assertions -#define ASSERT_ITS_EQUAL_I64(actual, expected) \ - TEST_ASSERT((int64_t)(actual) == (int64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_I64(actual, expected) \ - TEST_ASSERT((int64_t)(actual) < (int64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_I64(actual, expected) \ - TEST_ASSERT((int64_t)(actual) > (int64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_I64(actual, expected) \ - TEST_ASSERT((int64_t)(actual) <= (int64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_I64(actual, expected) \ - TEST_ASSERT((int64_t)(actual) >= (int64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_I64(actual, expected) \ - TEST_ASSERT((int64_t)(actual) != (int64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_I64(actual, expected) \ - TEST_ASSERT((int64_t)(actual) >= (int64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_I64(actual, expected) \ - TEST_ASSERT((int64_t)(actual) <= (int64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_I64(actual, expected) \ - TEST_ASSERT((int64_t)(actual) > (int64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_I64(actual, expected) \ - TEST_ASSERT((int64_t)(actual) < (int64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U8 Assertions -#define ASSERT_ITS_EQUAL_U8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_U8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_U8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_U8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_U8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_U8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_U8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_U8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_U8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_U8(actual, expected) \ - TEST_ASSERT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U16 Assertions -#define ASSERT_ITS_EQUAL_U16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_U16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_U16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_U16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_U16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_U16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_U16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_U16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_U16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_U16(actual, expected) \ - TEST_ASSERT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U32 Assertions -#define ASSERT_ITS_EQUAL_U32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_U32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_U32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_U32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_U32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_U32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_U32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_U32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_U32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_U32(actual, expected) \ - TEST_ASSERT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U64 Assertions -#define ASSERT_ITS_EQUAL_U64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSERT_ITS_LESS_THAN_U64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSERT_ITS_MORE_THAN_U64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSERT_ITS_LESS_OR_EQUAL_U64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSERT_ITS_MORE_OR_EQUAL_U64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSERT_NOT_EQUAL_U64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSERT_NOT_LESS_THAN_U64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSERT_NOT_MORE_THAN_U64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSERT_NOT_LESS_OR_EQUAL_U64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSERT_NOT_MORE_OR_EQUAL_U64(actual, expected) \ - TEST_ASSERT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// ************************************************** -// -// Null pointer assertions (_CNULL) -// -// ************************************************** - -// ITS set -#define ASSERT_ITS_CNULL(actual) \ - TEST_ASSERT((actual) == xnull, "Expected " #actual " to be xnull") - -#define ASSERT_NOT_CNULL(actual) \ - TEST_ASSERT((actual) != xnull, "Expected " #actual " to not be xnull") - -// General pointer assertions (_PTR) - -// ITS set -#define ASSERT_ITS_EQUAL_PTR(actual, expected) \ - TEST_ASSERT((actual) == (expected), "Expected pointer " #actual " to be equal to pointer " #expected " ") - -#define ASSERT_NOT_EQUAL_PTR(actual, expected) \ - TEST_ASSERT((actual) != (expected), "Expected pointer " #actual " to not be equal to pointer " #expected " ") - -// Size_t assertions - -// Equal -#define ASSERT_ITS_EQUAL_SIZE(actual, expected) \ - TEST_ASSERT((size_t)(actual) == (size_t)(expected), "Expected " #actual " to be equal to " #expected) - -// Less than -#define ASSERT_ITS_LESS_THAN_SIZE(actual, expected) \ - TEST_ASSERT((size_t)(actual) < (size_t)(expected), "Expected " #actual " to be less than " #expected) - -// More than -#define ASSERT_ITS_MORE_THAN_SIZE(actual, expected) \ - TEST_ASSERT((size_t)(actual) > (size_t)(expected), "Expected " #actual " to be more than " #expected) - -// Less or equal -#define ASSERT_ITS_LESS_OR_EQUAL_SIZE(actual, expected) \ - TEST_ASSERT((size_t)(actual) <= (size_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -// More or equal -#define ASSERT_ITS_MORE_OR_EQUAL_SIZE(actual, expected) \ - TEST_ASSERT((size_t)(actual) >= (size_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -// Not equal -#define ASSERT_NOT_EQUAL_SIZE(actual, expected) \ - TEST_ASSERT((size_t)(actual) != (size_t)(expected), "Expected " #actual " to not be equal to " #expected) - -// ************************************************** -// -// Range assertions -// -// ************************************************** - -// Assertion for checking if a value is within a specified range -#define ASSERT_ITS_WITHIN_RANGE(value, min, max) \ - TEST_ASSERT((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE(value, min, max) \ - TEST_ASSERT((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") - -// Unsigned integer type assertions - -#define ASSERT_ITS_WITHIN_RANGE_U8(value, min, max) \ - TEST_ASSERT((uint8_t)(value) >= (uint8_t)(min) && (uint8_t)(value) <= (uint8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_U8(value, min, max) \ - TEST_ASSERT((uint8_t)(value) < (uint8_t)(min) || (uint8_t)(value) > (uint8_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSERT_ITS_WITHIN_RANGE_U16(value, min, max) \ - TEST_ASSERT((uint16_t)(value) >= (uint16_t)(min) && (uint16_t)(value) <= (uint16_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_U16(value, min, max) \ - TEST_ASSERT((uint16_t)(value) < (uint16_t)(min) || (uint16_t)(value) > (uint16_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSERT_ITS_WITHIN_RANGE_U32(value, min, max) \ - TEST_ASSERT((uint32_t)(value) >= (uint32_t)(min) && (uint32_t)(value) <= (uint32_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_U32(value, min, max) \ - TEST_ASSERT((uint32_t)(value) < (uint32_t)(min) || (uint32_t)(value) > (uint32_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSERT_ITS_WITHIN_RANGE_U64(value, min, max) \ - TEST_ASSERT((uint64_t)(value) >= (uint64_t)(min) && (uint64_t)(value) <= (uint64_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_U64(value, min, max) \ - TEST_ASSERT((uint64_t)(value) < (uint64_t)(min) || (uint64_t)(value) > (uint64_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Signed integer type assertions - -#define ASSERT_ITS_WITHIN_RANGE_I8(value, min, max) \ - TEST_ASSERT((int8_t)(value) >= (int8_t)(min) && (int8_t)(value) <= (int8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_I8(value, min, max) \ - TEST_ASSERT((int8_t)(value) < (int8_t)(min) || (int8_t)(value) > (int8_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSERT_ITS_WITHIN_RANGE_I16(value, min, max) \ - TEST_ASSERT((int16_t)(value) >= (int16_t)(min) && (int16_t)(value) <= (int16_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_I16(value, min, max) \ - TEST_ASSERT((int16_t)(value) < (int16_t)(min) || (int16_t)(value) > (int16_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSERT_ITS_WITHIN_RANGE_I32(value, min, max) \ - TEST_ASSERT((int32_t)(value) >= (int32_t)(min) && (int32_t)(value) <= (int32_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_I32(value, min, max) \ - TEST_ASSERT((int32_t)(value) < (int32_t)(min) || (int32_t)(value) > (int32_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSERT_ITS_WITHIN_RANGE_I64(value, min, max) \ - TEST_ASSERT((int64_t)(value) >= (int64_t)(min) && (int64_t)(value) <= (int64_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_I64(value, min, max) \ - TEST_ASSERT((int64_t)(value) < (int64_t)(min) || (int64_t)(value) > (int64_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Floating point type assertions - -#define ASSERT_ITS_WITHIN_RANGE_F32(value, min, max) \ - TEST_ASSERT((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_F32(value, min, max) \ - TEST_ASSERT((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSERT_ITS_WITHIN_RANGE_F64(value, min, max) \ - TEST_ASSERT((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_F64(value, min, max) \ - TEST_ASSERT((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") - -// Byte char type assertions (uint8_t) - -#define ASSERT_ITS_WITHIN_RANGE_BCHAR(value, min, max) \ - TEST_ASSERT((uint8_t)(value) >= (uint8_t)(min) && (uint8_t)(value) <= (uint8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_BCHAR(value, min, max) \ - TEST_ASSERT((uint8_t)(value) < (uint8_t)(min) || (uint8_t)(value) > (uint8_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Char type assertions (char) - -#define ASSERT_ITS_WITHIN_RANGE_CCHAR(value, min, max) \ - TEST_ASSERT((char)(value) >= (char)(min) && (char)(value) <= (char)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_CCHAR(value, min, max) \ - TEST_ASSERT((char)(value) < (char)(min) || (char)(value) > (char)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Wide char type assertions (wchar_t) - -#define ASSERT_ITS_WITHIN_RANGE_WCHAR(value, min, max) \ - TEST_ASSERT((wchar_t)(value) >= (wchar_t)(min) && (wchar_t)(value) <= (wchar_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSERT_NOT_WITHIN_RANGE_WCHAR(value, min, max) \ - TEST_ASSERT((wchar_t)(value) < (wchar_t)(min) || (wchar_t)(value) > (wchar_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// ************************************************** -// -// String assertions -// -// ************************************************** - -// Wide char string equality check -#define ASSERT_ITS_EQUAL_WSTR(actual, expected) \ - TEST_ASSERT(wcscmp((actual), (expected)) == 0, "Expected wide string " #actual " to be equal to " #expected) - -#define ASSERT_NOT_EQUAL_WSTR(actual, expected) \ - TEST_ASSERT(wcscmp((actual), (expected)) != 0, "Expected wide string " #actual " to not be equal to " #expected) - -// For length comparison -#define ASSERT_ITS_LENGTH_EQUAL_WSTR(actual, expected_len) \ - TEST_ASSERT(wcslen((actual)) == (expected_len), "Expected length of wide string " #actual " to be equal to " #expected_len) - -// Byte string equality check -#define ASSERT_ITS_EQUAL_BSTR(actual, expected) \ - TEST_ASSERT(strcmp((const char*)(actual), (const char*)(expected)) == 0, "Expected byte string " #actual " to be equal to " #expected) - -#define ASSERT_NOT_EQUAL_BSTR(actual, expected) \ - TEST_ASSERT(strcmp((const char*)(actual), (const char*)(expected)) != 0, "Expected byte string " #actual " to not be equal to " #expected) - -// For length comparison -#define ASSERT_ITS_LENGTH_EQUAL_BSTR(actual, expected_len) \ - TEST_ASSERT(strlen((const char*)(actual)) == (expected_len), "Expected length of byte string " #actual " to be equal to " #expected_len) - -// Classic C string equality check -#define ASSERT_ITS_EQUAL_CSTR(actual, expected) \ - TEST_ASSERT(strcmp((actual), (expected)) == 0, "Expected C string " #actual " to be equal to " #expected) - -#define ASSERT_NOT_EQUAL_CSTR(actual, expected) \ - TEST_ASSERT(strcmp((actual), (expected)) != 0, "Expected C string " #actual " to not be equal to " #expected) - -// For length comparison -#define ASSERT_ITS_LENGTH_EQUAL_CSTR(actual, expected_len) \ - TEST_ASSERT(strlen((actual)) == (expected_len), "Expected length of C string " #actual " to be equal to " #expected_len) - -// ************************************************** -// -// Array assertions -// -// ************************************************** - -// Array equality check -#define ASSERT_ITS_EQUAL_ARRAY(actual, expected, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_ASSERT((actual)[i] == (expected)[i], "Expected array element " #actual " to be equal to " #expected); \ - } - -// Array inequality check -#define ASSERT_NOT_EQUAL_ARRAY(actual, expected, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_ASSERT((actual)[i] != (expected)[i], "Expected array element " #actual " to not be equal to " #expected); \ - } - -// Array length check -#define ASSERT_ITS_LENGTH_EQUAL_ARRAY(actual_length, expected_length) \ - TEST_ASSERT((actual_length) == (expected_length), "Expected array length " #actual_length " to be equal to " #expected_length) - -// Array element within range check -#define ASSERT_ITS_WITHIN_RANGE_ARRAY(array, min, max, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_ASSERT((array)[i] >= (min) && (array)[i] <= (max), "Expected array element " #array " to be within range [" #min ", " #max "]"); \ - } - -// Array element not within range check -#define ASSERT_NOT_WITHIN_RANGE_ARRAY(array, min, max, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_ASSERT((array)[i] < (min) || (array)[i] > (max), "Expected array element " #array " to not be within range [" #min ", " #max "]"); \ - } - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/code/logic/fossil/unittest/assume.h b/code/logic/fossil/unittest/assume.h deleted file mode 100644 index 92a3a94d..00000000 --- a/code/logic/fossil/unittest/assume.h +++ /dev/null @@ -1,868 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_TEST_ASSUME_TYPE_H -#define FOSSIL_TEST_ASSUME_TYPE_H - -#include // using assurt rules from Fossil Test - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// ************************************************** -// -// Boolean ASSUMEions -// -// ************************************************** - -// Boolean ITS ASSUMEions -#define ASSUME_ITS_TRUE(actual) \ - TEST_ASSUME((actual), "Expected " #actual " to be true") - -#define ASSUME_ITS_FALSE(actual) \ - TEST_ASSUME(!(actual), "Expected " #actual " to be false") - -// Boolean NOT ASSUMEions -#define ASSUME_NOT_TRUE(actual) \ - TEST_ASSUME(!(actual), "Expected " #actual " to not be true") - -#define ASSUME_NOT_FALSE(actual) \ - TEST_ASSUME((actual), "Expected " #actual " to not be false") - -// ************************************************** -// -// Floating point ASSUMEions -// -// ************************************************** - -// Double equality check with tolerance -#define ASSUME_ITS_EQUAL_F64(actual, expected, tol) \ - TEST_ASSUME(fabs((actual) - (expected)) <= (tol), "Expected " #actual " to be equal to " #expected " within tolerance " #tol) - -#define ASSUME_ITS_LESS_THAN_F64(actual, expected) \ - TEST_ASSUME((actual) < (expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_F64(actual, expected) \ - TEST_ASSUME((actual) > (expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_F64(actual, expected) \ - TEST_ASSUME((actual) <= (expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_F64(actual, expected) \ - TEST_ASSUME((actual) >= (expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_F64(actual, expected, tol) \ - TEST_ASSUME(fabs((actual) - (expected)) > (tol), "Expected " #actual " to not be equal to " #expected " within tolerance " #tol) - -#define ASSUME_NOT_LESS_THAN_F64(actual, expected) \ - TEST_ASSUME((actual) >= (expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_F64(actual, expected) \ - TEST_ASSUME((actual) <= (expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_F64(actual, expected) \ - TEST_ASSUME((actual) > (expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_F64(actual, expected) \ - TEST_ASSUME((actual) < (expected), "Expected " #actual " to not be more than or equal to " #expected) - -// Float equality check with tolerance -#define ASSUME_ITS_EQUAL_F32(actual, expected, tol) \ - TEST_ASSUME(fabsf((actual) - (expected)) <= (tol), "Expected " #actual " to be equal to " #expected " within tolerance " #tol) - -#define ASSUME_ITS_LESS_THAN_F32(actual, expected) \ - TEST_ASSUME((actual) < (expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_F32(actual, expected) \ - TEST_ASSUME((actual) > (expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_F32(actual, expected) \ - TEST_ASSUME((actual) <= (expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_F32(actual, expected) \ - TEST_ASSUME((actual) >= (expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_F32(actual, expected, tol) \ - TEST_ASSUME(fabsf((actual) - (expected)) > (tol), "Expected " #actual " to not be equal to " #expected " within tolerance " #tol) - -#define ASSUME_NOT_LESS_THAN_F32(actual, expected) \ - TEST_ASSUME((actual) >= (expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_F32(actual, expected) \ - TEST_ASSUME((actual) <= (expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_F32(actual, expected) \ - TEST_ASSUME((actual) > (expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_F32(actual, expected) \ - TEST_ASSUME((actual) < (expected), "Expected " #actual " to not be more than or equal to " #expected) - -// Float NaN and Infinity checks -#define ASSUME_ITS_NAN_F32(actual) \ - TEST_ASSUME(isnan(actual), "Expected " #actual " to be NaN") - -#define ASSUME_ITS_INF_F32(actual) \ - TEST_ASSUME(isinf(actual), "Expected " #actual " to be infinity") - -// Double NaN and Infinity checks -#define ASSUME_ITS_NAN_F64(actual) \ - TEST_ASSUME(isnan(actual), "Expected " #actual " to be NaN") - -#define ASSUME_ITS_INF_F64(actual) \ - TEST_ASSUME(isinf(actual), "Expected " #actual " to be infinity") - -// ************************************************** -// -// Numaric ASSUMEions -// -// ************************************************** - -// Octal ASSUMEions - -// O8 ASSUMEions -#define ASSUME_ITS_EQUAL_O8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_O8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_O8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_O8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_O8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_O8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_O8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_O8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_O8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_O8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// O16 ASSUMEions -#define ASSUME_ITS_EQUAL_O16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_O16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_O16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_O16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_O16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_O16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_O16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_O16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_O16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_O16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// O32 ASSUMEions -#define ASSUME_ITS_EQUAL_O32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_O32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_O32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_O32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_O32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_O32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_O32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_O32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_O32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_O32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// OI64 ASSUMEions -#define ASSUME_ITS_EQUAL_O64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_O64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_O64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_O64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_O64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_O64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_O64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_O64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_O64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_O64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// Hexadecimal ASSUMEions - -// H8 ASSUMEions -#define ASSUME_ITS_EQUAL_H8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_H8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_H8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_H8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_H8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_H8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_H8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_H8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_H8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_H8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// H16 ASSUMEions -#define ASSUME_ITS_EQUAL_H16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_H16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_H16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_H16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_H16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_H16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_H16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_H16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_H16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_H16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// H32 ASSUMEions -#define ASSUME_ITS_EQUAL_H32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_H32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_H32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_H32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_H32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_H32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_H32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_H32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_H32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_H32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// H64 ASSUMEions -#define ASSUME_ITS_EQUAL_H64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_H64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_H64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_H64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_H64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_H64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_H64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_H64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_H64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_H64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I8 ASSUMEions -#define ASSUME_ITS_EQUAL_I8(actual, expected) \ - TEST_ASSUME((int8_t)(actual) == (int8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_I8(actual, expected) \ - TEST_ASSUME((int8_t)(actual) < (int8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_I8(actual, expected) \ - TEST_ASSUME((int8_t)(actual) > (int8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_I8(actual, expected) \ - TEST_ASSUME((int8_t)(actual) <= (int8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_I8(actual, expected) \ - TEST_ASSUME((int8_t)(actual) >= (int8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_I8(actual, expected) \ - TEST_ASSUME((int8_t)(actual) != (int8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_I8(actual, expected) \ - TEST_ASSUME((int8_t)(actual) >= (int8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_I8(actual, expected) \ - TEST_ASSUME((int8_t)(actual) <= (int8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_I8(actual, expected) \ - TEST_ASSUME((int8_t)(actual) > (int8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_I8(actual, expected) \ - TEST_ASSUME((int8_t)(actual) < (int8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I16 ASSUMEions -#define ASSUME_ITS_EQUAL_I16(actual, expected) \ - TEST_ASSUME((int16_t)(actual) == (int16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_I16(actual, expected) \ - TEST_ASSUME((int16_t)(actual) < (int16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_I16(actual, expected) \ - TEST_ASSUME((int16_t)(actual) > (int16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_I16(actual, expected) \ - TEST_ASSUME((int16_t)(actual) <= (int16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_I16(actual, expected) \ - TEST_ASSUME((int16_t)(actual) >= (int16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_I16(actual, expected) \ - TEST_ASSUME((int16_t)(actual) != (int16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_I16(actual, expected) \ - TEST_ASSUME((int16_t)(actual) >= (int16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_I16(actual, expected) \ - TEST_ASSUME((int16_t)(actual) <= (int16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_I16(actual, expected) \ - TEST_ASSUME((int16_t)(actual) > (int16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_I16(actual, expected) \ - TEST_ASSUME((int16_t)(actual) < (int16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I32 ASSUMEions -#define ASSUME_ITS_EQUAL_I32(actual, expected) \ - TEST_ASSUME((int32_t)(actual) == (int32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_I32(actual, expected) \ - TEST_ASSUME((int32_t)(actual) < (int32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_I32(actual, expected) \ - TEST_ASSUME((int32_t)(actual) > (int32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_I32(actual, expected) \ - TEST_ASSUME((int32_t)(actual) <= (int32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_I32(actual, expected) \ - TEST_ASSUME((int32_t)(actual) >= (int32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_I32(actual, expected) \ - TEST_ASSUME((int32_t)(actual) != (int32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_I32(actual, expected) \ - TEST_ASSUME((int32_t)(actual) >= (int32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_I32(actual, expected) \ - TEST_ASSUME((int32_t)(actual) <= (int32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_I32(actual, expected) \ - TEST_ASSUME((int32_t)(actual) > (int32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_I32(actual, expected) \ - TEST_ASSUME((int32_t)(actual) < (int32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I64 ASSUMEions -#define ASSUME_ITS_EQUAL_I64(actual, expected) \ - TEST_ASSUME((int64_t)(actual) == (int64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_I64(actual, expected) \ - TEST_ASSUME((int64_t)(actual) < (int64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_I64(actual, expected) \ - TEST_ASSUME((int64_t)(actual) > (int64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_I64(actual, expected) \ - TEST_ASSUME((int64_t)(actual) <= (int64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_I64(actual, expected) \ - TEST_ASSUME((int64_t)(actual) >= (int64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_I64(actual, expected) \ - TEST_ASSUME((int64_t)(actual) != (int64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_I64(actual, expected) \ - TEST_ASSUME((int64_t)(actual) >= (int64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_I64(actual, expected) \ - TEST_ASSUME((int64_t)(actual) <= (int64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_I64(actual, expected) \ - TEST_ASSUME((int64_t)(actual) > (int64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_I64(actual, expected) \ - TEST_ASSUME((int64_t)(actual) < (int64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U8 ASSUMEions -#define ASSUME_ITS_EQUAL_U8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_U8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_U8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_U8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_U8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_U8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_U8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_U8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_U8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_U8(actual, expected) \ - TEST_ASSUME((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U16 ASSUMEions -#define ASSUME_ITS_EQUAL_U16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_U16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_U16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_U16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_U16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_U16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_U16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_U16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_U16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_U16(actual, expected) \ - TEST_ASSUME((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U32 ASSUMEions -#define ASSUME_ITS_EQUAL_U32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_U32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_U32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_U32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_U32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_U32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_U32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_U32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_U32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_U32(actual, expected) \ - TEST_ASSUME((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U64 ASSUMEions -#define ASSUME_ITS_EQUAL_U64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define ASSUME_ITS_LESS_THAN_U64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define ASSUME_ITS_MORE_THAN_U64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define ASSUME_ITS_LESS_OR_EQUAL_U64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define ASSUME_ITS_MORE_OR_EQUAL_U64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define ASSUME_NOT_EQUAL_U64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define ASSUME_NOT_LESS_THAN_U64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define ASSUME_NOT_MORE_THAN_U64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define ASSUME_NOT_LESS_OR_EQUAL_U64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define ASSUME_NOT_MORE_OR_EQUAL_U64(actual, expected) \ - TEST_ASSUME((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// ************************************************** -// -// Null pointer ASSUMEions (_CNULL) -// -// ************************************************** - -// ITS set -#define ASSUME_ITS_CNULL(actual) \ - TEST_ASSUME((actual) == xnull, "Expected " #actual " to be xnull") - -#define ASSUME_NOT_CNULL(actual) \ - TEST_ASSUME((actual) != xnull, "Expected " #actual " to not be xnull") - -// General pointer ASSUMEions (_PTR) - -// ITS set -#define ASSUME_ITS_EQUAL_PTR(actual, expected) \ - TEST_ASSUME((actual) == (expected), "Expected pointer " #actual " to be equal to pointer " #expected " ") - -#define ASSUME_NOT_EQUAL_PTR(actual, expected) \ - TEST_ASSUME((actual) != (expected), "Expected pointer " #actual " to not be equal to pointer " #expected " ") - -// Size_t ASSUMEions - -// Equal -#define ASSUME_ITS_EQUAL_SIZE(actual, expected) \ - TEST_ASSUME((size_t)(actual) == (size_t)(expected), "Expected " #actual " to be equal to " #expected) - -// Less than -#define ASSUME_ITS_LESS_THAN_SIZE(actual, expected) \ - TEST_ASSUME((size_t)(actual) < (size_t)(expected), "Expected " #actual " to be less than " #expected) - -// More than -#define ASSUME_ITS_MORE_THAN_SIZE(actual, expected) \ - TEST_ASSUME((size_t)(actual) > (size_t)(expected), "Expected " #actual " to be more than " #expected) - -// Less or equal -#define ASSUME_ITS_LESS_OR_EQUAL_SIZE(actual, expected) \ - TEST_ASSUME((size_t)(actual) <= (size_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -// More or equal -#define ASSUME_ITS_MORE_OR_EQUAL_SIZE(actual, expected) \ - TEST_ASSUME((size_t)(actual) >= (size_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -// Not equal -#define ASSUME_NOT_EQUAL_SIZE(actual, expected) \ - TEST_ASSUME((size_t)(actual) != (size_t)(expected), "Expected " #actual " to not be equal to " #expected) - -// ************************************************** -// -// Range ASSUMEions -// -// ************************************************** - -// ASSUMEion for checking if a value is within a specified range -#define ASSUME_ITS_WITHIN_RANGE(value, min, max) \ - TEST_ASSUME((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE(value, min, max) \ - TEST_ASSUME((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") - -// Unsigned integer type ASSUMEions - -#define ASSUME_ITS_WITHIN_RANGE_U8(value, min, max) \ - TEST_ASSUME((uint8_t)(value) >= (uint8_t)(min) && (uint8_t)(value) <= (uint8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_U8(value, min, max) \ - TEST_ASSUME((uint8_t)(value) < (uint8_t)(min) || (uint8_t)(value) > (uint8_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSUME_ITS_WITHIN_RANGE_U16(value, min, max) \ - TEST_ASSUME((uint16_t)(value) >= (uint16_t)(min) && (uint16_t)(value) <= (uint16_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_U16(value, min, max) \ - TEST_ASSUME((uint16_t)(value) < (uint16_t)(min) || (uint16_t)(value) > (uint16_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSUME_ITS_WITHIN_RANGE_U32(value, min, max) \ - TEST_ASSUME((uint32_t)(value) >= (uint32_t)(min) && (uint32_t)(value) <= (uint32_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_U32(value, min, max) \ - TEST_ASSUME((uint32_t)(value) < (uint32_t)(min) || (uint32_t)(value) > (uint32_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSUME_ITS_WITHIN_RANGE_U64(value, min, max) \ - TEST_ASSUME((uint64_t)(value) >= (uint64_t)(min) && (uint64_t)(value) <= (uint64_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_U64(value, min, max) \ - TEST_ASSUME((uint64_t)(value) < (uint64_t)(min) || (uint64_t)(value) > (uint64_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Signed integer type ASSUMEions - -#define ASSUME_ITS_WITHIN_RANGE_I8(value, min, max) \ - TEST_ASSUME((int8_t)(value) >= (int8_t)(min) && (int8_t)(value) <= (int8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_I8(value, min, max) \ - TEST_ASSUME((int8_t)(value) < (int8_t)(min) || (int8_t)(value) > (int8_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSUME_ITS_WITHIN_RANGE_I16(value, min, max) \ - TEST_ASSUME((int16_t)(value) >= (int16_t)(min) && (int16_t)(value) <= (int16_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_I16(value, min, max) \ - TEST_ASSUME((int16_t)(value) < (int16_t)(min) || (int16_t)(value) > (int16_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSUME_ITS_WITHIN_RANGE_I32(value, min, max) \ - TEST_ASSUME((int32_t)(value) >= (int32_t)(min) && (int32_t)(value) <= (int32_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_I32(value, min, max) \ - TEST_ASSUME((int32_t)(value) < (int32_t)(min) || (int32_t)(value) > (int32_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSUME_ITS_WITHIN_RANGE_I64(value, min, max) \ - TEST_ASSUME((int64_t)(value) >= (int64_t)(min) && (int64_t)(value) <= (int64_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_I64(value, min, max) \ - TEST_ASSUME((int64_t)(value) < (int64_t)(min) || (int64_t)(value) > (int64_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Floating point type ASSUMEions - -#define ASSUME_ITS_WITHIN_RANGE_F32(value, min, max) \ - TEST_ASSUME((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_F32(value, min, max) \ - TEST_ASSUME((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") - -#define ASSUME_ITS_WITHIN_RANGE_F64(value, min, max) \ - TEST_ASSUME((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_F64(value, min, max) \ - TEST_ASSUME((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") - -// Byte char type ASSUMEions (uint8_t) - -#define ASSUME_ITS_WITHIN_RANGE_BCHAR(value, min, max) \ - TEST_ASSUME((uint8_t)(value) >= (uint8_t)(min) && (uint8_t)(value) <= (uint8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_BCHAR(value, min, max) \ - TEST_ASSUME((uint8_t)(value) < (uint8_t)(min) || (uint8_t)(value) > (uint8_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Char type ASSUMEions (char) - -#define ASSUME_ITS_WITHIN_RANGE_CCHAR(value, min, max) \ - TEST_ASSUME((char)(value) >= (char)(min) && (char)(value) <= (char)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_CCHAR(value, min, max) \ - TEST_ASSUME((char)(value) < (char)(min) || (char)(value) > (char)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Wide char type ASSUMEions (wchar_t) - -#define ASSUME_ITS_WITHIN_RANGE_WCHAR(value, min, max) \ - TEST_ASSUME((wchar_t)(value) >= (wchar_t)(min) && (wchar_t)(value) <= (wchar_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define ASSUME_NOT_WITHIN_RANGE_WCHAR(value, min, max) \ - TEST_ASSUME((wchar_t)(value) < (wchar_t)(min) || (wchar_t)(value) > (wchar_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// ************************************************** -// -// String ASSUMEions -// -// ************************************************** - -// Wide char string equality check -#define ASSUME_ITS_EQUAL_WSTR(actual, expected) \ - TEST_ASSUME(wcscmp((actual), (expected)) == 0, "Expected wide string " #actual " to be equal to " #expected) - -#define ASSUME_NOT_EQUAL_WSTR(actual, expected) \ - TEST_ASSUME(wcscmp((actual), (expected)) != 0, "Expected wide string " #actual " to not be equal to " #expected) - -// For length comparison -#define ASSUME_ITS_LENGTH_EQUAL_WSTR(actual, expected_len) \ - TEST_ASSUME(wcslen((actual)) == (expected_len), "Expected length of wide string " #actual " to be equal to " #expected_len) - -// Byte string equality check -#define ASSUME_ITS_EQUAL_BSTR(actual, expected) \ - TEST_ASSUME(strcmp((const char*)(actual), (const char*)(expected)) == 0, "Expected byte string " #actual " to be equal to " #expected) - -#define ASSUME_NOT_EQUAL_BSTR(actual, expected) \ - TEST_ASSUME(strcmp((const char*)(actual), (const char*)(expected)) != 0, "Expected byte string " #actual " to not be equal to " #expected) - -// For length comparison -#define ASSUME_ITS_LENGTH_EQUAL_BSTR(actual, expected_len) \ - TEST_ASSUME(strlen((const char*)(actual)) == (expected_len), "Expected length of byte string " #actual " to be equal to " #expected_len) - -// Classic C string equality check -#define ASSUME_ITS_EQUAL_CSTR(actual, expected) \ - TEST_ASSUME(strcmp((actual), (expected)) == 0, "Expected C string " #actual " to be equal to " #expected) - -#define ASSUME_NOT_EQUAL_CSTR(actual, expected) \ - TEST_ASSUME(strcmp((actual), (expected)) != 0, "Expected C string " #actual " to not be equal to " #expected) - -// For length comparison -#define ASSUME_ITS_LENGTH_EQUAL_CSTR(actual, expected_len) \ - TEST_ASSUME(strlen((actual)) == (expected_len), "Expected length of C string " #actual " to be equal to " #expected_len) - -// ************************************************** -// -// Array ASSUMEions -// -// ************************************************** - -// Array equality check -#define ASSUME_ITS_EQUAL_ARRAY(actual, expected, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_ASSUME((actual)[i] == (expected)[i], "Expected array element " #actual " to be equal to " #expected); \ - } - -// Array inequality check -#define ASSUME_NOT_EQUAL_ARRAY(actual, expected, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_ASSUME((actual)[i] != (expected)[i], "Expected array element " #actual " to not be equal to " #expected); \ - } - -// Array length check -#define ASSUME_ITS_LENGTH_EQUAL_ARRAY(actual_length, expected_length) \ - TEST_ASSUME((actual_length) == (expected_length), "Expected array length " #actual_length " to be equal to " #expected_length) - -// Array element within range check -#define ASSUME_ITS_WITHIN_RANGE_ARRAY(array, min, max, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_ASSUME((array)[i] >= (min) && (array)[i] <= (max), "Expected array element " #array " to be within range [" #min ", " #max "]"); \ - } - -// Array element not within range check -#define ASSUME_NOT_WITHIN_RANGE_ARRAY(array, min, max, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_ASSUME((array)[i] < (min) || (array)[i] > (max), "Expected array element " #array " to not be within range [" #min ", " #max "]"); \ - } - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/code/logic/fossil/unittest/commands.h b/code/logic/fossil/unittest/commands.h deleted file mode 100644 index c4a5d828..00000000 --- a/code/logic/fossil/unittest/commands.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_TEST_COMMANDS_H -#define FOSSIL_TEST_COMMANDS_H - -#include "fossil/_common/common.h" -#include "internal.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -// Define the structure to hold parsed options -typedef struct { - bool show_version; - bool show_help; - bool show_tip; - bool show_info; - bool show_author; - bool only_tags; - char only_tags_value[256]; - bool reverse; - bool repeat_enabled; - int repeat_count; - bool shuffle_enabled; - bool verbose_enabled; - int verbose_level; // 0 for cutback, 1 for normal, 2 for verbose - bool list_tests; - bool summary_enabled; - bool color_enabled; - bool sanity_enabled; -} fossil_options_t; - -extern fossil_options_t _CLI; - -/** - * Function to initialize the options structure. - * - * @return The options structure - */ -fossil_options_t fossil_options_parse(int argc, char **argv); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/code/logic/fossil/unittest/console.h b/code/logic/fossil/unittest/console.h deleted file mode 100644 index 1fdd630a..00000000 --- a/code/logic/fossil/unittest/console.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_TEST_CONSOLE_H -#define FOSSIL_TEST_CONSOLE_H - -#include "fossil/_common/common.h" -#include "internal.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * Function to print a message to the console with a specific color. - * - * @param color_name The name of the color - * @param format The format string - * @param ... The arguments to format - */ -void fossil_test_cout(const char* color_name, const char* format, ...); - -void fossil_test_io_information(void); -void fossil_test_io_sanity_load(fossil_test_t *test); -void fossil_test_io_unittest_given(char *description); -void fossil_test_io_unittest_when(char *description); -void fossil_test_io_unittest_then(char *description); - -void fossil_test_io_unittest_start(fossil_test_t *test); -void fossil_test_io_unittest_step(xassert_info *assume); -void fossil_test_io_unittest_ended(fossil_test_t *test); -void fossil_test_io_asserted(xassert_info *assume); -void fossil_test_io_summary_start(void); -void fossil_test_io_summary_ended(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/code/logic/fossil/unittest/expect.h b/code/logic/fossil/unittest/expect.h deleted file mode 100644 index baee353b..00000000 --- a/code/logic/fossil/unittest/expect.h +++ /dev/null @@ -1,868 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_TEST_EXPECT_TYPE_H -#define FOSSIL_TEST_EXPECT_TYPE_H - -#include // using assurt rules from Fossil Test - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// ************************************************** -// -// Boolean EXPECTions -// -// ************************************************** - -// Boolean ITS EXPECTions -#define EXPECT_ITS_TRUE(actual) \ - TEST_EXPECT((actual), "Expected " #actual " to be true") - -#define EXPECT_ITS_FALSE(actual) \ - TEST_EXPECT(!(actual), "Expected " #actual " to be false") - -// Boolean NOT EXPECTions -#define EXPECT_NOT_TRUE(actual) \ - TEST_EXPECT(!(actual), "Expected " #actual " to not be true") - -#define EXPECT_NOT_FALSE(actual) \ - TEST_EXPECT((actual), "Expected " #actual " to not be false") - -// ************************************************** -// -// Floating point EXPECTions -// -// ************************************************** - -// Double equality check with tolerance -#define EXPECT_ITS_EQUAL_F64(actual, expected, tol) \ - TEST_EXPECT(fabs((actual) - (expected)) <= (tol), "Expected " #actual " to be equal to " #expected " within tolerance " #tol) - -#define EXPECT_ITS_LESS_THAN_F64(actual, expected) \ - TEST_EXPECT((actual) < (expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_F64(actual, expected) \ - TEST_EXPECT((actual) > (expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_F64(actual, expected) \ - TEST_EXPECT((actual) <= (expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_F64(actual, expected) \ - TEST_EXPECT((actual) >= (expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_F64(actual, expected, tol) \ - TEST_EXPECT(fabs((actual) - (expected)) > (tol), "Expected " #actual " to not be equal to " #expected " within tolerance " #tol) - -#define EXPECT_NOT_LESS_THAN_F64(actual, expected) \ - TEST_EXPECT((actual) >= (expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_F64(actual, expected) \ - TEST_EXPECT((actual) <= (expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_F64(actual, expected) \ - TEST_EXPECT((actual) > (expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_F64(actual, expected) \ - TEST_EXPECT((actual) < (expected), "Expected " #actual " to not be more than or equal to " #expected) - -// Float equality check with tolerance -#define EXPECT_ITS_EQUAL_F32(actual, expected, tol) \ - TEST_EXPECT(fabsf((actual) - (expected)) <= (tol), "Expected " #actual " to be equal to " #expected " within tolerance " #tol) - -#define EXPECT_ITS_LESS_THAN_F32(actual, expected) \ - TEST_EXPECT((actual) < (expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_F32(actual, expected) \ - TEST_EXPECT((actual) > (expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_F32(actual, expected) \ - TEST_EXPECT((actual) <= (expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_F32(actual, expected) \ - TEST_EXPECT((actual) >= (expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_F32(actual, expected, tol) \ - TEST_EXPECT(fabsf((actual) - (expected)) > (tol), "Expected " #actual " to not be equal to " #expected " within tolerance " #tol) - -#define EXPECT_NOT_LESS_THAN_F32(actual, expected) \ - TEST_EXPECT((actual) >= (expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_F32(actual, expected) \ - TEST_EXPECT((actual) <= (expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_F32(actual, expected) \ - TEST_EXPECT((actual) > (expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_F32(actual, expected) \ - TEST_EXPECT((actual) < (expected), "Expected " #actual " to not be more than or equal to " #expected) - -// Float NaN and Infinity checks -#define EXPECT_ITS_NAN_F32(actual) \ - TEST_EXPECT(isnan(actual), "Expected " #actual " to be NaN") - -#define EXPECT_ITS_INF_F32(actual) \ - TEST_EXPECT(isinf(actual), "Expected " #actual " to be infinity") - -// Double NaN and Infinity checks -#define EXPECT_ITS_NAN_F64(actual) \ - TEST_EXPECT(isnan(actual), "Expected " #actual " to be NaN") - -#define EXPECT_ITS_INF_F64(actual) \ - TEST_EXPECT(isinf(actual), "Expected " #actual " to be infinity") - -// ************************************************** -// -// Numaric EXPECTions -// -// ************************************************** - -// Octal EXPECTions - -// O8 EXPECTions -#define EXPECT_ITS_EQUAL_O8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_O8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_O8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_O8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_O8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_O8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_O8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_O8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_O8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_O8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// O16 EXPECTions -#define EXPECT_ITS_EQUAL_O16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_O16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_O16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_O16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_O16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_O16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_O16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_O16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_O16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_O16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// O32 EXPECTions -#define EXPECT_ITS_EQUAL_O32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_O32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_O32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_O32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_O32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_O32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_O32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_O32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_O32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_O32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// OI64 EXPECTions -#define EXPECT_ITS_EQUAL_O64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_O64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_O64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_O64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_O64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_O64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_O64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_O64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_O64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_O64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// Hexadecimal EXPECTions - -// H8 EXPECTions -#define EXPECT_ITS_EQUAL_H8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_H8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_H8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_H8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_H8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_H8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_H8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_H8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_H8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_H8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// H16 EXPECTions -#define EXPECT_ITS_EQUAL_H16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_H16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_H16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_H16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_H16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_H16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_H16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_H16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_H16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_H16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// H32 EXPECTions -#define EXPECT_ITS_EQUAL_H32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_H32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_H32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_H32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_H32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_H32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_H32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_H32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_H32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_H32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// H64 EXPECTions -#define EXPECT_ITS_EQUAL_H64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_H64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_H64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_H64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_H64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_H64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_H64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_H64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_H64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_H64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I8 EXPECTions -#define EXPECT_ITS_EQUAL_I8(actual, expected) \ - TEST_EXPECT((int8_t)(actual) == (int8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_I8(actual, expected) \ - TEST_EXPECT((int8_t)(actual) < (int8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_I8(actual, expected) \ - TEST_EXPECT((int8_t)(actual) > (int8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_I8(actual, expected) \ - TEST_EXPECT((int8_t)(actual) <= (int8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_I8(actual, expected) \ - TEST_EXPECT((int8_t)(actual) >= (int8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_I8(actual, expected) \ - TEST_EXPECT((int8_t)(actual) != (int8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_I8(actual, expected) \ - TEST_EXPECT((int8_t)(actual) >= (int8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_I8(actual, expected) \ - TEST_EXPECT((int8_t)(actual) <= (int8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_I8(actual, expected) \ - TEST_EXPECT((int8_t)(actual) > (int8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_I8(actual, expected) \ - TEST_EXPECT((int8_t)(actual) < (int8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I16 EXPECTions -#define EXPECT_ITS_EQUAL_I16(actual, expected) \ - TEST_EXPECT((int16_t)(actual) == (int16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_I16(actual, expected) \ - TEST_EXPECT((int16_t)(actual) < (int16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_I16(actual, expected) \ - TEST_EXPECT((int16_t)(actual) > (int16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_I16(actual, expected) \ - TEST_EXPECT((int16_t)(actual) <= (int16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_I16(actual, expected) \ - TEST_EXPECT((int16_t)(actual) >= (int16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_I16(actual, expected) \ - TEST_EXPECT((int16_t)(actual) != (int16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_I16(actual, expected) \ - TEST_EXPECT((int16_t)(actual) >= (int16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_I16(actual, expected) \ - TEST_EXPECT((int16_t)(actual) <= (int16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_I16(actual, expected) \ - TEST_EXPECT((int16_t)(actual) > (int16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_I16(actual, expected) \ - TEST_EXPECT((int16_t)(actual) < (int16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I32 EXPECTions -#define EXPECT_ITS_EQUAL_I32(actual, expected) \ - TEST_EXPECT((int32_t)(actual) == (int32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_I32(actual, expected) \ - TEST_EXPECT((int32_t)(actual) < (int32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_I32(actual, expected) \ - TEST_EXPECT((int32_t)(actual) > (int32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_I32(actual, expected) \ - TEST_EXPECT((int32_t)(actual) <= (int32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_I32(actual, expected) \ - TEST_EXPECT((int32_t)(actual) >= (int32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_I32(actual, expected) \ - TEST_EXPECT((int32_t)(actual) != (int32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_I32(actual, expected) \ - TEST_EXPECT((int32_t)(actual) >= (int32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_I32(actual, expected) \ - TEST_EXPECT((int32_t)(actual) <= (int32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_I32(actual, expected) \ - TEST_EXPECT((int32_t)(actual) > (int32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_I32(actual, expected) \ - TEST_EXPECT((int32_t)(actual) < (int32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// I64 EXPECTions -#define EXPECT_ITS_EQUAL_I64(actual, expected) \ - TEST_EXPECT((int64_t)(actual) == (int64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_I64(actual, expected) \ - TEST_EXPECT((int64_t)(actual) < (int64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_I64(actual, expected) \ - TEST_EXPECT((int64_t)(actual) > (int64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_I64(actual, expected) \ - TEST_EXPECT((int64_t)(actual) <= (int64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_I64(actual, expected) \ - TEST_EXPECT((int64_t)(actual) >= (int64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_I64(actual, expected) \ - TEST_EXPECT((int64_t)(actual) != (int64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_I64(actual, expected) \ - TEST_EXPECT((int64_t)(actual) >= (int64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_I64(actual, expected) \ - TEST_EXPECT((int64_t)(actual) <= (int64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_I64(actual, expected) \ - TEST_EXPECT((int64_t)(actual) > (int64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_I64(actual, expected) \ - TEST_EXPECT((int64_t)(actual) < (int64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U8 EXPECTions -#define EXPECT_ITS_EQUAL_U8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) == (uint8_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_U8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_U8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_U8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_U8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_U8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) != (uint8_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_U8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) >= (uint8_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_U8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) <= (uint8_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_U8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) > (uint8_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_U8(actual, expected) \ - TEST_EXPECT((uint8_t)(actual) < (uint8_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U16 EXPECTions -#define EXPECT_ITS_EQUAL_U16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) == (uint16_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_U16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_U16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_U16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_U16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_U16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) != (uint16_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_U16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) >= (uint16_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_U16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) <= (uint16_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_U16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) > (uint16_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_U16(actual, expected) \ - TEST_EXPECT((uint16_t)(actual) < (uint16_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U32 EXPECTions -#define EXPECT_ITS_EQUAL_U32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) == (uint32_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_U32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_U32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_U32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_U32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_U32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) != (uint32_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_U32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) >= (uint32_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_U32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) <= (uint32_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_U32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) > (uint32_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_U32(actual, expected) \ - TEST_EXPECT((uint32_t)(actual) < (uint32_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// U64 EXPECTions -#define EXPECT_ITS_EQUAL_U64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) == (uint64_t)(expected), "Expected " #actual " to be equal to " #expected) - -#define EXPECT_ITS_LESS_THAN_U64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to be less than " #expected) - -#define EXPECT_ITS_MORE_THAN_U64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to be more than " #expected) - -#define EXPECT_ITS_LESS_OR_EQUAL_U64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -#define EXPECT_ITS_MORE_OR_EQUAL_U64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -#define EXPECT_NOT_EQUAL_U64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) != (uint64_t)(expected), "Expected " #actual " to not be equal to " #expected) - -#define EXPECT_NOT_LESS_THAN_U64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) >= (uint64_t)(expected), "Expected " #actual " to not be less than " #expected) - -#define EXPECT_NOT_MORE_THAN_U64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) <= (uint64_t)(expected), "Expected " #actual " to not be more than " #expected) - -#define EXPECT_NOT_LESS_OR_EQUAL_U64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) > (uint64_t)(expected), "Expected " #actual " to not be less than or equal to " #expected) - -#define EXPECT_NOT_MORE_OR_EQUAL_U64(actual, expected) \ - TEST_EXPECT((uint64_t)(actual) < (uint64_t)(expected), "Expected " #actual " to not be more than or equal to " #expected) - -// ************************************************** -// -// Null pointer EXPECTions (_CNULL) -// -// ************************************************** - -// ITS set -#define EXPECT_ITS_CNULL(actual) \ - TEST_EXPECT((actual) == xnull, "Expected " #actual " to be xnull") - -#define EXPECT_NOT_CNULL(actual) \ - TEST_EXPECT((actual) != xnull, "Expected " #actual " to not be xnull") - -// General pointer EXPECTions (_PTR) - -// ITS set -#define EXPECT_ITS_EQUAL_PTR(actual, expected) \ - TEST_EXPECT((actual) == (expected), "Expected pointer " #actual " to be equal to pointer " #expected " ") - -#define EXPECT_NOT_EQUAL_PTR(actual, expected) \ - TEST_EXPECT((actual) != (expected), "Expected pointer " #actual " to not be equal to pointer " #expected " ") - -// Size_t EXPECTions - -// Equal -#define EXPECT_ITS_EQUAL_SIZE(actual, expected) \ - TEST_EXPECT((size_t)(actual) == (size_t)(expected), "Expected " #actual " to be equal to " #expected) - -// Less than -#define EXPECT_ITS_LESS_THAN_SIZE(actual, expected) \ - TEST_EXPECT((size_t)(actual) < (size_t)(expected), "Expected " #actual " to be less than " #expected) - -// More than -#define EXPECT_ITS_MORE_THAN_SIZE(actual, expected) \ - TEST_EXPECT((size_t)(actual) > (size_t)(expected), "Expected " #actual " to be more than " #expected) - -// Less or equal -#define EXPECT_ITS_LESS_OR_EQUAL_SIZE(actual, expected) \ - TEST_EXPECT((size_t)(actual) <= (size_t)(expected), "Expected " #actual " to be less than or equal to " #expected) - -// More or equal -#define EXPECT_ITS_MORE_OR_EQUAL_SIZE(actual, expected) \ - TEST_EXPECT((size_t)(actual) >= (size_t)(expected), "Expected " #actual " to be more than or equal to " #expected) - -// Not equal -#define EXPECT_NOT_EQUAL_SIZE(actual, expected) \ - TEST_EXPECT((size_t)(actual) != (size_t)(expected), "Expected " #actual " to not be equal to " #expected) - -// ************************************************** -// -// Range EXPECTions -// -// ************************************************** - -// EXPECTion for checking if a value is within a specified range -#define EXPECT_ITS_WITHIN_RANGE(value, min, max) \ - TEST_EXPECT((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE(value, min, max) \ - TEST_EXPECT((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") - -// Unsigned integer type EXPECTions - -#define EXPECT_ITS_WITHIN_RANGE_U8(value, min, max) \ - TEST_EXPECT((uint8_t)(value) >= (uint8_t)(min) && (uint8_t)(value) <= (uint8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_U8(value, min, max) \ - TEST_EXPECT((uint8_t)(value) < (uint8_t)(min) || (uint8_t)(value) > (uint8_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define EXPECT_ITS_WITHIN_RANGE_U16(value, min, max) \ - TEST_EXPECT((uint16_t)(value) >= (uint16_t)(min) && (uint16_t)(value) <= (uint16_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_U16(value, min, max) \ - TEST_EXPECT((uint16_t)(value) < (uint16_t)(min) || (uint16_t)(value) > (uint16_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define EXPECT_ITS_WITHIN_RANGE_U32(value, min, max) \ - TEST_EXPECT((uint32_t)(value) >= (uint32_t)(min) && (uint32_t)(value) <= (uint32_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_U32(value, min, max) \ - TEST_EXPECT((uint32_t)(value) < (uint32_t)(min) || (uint32_t)(value) > (uint32_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define EXPECT_ITS_WITHIN_RANGE_U64(value, min, max) \ - TEST_EXPECT((uint64_t)(value) >= (uint64_t)(min) && (uint64_t)(value) <= (uint64_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_U64(value, min, max) \ - TEST_EXPECT((uint64_t)(value) < (uint64_t)(min) || (uint64_t)(value) > (uint64_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Signed integer type EXPECTions - -#define EXPECT_ITS_WITHIN_RANGE_I8(value, min, max) \ - TEST_EXPECT((int8_t)(value) >= (int8_t)(min) && (int8_t)(value) <= (int8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_I8(value, min, max) \ - TEST_EXPECT((int8_t)(value) < (int8_t)(min) || (int8_t)(value) > (int8_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define EXPECT_ITS_WITHIN_RANGE_I16(value, min, max) \ - TEST_EXPECT((int16_t)(value) >= (int16_t)(min) && (int16_t)(value) <= (int16_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_I16(value, min, max) \ - TEST_EXPECT((int16_t)(value) < (int16_t)(min) || (int16_t)(value) > (int16_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define EXPECT_ITS_WITHIN_RANGE_I32(value, min, max) \ - TEST_EXPECT((int32_t)(value) >= (int32_t)(min) && (int32_t)(value) <= (int32_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_I32(value, min, max) \ - TEST_EXPECT((int32_t)(value) < (int32_t)(min) || (int32_t)(value) > (int32_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -#define EXPECT_ITS_WITHIN_RANGE_I64(value, min, max) \ - TEST_EXPECT((int64_t)(value) >= (int64_t)(min) && (int64_t)(value) <= (int64_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_I64(value, min, max) \ - TEST_EXPECT((int64_t)(value) < (int64_t)(min) || (int64_t)(value) > (int64_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Floating point type EXPECTions - -#define EXPECT_ITS_WITHIN_RANGE_F32(value, min, max) \ - TEST_EXPECT((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_F32(value, min, max) \ - TEST_EXPECT((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") - -#define EXPECT_ITS_WITHIN_RANGE_F64(value, min, max) \ - TEST_EXPECT((value) >= (min) && (value) <= (max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_F64(value, min, max) \ - TEST_EXPECT((value) < (min) || (value) > (max), "Value " #value " is within range [" #min ", " #max "]") - -// Byte char type EXPECTions (uint8_t) - -#define EXPECT_ITS_WITHIN_RANGE_BCHAR(value, min, max) \ - TEST_EXPECT((uint8_t)(value) >= (uint8_t)(min) && (uint8_t)(value) <= (uint8_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_BCHAR(value, min, max) \ - TEST_EXPECT((uint8_t)(value) < (uint8_t)(min) || (uint8_t)(value) > (uint8_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Char type EXPECTions (char) - -#define EXPECT_ITS_WITHIN_RANGE_CCHAR(value, min, max) \ - TEST_EXPECT((char)(value) >= (char)(min) && (char)(value) <= (char)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_CCHAR(value, min, max) \ - TEST_EXPECT((char)(value) < (char)(min) || (char)(value) > (char)(max), "Value " #value " is within range [" #min ", " #max "]") - -// Wide char type EXPECTions (wchar_t) - -#define EXPECT_ITS_WITHIN_RANGE_WCHAR(value, min, max) \ - TEST_EXPECT((wchar_t)(value) >= (wchar_t)(min) && (wchar_t)(value) <= (wchar_t)(max), "Value " #value " is not within range [" #min ", " #max "]") - -#define EXPECT_NOT_WITHIN_RANGE_WCHAR(value, min, max) \ - TEST_EXPECT((wchar_t)(value) < (wchar_t)(min) || (wchar_t)(value) > (wchar_t)(max), "Value " #value " is within range [" #min ", " #max "]") - -// ************************************************** -// -// String EXPECTions -// -// ************************************************** - -// Wide char string equality check -#define EXPECT_ITS_EQUAL_WSTR(actual, expected) \ - TEST_EXPECT(wcscmp((actual), (expected)) == 0, "Expected wide string " #actual " to be equal to " #expected) - -#define EXPECT_NOT_EQUAL_WSTR(actual, expected) \ - TEST_EXPECT(wcscmp((actual), (expected)) != 0, "Expected wide string " #actual " to not be equal to " #expected) - -// For length comparison -#define EXPECT_ITS_LENGTH_EQUAL_WSTR(actual, expected_len) \ - TEST_EXPECT(wcslen((actual)) == (expected_len), "Expected length of wide string " #actual " to be equal to " #expected_len) - -// Byte string equality check -#define EXPECT_ITS_EQUAL_BSTR(actual, expected) \ - TEST_EXPECT(strcmp((const char*)(actual), (const char*)(expected)) == 0, "Expected byte string " #actual " to be equal to " #expected) - -#define EXPECT_NOT_EQUAL_BSTR(actual, expected) \ - TEST_EXPECT(strcmp((const char*)(actual), (const char*)(expected)) != 0, "Expected byte string " #actual " to not be equal to " #expected) - -// For length comparison -#define EXPECT_ITS_LENGTH_EQUAL_BSTR(actual, expected_len) \ - TEST_EXPECT(strlen((const char*)(actual)) == (expected_len), "Expected length of byte string " #actual " to be equal to " #expected_len) - -// Classic C string equality check -#define EXPECT_ITS_EQUAL_CSTR(actual, expected) \ - TEST_EXPECT(strcmp((actual), (expected)) == 0, "Expected C string " #actual " to be equal to " #expected) - -#define EXPECT_NOT_EQUAL_CSTR(actual, expected) \ - TEST_EXPECT(strcmp((actual), (expected)) != 0, "Expected C string " #actual " to not be equal to " #expected) - -// For length comparison -#define EXPECT_ITS_LENGTH_EQUAL_CSTR(actual, expected_len) \ - TEST_EXPECT(strlen((actual)) == (expected_len), "Expected length of C string " #actual " to be equal to " #expected_len) - -// ************************************************** -// -// Array EXPECTions -// -// ************************************************** - -// Array equality check -#define EXPECT_ITS_EQUAL_ARRAY(actual, expected, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_EXPECT((actual)[i] == (expected)[i], "Expected array element " #actual " to be equal to " #expected); \ - } - -// Array inequality check -#define EXPECT_NOT_EQUAL_ARRAY(actual, expected, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_EXPECT((actual)[i] != (expected)[i], "Expected array element " #actual " to not be equal to " #expected); \ - } - -// Array length check -#define EXPECT_ITS_LENGTH_EQUAL_ARRAY(actual_length, expected_length) \ - TEST_EXPECT((actual_length) == (expected_length), "Expected array length " #actual_length " to be equal to " #expected_length) - -// Array element within range check -#define EXPECT_ITS_WITHIN_RANGE_ARRAY(array, min, max, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_EXPECT((array)[i] >= (min) && (array)[i] <= (max), "Expected array element " #array " to be within range [" #min ", " #max "]"); \ - } - -// Array element not within range check -#define EXPECT_NOT_WITHIN_RANGE_ARRAY(array, min, max, length) \ - for (size_t i = 0; i < (length); i++) { \ - TEST_EXPECT((array)[i] < (min) || (array)[i] > (max), "Expected array element " #array " to not be within range [" #min ", " #max "]"); \ - } - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/code/logic/fossil/unittest/framework.h b/code/logic/fossil/unittest/framework.h deleted file mode 100644 index 966ada6f..00000000 --- a/code/logic/fossil/unittest/framework.h +++ /dev/null @@ -1,695 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_TEST_FRAMEWORK_H -#define FOSSIL_TEST_FRAMEWORK_H - -// Fossil test specific header section of the test framework - -#include "fossil/_common/common.h" -#include "fossil/_common/platform.h" -#include "internal.h" -#include "console.h" -#include "commands.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern fossil_env_t _TEST_ENV; -extern xassert_info _ASSERT_INFO; - -// ================================================================= -// Initial implementation -// ================================================================= - -// Function prototypes -fossil_env_t fossil_test_environment_create(int argc, char **argv); -void fossil_test_environment_run(fossil_env_t *env); -void fossil_test_environment_add(fossil_env_t *env, fossil_test_t *test, fossil_fixture_t *fixture); -int fossil_test_environment_summary(void); - -void fossil_test_apply_mark(fossil_test_t *test, const char *mark); -void fossil_test_apply_xtag(fossil_test_t *test, const char *tag); -void fossil_test_apply_priority(fossil_test_t *test, const char *priority); - -/** - * @brief Internal function for handling test assertions. - * - * @param expression The expression to evaluate. - * @param behavior The behavior of the assertion (e.g., ASSERT, EXPECT, ASSUME). - * @param message The message associated with the assertion. - * @param file The file name where the assertion occurred. - * @param line The line number where the assertion occurred. - * @param func The function name where the assertion occurred. - */ -void _fossil_test_assert_class(bool expression, xassert_type_t behavior, char* message, char* file, int line, char* func); - - -/** - * @brief Macro to apply a priority to a test case. - * - * This macro is used to apply a priority to a test case. It is used in conjunction - * with the _APPLY_PRIORITY macro to define the priority to be applied. - * - * @param test_case The test case to which the priority is to be applied. - * @param priority The priority to be applied. - */ -#define _APPLY_PRIORITY(test_case, priority) fossil_test_apply_priority(test_case, (char*)priority) - -/** - * @brief Macro to apply a tag to a test case. - * - * This macro is used to apply a tag to a test case. It is used in conjunction - * with the _APPLY_XTAG macro to define the tag to be applied. - * - * @param test_case The test case to which the tag is to be applied. - * @param xtag The tag to be applied. - */ -#define _APPLY_XTAG(test_case, xtag) fossil_test_apply_xtag(&test_case, (char*)xtag) - -/** - * @brief Macro to apply a mark to a test case. - * - * This macro is used to apply a mark to a test case. It is used in conjunction - * with the _APPLY_MARK macro to define the mark to be applied. - * - * @param test_case The test case to which the mark is to be applied. - * @param mark The mark to be applied. - */ -#define _APPLY_MARK(test_case, mark) fossil_test_apply_mark(&test_case, (char*)mark) - -/** - * @brief Macro to add a test case. - * - * This macro is used to add a test case. It is used in conjunction with the - * _ADD_TEST macro to define the test case function. - * - * @param test_case The test case to be added. - */ -#define _ADD_TEST(test_case) fossil_test_environment_add(test_env, &test_case, xnullptr) - -/** - * @brief Macro to add a test case with a fixture. - * - * This macro is used to add a test case with a fixture. It is used in conjunction - * with the _FOSSIL_FIXTURE macro to define the fixture structure. - * - * @param test_case The test case to be added. - * @param fixture The fixture to be added. - */ -#define _ADD_TESTF(test_case, fixture) fossil_test_environment_add(test_env, &test_case, &fixture) - -/** - * @brief Macro to define a fixture. - * - * This macro is used to define a fixture. It is used in conjunction with the - * _FOSSIL_SETUP and _FOSSIL_TEARDOWN macros to define the setup and teardown functions for - * the fixture. - * - * @param fixture_name The name of the fixture. - * @param setup The setup function for the fixture. - * @param teardown The teardown function for the fixture. - */ -#define _FOSSIL_FIXTURE(fixture_name) \ - void setup_##fixture_name(void); \ - void teardown_##fixture_name(void); \ - fossil_fixture_t fixture_name = { setup_##fixture_name, teardown_##fixture_name } - -/** - * @brief Macro to define a setup function for a fixture. - * - * This macro is used to define a setup function for a fixture. It is used in - * conjunction with the _FOSSIL_FIXTURE macro to define the fixture structure. - * - * @param fixture_name The name of the fixture. - */ -#define _FOSSIL_SETUP(fixture_name) void setup_##fixture_name(void) - -/** - * @brief Macro to define a teardown function for a fixture. - * - * This macro is used to define a teardown function for a fixture. It is used in - * conjunction with the _FOSSIL_FIXTURE macro to define the fixture structure. - * - * @param fixture_name The name of the fixture. - */ -#define _FOSSIL_TEARDOWN(fixture_name) void teardown_##fixture_name(void) - -/** - * @brief Macro to define a test case. - * - * This macro is used to define a test case. It is used in conjunction with the - * _FOSSIL_TEST macro to define the test case function. - * - * @param name The name of the test case. - */ -#define _FOSSIL_TEST(name) \ - void name##_fossil_test(void); \ - fossil_test_t name = { \ - (char*)#name, \ - name##_fossil_test, \ - (char*)"fossil", \ - (char*)"fossil", \ - {0, 0, 0, {0, 0, 0, 0, 0}}, \ - {xnull, xnull}, \ - 0, \ - xnull, \ - xnull \ - }; \ - void name##_fossil_test(void) - -/** - * @brief Macro to define a test case with a priority. - * - * This macro is used to define a test case with a priority. It is used in conjunction - * with the _FOSSIL_TEST macro to define the test case function. - * - * @param name The name of the test case. - * @param priority The priority of the test case. - */ -#define _FOSSIL_TEST_ERASE() fossil_test_environment_summary() - -/** Macro to create the test environment. - * - * This macro is used to create the test environment by calling the _fossil_test_environment_create function. - * - * @param argc The number of command line arguments. - * @param argv The array of command line arguments. - */ -#define _FOSSIL_TEST_CREATE(argc, argv) _TEST_ENV = fossil_test_environment_create(argc, argv) - -/** Macro to run the test environment. - * - * This macro is used to run the test environment by calling the fossil_test_environment_run function. - */ -#define _FOSSIL_TEST_RUN() fossil_test_environment_run(&_TEST_ENV) - -/** - * @brief Define macro for defining a test queue. - * - * This macro is used to define a test queue function for a specific test group. - * It creates a function definition with the given group name and accepts a pointer - * to a TestRegistry structure as a parameter. This function typically registers - * all tests within the specified test group to the provided test registry. - * - * @param group_name The name of the test group. - */ -#define _FOSSIL_TEST_GROUP(group_name) void group_name(fossil_env_t* test_env) - -/** - * @brief Define macro for declaring an external test queue. - * - * This macro is used to declare an external test queue function for a specific - * test group. It creates an external function declaration with the given group name - * and accepts a pointer to a TestRegistry structure as a parameter. This declaration - * allows the test queue function to be defined in a separate source file and linked - * with the test framework. - * - * @param group_name The name of the test group. - */ -#define _FOSSIL_TEST_EXPORT(group_name) extern void group_name(fossil_env_t* test_env) - -/** - * @brief Define macro for importing and executing a test queue. - * - * This macro is used to import and execute a test queue function for a specific - * test group. It calls the test queue function with the provided TestRegistry - * structure, typically registering all tests within the specified test group - * to the test registry. - * - * @param group_name The name of the test group. - */ -#define _FOSSIL_TEST_IMPORT(group_name) group_name(&_TEST_ENV) - -#define _GIVEN(description) fossil_test_io_unittest_given(description); if (true) -#define _WHEN(description) fossil_test_io_unittest_when(description); if (true) -#define _THEN(description) fossil_test_io_unittest_then(description); if (true) - - - -// ================================================================= -// XTest create and erase commands -// ================================================================= - -/** - * Macro to create and initialize a test environment. - * This macro simplifies the process of calling the function to create a test environment, - * making the code more concise and readable. It initializes an fossil_env_t structure named `test_env`, - * which is used to manage the state and configuration of the test environment. - * - * Usage: FOSSIL_TEST_CREATE(argc, argv) - * - * @param argc The argument count from the command line. This is typically passed from the `main` function. - * @param argv The argument vector from the command line. This is typically passed from the `main` function. - * - * Example: - * int main(int argc, char *argv[]) { - * // Initialize the test environment with command-line arguments - * FOSSIL_TEST_CREATE(argc, argv); - * - * // Your test code here - * - * // Clean up the test environment before exiting - * return FOSSIL_TEST_ERASE(); - * } - */ -#define FOSSIL_TEST_CREATE(argc, argv) _FOSSIL_TEST_CREATE(argc, argv) - -/** - * @brief Macro to start the execution of the test environment. - * - * This macro serves as the primary entry point to run all the tests - * defined within the testing framework. When invoked, it calls the - * `_fossil_test_environment_run` function, which initializes the testing - * environment, executes all the test cases, and provides a summary - * of the test results. - * - * @details - * The `_fossil_test_environment_run` function performs several key tasks: - * 1. Initializes the test environment, which includes setting up - * necessary data structures, parsing command-line arguments, - * and preparing for test execution. - * 2. Executes each test case in the order they were defined or - * according to specified priorities. - * 3. Collects and aggregates test results, including counts of - * passed, failed, skipped, and timed-out tests. - * 4. Generates and outputs a summary report of the test execution, - * providing detailed information about each test case and the - * overall testing outcome. - * - * Usage: - * To use this macro, simply include it at the point in your test - * program where you want to initiate the test execution. Typically, - * this is done at the end of the `main` function after all test - * cases have been defined and added to the test suite. - * - * Example: - * @code - * int main(int argc, char *argv[]) { - * // Initialize the test suite and define test cases - * fossil_test_define_cases(); - * - * // Run all defined test cases - * FOSSIL_TEST_RUN(); - * - * return 0; - * } - * @endcode - * - * Note: - * - Ensure that all test cases are defined and properly configured - * before invoking `FOSSIL_TEST_RUN()`. Any test cases added after the - * macro is called will not be executed. - * - This macro abstracts the complexity of the underlying test - * execution function, providing a clean and simple interface for - * running the tests. - * - * @see _fossil_test_environment_run - */ -#define FOSSIL_TEST_RUN() _FOSSIL_TEST_RUN() - -/** - * Macro to erase and clean up the test environment. - * This macro simplifies the process of calling the function to clean up the test environment, - * ensuring that all allocated resources are properly released and the environment is reset. - * It operates on the `test_env` variable that was initialized using the FOSSIL_TEST_CREATE macro. - * - * Usage: FOSSIL_TEST_ERASE() - * - * Example: - * int main(int argc, char *argv[]) { - * // Initialize the test environment with command-line arguments - * FOSSIL_TEST_CREATE(argc, argv); - * - * // Your test code here - * - * // Clean up the test environment before exiting - * return FOSSIL_TEST_ERASE(); - * } - */ -#define FOSSIL_TEST_ERASE() _FOSSIL_TEST_ERASE() - -// ================================================================= -// XTest run commands -// ================================================================= - -/** - * @brief Assign a mark to a test case. - * - * This macro is used to apply a mark to a given test case. It wraps the - * _fossil_test_apply_mark function, providing a convenient way to mark test cases - * with specific attributes or states. - * - * @param test_case The test case to which the mark will be applied. This should - * be a valid identifier for a registered test case. - * @param mark The mark to assign to the test case. This is typically a string - * used to indicate specific attributes or states of the test case. - * The mark is cast to char* for compatibility. - * - * Example usage: - * - * APPLY_MARK(my_test_case, "skip"); - * - * This would mark 'my_test_case' with the "skip" mark, indicating that the test - * should be skipped during execution. - */ -#define APPLY_MARK(test_case, mark) _APPLY_MARK(test_case, mark) - -/** - * @brief Assign an xtag to a test case. - * - * This macro is used to apply an xtag (extra tag) to a given test case. It wraps - * the _fossil_test_apply_xtag function, providing a convenient way to tag test cases - * with additional metadata. - * - * @param test_case The test case to which the xtag will be applied. This should - * be a valid identifier for a registered test case. - * @param xtag The xtag to assign to the test case. This is typically a string - * used to add additional metadata or categorization to the test - * case. The xtag is cast to char* for compatibility. - * - * Example usage: - * - * APPLY_XTAG(my_test_case, "regression"); - * - * This would tag 'my_test_case' with the "regression" xtag. - */ -#define APPLY_XTAG(test_case, xtag) _APPLY_XTAG(test_case, xtag) - -/** - * @brief Assign a priority to a test case. - * - * This macro is used to set the priority of a given test case. It wraps the - * _fossil_test_apply_priority function, providing a more intuitive and convenient - * way to specify test priorities in the code. - * - * @param test_case The test case to which the priority will be applied. This should - * be a valid identifier for a registered test case. - * @param priority The priority level to assign to the test case. Higher values - * typically indicate higher priority, though this depends on the - * implementation details of _fossil_test_apply_priority. - * - * Example usage: - * - * APPLY_PRIORITY(my_test_case, 5); - * - * This would set the priority of 'my_test_case' to 5. - */ -#define APPLY_PRIORITY(test_case, priority) _APPLY_PRIORITY(test_case, priority) - -/** - * @brief Macro for adding a test to the test registry. - * - * This macro is used to add a test to the test registry. It takes the test - * name as an argument and adds the corresponding Test structure to the registry. - * - * @param test The test to be added to the registry. - */ -#define ADD_TEST(test_case) _ADD_TEST(test_case) - -/** - * @brief Macro for adding a test with a fixture to the test registry. - * - * This macro is used to add a test with a fixture to the test registry. It - * takes the test name and fixture name as arguments, and adds the corresponding - * Test structure to the registry, along with the setup and teardown functions - * for the specified fixture. - * - * @param test The test to be added to the registry. - * @param fixture The fixture associated with the test. - */ -#define ADD_TESTF(test_case, fixture) _ADD_TESTF(test_case, fixture) - -/** - * @brief Define macro for declaring a test fixture. - * - * This macro is used to declare setup and teardown functions for a test fixture. - * It creates function declarations for the setup and teardown functions associated - * with the specified fixture name. These functions typically perform initialization - * and cleanup tasks before and after each test case, respectively. - * - * @param fixture_name The name of the test fixture. - */ -#define FOSSIL_FIXTURE(fixture_name) _FOSSIL_FIXTURE(fixture_name) - -/** - * @brief Define macro for declaring a BDD test fixture. - * - * This macro is used to declare a BDD test fixture. It creates function declarations - * for the setup and teardown functions associated with the specified fixture name. - * These functions typically perform initialization and cleanup tasks before and after - * - * @param fixture_name The name of the test fixture. - */ -#define FOSSIL_FEATURE(fixture_name) _FOSSIL_FIXTURE(fixture_name) - -/** - * @brief Define macro for declaring a setup function for a test fixture. - * - * This macro is used to declare a setup function for a test fixture. It creates - * a function declaration for the setup function associated with the specified - * fixture name. This function typically performs initialization tasks before - * each test case. - * - * @param fixture_name The name of the test fixture. - */ -#define FOSSIL_SETUP(fixture_name) _FOSSIL_SETUP(fixture_name) - -/** - * @brief Define macro for declaring a teardown function for a test fixture. - * - * This macro is used to declare a teardown function for a test fixture. It creates - * a function declaration for the teardown function associated with the specified - * fixture name. This function typically performs cleanup tasks after each test case. - * - * @param fixture_name The name of the test fixture. - */ -#define FOSSIL_TEARDOWN(fixture_name) _FOSSIL_TEARDOWN(fixture_name) - -/** - * Defines a test case with a given name and sets up its properties. - * - * This macro generates a function prototype and an instance of an fossil_test_t struct - * for the specified test case name. It initializes the test case with default - * values for various properties, including mark and tag rules, description - * strings, and flags. - * - * @param name The name of the test case. This name is used to generate the function - * prototype and the fossil_test_t struct instance. - */ -#define FOSSIL_TEST(name) _FOSSIL_TEST(name) - -/** - * @brief Define macro for a BDD style test case. - * - * This macro is used to define a BDD style test case. It creates a function prototype - * and an instance of an fossil_test_t struct for the specified test case name. It initializes - * the test case with default values for various properties, including mark and tag rules, - * description strings, and flags. This macro is typically used for behavior-driven - * development (BDD) style tests, where the test case is structured as a series of GIVEN, - * WHEN, and THEN conditions. - * - * @param name The name of the test case. - */ -#define FOSSIL_SONERO(name) _FOSSIL_TEST(name) - -// ================================================================= -// Test pool commands -// ================================================================= - -/** - * @brief Define macro for defining a test queue. - * - * This macro is used to define a test queue function for a specific test group. - * It creates a function definition with the given group name and accepts a pointer - * to a TestRegistry structure as a parameter. This function typically registers - * all tests within the specified test group to the provided test registry. - * - * @param group_name The name of the test group. - */ -#define FOSSIL_TEST_GROUP(group_name) _FOSSIL_TEST_GROUP(group_name) - -/** - * @brief Define macro for declaring an external test queue. - * - * This macro is used to declare an external test queue function for a specific - * test group. It creates an external function declaration with the given group name - * and accepts a pointer to a TestRegistry structure as a parameter. This declaration - * allows the test queue function to be defined in a separate source file and linked - * with the test framework. - * - * @param group_name The name of the test group. - */ -#define FOSSIL_TEST_EXPORT(group_name) _FOSSIL_TEST_EXPORT(group_name) - -/** - * @brief Define macro for importing and executing a test queue. - * - * This macro is used to import and execute a test queue function for a specific - * test group. It calls the test queue function with the provided TestRegistry - * structure, typically registering all tests within the specified test group - * to the test registry. - * - * @param group_name The name of the test group. - */ -#define FOSSIL_TEST_IMPORT(group_name) _FOSSIL_TEST_IMPORT(group_name) - -// ================================================================= -// BDD specific commands -// ================================================================= - -/** - * @brief Define macro for specifying a GIVEN condition in a test scenario. - * - * This macro is used to specify a GIVEN condition in a test scenario. - * It allows the test writer to describe the initial context or setup - * for the test. The condition is always true, indicating that the - * GIVEN condition is assumed to be true for the test scenario. - * - * @param description The description of the GIVEN condition. - */ -#define GIVEN(description) _GIVEN(description) - -/** - * @brief Define macro for specifying a WHEN condition in a test scenario. - * - * This macro is used to specify a WHEN condition in a test scenario. - * It allows the test writer to describe the action or event that - * triggers the behavior being tested. The condition is always true, - * indicating that the WHEN condition is assumed to be true for the - * test scenario. - * - * @param description The description of the WHEN condition. - */ -#define WHEN(description) _WHEN(description) - -/** - * @brief Define macro for specifying a THEN condition in a test scenario. - * - * This macro is used to specify a THEN condition in a test scenario. - * It allows the test writer to describe the expected outcome or result - * of the test scenario. The condition is always true, indicating that - * the THEN condition is assumed to be true for the test scenario. - * - * @param description The description of the THEN condition. - */ -#define THEN(description) _THEN(description) - -// ================================================================= -// TDD specific commands -// ================================================================= - -/** - * @brief Define macro for defining test data structures. - * - * This macro is used to define test data structures for a specific test group. - * It creates a typedef for the test data structure with the given group name - * and defines a struct with the same name suffixed with "_xdata". - * - * @param group_name The name of the test group. - */ -#define FOSSIL_TEST_DATA(group_name) typedef struct group_name##_xdata group_name##_xdata; struct group_name##_xdata - -/** - * @brief Define macro for indicating that a test is not implemented yet. - * - * This macro is used to mark a test as not implemented yet. It invokes - * the TEST_ASSUME macro with a false condition, indicating that the test - * is not implemented, and includes a message indicating the same. - */ -#define FOSSIL_TEST_NOT_IMPLEMENTED() TEST_ASSUME(false, (char*)"Test not implemented yet") - -// ================================================================= -// Assertion specific commands -// ================================================================= - -/** - * @brief Define macros for test assertions with expression and message. - * - * This macro is used to define a test assertion. It checks the given expression - * and, if the expression evaluates to false, logs the failure with the provided - * message, file name, line number, and function name. This type of assertion - * typically halts the test execution upon failure. - * - * @param expression The expression to be evaluated. - * @param message The message to log if the assertion fails. - */ -#define TEST_ASSERT(expression, message) \ - _fossil_test_assert_class(expression, TEST_ASSERT_AS_CLASS_ASSERT, (char*)message, (char*)__FILE__, __LINE__, (char*)__func__) - -/** - * @brief Define macros for test expectations with expression and message. - * - * This macro is used to define a test expectation. It checks the given expression - * and, if the expression evaluates to false, logs the failure with the provided - * message, file name, line number, and function name. Unlike assertions, expectations - * typically do not halt the test execution upon failure, allowing subsequent tests to run. - * - * @param expression The expression to be evaluated. - * @param message The message to log if the expectation fails. - */ -#define TEST_EXPECT(expression, message) \ - _fossil_test_assert_class(expression, TEST_ASSERT_AS_CLASS_EXPECT, (char*)message, (char*)__FILE__, __LINE__, (char*)__func__) - -/** - * @brief Define macros for test assumptions with expression and message. - * - * This macro is used to define a test assumption. It checks the given expression - * and, if the expression evaluates to false, logs the failure with the provided - * message, file name, line number, and function name. Assumptions are used to - * validate preconditions for the test and can halt the test execution if a failure - * occurs. However, they may allow multiple failures before halting, depending on the implementation. - * - * @param expression The expression to be evaluated. - * @param message The message to log if the assumption fails. - */ -#define TEST_ASSUME(expression, message) \ - _fossil_test_assert_class(expression, TEST_ASSERT_AS_CLASS_ASSUME, (char*)message, (char*)__FILE__, __LINE__, (char*)__func__) - -/** - * @brief Define macros for exception testing with expression and message. - * - * This macro is used to define a test for exceptions. It checks the given expression - * and, if the expression evaluates to false, logs the failure with the provided - * message, file name, line number, and function name. This is typically used to - * validate that the code under test correctly handles exceptions or error conditions. - * - * @param expression The expression to be evaluated. - * @param message The message to log if the exception test fails. - */ -#define TEST_EXCEPT(expression, message) \ - _fossil_test_assert_class(expression, TEST_ASSERT_AS_CLASS_EXCEPT, (char*)message, (char*)__FILE__, __LINE__, (char*)__func__) - -/** - * @brief Define macros for sanity pen testing with expression and message. - * - * This macro is used to define a sanity check for penetration testing. It checks - * the given expression and, if the expression evaluates to false, logs the failure - * with the provided message, file name, line number, and function name. Sanity checks - * are typically used for exact validation and security testing to ensure the system - * behaves as expected under specific conditions. - * - * @param expression The expression to be evaluated. - * @param message The message to log if the sanity test fails. - */ -#define TEST_SANITY(expression, message) \ - _fossil_test_assert_class(expression, TEST_ASSERT_AS_CLASS_SANITY, (char*)message, (char*)__FILE__, __LINE__, (char*)__func__) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/code/logic/fossil/unittest/internal.h b/code/logic/fossil/unittest/internal.h deleted file mode 100644 index 022ba4dd..00000000 --- a/code/logic/fossil/unittest/internal.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_TEST_INTERNAL_H -#define FOSSIL_TEST_INTERNAL_H - -#include "fossil/_common/common.h" -#include "fossil/_common/platform.h" - -/** - * Introspection Data in Fossil Test - * - * Introspection, in the context of Fossil Test, refers to the process of gathering - * detailed information about the testing environment. This information is crucial - * for ensuring test stability, reliability, and portability across different - * platforms and environments. Fossil Test relies heavily on introspection data to - * adapt its behavior dynamically based on the characteristics of the system where - * it runs. - * - * The importance of introspection data can be summarized as follows: - * - * 1. System Compatibility: - * Introspection data allows Fossil Test to identify the underlying architecture, - * operating system, CPU count, endianness, and memory size of the test environment. - * This information is vital for ensuring that tests execute correctly on diverse - * platforms, including ARM, Windows, macOS, and various POSIX-based systems. - * - * 2. Test Adaptation: - * By analyzing introspection data, Fossil Test can adapt its behavior and configuration - * to suit the characteristics of the current environment. For example, the console - * output may be adjusted based on the console width and height, and color support - * may be enabled or disabled depending on the capabilities of the terminal. - * - * 3. Performance Optimization: - * Introspection data helps Fossil Test optimize test execution performance by providing - * insights into system resources such as CPU count and memory size. This information - * allows Fossil Test to allocate resources efficiently and prioritize test execution - * based on available hardware resources. - * - * 4. Cross-Platform Testing: - * With introspection data, Fossil Test can facilitate cross-platform testing by - * identifying and handling platform-specific differences transparently. Whether - * running on Windows, macOS, Linux, or other operating systems, Fossil Test can - * leverage introspection data to ensure consistent test behavior and results. - * - * In conclusion, introspection data forms the foundation of Fossil Test's ability - * to operate effectively in diverse testing environments. By gathering and analyzing - * detailed information about the test environment, Fossil Test enhances compatibility, - * adaptability, performance, and cross-platform testing capabilities, thereby - * empowering developers to write robust and portable test suites. - */ - -// Define thread pool size -enum { - FOSSIL_TEST_MAX_FILTER_LENGTH = 50, - FOSSIL_TEST_ASSUME_MAX = 5, - FOSSIL_TEST_EXCEPT_MAX = 5, - FOSSIL_TEST_MAX_REPEATS = 100, - FOSSIL_TEST_MIN_REPEATS = 1, - FOSSIL_TEST_MAX_PRIORITY = 100, - FOSSIL_TEST_MIN_PRIORITY = 1, - MAX_EXPECTED_TIME_FAST = 1000, // Example value: 1000 milliseconds (1 second) - MAX_EXPECTED_TIME_SLOW = 2000, // 2000 milliseconds (2 seconds) - FOSSIL_TESTAULT_PRIORITY_THRESHOLD = 50, - FOSSIL_TEST_ABORT_FAIL = -1, -}; - -typedef enum { - FOSSIL_TEST_IO_AS_HUMAN, - FOSSIL_TEST_IO_AS_CUTBACK, - FOSSIL_TEST_IO_AS_TURBO -} fossil_test_mode; - -/** - * @brief Enumeration representing different types of assertion rules. - * - * This enum defines various types of assertion rules that can be applied to test cases. - * Each value represents a specific type of assertion behavior. - */ -typedef enum { - TEST_ASSERT_AS_CLASS_ASSERT, /**< Standard assert, used to enforce conditions that must be true. */ - TEST_ASSERT_AS_CLASS_EXPECT, /**< Expectation, used to define conditions that are expected but not mandatory. */ - TEST_ASSERT_AS_CLASS_ASSUME, /**< Assumption, used to specify assumptions that must hold true for the test to proceed. */ - TEST_ASSERT_AS_CLASS_EXCEPT, /**< Exception, used to handle conditions that are expected to raise exceptions. */ - TEST_ASSERT_AS_CLASS_SANITY /**< Sanity check, used for basic checks to ensure the test environment is stable. */ -} xassert_type_t; - -/** - * @brief Enumeration representing different priority rules for test assertions. - * - * This enum defines various priority rules for test assertions, indicating the importance - * or urgency of the tests. Tests with higher priority values are considered more critical. - */ -typedef enum { - TEST_ASSERT_PRIORITY_RULE_LOW, /**< Priority for tests with low importance. */ - TEST_ASSERT_PRIORITY_RULE_NORMAL, /**< Priority for tests with normal importance. */ - TEST_ASSERT_PRIORITY_RULE_HIGH, /**< Priority for tests with high importance. */ - TEST_ASSERT_PRIORITY_RULE_CRITICAL /**< Priority for tests with critical importance. */ -} xassert_priority_t; - -/** - * @brief Enumeration representing different mark rules for test assertions. - * - * This enum defines various marking rules for test assertions, indicating the expected - * outcome or behavior of the tests. - */ -typedef enum { - TEST_ASSERT_MARK_RULE_SKIP, /**< Mark for tests that should be skipped. */ - TEST_ASSERT_MARK_RULE_DEFAULT, /**< Default mark for tests with no specific expected outcome. */ - TEST_ASSERT_MARK_RULE_TIMEOUT, /**< Mark for tests that are expected to timeout. */ - TEST_ASSERT_MARK_RULE_ERROR, /**< Mark for tests that are expected to throw an error. */ - TEST_ASSERT_MARK_RULE_NONE, /**< Mark for tests with no specific expected outcome. */ - TEST_ASSERT_MARK_RULE_ONLY /**< Mark for tests that are the only ones to be run. */ -} xassert_mark_t; - -/** - * Structure representing rules or attributes of a test case. - * This structure is used to track various states or characteristics of a test case, - * such as whether it passed, was skipped, or was categorized as fast or slow. - */ -typedef struct { - bool should_pass; /**< Boolean indicating whether the test case passed. */ - bool skipped; /**< Boolean indicating whether the test case was skipped. */ - bool timeout; /**< Boolean indicating whether the test case timed out. */ - bool error; /**< Boolean indicating whether the test case threw an error. */ -} fossil_test_rule_t; - -/** - * @brief Structure to hold timing information for tests. - * - * This structure stores the timing information for tests, including the start time, - * end time, elapsed time, and detailed timing information in different units. - * It is used to track the duration of test executions to provide performance metrics. - */ -typedef struct { - clock_t start; /**< Processor time at the start of tests. */ - clock_t end; /**< Processor time at the end of tests. */ - clock_t elapsed; /**< Elapsed processor time for the tests. */ - struct { - int64_t minutes; /**< Elapsed time in minutes. */ - int64_t seconds; /**< Elapsed time in seconds. */ - int64_t milliseconds; /**< Elapsed time in milliseconds. */ - int64_t microseconds; /**< Elapsed time in microseconds. */ - int64_t nanoseconds; /**< Elapsed time in nanoseconds. */ - } detail; /**< Detailed timing information, providing a breakdown of elapsed time in various units. */ -} fossil_test_timer_t; - -/** - * Structure representing fixture information with setup and teardown functions. - * A fixture is used to set up any necessary environment or state before running a test - * and to clean up afterward. This is useful for initializing resources or configurations - * that multiple test cases share. - */ -typedef struct { - void (*setup)(void); /**< Function pointer to the setup function for the fixture. - This function is called before each test case to set up - the test environment. */ - void (*teardown)(void); /**< Function pointer to the teardown function for the fixture. - This function is called after each test case to clean up - the test environment. */ -} fossil_fixture_t; - -/** - * Structure representing a test case. - * This structure contains all the necessary information for a test case, including its name, - * the function implementing the test, priority, tags, and links to setup and teardown functions. - */ -typedef struct fossil_test_t fossil_test_t; -typedef struct fossil_test_t { - const char* name; /**< Name of the test case. */ - void (*test_function)(void); /**< Function pointer to the test case's implementation. */ - char* tags; /**< Array of tags associated with the test case. */ - char* marks; /**< Array of marks associated with the test case. */ - fossil_test_timer_t timer; /**< Timer for tracking the duration of the test case. */ - fossil_fixture_t fixture; /**< The fixture settings for setup and teardown functions. */ - int32_t priority; /**< Priority of the test case (higher value indicates higher priority). */ - struct fossil_test_t *prev; /**< Pointer to the previous fossil_test_t node in a linked list. */ - struct fossil_test_t *next; /**< Pointer to the next fossil_test_t node in a linked list. */ -} fossil_test_t; - -/** - * Structure representing a deque (double-ended queue) for managing test cases. - * This structure allows for the addition and removal of test cases from both ends of the queue. - */ -typedef struct { - fossil_test_t *front; /**< Pointer to the front of the deque. */ - fossil_test_t *rear; /**< Pointer to the rear of the deque. */ -} fossil_test_queue_t; - -/** - * Structure representing statistics for tracking test results. - * This structure keeps track of various counts related to the outcomes of test cases, - * including passed, failed, skipped, and timed-out tests. - */ -typedef struct { - uint16_t expected_passed_count; /**< Number of expected passed tests. */ - uint16_t expected_failed_count; /**< Number of expected failed tests. */ - uint16_t unexpected_passed_count; /**< Number of unexpected passed tests. */ - uint16_t unexpected_failed_count; /**< Number of unexpected failed tests. */ - uint16_t expected_skipped_count; /**< Number of skipped tests. */ - uint16_t expected_empty_count; /**< Number of empty tests. */ - uint16_t expected_timeout_count; /**< Number of tests that timed out. */ - uint16_t expected_total_count; /**< Total number of unit tests that were run. */ - uint16_t untested_count; /**< Total number of untested cases when exit or abort is called - from an assert. */ -} fossil_test_score_t; - -/** - * Structure representing information about an assertion. - * This structure contains detailed information about an assertion, including the name of the test case, - * the message associated with the assertion, the file name, line number, function name, timestamp, assertion type, - * execution time, test case identifier, severity level, custom data, stack trace, and result of the test case. - */ -typedef struct { - bool shoudl_timeout; /**< Flag indicating whether the test case should timeout (1 for true, 0 for false). */ - bool should_fail; /**< Flag indicating whether the test case should fail (1 for true, 0 for false). */ - bool has_assert; /**< Flag indicating if an assertion occurred (1 for true, 0 for false). */ - bool same_assert; /**< Flag indicating if the test case is the same (1 for true, 0 for false). */ - int32_t num_asserts; /**< Number of assertions that occurred. */ - int32_t line; /**< Line number where the assertion occurred. */ - char *func; /**< Function name where the assertion occurred. */ - char *file; /**< File name where the assertion occurred. */ - char *message; /**< Message associated with the assertion. */ -} xassert_info; - -/** - * Structure representing the test environment, holding overall test statistics and timing information. - * This structure is used to manage the state of the testing process, including the queue of test cases - * and the timer for tracking the duration of the tests. - */ -typedef struct { - fossil_test_score_t stats; /**< Test statistics, including counts of passed, failed, and skipped tests. */ - fossil_test_timer_t timer; /**< Timer for tracking the time taken to run the tests. */ - fossil_test_queue_t* queue; /**< Queue to hold the test cases, allowing them to be managed and executed in order. */ - fossil_test_rule_t rule; /**< Rule for the test case, including whether it should pass, fail, or be skipped. */ - uint8_t current_except_count; /**< Counter for the number of exceptions that occurred during testing. */ - uint8_t current_assume_count; /**< Counter for the number of assumptions that occurred during testing. */ -} fossil_env_t; - -#endif diff --git a/code/logic/meson.build b/code/logic/meson.build index 5fbbb4b0..8e23338e 100644 --- a/code/logic/meson.build +++ b/code/logic/meson.build @@ -1,5 +1,12 @@ dir = include_directories('.') -subdir('unittest') -subdir('mockup') -subdir('benchmark') \ No newline at end of file +test_code = ['mockup.c', 'unittest.c', 'benchmark.c'] + +fossil_test_lib = library('fossil-test', + test_code, + install: true, + include_directories: dir) + +fossil_test_dep = declare_dependency( + link_with: fossil_test_lib, + include_directories: dir) diff --git a/code/logic/mockup/mockup.c b/code/logic/mockup.c similarity index 93% rename from code/logic/mockup/mockup.c rename to code/logic/mockup.c index c7bb49a9..f35425bd 100644 --- a/code/logic/mockup/mockup.c +++ b/code/logic/mockup.c @@ -14,11 +14,13 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include "fossil/mockup/mockup.h" +#include "fossil/test/mockup.h" + +extern char *_custom_fossil_test_strdup(const char *str); void fossil_mock_init(MockCallList *list) { - list->head = xnullptr; - list->tail = xnullptr; + list->head = NULL; + list->tail = NULL; list->size = 0; } @@ -44,7 +46,7 @@ void fossil_mock_add_call(MockCallList *list, const char *function_name, char ** call->arguments[i] = _custom_fossil_test_strdup(arguments[i]); } call->num_args = num_args; - call->next = xnullptr; + call->next = NULL; if (list->tail) { list->tail->next = call; diff --git a/code/logic/mockup/meson.build b/code/logic/mockup/meson.build deleted file mode 100644 index 1f615858..00000000 --- a/code/logic/mockup/meson.build +++ /dev/null @@ -1,10 +0,0 @@ -mock_code = ['mockup.c'] - -fossil_mock_lib = library('fossil-mock', - mock_code, - install: true, - include_directories: dir) - -fossil_mock_dep = declare_dependency( - link_with: fossil_mock_lib, - include_directories: dir) diff --git a/code/logic/unittest.c b/code/logic/unittest.c new file mode 100644 index 00000000..45900969 --- /dev/null +++ b/code/logic/unittest.c @@ -0,0 +1,508 @@ +/* + * ----------------------------------------------------------------------------- + * Project: Fossil Logic + * + * This file is part of the Fossil Logic project, which aims to develop high- + * performance, cross-platform applications and libraries. The code contained + * herein is subject to the terms and conditions defined in the project license. + * + * Author: Michael Gene Brockus (Dreamer) + * Date: 07/01/2024 + * + * Copyright (C) 2024 Fossil Logic. All rights reserved. + * ----------------------------------------------------------------------------- + */ +#include "fossil/test/unittest.h" + +#ifdef __WIN32 +// Array of messages for each category +const char *sarcastic_messages[] = { + "Wow, no tests were run! What a productive day!", + "No tests to run, guess we're all just too good at writing code.", + "Congratulations, you’ve done absolutely nothing today.", + "Oh, look! No tests were executed. What an achievement!", + "Not a single test run, but hey, that's one way to keep things perfect!", + "All set for a day of zero productivity? Nice!", + "The test suite is empty, but hey, at least the code didn’t break!", + "Zero tests executed. Clearly, you've mastered the art of doing nothing.", + "Great! We’ve made it through an entire test run without running a single test.", + "Isn’t it great when there’s nothing to test?" +}; + +const char *humorous_messages[] = { + "Well, that was an epic failure! Better luck next time!", + "Whoops! Someone’s definitely gonna need to debug that.", + "Looks like someone forgot to write the test cases.", + "Your tests failed, but at least you got closer to perfection... not.", + "Not all heroes wear capes. Some of them fail tests.", + "Don't worry, failure is just success in disguise. Or maybe not.", + "Well, that was awkward. Let's try again, shall we?", + "Looks like we’ve encountered a bug! Hope you’ve got a magnifying glass.", + "Your tests are taking a nap, but don’t worry, we’ll wake them up!", + "It’s not a failure, it’s just a learning experience! A very *expensive* one." +}; + +const char *great_news_messages[] = { + "Great news! All tests passed. You’re a testing genius!", + "Success! Everything works as expected. Go celebrate!", + "You did it! All tests passed. You’re officially a rock star!", + "Congrats, all tests passed! You’ve earned a gold star!", + "Woohoo! All tests passed with flying colors!", + "No bugs found today, you’re on fire!", + "Amazing! You’ve got a perfect test suite. Keep it up!", + "Nice job! All tests passed. I think we’ve found the next coding superhero!", + "Fantastic! No issues at all, just pure success!", + "All tests passed, everything’s awesome." +}; + +#else + +// Array of messages for each category +const char *sarcastic_messages[] = { + "Wow, no tests were run! What a productive day! 😏", + "No tests to run, guess we're all just too good at writing code. 🧐", + "Congratulations, you’ve done absolutely nothing today. 🙃", + "Oh, look! No tests were executed. What an achievement! 🥳", + "Not a single test run, but hey, that's one way to keep things perfect! 😆", + "All set for a day of zero productivity? Nice! 💤", + "The test suite is empty, but hey, at least the code didn’t break! 😜", + "Zero tests executed. Clearly, you've mastered the art of doing nothing. 😎", + "Great! We’ve made it through an entire test run without running a single test. 🥳", + "Isn’t it great when there’s nothing to test? 🙃" +}; + +const char *humorous_messages[] = { + "Well, that was an epic failure! Better luck next time! 😂", + "Whoops! Someone’s definitely gonna need to debug that. 🐞", + "Looks like someone forgot to write the test cases. 🤷‍♂️", + "Your tests failed, but at least you got closer to perfection... not. 🤦‍♂️", + "Not all heroes wear capes. Some of them fail tests. 🦸‍♂️", + "Don't worry, failure is just success in disguise. Or maybe not. 😅", + "Well, that was awkward. Let's try again, shall we? 🤔", + "Looks like we’ve encountered a bug! Hope you’ve got a magnifying glass. 🧐", + "Your tests are taking a nap, but don’t worry, we’ll wake them up! 😴", + "It’s not a failure, it’s just a learning experience! A very *expensive* one. 💸" +}; + +const char *great_news_messages[] = { + "Great news! All tests passed. You’re a testing genius! 🎉", + "Success! Everything works as expected. Go celebrate! 🥳", + "You did it! All tests passed. You’re officially a rock star! 🌟", + "Congrats, all tests passed! You’ve earned a gold star! 🏅", + "Woohoo! All tests passed with flying colors! 🎨", + "No bugs found today, you’re on fire! 🔥", + "Amazing! You’ve got a perfect test suite. Keep it up! 💪", + "Nice job! All tests passed. I think we’ve found the next coding superhero! 🦸‍♀️", + "Fantastic! No issues at all, just pure success! 😎", + "All tests passed, everything’s awesome. 🎶" +}; + +#endif + +jmp_buf test_jump_buffer; // This will hold the jump buffer for longjmp + +char *_custom_fossil_test_strdup(const char *str) { + size_t len = strlen(str) + 1; + char *new_str = (char *)malloc(len); + if (new_str == NULL) { + return NULL; + } + memcpy(new_str, str, len); + return new_str; +} + +// Initialize the options structure +fossil_options_t init_options(void) { + fossil_options_t options; + options.show_version = false; + options.show_help = false; + options.show_info = false; + options.reverse = false; + options.repeat_enabled = false; + options.repeat_count = 1; + options.shuffle_enabled = false; + return options; +} + +void usage_info(void) { + printf("Usage: fossil [options] [command]\n"); + printf("Options:\n"); + printf(" --version\t\tDisplays the current version of Fossil Test\n"); + printf(" --help\t\tShows help message with usage\n"); + printf(" --info\t\tDisplays detailed information about the test run.\n"); + printf("Commands:\n"); + printf(" reverse [enable|disable]\tEnables or disables reverse order of test execution\n"); + printf(" repeat [count]\t\tRepeats the test suite a specified number of times\n"); + printf(" shuffle [enable|disable]\tEnables or disables shuffling of test execution order\n"); +} + +void version_info(void) { + printf("Fossil Logic Test Framework\n"); + printf("Version: 1.0.7\n"); + printf("Author: Michael Gene Brockus (Dreamer)\n"); + printf("License: Mozila Public License 2.0\n"); +} + +// Parse command-line arguments +fossil_options_t fossil_options_parse(int argc, char **argv) { + fossil_options_t options = init_options(); + + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "--version") == 0) { + options.show_version = true; + } else if (strcmp(argv[i], "--help") == 0) { + options.show_help = true; + } else if (strcmp(argv[i], "--info") == 0) { + options.show_info = true; + } else if (strcmp(argv[i], "reverse") == 0) { + if (i + 1 < argc && strcmp(argv[i + 1], "enable") == 0) { + options.reverse = true; + } else if (i + 1 < argc && strcmp(argv[i + 1], "disable") == 0) { + options.reverse = false; + } + } else if (strcmp(argv[i], "repeat") == 0) { + options.repeat_enabled = true; + if (i + 1 < argc && argv[i + 1][0] != '-') { + options.repeat_count = atoi(argv[i + 1]); + i++; + } + } else if (strcmp(argv[i], "shuffle") == 0) { + if (i + 1 < argc && strcmp(argv[i + 1], "enable") == 0) { + options.shuffle_enabled = true; + } else if (i + 1 < argc && strcmp(argv[i + 1], "disable") == 0) { + options.shuffle_enabled = false; + } + } + } + + return options; +} + +// Function to reverse the order of test cases in the linked list +void reverse_test_cases(test_case_t **test_cases) { + if (!test_cases || !*test_cases) { + return; // No test cases to reverse + } + + test_case_t *prev = NULL; + test_case_t *current = *test_cases; + test_case_t *next = NULL; + + // Traverse the linked list and reverse the 'next' pointers + while (current) { + next = current->next; // Store the next node + current->next = prev; // Reverse the current node's pointer + prev = current; // Move prev and current one step forward + current = next; + } + + // After the loop, prev will point to the new head of the list + *test_cases = prev; +} + +// Function to shuffle test cases using the Fisher-Yates algorithm +void shuffle_test_cases(test_case_t **test_cases) { + if (!test_cases || !*test_cases) { + return; // No test cases to shuffle + } + + // Calculate the length of the linked list (number of test cases) + int n = 0; + test_case_t *current = *test_cases; + while (current) { + n++; + current = current->next; + } + + // If there is only one or zero test cases, no need to shuffle + if (n <= 1) { + return; + } + + // Create an array to hold the test cases + test_case_t **array = malloc(sizeof(test_case_t *) * n); + if (!array) { + return; // Memory allocation failed + } + + // Fill the array with the test case pointers + current = *test_cases; + for (int i = 0; i < n; i++) { + array[i] = current; + current = current->next; + } + + // Shuffle the array using the Fisher-Yates algorithm + srand(time(NULL)); // Seed the random number generator + + for (int i = n - 1; i > 0; i--) { + // Generate a random index between 0 and i + int j = rand() % (i + 1); + + // Swap the elements + test_case_t *temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + + // Rebuild the linked list from the shuffled array + for (int i = 0; i < n - 1; i++) { + array[i]->next = array[i + 1]; + } + array[n - 1]->next = NULL; // Last test case points to NULL + + // Update the original test cases pointer + *test_cases = array[0]; + + // Free the array after use + free(array); +} + +// Creates and returns a new test suite +test_suite_t* fossil_test_create_suite(const char *name) { + test_suite_t *suite = (test_suite_t*)malloc(sizeof(test_suite_t)); + suite->name = name; + suite->suite_setup_func = NULL; + suite->suite_teardown_func = NULL; + suite->tests = NULL; + suite->next = NULL; + return suite; +} + +// Registers a test suite in the environment +void fossil_test_register_suite(fossil_test_env_t *env, test_suite_t *suite) { + if (!suite) return; + suite->next = env->test_suites; + env->test_suites = suite; + if (env->options.show_info) { + printf(COLOR_INFO "Registered test suite: %s\n" COLOR_RESET, suite->name); + } +} + +// Adds a test case to a suite +void fossil_test_add_case(test_suite_t *suite, test_case_t *test_case) { + if (!suite || !test_case) return; + + test_case->next = suite->tests; + suite->tests = test_case; +} + +// Removes and frees a test case from a suite +void fossil_test_remove_case(test_suite_t *suite, test_case_t *test_case) { + if (!suite || !test_case) return; + + test_case_t *prev = NULL; + test_case_t *curr = suite->tests; + + while (curr) { + if (curr == test_case) { + if (prev) { + prev->next = curr->next; + } else { + suite->tests = curr->next; + } + free(curr); + return; + } + prev = curr; + curr = curr->next; + } +} + +// Setup for individual test case +void fossil_test_case_setup(test_case_t *test_case) { + if (test_case && test_case->setup_func) { + test_case->setup_func(); + } +} + +// Teardown for individual test case +void fossil_test_case_teardown(test_case_t *test_case) { + if (test_case && test_case->teardown_func) { + test_case->teardown_func(); + } +} + +// Run an individual test case +void fossil_test_run_case(test_case_t *test_case, fossil_test_env_t *env) { + if (!test_case) return; + + test_case->status = TEST_STATUS_PASS; + + // Run setup + fossil_test_case_setup(test_case); + + clock_t test_start_time = clock(); + if (setjmp(env->env) == 0) { + for (int i = 0; i < env->options.repeat_count; i++) { + test_case->test_func(); + } + } else { + test_case->status = TEST_STATUS_FAIL; + printf(COLOR_FAIL "FAIL: " COLOR_INFO " %s\n", test_case->name); + printf("Failure Message: %s\n" COLOR_RESET, test_case->failure_message); + } + test_case->execution_time = (double)(clock() - test_start_time) / CLOCKS_PER_SEC; + + // Run teardown + fossil_test_case_teardown(test_case); + + // Log result + if (test_case->status == TEST_STATUS_PASS) { + if (env->options.show_info) { + printf(COLOR_PASS "PASS: " COLOR_INFO " %s (%.3f seconds)\n" COLOR_RESET, test_case->name, test_case->execution_time); + } + } else if (test_case->status == TEST_STATUS_FAIL) { + env->fail_count++; + } else if (test_case->status == TEST_STATUS_SKIP) { + env->skip_count++; + } +} + +// Run all test cases in a test suite +void fossil_test_run_suite(test_suite_t *suite, fossil_test_env_t *env) { + if (!suite) return; + + if (env->options.show_info) { + printf(COLOR_INFO "Running suite: %s\n" COLOR_RESET, suite->name); + } + + if (env->options.shuffle_enabled){ + shuffle_test_cases(&suite->tests); + } + + if (env->options.reverse) { + reverse_test_cases(&suite->tests); + } + + if (suite->suite_setup_func) { + suite->suite_setup_func(); + } + + double total_execution_time = 0.0; + test_case_t *current_test = suite->tests; + while (current_test) { + fossil_test_run_case(current_test, env); + total_execution_time += current_test->execution_time; + current_test = current_test->next; + } + + if (suite->suite_teardown_func) { + suite->suite_teardown_func(); + } + + if (env->options.show_info) { + printf(COLOR_CYAN "Total execution time for suite %s: %.3f seconds\n" COLOR_RESET, suite->name, total_execution_time); + } +} + +// Internal function to handle assertions +void fossil_test_assert_internal(bool condition, const char *message, const char *file, int line, const char *func) { + if (!condition) { + printf("Assertion failed: %s (%s:%d in %s)\n", message, file, line, func); + longjmp(test_jump_buffer, 1); // Jump back to test case failure handler + } +} + +void fossil_test_run_all(fossil_test_env_t *env) { + test_suite_t *current_suite = env->test_suites; + + while (current_suite) { + fossil_test_run_suite(current_suite, env); + current_suite = current_suite->next; + } +} + +void fossil_test_init(fossil_test_env_t *env, int argc, char **argv) { + env->options = fossil_options_parse(argc, argv); + if (env->options.show_version) { + version_info(); + exit(EXIT_SUCCESS); + } + if (env->options.show_help) { + usage_info(); + exit(EXIT_SUCCESS); + } + env->pass_count = 0; + env->fail_count = 0; + env->skip_count = 0; + env->total_tests = 0; + env->total_execution_time = clock(); + env->unexpected_count = 0; + env->test_suites = NULL; +} + +// Function to generate a dynamic message based on the test results +void fossil_test_message(fossil_test_env_t *env) { + // Seed random number generator + srand(time(NULL)); + + // Sarcastic message for no tests run + if (env->pass_count == 0 && env->fail_count == 0 && env->skip_count == 0) { + printf(COLOR_INFO "%s\n" COLOR_RESET, sarcastic_messages[rand() % 10]); + } + // Humorous message for failed tests + else if (env->fail_count > 0) { + printf(COLOR_FAIL "%s\n" COLOR_RESET, humorous_messages[rand() % 10]); + } + // Great news for passed tests + else if (env->pass_count > 0) { + printf(COLOR_PASS "%s\n" COLOR_RESET, great_news_messages[rand() % 10]); + } + // Default message for mixed results + else { + printf(COLOR_INFO "Test results are in. Keep pushing, you’re getting there! 💪\n" COLOR_RESET); + } +} + +// Summary function for test results +void fossil_test_summary(fossil_test_env_t *env) { + double total_time = 0.0; + test_suite_t *suite = env->test_suites; + while (suite != NULL) { + test_case_t *test = suite->tests; + while (test != NULL) { + total_time += test->execution_time; + + if (test->status == TEST_STATUS_PASS) { + env->pass_count++; + } else if (test->status == TEST_STATUS_FAIL) { + env->fail_count++; + if (test->failure_message) { + printf("Test '%s' failed: %s\n", test->name, test->failure_message); + } + } else if (test->status == TEST_STATUS_SKIP) { + env->skip_count++; + } else { + env->unexpected_count++; + } + + test = test->next; + } + suite = suite->next; + } + + printf(COLOR_INFO "====================================" COLOR_RESET); + printf(COLOR_INFO "\nFossil Test Summary:\n" COLOR_RESET); + printf(COLOR_INFO "====================================\n" COLOR_RESET); + + printf(COLOR_INFO "Passed: " COLOR_PASS " %d\n" COLOR_RESET, env->pass_count); + printf(COLOR_INFO "Failed: " COLOR_FAIL " %d\n" COLOR_RESET, env->fail_count); + printf(COLOR_INFO "Skipped: " COLOR_SKIP " %d\n" COLOR_RESET, env->skip_count); + printf(COLOR_INFO "Total: %d tests\n" COLOR_RESET, env->pass_count + env->fail_count + env->skip_count); + + // Optionally, you could add the total execution time summary here + printf(COLOR_INFO "====================================\n" COLOR_RESET); + printf(COLOR_INFO "Total execution time: %.3f seconds\n" COLOR_RESET, (env->total_execution_time - total_time) / CLOCKS_PER_SEC); + printf(COLOR_INFO "====================================\n" COLOR_RESET); + + fossil_test_message(env); +} + +void fossil_test_print_stack_trace(stack_frame_t *stack_trace) { + stack_frame_t *current_frame = stack_trace; + while (current_frame) { + printf(" at %s (%s:%d)\n", current_frame->func, current_frame->file, current_frame->line); + current_frame = current_frame->next; + } +} diff --git a/code/logic/unittest/commands.c b/code/logic/unittest/commands.c deleted file mode 100644 index 780dcf8a..00000000 --- a/code/logic/unittest/commands.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include "fossil/unittest/commands.h" -#include "fossil/unittest/framework.h" -#include "fossil/unittest/console.h" -#include -#include - -fossil_options_t _CLI; - -// Initialize the options structure -fossil_options_t init_options(void) { - fossil_options_t options; - options.show_version = false; - options.show_help = false; - options.show_tip = false; - options.show_info = false; - options.show_author = false; - options.only_tags = false; - options.reverse = false; - options.repeat_enabled = false; - options.repeat_count = 1; - options.shuffle_enabled = false; - options.verbose_enabled = false; - options.verbose_level = 1; - options.list_tests = false; - options.summary_enabled = false; - options.color_enabled = false; - options.sanity_enabled = false; - return options; -} - -// Parse command-line arguments -fossil_options_t fossil_options_parse(int argc, char **argv) { - fossil_options_t options = init_options(); - - for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "--version") == 0) { - options.show_version = true; - } else if (strcmp(argv[i], "--help") == 0) { - options.show_help = true; - } else if (strcmp(argv[i], "--tip") == 0) { - options.show_tip = true; - } else if (strcmp(argv[i], "--info") == 0) { - options.show_info = true; - } else if (strcmp(argv[i], "--author") == 0) { - options.show_author = true; - } else if (strcmp(argv[i], "only") == 0) { - options.only_tags = true; - if (i + 1 < argc && argv[i + 1][0] != '-') { - strcpy(options.only_tags_value, argv[i + 1]); - i++; - } - } else if (strcmp(argv[i], "reverse") == 0) { - if (i + 1 < argc && strcmp(argv[i + 1], "enable") == 0) { - options.reverse = true; - } else if (i + 1 < argc && strcmp(argv[i + 1], "disable") == 0) { - options.reverse = false; - } - } else if (strcmp(argv[i], "repeat") == 0) { - options.repeat_enabled = true; - if (i + 1 < argc && argv[i + 1][0] != '-') { - options.repeat_count = atoi(argv[i + 1]); - i++; - } - } else if (strcmp(argv[i], "shuffle") == 0) { - if (i + 1 < argc && strcmp(argv[i + 1], "enable") == 0) { - options.shuffle_enabled = true; - } else if (i + 1 < argc && strcmp(argv[i + 1], "disable") == 0) { - options.shuffle_enabled = false; - } - } else if (strcmp(argv[i], "verbose") == 0) { - options.verbose_enabled = true; - if (i + 1 < argc && strcmp(argv[i + 1], "cutback") == 0) { - options.verbose_level = 0; - } else if (i + 1 < argc && strcmp(argv[i + 1], "verbose") == 0) { - options.verbose_level = 2; - } - } else if (strcmp(argv[i], "list") == 0) { - options.list_tests = true; - } else if (strcmp(argv[i], "summary") == 0) { - if (i + 1 < argc && strcmp(argv[i + 1], "enable") == 0) { - options.summary_enabled = true; - } else if (i + 1 < argc && strcmp(argv[i + 1], "disable") == 0) { - options.summary_enabled = false; - } - } else if (strcmp(argv[i], "color") == 0) { - if (i + 1 < argc && strcmp(argv[i + 1], "enable") == 0) { - options.color_enabled = true; - } else if (i + 1 < argc && strcmp(argv[i + 1], "disable") == 0) { - options.color_enabled = false; - } - } else if (strcmp(argv[i], "sanity") == 0) { - if (i + 1 < argc && strcmp(argv[i + 1], "enable") == 0) { - options.sanity_enabled = true; - } else if (i + 1 < argc && strcmp(argv[i + 1], "disable") == 0) { - options.sanity_enabled = false; - } - } - } - - return options; -} diff --git a/code/logic/unittest/console.c b/code/logic/unittest/console.c deleted file mode 100644 index a6055e54..00000000 --- a/code/logic/unittest/console.c +++ /dev/null @@ -1,491 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include "fossil/unittest/console.h" -#include "fossil/unittest/framework.h" -#include "fossil/unittest/commands.h" -#include - -static const char* FOSSIL_TEST_NAME = "Fossil Test"; -static const char* FOSSIL_TEST_AUTH = "Michael Gene Brockus (Dreamer)"; -static const char* FOSSIL_TEST_VERSION = "1.0.3"; -static const char* FOSSIL_TEST_INFO = "Fossil Test is a next-generation unit testing/mockup framework for C/C++."; - -// ============================================================================== -// Xtest internal console stream logic -// ============================================================================== - -// Function to generate a random humorous comment about an empty test runner -// becuse way not add a little sillyness. -char* empty_runner_comment(void) { - char* comments[] = { // add more to this - "Looks like the test runner is on a coffee break!", - "The test runner is feeling a bit empty today, like my coffee cup.", - "The test runner is as empty as a developer's coffee mug on Monday morning.", - "Did someone forget to load the tests? The runner seems quite empty!", - "The test runner is as empty as a promise to write documentation.", - "The test runner is emptier than a developer's promise to refactor code.", - "The test runner seems to be on a diet - it's looking quite empty!", - "Did the tests escape? The runner seems unusually empty!", - "The test runner is as empty as a JavaScript developer's promises.", - "The test runner seems as empty as my enthusiasm for Monday mornings.", - "The test runner is emptier than a meeting agenda without a clear purpose.", - "The test runner is looking as empty as a developer's patience with legacy code.", - "The test runner is as empty as a database without any data.", - "The test runner seems to be in stealth mode - it's quite empty!", - "The test runner is emptier than a startup's promise of equity.", - "The test runner is as empty as a meeting room during a free lunch seminar.", - "The test runner is looking as empty as a developer's snack stash on Friday afternoon.", - "The test runner seems to be as empty as a Git repository with no commits.", - "The test runner is emptier than a developer's memory after a long debugging session.", - "The test runner is looking as empty as a developer's inbox after vacation.", - "The test runner is as empty as a conference room during a fire drill.", - "The test runner seems to be as empty as a developer's coffee pot after a long night of coding.", - "The test runner is emptier than a developer's promise to write unit tests." - }; - - int num_comments = sizeof(comments) / sizeof(comments[0]); - - srand(time(xnullptr)); - - // Generate a random index - int random_index = rand() % num_comments; - - return comments[random_index]; -} - -char* passing_test_comment(void) { - char* comments[] = { - "Success! The test passed faster than a speeding processor!", - "Hooray! The test passed like a champ!", - "All green! The test passed with flying colors!", - "The test passed as smoothly as butter on a hot pancake!", - "Great job! The test passed like a breeze on a sunny day!", - "The test passed with more grace than a ballerina on stage!", - "Fantastic! The test passed like it was on a mission!", - "Woohoo! The test passed like a pro!", - "The test passed like a well-oiled machine!", - "Brilliant! The test passed without a hitch!", - "The test passed like a hot knife through butter!", - "Outstanding! The test passed like a well-orchestrated symphony!", - "Victory! The test passed like a champion!", - "The test passed as smoothly as a Tesla on autopilot!", - "Amazing! The test passed like a rocket to the moon!", - "The test passed like a marathon runner crossing the finish line!", - "Excellent! The test passed without breaking a sweat!", - "The test passed like a star pupil acing an exam!", - "Spectacular! The test passed with flying colors!", - "The test passed like a well-rehearsed play!", - "The test passed like a breeze through an open window!", - "The test passed like a pro on its first try!", - "The test passed like a dream come true!" - }; - - int num_comments = sizeof(comments) / sizeof(comments[0]); - - srand(time(NULL)); - - // Generate a random index - int random_index = rand() % num_comments; - - return comments[random_index]; -} - -char* failure_test_comment(void) { - char* comments[] = { - "Oops! The test failed like a buttered cat falling from the ceiling!", - "Yikes! The test failed harder than my New Year's resolutions!", - "Darn it! The test failed like a paper airplane in a storm!", - "Bummer! The test failed like a joke at a silent party!", - "Oh no! The test failed like my diet on a cheat day!", - "Rats! The test failed like a house of cards in a windstorm!", - "Drat! The test failed like a deflated balloon at a party!", - "Egads! The test failed like a bad pun in a dad joke contest!", - "Alas! The test failed like my plans to wake up early!", - "Shoot! The test failed like my internet connection during a crucial moment!", - "Dang it! The test failed like a soap opera plot twist!", - "Blast! The test failed like a lead balloon!", - "Crud! The test failed like my attempts to avoid procrastination!", - "Oh dear! The test failed like a misplaced semicolon!", - "Bother! The test failed like a comedian at a serious event!", - "Son of a gun! The test failed like a tech demo at a live presentation!", - "Aw, shucks! The test failed like my weekend plans to relax!", - "Fiddlesticks! The test failed like a magician's trick gone wrong!", - "Good grief! The test failed like a server on Black Friday!", - "Zounds! The test failed like my Wi-Fi when I need it most!", - "Oh snap! The test failed like a toaster in the bathtub!", - "Cripes! The test failed like a fish out of water!", - "Dagnabbit! The test failed like a cat trying to swim!", - "Holy moly! The test failed like a balloon in a cactus field!" - }; - - int num_comments = sizeof(comments) / sizeof(comments[0]); - - srand(time(NULL)); - - // Generate a random index - int random_index = rand() % num_comments; - - return comments[random_index]; -} - -// Function to generate a random tip for unit testing released tasks -// as this would servse as a handy feature and be helpful for teaching -// new developers how they can write good test cases. -char* helpful_tester_tip(void) { - char* tips[] = { - "Always write meaningful test names.", - "Test both positive and negative cases.", - "Use mocking for external dependencies.", - "Run tests frequently during development.", - "Ensure tests are isolated and independent.", - "Avoid hardcoding values in test cases.", - "Focus on testing the functionality, not the implementation.", - "Regularly update and maintain test cases.", - "Use code coverage tools to identify untested code.", - "Test edge cases and boundary conditions.", - "Keep unit tests fast and repeatable.", - "Use setup and teardown methods when necessary.", - "Automate the execution of tests.", - "Review and refactor tests regularly.", - "Write tests for both happy paths and error paths.", - "Test for performance and scalability where applicable.", - "Use assertions effectively to verify outcomes.", - "Consider using property-based testing for complex logic.", - "Document the purpose and expected run_as of each test.", - "Collaborate with the development team to identify test cases.", - "Prioritize and focus on critical and high-risk areas.", - "Write tests early in the development process.", - "Use version control for test code and test data.", - "Ensure that tests can run in different environments.", - "Consider the maintainability and readability of test code.", - "Use test frameworks and libraries to simplify testing.", - "Use test data generation tools to create test data.", - "Use test reporting tools to track test results.", - "Use test management tools to organize and execute tests.", - "Use continuous integration to automate test execution." - }; - - int num_tips = sizeof(tips) / sizeof(tips[0]); - - srand(time(xnullptr)); - - // Generate a random index - int random_index = rand() % num_tips; - - return tips[random_index]; -} - -char *summary_message(fossil_env_t *env) { - if (env->stats.expected_failed_count == 0 && env->stats.expected_passed_count > 0) { - return passing_test_comment(); - } else if (env->stats.expected_failed_count > 0) { - return failure_test_comment(); - } else { - return empty_runner_comment(); - } - return "No summary message available"; -} - -char* current_datetime(void) { - time_t rawtime; - struct tm* timeinfo; - static char datetime[20]; // Buffer to hold the formatted date and time - - time(&rawtime); - timeinfo = localtime(&rawtime); - - strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", timeinfo); - - char* copy = _custom_fossil_test_strdup(datetime); // Return a dynamically allocated copy of the datetime - if (!copy) { - return xnullptr; // Check for memory allocation failure - } - - char* result = _custom_fossil_test_strdup(datetime); // Return a dynamically allocated copy of the datetime - free(copy); // Free the temporary copy - - return result; -} - -static char* replace_underscore(const char* str) { - if (!str) { - return xnullptr; // Check for xnull input - } - - char* result = _custom_fossil_test_strdup(str); - if (!result) { - return xnullptr; // Check for memory allocation failure - } - - for (char* ptr = result; *ptr; ptr++) { - if (*ptr == '_') { - *ptr = ' '; - } - } - - char* copy = _custom_fossil_test_strdup(result); // Create a copy to free the original - free(result); // Free the original - - return copy; -} - -// Define color codes -#define COLOR_RED "\033[1;31m" -#define COLOR_GREEN "\033[1;32m" -#define COLOR_YELLOW "\033[1;33m" -#define COLOR_BLUE "\033[1;34m" -#define COLOR_BRIGHT_BLUE "\033[1;94m" -#define COLOR_DARK_BLUE "\033[0;34m" -#define COLOR_MAGENTA "\033[1;35m" -#define COLOR_CYAN "\033[1;36m" -#define COLOR_WHITE "\033[1;37m" -#define COLOR_RESET "\033[0m" - -// Define a structure to map color names to their corresponding codes -typedef struct { - const char* name; - const char* code; -} ColorMap; - -// Custom print function with color support -void fossil_test_cout(const char* color_name, const char* format, ...) { - static const ColorMap color_map[] = { - {"red", COLOR_RED}, - {"green", COLOR_GREEN}, - {"yellow", COLOR_YELLOW}, - {"blue", COLOR_BLUE}, - {"bright blue", COLOR_BRIGHT_BLUE}, - {"dark blue", COLOR_DARK_BLUE}, - {"magenta", COLOR_MAGENTA}, - {"cyan", COLOR_CYAN}, - {"white", COLOR_WHITE}, - {NULL, COLOR_RESET} // Default color - }; - - va_list args; - va_start(args, format); - - // Check if color output is enabled - if (_CLI.color_enabled) { - // Default color code - const char* color_code = COLOR_RESET; - - // Find the corresponding color code - for (int i = 0; color_map[i].name != NULL; i++) { - if (strcmp(color_name, color_map[i].name) == 0) { - color_code = color_map[i].code; - break; - } - } - - // Print color code and formatted string - printf("%s", color_code); - vprintf(format, args); - printf("%s", COLOR_RESET); // Reset color - } else { - // Color output disabled, print formatted string directly - vprintf(format, args); - } - - va_end(args); -} - -// Internal function to calculate elapsed time for a test -static void calculate_elapsed_time(fossil_test_timer_t *timer) { - timer->end = clock(); - // Calculate elapsed time - timer->elapsed = timer->end - timer->start; - - // Convert elapsed time to different units - timer->detail.minutes = timer->elapsed / (CLOCKS_PER_SEC * 60); - timer->detail.seconds = (timer->elapsed / CLOCKS_PER_SEC) % 60; - timer->detail.milliseconds = (timer->elapsed * 1000) / CLOCKS_PER_SEC; - timer->detail.microseconds = (timer->elapsed * 1000000) / CLOCKS_PER_SEC; - timer->detail.nanoseconds = (timer->elapsed * 1000000000) / CLOCKS_PER_SEC; -} - -// Function to handle CLI information output -void fossil_test_io_information(void) { - if (_CLI.show_version) { - fossil_test_cout("blue", "%s\n", FOSSIL_TEST_VERSION); - exit(0); - } else if (_CLI.show_info) { - fossil_test_cout("blue", "%s\n", FOSSIL_TEST_INFO); - exit(0); - } else if (_CLI.show_tip) { - fossil_test_cout("blue", "%s\n", helpful_tester_tip()); - exit(0); - } else if (_CLI.show_author) { - fossil_test_cout("blue", "%s\n", FOSSIL_TEST_AUTH); - exit(0); - } else if (_CLI.show_help) { - fossil_test_cout("blue", "Usage: fossil_test_cli [options]\n"); - fossil_test_cout("blue", "Options:\n"); - fossil_test_cout("cyan", " --version Displays the version of the Fossil Test CLI\n"); - fossil_test_cout("cyan", " --help Shows the help message with usage instructions\n"); - fossil_test_cout("cyan", " --tip Provides a tip or hint about using the Fossil Test CLI\n"); - fossil_test_cout("cyan", " --info Displays information about the test runner\n"); - fossil_test_cout("cyan", " --author Shows information about the author of the test runner\n"); - fossil_test_cout("cyan", " only= or only= Runs only the tests tagged with the specified tag(s)\n"); - fossil_test_cout("cyan", " reverse [enable/disable] Enables or disables the reverse order of test execution\n"); - fossil_test_cout("cyan", " repeat= Repeats the test suite for the specified number of times\n"); - fossil_test_cout("cyan", " shuffle [enable/disable] Enables or disables the shuffling of test execution order\n"); - fossil_test_cout("cyan", " verbose [cutback/normal/verbose] Sets the verbosity level of the output\n"); - fossil_test_cout("cyan", " list Lists all available tests\n"); - fossil_test_cout("cyan", " summary [enable/disable] Enables or disables the summary of test results after execution\n"); - fossil_test_cout("cyan", " color [enable/disable] Enables or disables colored output in the terminal\n"); - fossil_test_cout("cyan", " sanity [enable/disable] Enables or disables sanity checks before running the tests\n"); - exit(0); - } -} - -void fossil_test_io_sanity_load(fossil_test_t *test) { - if (_CLI.verbose_level == 2 && _CLI.sanity_enabled) { - fossil_test_cout("blue", "load test: "); - fossil_test_cout("cyan", " -> id: %.4d, tag: %s, name: %s\n", _TEST_ENV.stats.untested_count + 1, test->tags, test->name); - } else if (_CLI.verbose_level == 1 && _CLI.sanity_enabled) { - fossil_test_cout("blue", "[loaded] test: "); - fossil_test_cout("cyan", " -> %.4d %s\n", _TEST_ENV.stats.untested_count + 1, test->name); - } -} - -void fossil_test_io_unittest_start(fossil_test_t *test) { - test->timer.start = clock(); - - if (_CLI.verbose_level == 2) { - fossil_test_cout("blue", "%s[%.4d]%s\n", "=[started case]=====================================================================", - _TEST_ENV.stats.expected_total_count + 1, "==="); - fossil_test_cout("blue", "test name : "); - fossil_test_cout("cyan", " -> %s\n", replace_underscore(test->name)); - fossil_test_cout("blue", "priority : "); - fossil_test_cout("cyan", " -> %d\n", test->priority); - fossil_test_cout("blue", "tags : "); - fossil_test_cout("cyan", " -> %s\n", test->tags); - fossil_test_cout("blue", "marker : "); - fossil_test_cout("cyan", " -> %s\n", test->marks); - } else if (_CLI.verbose_level == 1) { - fossil_test_cout("blue", "[start] "); - fossil_test_cout("cyan", "%.4d: %s tag: %s mark: %s\n", _TEST_ENV.stats.expected_total_count + 1, replace_underscore(test->name), test->tags, test->marks); - } -} - -void fossil_test_io_unittest_given(char *description) { - if (_CLI.verbose_level == 2) { - fossil_test_cout("blue", " : "); - fossil_test_cout("magenta", "%s%s\n", "GIVEN ", description); - } -} - -void fossil_test_io_unittest_when(char *description) { - if (_CLI.verbose_level == 2) { - fossil_test_cout("blue", " : "); - fossil_test_cout("magenta", "%s%s\n", "\tWHEN ", description); - } -} - -void fossil_test_io_unittest_then(char *description) { - if (_CLI.verbose_level == 2) { - fossil_test_cout("blue", " : "); - fossil_test_cout("magenta", "%s%s\n", "\t\tTHEN ", description); - } -} - -void fossil_test_io_unittest_step(xassert_info *assume) { - if (_CLI.verbose_level == 2) { - fossil_test_cout("blue", "has assert : "); - fossil_test_cout("cyan", " -> %s\n", assume->has_assert ? COLOR_GREEN "has assertions" COLOR_RESET : COLOR_RED "missing assertions" COLOR_RESET); - fossil_test_cout("blue", "asserts used: "); - fossil_test_cout("cyan", COLOR_GREEN "%3i\n" COLOR_RESET , assume->num_asserts); - } else if (_CLI.verbose_level == 1) { - fossil_test_cout("blue", "[intro] has_assert : "); - fossil_test_cout("cyan", "%s\n", assume->has_assert ? COLOR_GREEN "yes" COLOR_RESET : COLOR_RED "no" COLOR_RESET); - fossil_test_cout("blue", "[intro] same_assert: "); - fossil_test_cout("cyan", "%s\n", assume->same_assert ? COLOR_RED "yes" COLOR_RESET : COLOR_GREEN "no" COLOR_RESET); - fossil_test_cout("blue", "[intro] num_asserts: "); - fossil_test_cout("cyan", COLOR_GREEN "%3i\n" COLOR_RESET , assume->num_asserts); - } -} - -void fossil_test_io_unittest_ended(fossil_test_t *test) { - calculate_elapsed_time(&test->timer); - - if (_CLI.verbose_level == 2) { - fossil_test_cout("blue", "timestamp : "); - fossil_test_cout("cyan", " -> %ld minutes, %ld seconds, %ld milliseconds, %ld microseconds, %ld nanoseconds\n", - (uint32_t)test->timer.detail.minutes, (uint32_t)test->timer.detail.seconds, (uint32_t)test->timer.detail.milliseconds, - (uint32_t)test->timer.detail.microseconds, (uint32_t)test->timer.detail.nanoseconds); - fossil_test_cout("blue", "%s\n", "=[ ended case ]=============================================================================="); - } else if (_CLI.verbose_level == 1) { - fossil_test_cout("blue", "[ended] time: "); - fossil_test_cout("cyan", "%ld:%ld:%ld:%ld:%ld\n", - (uint32_t)test->timer.detail.minutes, (uint32_t)test->timer.detail.seconds, (uint32_t)test->timer.detail.milliseconds, - (uint32_t)test->timer.detail.microseconds, (uint32_t)test->timer.detail.nanoseconds); - } else if (_CLI.verbose_level == 0 && !_ASSERT_INFO.should_fail) { - fossil_test_cout("green", "[#]"); - } - - // Check for timeout - if (test->timer.elapsed >= (2 * 60 * CLOCKS_PER_SEC)) { - _TEST_ENV.rule.timeout = true; - } -} - -void fossil_test_io_asserted(xassert_info *assume) { - if (_CLI.verbose_level == 2) { - fossil_test_cout("red", "=[F]=[assertion failed]======================================================================\n"); - fossil_test_cout("red", "message : -> %s\n", assume->message); - fossil_test_cout("red", "file name: -> %s\n", assume->file); - fossil_test_cout("red", "line num : -> %d\n", assume->line); - fossil_test_cout("red", "function : -> %s\n", assume->func); - fossil_test_cout("red", "=========================================================================================[F]=\n"); - } else if (_CLI.verbose_level == 1) { - fossil_test_cout("red", "name: %s line: -> %d msg: -> %s\n", assume->func, assume->line, assume->message); - } else { - fossil_test_cout("red", "[#]"); - } -} - -void fossil_test_io_summary_start(void) { - fossil_test_cout("blue", "=============================================================================================\n"); - fossil_test_cout("blue", "%s\n", "platform meta data about the host system:"); - fossil_test_cout("blue", "endian(%6s) cpus(%2i) memory(%4i) os(%s) arch(%s)\n", - _fossil_test_assert_is_big_endian() ? "big" : "little", _fossil_test_get_num_cpus(), _fossil_test_get_memory_size(), _fossil_test_get_os_name(), _fossil_test_get_architecture()); - fossil_test_cout("blue", "=============================================================================================\n"); -} - -void fossil_test_io_summary_ended(void) { - char *color = "green"; - if (_TEST_ENV.stats.expected_failed_count > 0) { - color = "red"; - } else if (_TEST_ENV.stats.expected_passed_count == 0) { - color = "yellow"; - } - - fossil_test_cout("blue", "\n%s %s: %s\n\n", FOSSIL_TEST_NAME, FOSSIL_TEST_VERSION, FOSSIL_TEST_INFO); - fossil_test_cout("blue", "=============================================================================================\n"); - fossil_test_cout("blue", "%s", " message: "); - fossil_test_cout(color, "%s\n", summary_message(&_TEST_ENV)); - fossil_test_cout("cyan", "> Expected Passed : %3d Expected Failed: %3d\n", _TEST_ENV.stats.expected_passed_count, _TEST_ENV.stats.expected_failed_count); - fossil_test_cout("cyan", "> Unexpected Passed: %3d Unexpected Failed: %3d\n", _TEST_ENV.stats.unexpected_passed_count, _TEST_ENV.stats.expected_failed_count); - fossil_test_cout("cyan", "> Timeout: %3d Skipped: %3d Empty: %3d\n", _TEST_ENV.stats.expected_timeout_count, _TEST_ENV.stats.expected_skipped_count, _TEST_ENV.stats.expected_empty_count); - fossil_test_cout("blue", "=============================================================================================\n"); - fossil_test_cout("blue", "Total Tests: %d\n", _TEST_ENV.stats.expected_total_count); - fossil_test_cout("blue", "Total Ghost: %d\n", _TEST_ENV.stats.untested_count); - fossil_test_cout("blue", "=============================================================================================\n"); - calculate_elapsed_time(&_TEST_ENV.timer); - fossil_test_cout("yellow", "timestamp : -> %ld minutes, %ld seconds, %ld milliseconds, %ld microseconds, %ld nanoseconds\n", - (uint32_t)_TEST_ENV.timer.detail.minutes, (uint32_t)_TEST_ENV.timer.detail.seconds, (uint32_t)_TEST_ENV.timer.detail.milliseconds, - (uint32_t)_TEST_ENV.timer.detail.microseconds, (uint32_t)_TEST_ENV.timer.detail.nanoseconds); -} diff --git a/code/logic/unittest/meson.build b/code/logic/unittest/meson.build deleted file mode 100644 index 5b4870af..00000000 --- a/code/logic/unittest/meson.build +++ /dev/null @@ -1,10 +0,0 @@ -test_code = ['commands.c', 'console.c', 'unittest.c'] - -fossil_test_lib = library('fossil-test', - test_code, - install: true, - include_directories: dir) - -fossil_test_dep = declare_dependency( - link_with: fossil_test_lib, - include_directories: dir) diff --git a/code/logic/unittest/unittest.c b/code/logic/unittest/unittest.c deleted file mode 100644 index ede63711..00000000 --- a/code/logic/unittest/unittest.c +++ /dev/null @@ -1,809 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include "fossil/unittest/framework.h" -#include "fossil/_common/common.h" -#include "fossil/unittest/console.h" -#include "fossil/unittest/commands.h" -#include - -#define MAX_ASSERT_HISTORY 100 - -typedef struct { - bool expression; - xassert_type_t behavior; - char* message; - char* file; - int line; - unsigned long fingerprint; - char* func; -} assert_history_t; - -static assert_history_t assert_history[MAX_ASSERT_HISTORY]; -static int assert_history_count = 0; - -fossil_env_t _TEST_ENV; -xassert_info _ASSERT_INFO; - -fossil_test_queue_t* fossil_test_queue_create(void) { - fossil_test_queue_t* queue = (fossil_test_queue_t*)malloc(sizeof(fossil_test_queue_t)); - if (queue != xnullptr) { - queue->front = xnullptr; - queue->rear = xnullptr; - } else { - // Handle memory allocation failure - perror("Failed to allocate memory for queue"); - return xnullptr; - } - return queue; -} - -void fossil_test_queue_erase(fossil_test_queue_t* queue) { - fossil_test_t* current = queue->front; - fossil_test_t* next; - - while (current != xnullptr) { - next = current->next; - free(current); - current = next; - } - - queue->front = xnullptr; - queue->rear = xnullptr; -} - -// Function to add a test to the front of the queue -void fossil_test_queue_push_front(fossil_test_t *test, fossil_test_queue_t *queue) { - if (test == xnullptr || queue == xnullptr) { - return; - } - - if (queue->front == xnullptr) { - // The queue is empty - queue->front = test; - queue->rear = test; - } else { - // Insert test at the front - test->next = queue->front; - queue->front->prev = test; - queue->front = test; - } - test->prev = xnullptr; // Ensure previous pointer of new front is NULL -} - -// Function to add a test to the rear of the queue -void fossil_test_queue_push_back(fossil_test_t *test, fossil_test_queue_t *queue) { - if (test == xnullptr || queue == xnullptr) { - return; - } - - if (queue->rear == xnullptr) { - // The queue is empty - queue->front = test; - queue->rear = test; - } else { - // Insert test at the rear - queue->rear->next = test; - test->prev = queue->rear; - queue->rear = test; - } - test->next = xnullptr; // Ensure next pointer of new rear is NULL -} - -// Function to remove and return the test from the front of the queue -fossil_test_t* fossil_test_queue_pop_front(fossil_test_queue_t *queue) { - if (queue == xnullptr || queue->front == xnullptr) { - return xnullptr; - } - - fossil_test_t *front_test = queue->front; - - if (queue->front == queue->rear) { - // The queue has only one test - queue->front = xnullptr; - queue->rear = xnullptr; - } else { - // Remove test from the front - queue->front = queue->front->next; - queue->front->prev = xnullptr; - } - - return front_test; -} - -// Function to remove and return the test from the rear of the queue -fossil_test_t* fossil_test_queue_pop_back(fossil_test_queue_t *queue) { - if (queue == xnullptr || queue->rear == xnullptr) { - return xnullptr; - } - - fossil_test_t *rear_test = queue->rear; - - if (queue->front == queue->rear) { - // The queue has only one test - queue->front = xnullptr; - queue->rear = xnullptr; - } else { - // Remove test from the rear - queue->rear = queue->rear->prev; - queue->rear->next = xnullptr; - } - - return rear_test; -} - -// Function to add a test to the queue based on priority -void add_test_to_queue(fossil_test_t *test, fossil_test_queue_t *queue) { - fossil_test_queue_push_back(test, queue); -} - -// Function to remove and return the test with the highest priority from the queue -fossil_test_t* get_highest_priority_test(fossil_test_queue_t *queue) { - // In this implementation, the test with the highest priority is the one at the front of the queue - return fossil_test_queue_pop_front(queue); -} - -// Function to remove and return the test with the lowest priority from the queue -fossil_test_t* get_lowest_priority_test(fossil_test_queue_t *queue) { - // In this implementation, the test with the lowest priority is the one at the rear of the queue - return fossil_test_queue_pop_back(queue); -} - -// Function to search for a test by tag in the queue -fossil_test_t* fossil_test_queue_search_by_tag(fossil_test_queue_t *queue, const char *tag) { - if (queue == xnullptr || tag == xnullptr) { - return xnullptr; - } - - fossil_test_t *current = queue->front; - while (current != xnullptr) { - if (strcmp(current->tags, tag) == 0) { - return current; - } - current = current->next; - } - return xnullptr; -} - -// Function to search for a test by name in the queue -fossil_test_t* fossil_test_queue_search_by_name(fossil_test_queue_t *queue, const char *name) { - if (queue == xnullptr || name == xnullptr) { - return xnullptr; - } - - fossil_test_t *current = queue->front; - while (current != xnullptr) { - if (strcmp(current->name, name) == 0) { - return current; - } - current = current->next; - } - return xnullptr; -} - -void fossil_test_queue_reverse(fossil_test_queue_t *queue) { - if (queue == xnullptr) { - return; - } - - fossil_test_t *current = queue->front; - fossil_test_t *temp = xnullptr; - - // Swap the next and prev pointers for each node - while (current != xnullptr) { - temp = current->prev; - current->prev = current->next; - current->next = temp; - current = current->prev; - } - - // Swap the front and rear pointers of the queue - if (temp != xnullptr) { - temp = queue->front; - queue->front = queue->rear; - queue->rear = temp; - } -} - -// Function to convert queue to an array -fossil_test_t** queue_to_array(fossil_test_queue_t *queue, int *size) { - if (queue == xnullptr) { - return xnullptr; - } - - int count = 0; - fossil_test_t *current = queue->front; - while (current != xnullptr) { - count++; - current = current->next; - } - - fossil_test_t **array = (fossil_test_t**)malloc(count * sizeof(fossil_test_t*)); - current = queue->front; - for (int i = 0; i < count; i++) { - array[i] = current; - current = current->next; - } - - *size = count; - return array; -} - -// Function to convert array to a queue -void array_to_queue(fossil_test_t **array, int size, fossil_test_queue_t *queue) { - if (queue == xnullptr || array == xnullptr) { - return; - } - - queue->front = xnullptr; - queue->rear = xnullptr; - - for (int i = 0; i < size; i++) { - array[i]->next = xnullptr; - array[i]->prev = xnullptr; - fossil_test_queue_push_back(array[i], queue); - } -} - -// Fisher-Yates shuffle algorithm -void fossil_test_queue_shuffle(fossil_test_queue_t *queue) { - if (queue == xnullptr) { - return; - } - - int size; - fossil_test_t **array = queue_to_array(queue, &size); - if (array == xnullptr) { - return; - } - - srand(time(xnullptr)); - for (int i = size - 1; i > 0; i--) { - int j = rand() % (i + 1); - fossil_test_t *temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - - array_to_queue(array, size, queue); - free(array); -} - -// -// Fossil Test Environment functions -// - -void fossil_test_environment_erase(void) { - if (_TEST_ENV.queue != xnullptr) { - free(_TEST_ENV.queue); // Fix memory leak by uncommenting free statement - } -} - -fossil_env_t fossil_test_environment_create(int argc, char **argv) { - _CLI = fossil_options_parse(argc, argv); - fossil_test_io_information(); // checkpoint for simple commands - - fossil_env_t env; - - // Initialize test statistics - env.stats.expected_passed_count = 0; - env.stats.expected_failed_count = 0; - env.stats.unexpected_passed_count = 0; - env.stats.unexpected_failed_count = 0; - env.stats.expected_skipped_count = 0; - env.stats.expected_empty_count = 0; - env.stats.expected_timeout_count = 0; - env.stats.expected_total_count = 0; - env.stats.untested_count = 0; - - // Initialize test rules - env.rule.should_pass = true; - env.rule.skipped = false; - env.rule.timeout = false; - env.rule.error = false; - - // Initialize test timer - env.timer.start = 0; - env.timer.end = 0; - env.timer.elapsed = 0; - env.timer.detail.minutes = 0; - env.timer.detail.seconds = 0; - env.timer.detail.milliseconds = 0; - env.timer.detail.microseconds = 0; - env.timer.detail.nanoseconds = 0; - - // Initialize test queue - env.queue = fossil_test_queue_create(); - atexit(fossil_test_environment_erase); // ensure memory leaks do not occur - - // Initialize exception and assumption counts - env.current_except_count = 0; - env.current_assume_count = 0; - - fossil_test_io_summary_start(); - - return env; -} - -void _fossil_test_scoreboard_update(void) { - // here we just update the scoreboard count - // add one to total tested cases and remove - // one from untested ghost cases. - // - // The main goal is to ensure ghost cases are removed - // accordingly and the total tested cases are updated. - // - // However in the event exit is called we will have - // record of test that are tested and those that are - // not tested. - _TEST_ENV.stats.untested_count--; - _TEST_ENV.stats.expected_total_count++; -} - -void _fossil_test_scoreboard_expected_rules(void) { - if (!_TEST_ENV.rule.should_pass) { - _TEST_ENV.stats.expected_failed_count++; - _TEST_ENV.rule.should_pass = false; - } else { - _TEST_ENV.stats.expected_passed_count++; - } -} - -void _fossil_test_scoreboard_unexpected_rules(void) { - if (_TEST_ENV.rule.should_pass) { - _TEST_ENV.stats.unexpected_failed_count++; - } else { - _TEST_ENV.stats.unexpected_passed_count++; - } -} - -void _fossil_test_scoreboard_feature_rules(fossil_test_t *test_case) { - if (_TEST_ENV.rule.skipped && strcmp(test_case->marks, "skip") == 0) { - _TEST_ENV.stats.expected_skipped_count++; - _TEST_ENV.rule.skipped = false; - } else if (!_ASSERT_INFO.has_assert && strcmp(test_case->marks, "tofu") != 0) { - _TEST_ENV.stats.expected_empty_count++; - } else if (!_TEST_ENV.rule.should_pass && strcmp(test_case->marks, "fail") == 0) { - if (_ASSERT_INFO.should_fail) { - _fossil_test_scoreboard_expected_rules(); - } else { - _fossil_test_scoreboard_unexpected_rules(); - } - } else { - _TEST_ENV.stats.expected_passed_count++; - } -} - -void fossil_test_environment_scoreboard(fossil_test_t *test) { - // for the first part we check if the given test case - // has any feature flags or rules triggered. - if (strcmp(test->marks, "fossil") != 0) { - _fossil_test_scoreboard_feature_rules(test); - } else { - _fossil_test_scoreboard_expected_rules(); - } - - // we just need to update the total scoreboard - // so it is accurate for the fossil test. - _fossil_test_scoreboard_update(); - _TEST_ENV.rule.should_pass = true; // reset counter for next test -} - -void fossil_test_run_testcase(fossil_test_t *test) { - if (test == xnullptr) { - return; - } - // set and reset step for assert scanning - _ASSERT_INFO.has_assert = false; - _ASSERT_INFO.should_fail = false; - _ASSERT_INFO.shoudl_timeout = false; - _ASSERT_INFO.num_asserts = 0; - _ASSERT_INFO.same_assert = false; - - if (_TEST_ENV.rule.skipped && strcmp(test->marks, "skip") == 0) { - return; - } else if (!_ASSERT_INFO.should_fail && strcmp(test->marks, "fail") == 0) { - _ASSERT_INFO.should_fail = true; - } - - fossil_test_io_unittest_start(test); - if (test->fixture.setup != xnullptr) { - test->fixture.setup(); - } - - // Run the test function - for (int32_t iter = 0; iter < _CLI.repeat_count; iter++) { - test->test_function(); - } - fossil_test_io_unittest_step(&_ASSERT_INFO); - - if (test->fixture.teardown != xnullptr) { - test->fixture.teardown(); - } - - fossil_test_io_unittest_ended(test); - fossil_test_environment_scoreboard(test); -} - -void fossil_test_environment_algorithms(fossil_env_t *env) { - if (env == xnullptr) { - return; - } - // Start the timer - env->timer.start = clock(); - - if (_CLI.shuffle_enabled) { - fossil_test_queue_shuffle(env->queue); - } - - if (_CLI.reverse) { - fossil_test_queue_reverse(env->queue); - } - - if (_CLI.only_tags) { - fossil_test_t *test = fossil_test_queue_search_by_tag(env->queue, _CLI.only_tags_value); - if (test != xnullptr) { - fossil_test_queue_erase(env->queue); - add_test_to_queue(test, env->queue); - } - } -} - -// Function to run the test environment -void fossil_test_environment_run(fossil_env_t *env) { - if (env == xnullptr) { - return; - } - // Apply the test environment algorithms for the given test cases - fossil_test_environment_algorithms(env); - - - - // Iterate through the test queue and run each test - fossil_test_t *current_test = env->queue->front; - while (current_test != xnullptr) { - // Run the test function - fossil_test_run_testcase(current_test); - - // Move to the next test - current_test = current_test->next; - } - - // Stop the timer - env->timer.end = clock(); - env->timer.elapsed = env->timer.end - env->timer.start; -} - -// Function to summarize the test environment -int fossil_test_environment_summary(void) { - fossil_test_io_summary_ended(); - int result = (_TEST_ENV.stats.expected_failed_count + - _TEST_ENV.stats.unexpected_failed_count + - _TEST_ENV.stats.unexpected_passed_count + - _TEST_ENV.stats.expected_timeout_count + - _TEST_ENV.stats.untested_count); - - return result; -} - -// Function to add a test to the test environment -void fossil_test_environment_add(fossil_env_t *env, fossil_test_t *test, fossil_fixture_t *fixture) { - if (test == xnullptr || env == xnullptr || env->queue == xnullptr) { - return; - } - - if (fixture != xnullptr) { - test->fixture.setup = fixture->setup; - test->fixture.teardown = fixture->teardown; - } - - // Update test statistics - add_test_to_queue(test, env->queue); - _TEST_ENV.stats.untested_count++; - fossil_test_io_sanity_load(test); -} - -// -// Feature function implementations -// - -// Function to apply a mark to a test case -void fossil_test_apply_mark(fossil_test_t *test, const char *mark) { - if (!test) { - return; - } else if (!mark) { - return; - } - - // we handle any rules for marks - if (strcmp(mark, "skip") == 0) { - test->marks = "skip"; - _TEST_ENV.rule.skipped = true; - } else if (strcmp(mark, "ghost") == 0) { - test->marks = "ghost"; // remember to call the ghostbusters whena team member marks an empty case. - } else if (strcmp(mark, "error") == 0) { - test->marks = "error"; - _TEST_ENV.rule.should_pass = false; - } else if (strcmp(mark, "fail") == 0){ - test->marks = "fail"; - _TEST_ENV.rule.should_pass = false; - } else if (strcmp(mark, "none") == 0) { - test->marks = "none"; - } else if (strcmp(mark, "only") == 0) { - test->marks = "only"; - } -} - -// Function to apply an extended tag to a test case -void fossil_test_apply_xtag(fossil_test_t *test, const char *tag) { - if (!test) { - return; - } else if (!tag) { - return; - } - - // we handle any rules for tags - // to be used in a run via tag feature. - if (strcmp(tag, "fast") == 0) { - test->tags = "fast"; - } else if (strcmp(tag, "slow") == 0) { - test->tags = "slow"; - } else if (strcmp(tag, "bug") == 0) { - test->tags = "bug"; - } else if (strcmp(tag, "feature") == 0) { - test->tags = "feature"; - } else if (strcmp(tag, "security") == 0) { - test->tags = "security"; - } else if (strcmp(tag, "performance") == 0) { - test->tags = "performance"; - } else if (strcmp(tag, "stress") == 0) { - test->tags = "stress"; - } else if (strcmp(tag, "regression") == 0) { - test->tags = "regression"; - } else if (strcmp(tag, "compatibility") == 0) { - test->tags = "compatibility"; - } else if (strcmp(tag, "usability") == 0) { - test->tags = "usability"; - } else if (strcmp(tag, "robustness") == 0) { - test->tags = "robustness"; - } else if (strcmp(tag, "corner case") == 0) { - test->tags = "corner case"; - } else if (strcmp(tag, "edge case") == 0) { - test->tags = "edge case"; - } else if (strcmp(tag, "boundary case") == 0) { - test->tags = "boundary case"; - } else if (strcmp(tag, "negative case") == 0) { - test->tags = "negative case"; - } else if (strcmp(tag, "positive case") == 0) { - test->tags = "positive case"; - } else if (strcmp(tag, "sanity") == 0) { - test->tags = "sanity"; - } else if (strcmp(tag, "smoke") == 0) { - test->tags = "smoke"; - } else if (strcmp(tag, "acceptance") == 0) { - test->tags = "acceptance"; - } else if (strcmp(tag, "regression") == 0) { - test->tags = "regression"; - } else if (strcmp(tag, "functional") == 0) { - test->tags = "functional"; - } else if (strcmp(tag, "integration") == 0) { - test->tags = "integration"; - } else if (strcmp(tag, "system") == 0) { - test->tags = "system"; - } else if (strcmp(tag, "end-to-end") == 0) { - test->tags = "end-to-end"; - } else if (strcmp(tag, "unit") == 0) { - test->tags = "unit"; - } else if (strcmp(tag, "component") == 0) { - test->tags = "component"; - } else if (strcmp(tag, "module") == 0) { - test->tags = "module"; - } else if (strcmp(tag, "api") == 0) { - test->tags = "api"; - } else if (strcmp(tag, "ui") == 0) { - test->tags = "ui"; - } else if (strcmp(tag, "usability") == 0) { - test->tags = "usability"; - } else if (strcmp(tag, "performance") == 0) { - test->tags = "performance"; - } else if (strcmp(tag, "security") == 0) { - test->tags = "security"; - } else if (strcmp(tag, "stress") == 0) { - test->tags = "stress"; - } -} - -// Function to apply a priority to a test case -void fossil_test_apply_priority(fossil_test_t *test, const char *priority) { - if (!test) { - return; - } else if (!priority) { - return; - } - - if (strcmp(priority, "lowest") == 0) { - test->priority = 0; - } else if (strcmp(priority, "very low") == 0) { - test->priority = 10; - } else if (strcmp(priority, "low") == 0) { - test->priority = 20; - } else if (strcmp(priority, "medium") == 0) { - test->priority = 50; - } else if (strcmp(priority, "high") == 0) { - test->priority = 70; - } else if (strcmp(priority, "very high") == 0) { - test->priority = 90; - } else if (strcmp(priority, "highest") == 0) { - test->priority = 100; - } else if (strcmp(priority, "urgent") == 0) { - test->priority = 95; - } else if (strcmp(priority, "critical") == 0) { - test->priority = 100; - } else if (strcmp(priority, "normal") == 0) { - test->priority = 50; - } else { - int priority_value = atoi(priority); - if (priority_value < 0 || priority_value > 100) { - return; - } - - test->priority = priority_value; - } -} - -// -// Assertion function implementations -// - -// Custom assumptions function with optional message. -void fossil_test_assert_impl_assume(bool expression, xassert_info *assume) { - if (_TEST_ENV.current_assume_count == FOSSIL_TEST_ASSUME_MAX) { - exit(FOSSIL_TEST_ABORT_FAIL); - return; - } - - if (!_ASSERT_INFO.should_fail) { - if (!expression) { - _TEST_ENV.rule.should_pass = false; - _TEST_ENV.current_assume_count++; - fossil_test_io_asserted(assume); - } - } else { - if (!expression) { - _TEST_ENV.rule.should_pass = true; - } else if (expression) { - _TEST_ENV.rule.should_pass = false; - _TEST_ENV.current_assume_count++; - fossil_test_io_asserted(assume); - } - } -} // end of func - -// Custom assertion function with optional message. -void fossil_test_assert_impl_assert(bool expression, xassert_info *assume) { - if (_ASSERT_INFO.should_fail) { - if (!expression) { - _TEST_ENV.rule.should_pass = true; - } else if (expression) { - _TEST_ENV.rule.should_pass = false; - fossil_test_io_asserted(assume); - exit(FOSSIL_TEST_ABORT_FAIL); - } - } else { - if (!expression) { - _TEST_ENV.rule.should_pass = false; - fossil_test_io_asserted(assume); - exit(FOSSIL_TEST_ABORT_FAIL); - } - } -} // end of func - -// Custom expectation function with optional message. -void fossil_test_assert_impl_expect(bool expression, xassert_info *assume) { - if (_ASSERT_INFO.should_fail) { - if (!expression) { - _TEST_ENV.rule.should_pass = true; - } else if (expression) { - _TEST_ENV.rule.should_pass = false; - fossil_test_io_asserted(assume); - } - } else { - if (!expression) { - _TEST_ENV.rule.should_pass = false; - fossil_test_io_asserted(assume); - } - } -} // end of func - -bool is_assert_in_history(bool expression, xassert_type_t behavior, char* message, char* file, int line, char* func) { - for (int i = 0; i < assert_history_count; i++) { - if (assert_history[i].expression == expression && - assert_history[i].behavior == behavior && - strcmp(assert_history[i].message, message) == 0 && - strcmp(assert_history[i].file, file) == 0 && - assert_history[i].line == line && - strcmp(assert_history[i].func, func) == 0) { - return true; - } - } - return false; -} - -unsigned long generate_fingerprint(bool expression, xassert_type_t behavior, char* message, char* file, int line, char* func) { - unsigned long hash = 5381; - int c; - - hash = ((hash << 5) + hash) + expression; - hash = ((hash << 5) + hash) + behavior; - - while ((c = *message++)) - hash = ((hash << 5) + hash) + c; - - while ((c = *file++)) - hash = ((hash << 5) + hash) + c; - - hash = ((hash << 5) + hash) + line; - - while ((c = *func++)) - hash = ((hash << 5) + hash) + c; - - return hash; -} - -bool is_assert_similar_in_history(unsigned long fingerprint) { - for (int i = 0; i < assert_history_count; i++) { - if (assert_history[i].fingerprint == fingerprint) { - return true; - } - } - return false; -} - -void _fossil_test_assert_class(bool expression, xassert_type_t behavior, char* message, char* file, int line, char* func) { - unsigned long fingerprint = generate_fingerprint(expression, behavior, message, file, line, func); - - if (is_assert_similar_in_history(fingerprint)) { - // Skip the assertion as a similar one has already been executed - _ASSERT_INFO.same_assert = true; - return; - } - - _ASSERT_INFO.func = func; - _ASSERT_INFO.file = file; - _ASSERT_INFO.line = line; - _ASSERT_INFO.message = message; - - if (behavior == TEST_ASSERT_AS_CLASS_ASSUME) { - fossil_test_assert_impl_assume(expression, &_ASSERT_INFO); - } else if (behavior == TEST_ASSERT_AS_CLASS_ASSERT) { - fossil_test_assert_impl_assert(expression, &_ASSERT_INFO); - } else if (behavior == TEST_ASSERT_AS_CLASS_EXPECT) { - fossil_test_assert_impl_expect(expression, &_ASSERT_INFO); - } - - _ASSERT_INFO.num_asserts++; // increment the number of asserts - _ASSERT_INFO.has_assert = true; // Make note of an assert being added in a given test case - - // Add the assertion to the history with its fingerprint - if (assert_history_count < MAX_ASSERT_HISTORY) { - assert_history[assert_history_count].expression = expression; - assert_history[assert_history_count].behavior = behavior; - assert_history[assert_history_count].message = message; - assert_history[assert_history_count].file = file; - assert_history[assert_history_count].line = line; - assert_history[assert_history_count].func = func; - assert_history[assert_history_count].fingerprint = fingerprint; - assert_history_count++; - } -} diff --git a/code/tests/meson.build b/code/tests/meson.build index 8e3aacb1..b69d25fb 100644 --- a/code/tests/meson.build +++ b/code/tests/meson.build @@ -1,15 +1,15 @@ if get_option('with_test').enabled() - run_command(['python3', 'generate-runner.py'], check: true) + run_command(['python3', 'tools' / 'generate-runner.py'], check: true) test_src = ['unit_runner.c'] test_cubes = [ - 'mocks', 'marks', 'xfixture', 'xsoneros', 'bdd', 'tdd', 'tags', + 'sample', 'bdd', 'tdd', ] foreach cube : test_cubes test_src += ['test_' + cube + '.c'] endforeach - pizza = executable('xcli', test_src, include_directories: dir, dependencies: [fossil_test_dep, fossil_mock_dep, fossil_mark_dep]) + pizza = executable('xcli', test_src, include_directories: dir, dependencies: [fossil_test_dep]) test('fossil_tests', pizza) # Renamed the test target for clarity endif diff --git a/code/tests/test_bdd.c b/code/tests/test_bdd.c index 152e4325..ddb0a7c0 100644 --- a/code/tests/test_bdd.c +++ b/code/tests/test_bdd.c @@ -12,7 +12,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Utilites @@ -21,7 +21,18 @@ // mock objects are set here. // * * * * * * * * * * * * * * * * * * * * * * * * -// placeholder +// Define the test suite and add test cases +FOSSIL_TEST_SUITE(bdd_suite); + +// Setup function for the test suite +FOSSIL_SETUP(bdd_suite) { + // Setup code here +} + +// Teardown function for the test suite +FOSSIL_TEARDOWN(bdd_suite) { + // Teardown code here +} // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Cases @@ -31,7 +42,7 @@ // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_SONERO(xbdd_logic_test) { +FOSSIL_TEST_CASE(xbdd_logic_test) { GIVEN("a valid statement is passed") { // Set up the context bool givenExecuted = true; @@ -44,15 +55,15 @@ FOSSIL_SONERO(xbdd_logic_test) { // Check the expected outcome bool thenExecuted = true; - TEST_EXPECT(givenExecuted, "Given statement should have executed"); - TEST_EXPECT(whenExecuted, "When statement should have executed"); - TEST_EXPECT(thenExecuted, "Then statement should have executed"); + FOSSIL_TEST_ASSUME(givenExecuted, "Given statement should have executed"); + FOSSIL_TEST_ASSUME(whenExecuted, "When statement should have executed"); + FOSSIL_TEST_ASSUME(thenExecuted, "Then statement should have executed"); } } } } // end of case -FOSSIL_SONERO(xbdd_user_account) { +FOSSIL_TEST_CASE(xbdd_user_account) { GIVEN("a user's account with sufficient balance") { // Set up the context float accountBalance = 500.0; @@ -68,13 +79,13 @@ FOSSIL_SONERO(xbdd_user_account) { // Simulate the scenario float compareBalance = 500.0; - TEST_EXPECT(accountBalance == (compareBalance - withdrawalAmount), "Account balance should have been deducted by $200"); + FOSSIL_TEST_ASSUME(accountBalance == (compareBalance - withdrawalAmount), "Account balance should have been deducted by $200"); } } } } // end of case -FOSSIL_SONERO(xbdd_empty_cart) { +FOSSIL_TEST_CASE(xbdd_empty_cart) { GIVEN("a user with an empty shopping cart") { // Set up the context int cartItemCount = 0; @@ -86,13 +97,13 @@ FOSSIL_SONERO(xbdd_empty_cart) { // Check the expected outcome cartItemCount++; - TEST_EXPECT(cartItemCount == 1, "Cart item count should have increased by 1"); + FOSSIL_TEST_ASSUME(cartItemCount == 1, "Cart item count should have increased by 1"); } } } } // end of case -FOSSIL_SONERO(xbdd_valid_login) { +FOSSIL_TEST_CASE(xbdd_valid_login) { GIVEN("a registered user with valid credentials") { // Set up the context const char* validUsername = "user123"; @@ -106,8 +117,8 @@ FOSSIL_SONERO(xbdd_valid_login) { THEN("the login should be successful") { // Check the expected outcome // Simulate login validation - TEST_EXPECT(strcmp(inputUsername, validUsername) == 0, "Username should match"); - TEST_EXPECT(strcmp(inputPassword, validPassword) == 0, "Password should match"); + FOSSIL_TEST_ASSUME(strcmp(inputUsername, validUsername) == 0, "Username should match"); + FOSSIL_TEST_ASSUME(strcmp(inputPassword, validPassword) == 0, "Password should match"); } } @@ -119,8 +130,8 @@ FOSSIL_SONERO(xbdd_valid_login) { THEN("the login should fail with an error message") { // Check the expected outcome // Simulate login validation - TEST_EXPECT(strcmp(inputUsername, validUsername) == 0, "Username should match"); - TEST_EXPECT(strcmp(inputPassword, validPassword) != 0, "Password should not match"); + FOSSIL_TEST_ASSUME(strcmp(inputUsername, validUsername) == 0, "Username should match"); + FOSSIL_TEST_ASSUME(strcmp(inputPassword, validPassword) != 0, "Password should not match"); } } } @@ -130,8 +141,10 @@ FOSSIL_SONERO(xbdd_valid_login) { // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * FOSSIL_TEST_GROUP(bdd_test_group) { - ADD_TEST(xbdd_logic_test); - ADD_TEST(xbdd_user_account); - ADD_TEST(xbdd_empty_cart); - ADD_TEST(xbdd_valid_login); + FOSSIL_TEST_ADD(bdd_suite, xbdd_logic_test); + FOSSIL_TEST_ADD(bdd_suite, xbdd_user_account); + FOSSIL_TEST_ADD(bdd_suite, xbdd_empty_cart); + FOSSIL_TEST_ADD(bdd_suite, xbdd_valid_login); + + FOSSIL_TEST_REGISTER(bdd_suite); } // end of group diff --git a/code/tests/test_marks.c b/code/tests/test_marks.c deleted file mode 100644 index 938c5707..00000000 --- a/code/tests/test_marks.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include // basic test tools -#include // assertion tools -#include // benchmark tools - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Utilites -// * * * * * * * * * * * * * * * * * * * * * * * * -// Setup steps for things like test fixtures and -// mock objects are set here. -// * * * * * * * * * * * * * * * * * * * * * * * * - -// Algorithm 1: Bubble Sort -void bubble_sort(int *array, size_t size) { - for (size_t i = 0; i < size - 1; ++i) { - for (size_t j = 0; j < size - i - 1; ++j) { - if (*(array + j) > *(array + j + 1)) { - int temp = *(array + j); - *(array + j) = *(array + j + 1); - *(array + j + 1) = temp; - } - } - } -} - -// Algorithm 2: Insertion Sort -void insertion_sort(int *array, size_t size) { - int key, j; - for (size_t i = 1; i < size; ++i) { - key = array[i]; - j = i - 1; - while (j >= 0 && array[j] > key) { - array[j + 1] = array[j]; - j = j - 1; - } - array[j + 1] = key; - } -} - -// Algorithm 3: Selection Sort -void selection_sort(int *array, size_t size) { - for (size_t i = 0; i < size - 1; ++i) { - size_t min_index = i; - for (size_t j = i + 1; j < size; ++j) { - if (array[j] < array[min_index]) { - min_index = j; - } - } - int temp = array[min_index]; - array[min_index] = array[i]; - array[i] = temp; - } -} - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Cases -// * * * * * * * * * * * * * * * * * * * * * * * * -// The test cases below are provided as samples, inspired -// by the Meson build system's approach of using test cases -// as samples for library usage. -// * * * * * * * * * * * * * * * * * * * * * * * * - -// Test cases for Bubble Sort -FOSSIL_TEST(bubble_sort_case_1) { - // Test case 1 - int data[] = {5, 1, 4, 2, 8}; - size_t size = sizeof(data) / sizeof(data[0]); - TEST_BENCHMARK(); - bubble_sort(data, size); - TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); -} - -FOSSIL_TEST(bubble_sort_case_2) { - // Test case 2 - int data[] = {9, 6, 7, 3, 1}; - size_t size = sizeof(data) / sizeof(data[0]); - TEST_BENCHMARK(); - bubble_sort(data, size); - TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); -} - -FOSSIL_TEST(bubble_sort_case_3) { - // Test case 3 - int data[] = {8, 2, 4, 1, 7}; - size_t size = sizeof(data) / sizeof(data[0]); - TEST_BENCHMARK(); - bubble_sort(data, size); - TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); -} - -// Test cases for Insertion Sort -FOSSIL_TEST(insertion_sort_case_1) { - // Test case 1 - int data[] = {5, 1, 4, 2, 8, 6, 3, 7}; - size_t size = sizeof(data) / sizeof(data[0]); - TEST_BENCHMARK(); - insertion_sort(data, size); - TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); -} - -FOSSIL_TEST(insertion_sort_case_2) { - // Test case 2 - int data[] = {9, 6, 7, 3, 1, 5, 2, 4}; - size_t size = sizeof(data) / sizeof(data[0]); - TEST_BENCHMARK(); - insertion_sort(data, size); - TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); -} - -FOSSIL_TEST(insertion_sort_case_3) { - // Test case 3 - int data[] = {8, 2, 4, 1, 7, 5, 9, 3}; - size_t size = sizeof(data) / sizeof(data[0]); - TEST_BENCHMARK(); - insertion_sort(data, size); - TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); -} - -// Test cases for Selection Sort -FOSSIL_TEST(selection_sort_case_1) { - // Test case 1 - int data[] = {5, 1, 4, 2, 8, 6, 3, 7, 9}; - size_t size = sizeof(data) / sizeof(data[0]); - TEST_BENCHMARK(); - selection_sort(data, size); - TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); -} - -FOSSIL_TEST(selection_sort_case_2) { - // Test case 2 - int data[] = {9, 6, 7, 3, 1, 5, 2, 4, 8}; - size_t size = sizeof(data) / sizeof(data[0]); - TEST_BENCHMARK(); - selection_sort(data, size); - TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); -} - -FOSSIL_TEST(selection_sort_case_3) { - // Test case 3 - int data[] = {8, 2, 4, 1, 7, 5, 9, 3, 6}; - size_t size = sizeof(data) / sizeof(data[0]); - TEST_BENCHMARK(); - selection_sort(data, size); - TEST_DURATION_SEC(TEST_CURRENT_TIME(), 1.0); -} - -// Test Case for Bubble Sort with Small Input -FOSSIL_TEST(benchmark_bubble_sort_small) { - const int size = 100; - int arr[size]; - for (int i = 0; i < size; ++i) { - arr[i] = rand(); - } - - MARK_BENCHMARK(bench_bubble_sort_small); - { - MARK_SCOPED(bench_bubble_sort_small); - bubble_sort(arr, size); - } - MARK_REPORT(bench_bubble_sort_small); - - for (int i = 0; i < size - 1; ++i) { - ASSUME_ITS_TRUE(arr[i] <= arr[i + 1]); - } -} - -// Test Case for Bubble Sort with Medium Input -FOSSIL_TEST(benchmark_bubble_sort_medium) { - const int size = 1000; - int arr[size]; - for (int i = 0; i < size; ++i) { - arr[i] = rand(); - } - - MARK_BENCHMARK(bench_bubble_sort_medium); - { - MARK_SCOPED(bench_bubble_sort_medium); - bubble_sort(arr, size); - } - MARK_REPORT(bench_bubble_sort_medium); - - for (int i = 0; i < size - 1; ++i) { - ASSUME_ITS_TRUE(arr[i] <= arr[i + 1]); - } -} - -// Test Case for Bubble Sort with Large Input -FOSSIL_TEST(benchmark_bubble_sort_large) { - const int size = 10000; - int arr[size]; - for (int i = 0; i < size; ++i) { - arr[i] = rand(); - } - - MARK_BENCHMARK(bench_bubble_sort_large); - { - MARK_SCOPED(bench_bubble_sort_large); - bubble_sort(arr, size); - } - MARK_REPORT(bench_bubble_sort_large); - - for (int i = 0; i < size - 1; ++i) { - ASSUME_ITS_TRUE(arr[i] <= arr[i + 1]); - } -} - -// XUNIT-GROUP -FOSSIL_TEST_GROUP(benchmark_group) { - APPLY_MARK(bubble_sort_case_1, "ghost"); - ADD_TEST(bubble_sort_case_1); - APPLY_MARK(bubble_sort_case_2, "ghost"); - ADD_TEST(bubble_sort_case_2); - APPLY_MARK(bubble_sort_case_3, "ghost"); - ADD_TEST(bubble_sort_case_3); - - APPLY_MARK(insertion_sort_case_1, "ghost"); - ADD_TEST(insertion_sort_case_1); - APPLY_MARK(insertion_sort_case_2, "ghost"); - ADD_TEST(insertion_sort_case_2); - APPLY_MARK(insertion_sort_case_3, "ghost"); - ADD_TEST(insertion_sort_case_3); - - APPLY_MARK(selection_sort_case_1, "ghost"); - ADD_TEST(selection_sort_case_1); - APPLY_MARK(selection_sort_case_2, "ghost"); - ADD_TEST(selection_sort_case_2); - APPLY_MARK(selection_sort_case_3, "ghost"); - ADD_TEST(selection_sort_case_3); - - ADD_TEST(benchmark_bubble_sort_small); - ADD_TEST(benchmark_bubble_sort_medium); - ADD_TEST(benchmark_bubble_sort_large); -} diff --git a/code/tests/test_mocks.c b/code/tests/test_mocks.c deleted file mode 100644 index 237b3081..00000000 --- a/code/tests/test_mocks.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include // basic test tools -#include // library under test - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Utilites -// * * * * * * * * * * * * * * * * * * * * * * * * -// Setup steps for things like test fixtures and -// mock objects are set here. -// * * * * * * * * * * * * * * * * * * * * * * * * - -// placeholder - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Cases -// * * * * * * * * * * * * * * * * * * * * * * * * -// The test cases below are provided as samples, inspired -// by the Meson build system's approach of using test cases -// as samples for library usage. -// * * * * * * * * * * * * * * * * * * * * * * * * - -// Test Case for Mocking a Function -FOSSIL_TEST(mock_function_test) { - MockCallList mock; - MOCK_INIT(mock); - - // Simulating function calls - char *args1[] = {"arg1", "arg2"}; - MOCK_ADD_CALL(mock, "mock_function", args1, 2); - - char *args2[] = {"arg3", "arg4"}; - MOCK_ADD_CALL(mock, "mock_function", args2, 2); - - // Validate that the calls were recorded - printf("Mock function calls:\n"); - MOCK_PRINT(mock); - - MOCK_DESTROY(mock); -} - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Pool -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST_GROUP(test_using_mock_group) { - ADD_TEST(mock_function_test); -} diff --git a/code/tests/test_sample.c b/code/tests/test_sample.c new file mode 100644 index 00000000..34983dc2 --- /dev/null +++ b/code/tests/test_sample.c @@ -0,0 +1,60 @@ +/* + * ----------------------------------------------------------------------------- + * Project: Fossil Logic + * + * This file is part of the Fossil Logic project, which aims to develop high- + * performance, cross-platform applications and libraries. The code contained + * herein is subject to the terms and conditions defined in the project license. + * + * Author: Michael Gene Brockus (Dreamer) + * Date: 07/01/2024 + * + * Copyright (C) 2024 Fossil Logic. All rights reserved. + * ----------------------------------------------------------------------------- + */ + +#include "fossil/test/framework.h" + +// Test data structure for a sample test +FOSSIL_TEST_DATA(SampleTestData) { + int input; + int expected_output; +} SampleTestData; + +// Setup function for the test suite +FOSSIL_SETUP(sample_suite) { + // Setup code here +} + +// Teardown function for the test suite +FOSSIL_TEARDOWN(sample_suite) { + // Teardown code here +} + +// Define the test suite and add test cases +FOSSIL_TEST_SUITE(sample_suite); + +// A simple test case to check if input + 1 equals expected_output +FOSSIL_TEST_CASE(test_input_increment) { + SampleTestData data = { .input = 5, .expected_output = 6 }; + + int actual_output = data.input + 1; + + FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Increment test failed"); +} + +// A simple test case to check if input - 1 equals expected_output +FOSSIL_TEST_CASE(test_input_decrement) { + SampleTestData data = { .input = 5, .expected_output = 4 }; + + int actual_output = data.input - 1; + + FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Decrement test failed"); +} + +FOSSIL_TEST_GROUP(sample_test_group) { + FOSSIL_TEST_ADD(sample_suite, test_input_increment); + FOSSIL_TEST_ADD(sample_suite, test_input_decrement); + + FOSSIL_TEST_REGISTER(sample_suite); +} diff --git a/code/tests/test_tags.c b/code/tests/test_tags.c deleted file mode 100644 index a29fbd00..00000000 --- a/code/tests/test_tags.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Utilites -// * * * * * * * * * * * * * * * * * * * * * * * * -// Setup steps for things like test fixtures and -// mock objects are set here. -// * * * * * * * * * * * * * * * * * * * * * * * * - -// placeholder - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Cases -// * * * * * * * * * * * * * * * * * * * * * * * * -// The test cases below are provided as samples, inspired -// by the Meson build system's approach of using test cases -// as samples for library usage. -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST(testing_slow_tags) { - int x = 42; - int y = 20; - - // Test cases - TEST_ASSERT(x == 42, "Should have passed the test case"); - TEST_ASSERT(y == 20, "Should have passed the test case"); - TEST_ASSERT(x != y, "Should have passed the test case"); - TEST_ASSERT(y < x, "Should have passed the test case"); - TEST_ASSERT(y <= x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(testing_fast_tags) { - int x = 42; - int y = 20; - - // Test cases - TEST_ASSERT(x == 42, "Should have passed the test case"); - TEST_ASSERT(y == 20, "Should have passed the test case"); - TEST_ASSERT(x != y, "Should have passed the test case"); - TEST_ASSERT(y < x, "Should have passed the test case"); - TEST_ASSERT(y <= x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(testing_no_tags) { - int x = 42; - int y = 20; - - // Test cases - TEST_ASSERT(x == 42, "Should have passed the test case"); - TEST_ASSERT(y == 20, "Should have passed the test case"); - TEST_ASSERT(x != y, "Should have passed the test case"); - TEST_ASSERT(y < x, "Should have passed the test case"); - TEST_ASSERT(y <= x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(testing_fake_tags) { - int x = 42; - int y = 20; - - // Test cases - TEST_ASSERT(x == 42, "Should have passed the test case"); - TEST_ASSERT(y == 20, "Should have passed the test case"); - TEST_ASSERT(x != y, "Should have passed the test case"); - TEST_ASSERT(y < x, "Should have passed the test case"); - TEST_ASSERT(y <= x, "Should have passed the test case"); -} // end case - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Pool -// * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_GROUP(tags_test_group) { - // Should do nothing beyond show an error message that the tag does not exist - APPLY_XTAG(testing_fake_tags, "pizza pizza pizza"); - ADD_TEST(testing_fake_tags); - APPLY_XTAG(testing_slow_tags, "slow"); - ADD_TEST(testing_slow_tags); - APPLY_XTAG(testing_fast_tags, "fast"); - ADD_TEST(testing_fast_tags); - - // No tags should affect this test case - ADD_TEST(testing_no_tags); -} // end of group diff --git a/code/tests/test_tdd.c b/code/tests/test_tdd.c index 5200a7ff..dc19182f 100644 --- a/code/tests/test_tdd.c +++ b/code/tests/test_tdd.c @@ -12,13 +12,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include - -// list of include headers that extends -// the framework assertion collection. -#include -#include -#include +#include // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Utilites @@ -27,7 +21,18 @@ // mock objects are set here. // * * * * * * * * * * * * * * * * * * * * * * * * -// placeholder +// Define the test suite and add test cases +FOSSIL_TEST_SUITE(tdd_suite); + +// Setup function for the test suite +FOSSIL_SETUP(tdd_suite) { + // Setup code here +} + +// Teardown function for the test suite +FOSSIL_TEARDOWN(tdd_suite) { + // Teardown code here +} // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Cases @@ -37,175 +42,67 @@ // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST(xassert_run_of_int) { +FOSSIL_TEST_CASE(xassume_run_of_int) { int x = 42; int y = 20; // Test cases - TEST_ASSERT(x == 42, "Should have passed the test case"); - TEST_ASSERT(y == 20, "Should have passed the test case"); - TEST_ASSERT(x != y, "Should have passed the test case"); - TEST_ASSERT(y < x, "Should have passed the test case"); - TEST_ASSERT(y <= x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassert_run_of_int8) { - int8_t x = 42; - int8_t y = 20; - - // Test cases - TEST_ASSERT((int8_t)x == 42, "Should have passed the test case"); - TEST_ASSERT((int8_t)y == 20, "Should have passed the test case"); - TEST_ASSERT((int8_t)x != (int8_t)y, "Should have passed the test case"); - TEST_ASSERT((int8_t)y < (int8_t)x, "Should have passed the test case"); - TEST_ASSERT((int8_t)y <= (int8_t)x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassert_run_of_int16) { - int16_t x = 42; - int16_t y = 20; - - // Test cases - TEST_ASSERT((int16_t)x == 42, "Should have passed the test case"); - TEST_ASSERT((int16_t)y == 20, "Should have passed the test case"); - TEST_ASSERT((int16_t)x != (int16_t)y, "Should have passed the test case"); - TEST_ASSERT((int16_t)y < (int16_t)x, "Should have passed the test case"); - TEST_ASSERT((int16_t)y <= (int16_t)x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassert_run_of_int32) { - int32_t x = 42; - int32_t y = 20; - - // Test cases - TEST_ASSERT((int32_t)x == 42, "Should have passed the test case"); - TEST_ASSERT((int32_t)y == 20, "Should have passed the test case"); - TEST_ASSERT((int32_t)x != (int32_t)y, "Should have passed the test case"); - TEST_ASSERT((int32_t)y < (int32_t)x, "Should have passed the test case"); - TEST_ASSERT((int32_t)y <= (int32_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); } // end case -FOSSIL_TEST(xassert_run_of_int64) { - int64_t x = 42; - int64_t y = 20; - - // Test cases - TEST_ASSERT((int64_t)x == 42, "Should have passed the test case"); - TEST_ASSERT((int64_t)y == 20, "Should have passed the test case"); - TEST_ASSERT((int64_t)x != (int64_t)y, "Should have passed the test case"); - TEST_ASSERT((int64_t)y < (int64_t)x, "Should have passed the test case"); - TEST_ASSERT((int64_t)y <= (int64_t)x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassert_run_of_int8_shortcut) { +FOSSIL_TEST_CASE(xassume_run_of_int8) { int8_t x = 42; int8_t y = 20; // Test cases - ASSERT_ITS_EQUAL_I8((int8_t)x, 42); - ASSERT_ITS_EQUAL_I8((int8_t)y, 20); - ASSERT_NOT_EQUAL_I8((int8_t)x, (int8_t)y); - ASSERT_ITS_LESS_THAN_I8((int8_t)y, (int8_t)x); - ASSERT_ITS_LESS_OR_EQUAL_I8((int8_t)y, (int8_t)x); + FOSSIL_TEST_ASSUME((int8_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int8_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int8_t)x != (int8_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int8_t)y < (int8_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int8_t)y <= (int8_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST(xassert_run_of_int16_shortcut) { +FOSSIL_TEST_CASE(xassume_run_of_int16) { int16_t x = 42; int16_t y = 20; // Test cases - ASSERT_ITS_EQUAL_I16((int16_t)x, 42); - ASSERT_ITS_EQUAL_I16((int16_t)y, 20); - ASSERT_NOT_EQUAL_I16((int16_t)x, (int16_t)y); - ASSERT_ITS_LESS_THAN_I16((int16_t)y, (int16_t)x); - ASSERT_ITS_LESS_OR_EQUAL_I16((int16_t)y, (int16_t)x); + FOSSIL_TEST_ASSUME((int16_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int16_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int16_t)x != (int16_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int16_t)y < (int16_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int16_t)y <= (int16_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST(xassert_run_of_int32_shortcut) { +FOSSIL_TEST_CASE(xassume_run_of_int32) { int32_t x = 42; int32_t y = 20; // Test cases - ASSERT_ITS_EQUAL_I32((int32_t)x, 42); - ASSERT_ITS_EQUAL_I32((int32_t)y, 20); - ASSERT_NOT_EQUAL_I32((int32_t)x, (int32_t)y); - ASSERT_ITS_LESS_THAN_I32((int32_t)y, (int32_t)x); - ASSERT_ITS_LESS_OR_EQUAL_I32((int32_t)y, (int32_t)x); + FOSSIL_TEST_ASSUME((int32_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int32_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int32_t)x != (int32_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int32_t)y < (int32_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int32_t)y <= (int32_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST(xassert_run_of_int64_shortcut) { +FOSSIL_TEST_CASE(xassume_run_of_int64) { int64_t x = 42; int64_t y = 20; // Test cases - ASSERT_ITS_EQUAL_I64((int64_t)x, 42); - ASSERT_ITS_EQUAL_I64((int64_t)y, 20); - ASSERT_NOT_EQUAL_I64((int64_t)x, (int64_t)y); - ASSERT_ITS_LESS_THAN_I64((int64_t)y, (int64_t)x); - ASSERT_ITS_LESS_OR_EQUAL_I64((int64_t)y, (int64_t)x); -} // end case - -FOSSIL_TEST(xassume_run_of_int) { - int x = 42; - int y = 20; - - // Test cases - TEST_ASSUME(x == 42, "Should have passed the test case"); - TEST_ASSUME(y == 20, "Should have passed the test case"); - TEST_ASSUME(x != y, "Should have passed the test case"); - TEST_ASSUME(y < x, "Should have passed the test case"); - TEST_ASSUME(y <= x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int64_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int64_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int64_t)x != (int64_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int64_t)y < (int64_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((int64_t)y <= (int64_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST(xassume_run_of_int8) { - int8_t x = 42; - int8_t y = 20; - - // Test cases - TEST_ASSUME((int8_t)x == 42, "Should have passed the test case"); - TEST_ASSUME((int8_t)y == 20, "Should have passed the test case"); - TEST_ASSUME((int8_t)x != (int8_t)y, "Should have passed the test case"); - TEST_ASSUME((int8_t)y < (int8_t)x, "Should have passed the test case"); - TEST_ASSUME((int8_t)y <= (int8_t)x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassume_run_of_int16) { - int16_t x = 42; - int16_t y = 20; - - // Test cases - TEST_ASSUME((int16_t)x == 42, "Should have passed the test case"); - TEST_ASSUME((int16_t)y == 20, "Should have passed the test case"); - TEST_ASSUME((int16_t)x != (int16_t)y, "Should have passed the test case"); - TEST_ASSUME((int16_t)y < (int16_t)x, "Should have passed the test case"); - TEST_ASSUME((int16_t)y <= (int16_t)x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassume_run_of_int32) { - int32_t x = 42; - int32_t y = 20; - - // Test cases - TEST_ASSUME((int32_t)x == 42, "Should have passed the test case"); - TEST_ASSUME((int32_t)y == 20, "Should have passed the test case"); - TEST_ASSUME((int32_t)x != (int32_t)y, "Should have passed the test case"); - TEST_ASSUME((int32_t)y < (int32_t)x, "Should have passed the test case"); - TEST_ASSUME((int32_t)y <= (int32_t)x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassume_run_of_int64) { - int64_t x = 42; - int64_t y = 20; - - // Test cases - TEST_ASSUME((int64_t)x == 42, "Should have passed the test case"); - TEST_ASSUME((int64_t)y == 20, "Should have passed the test case"); - TEST_ASSUME((int64_t)x != (int64_t)y, "Should have passed the test case"); - TEST_ASSUME((int64_t)y < (int64_t)x, "Should have passed the test case"); - TEST_ASSUME((int64_t)y <= (int64_t)x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassume_run_of_int8_shortcut) { +FOSSIL_TEST_CASE(xassume_run_of_int8_shortcut) { int8_t x = 42; int8_t y = 20; @@ -217,7 +114,7 @@ FOSSIL_TEST(xassume_run_of_int8_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I8((int8_t)y, (int8_t)x); } // end case -FOSSIL_TEST(xassume_run_of_int16_shortcut) { +FOSSIL_TEST_CASE(xassume_run_of_int16_shortcut) { int16_t x = 42; int16_t y = 20; @@ -229,7 +126,7 @@ FOSSIL_TEST(xassume_run_of_int16_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I16((int16_t)y, (int16_t)x); } // end case -FOSSIL_TEST(xassume_run_of_int32_shortcut) { +FOSSIL_TEST_CASE(xassume_run_of_int32_shortcut) { int32_t x = 42; int32_t y = 20; @@ -241,7 +138,7 @@ FOSSIL_TEST(xassume_run_of_int32_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I32((int32_t)y, (int32_t)x); } // end case -FOSSIL_TEST(xassume_run_of_int64_shortcut) { +FOSSIL_TEST_CASE(xassume_run_of_int64_shortcut) { int64_t x = 42; int64_t y = 20; @@ -253,143 +150,19 @@ FOSSIL_TEST(xassume_run_of_int64_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I64((int64_t)y, (int64_t)x); } // end case -FOSSIL_TEST(xexpect_run_of_int) { - int x = 42; - int y = 20; - - // Test cases - TEST_EXPECT(x == 42, "Should have passed the test case"); - TEST_EXPECT(y == 20, "Should have passed the test case"); - TEST_EXPECT(x != y, "Should have passed the test case"); - TEST_EXPECT(y < x, "Should have passed the test case"); - TEST_EXPECT(y <= x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xexpect_run_of_int8) { - int8_t x = 42; - int8_t y = 20; - - // Test cases - TEST_EXPECT((int8_t)x == 42, "Should have passed the test case"); - TEST_EXPECT((int8_t)y == 20, "Should have passed the test case"); - TEST_EXPECT((int8_t)x != (int8_t)y, "Should have passed the test case"); - TEST_EXPECT((int8_t)y < (int8_t)x, "Should have passed the test case"); - TEST_EXPECT((int8_t)y <= (int8_t)x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xexpect_run_of_int16) { - int16_t x = 42; - int16_t y = 20; - - // Test cases - TEST_EXPECT((int16_t)x == 42, "Should have passed the test case"); - TEST_EXPECT((int16_t)y == 20, "Should have passed the test case"); - TEST_EXPECT((int16_t)x != (int16_t)y, "Should have passed the test case"); - TEST_EXPECT((int16_t)y < (int16_t)x, "Should have passed the test case"); - TEST_EXPECT((int16_t)y <= (int16_t)x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xexpect_run_of_int32) { - int32_t x = 42; - int32_t y = 20; - - // Test cases - TEST_EXPECT((int32_t)x == 42, "Should have passed the test case"); - TEST_EXPECT((int32_t)y == 20, "Should have passed the test case"); - TEST_EXPECT((int32_t)x != (int32_t)y, "Should have passed the test case"); - TEST_EXPECT((int32_t)y < (int32_t)x, "Should have passed the test case"); - TEST_EXPECT((int32_t)y <= (int32_t)x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xexpect_run_of_int64) { - int64_t x = 42; - int64_t y = 20; - - // Test cases - TEST_EXPECT((int64_t)x == 42, "Should have passed the test case"); - TEST_EXPECT((int64_t)y == 20, "Should have passed the test case"); - TEST_EXPECT((int64_t)x != (int64_t)y, "Should have passed the test case"); - TEST_EXPECT((int64_t)y < (int64_t)x, "Should have passed the test case"); - TEST_EXPECT((int64_t)y <= (int64_t)x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xexpect_run_of_int8_shortcut) { - int8_t x = 42; - int8_t y = 20; - - // Test cases - EXPECT_ITS_EQUAL_I8((int8_t)x, 42); - EXPECT_ITS_EQUAL_I8((int8_t)y, 20); - EXPECT_NOT_EQUAL_I8((int8_t)x, (int8_t)y); - EXPECT_ITS_LESS_THAN_I8((int8_t)y, (int8_t)x); - EXPECT_ITS_LESS_OR_EQUAL_I8((int8_t)y, (int8_t)x); -} // end case - -FOSSIL_TEST(xexpect_run_of_int16_shortcut) { - int16_t x = 42; - int16_t y = 20; - - // Test cases - EXPECT_ITS_EQUAL_I16((int16_t)x, 42); - EXPECT_ITS_EQUAL_I16((int16_t)y, 20); - EXPECT_NOT_EQUAL_I16((int16_t)x, (int16_t)y); - EXPECT_ITS_LESS_THAN_I16((int16_t)y, (int16_t)x); - EXPECT_ITS_LESS_OR_EQUAL_I16((int16_t)y, (int16_t)x); -} // end case - -FOSSIL_TEST(xexpect_run_of_int32_shortcut) { - int32_t x = 42; - int32_t y = 20; - - // Test cases - EXPECT_ITS_EQUAL_I32((int32_t)x, 42); - EXPECT_ITS_EQUAL_I32((int32_t)y, 20); - EXPECT_NOT_EQUAL_I32((int32_t)x, (int32_t)y); - EXPECT_ITS_LESS_THAN_I32((int32_t)y, (int32_t)x); - EXPECT_ITS_LESS_OR_EQUAL_I32((int32_t)y, (int32_t)x); -} // end case - -FOSSIL_TEST(xexpect_run_of_int64_shortcut) { - int64_t x = 42; - int64_t y = 20; - - // Test cases - EXPECT_ITS_EQUAL_I64((int64_t)x, 42); - EXPECT_ITS_EQUAL_I64((int64_t)y, 20); - EXPECT_NOT_EQUAL_I64((int64_t)x, (int64_t)y); - EXPECT_ITS_LESS_THAN_I64((int64_t)y, (int64_t)x); - EXPECT_ITS_LESS_OR_EQUAL_I64((int64_t)y, (int64_t)x); -} // end case - // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * FOSSIL_TEST_GROUP(tdd_test_group) { - ADD_TEST(xassert_run_of_int); - ADD_TEST(xassert_run_of_int8); - ADD_TEST(xassert_run_of_int16); - ADD_TEST(xassert_run_of_int32); - ADD_TEST(xassert_run_of_int64); - ADD_TEST(xassert_run_of_int8_shortcut); - ADD_TEST(xassert_run_of_int16_shortcut); - ADD_TEST(xassert_run_of_int32_shortcut); - ADD_TEST(xassert_run_of_int64_shortcut); - ADD_TEST(xassume_run_of_int); - ADD_TEST(xassume_run_of_int8); - ADD_TEST(xassume_run_of_int16); - ADD_TEST(xassume_run_of_int32); - ADD_TEST(xassume_run_of_int64); - ADD_TEST(xassume_run_of_int8_shortcut); - ADD_TEST(xassume_run_of_int16_shortcut); - ADD_TEST(xassume_run_of_int32_shortcut); - ADD_TEST(xassume_run_of_int64_shortcut); - ADD_TEST(xexpect_run_of_int); - ADD_TEST(xexpect_run_of_int8); - ADD_TEST(xexpect_run_of_int16); - ADD_TEST(xexpect_run_of_int32); - ADD_TEST(xexpect_run_of_int64); - ADD_TEST(xexpect_run_of_int8_shortcut); - ADD_TEST(xexpect_run_of_int16_shortcut); - ADD_TEST(xexpect_run_of_int32_shortcut); - ADD_TEST(xexpect_run_of_int64_shortcut); + FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int); + FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int8); + FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int16); + FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int32); + FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int64); + FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int8_shortcut); + FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int16_shortcut); + FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int32_shortcut); + FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int64_shortcut); + + FOSSIL_TEST_REGISTER(tdd_suite); } // end of group diff --git a/code/tests/test_xfixture.c b/code/tests/test_xfixture.c deleted file mode 100644 index 1430a5bf..00000000 --- a/code/tests/test_xfixture.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Utilites -// * * * * * * * * * * * * * * * * * * * * * * * * -// Setup steps for things like test fixtures and -// mock objects are set here. -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST_DATA(sample_data) { - int x; - int y; -} sample_data; - -// Fixture setup and teardown procedures -FOSSIL_FIXTURE(sample_fixture); - -FOSSIL_SETUP(sample_fixture) { - sample_data.x = 42; - sample_data.y = 20; -} // end of setup - -FOSSIL_TEARDOWN(sample_fixture) { - // Teardown code goes here -} // end of teardown - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Cases -// * * * * * * * * * * * * * * * * * * * * * * * * -// The test cases below are provided as samples, inspired -// by the Meson build system's approach of using test cases -// as samples for library usage. -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST(xassert_with_fixture_run_of_int) { - // Test cases - TEST_ASSERT(sample_data.x == 42, "Should have passed the test case"); - TEST_ASSERT(sample_data.y == 20, "Should have passed the test case"); - TEST_ASSERT(sample_data.x != sample_data.y, "Should have passed the test case"); - TEST_ASSERT(sample_data.y < sample_data.x, "Should have passed the test case"); - TEST_ASSERT(sample_data.y <= sample_data.x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassert_with_fixture_run_of_int8) { - TEST_ASSERT((int8_t)sample_data.x == 42, "Should have passed the test case"); - TEST_ASSERT((int8_t)sample_data.y == 20, "Should have passed the test case"); - TEST_ASSERT((int8_t)sample_data.x != (int8_t)sample_data.y, "Should have passed the test case"); - TEST_ASSERT((int8_t)sample_data.y < (int8_t)sample_data.x, "Should have passed the test case"); - TEST_ASSERT((int8_t)sample_data.y <= (int8_t)sample_data.x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassert_with_fixture_run_of_int16) { - TEST_ASSERT((int16_t)sample_data.x == 42, "Should have passed the test case"); - TEST_ASSERT((int16_t)sample_data.y == 20, "Should have passed the test case"); - TEST_ASSERT((int16_t)sample_data.x != (int16_t)sample_data.y, "Should have passed the test case"); - TEST_ASSERT((int16_t)sample_data.y < (int16_t)sample_data.x, "Should have passed the test case"); - TEST_ASSERT((int16_t)sample_data.y <= (int16_t)sample_data.x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassert_with_fixture_run_of_int32) { - TEST_ASSERT((int32_t)sample_data.x == 42, "Should have passed the test case"); - TEST_ASSERT((int32_t)sample_data.y == 20, "Should have passed the test case"); - TEST_ASSERT((int32_t)sample_data.x != (int32_t)sample_data.y, "Should have passed the test case"); - TEST_ASSERT((int32_t)sample_data.y < (int32_t)sample_data.x, "Should have passed the test case"); - TEST_ASSERT((int32_t)sample_data.y <= (int32_t)sample_data.x, "Should have passed the test case"); -} // end case - -FOSSIL_TEST(xassert_with_fixture_run_of_int64) { - TEST_ASSERT((int64_t)sample_data.x == 42, "Should have passed the test case"); - TEST_ASSERT((int64_t)sample_data.y == 20, "Should have passed the test case"); - TEST_ASSERT((int64_t)sample_data.x != (int64_t)sample_data.y, "Should have passed the test case"); - TEST_ASSERT((int64_t)sample_data.y < (int64_t)sample_data.x, "Should have passed the test case"); - TEST_ASSERT((int64_t)sample_data.y <= (int64_t)sample_data.x, "Should have passed the test case"); -} // end case - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Pool -// * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_GROUP(fixture_test_group) { - ADD_TESTF(xassert_with_fixture_run_of_int, sample_fixture); - ADD_TESTF(xassert_with_fixture_run_of_int8, sample_fixture); - ADD_TESTF(xassert_with_fixture_run_of_int16, sample_fixture); - ADD_TESTF(xassert_with_fixture_run_of_int32, sample_fixture); - ADD_TESTF(xassert_with_fixture_run_of_int64, sample_fixture); -} // end of group diff --git a/code/tests/test_xsoneros.c b/code/tests/test_xsoneros.c deleted file mode 100644 index 1b44e0e8..00000000 --- a/code/tests/test_xsoneros.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Utilites -// * * * * * * * * * * * * * * * * * * * * * * * * -// Setup steps for things like test fixtures and -// mock objects are set here. -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST_DATA(sample_block) { - int x; - int y; -} sample_block; - -// Fixture setup and teardown procedures -FOSSIL_FEATURE(sample_feature); - -FOSSIL_SETUP(sample_feature) { - sample_block.x = 42; - sample_block.y = 20; -} // end of setup - -FOSSIL_TEARDOWN(sample_feature) { - // Teardown code goes here -} // end of teardown - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Cases -// * * * * * * * * * * * * * * * * * * * * * * * * -// The test cases below are provided as samples, inspired -// by the Meson build system's approach of using test cases -// as samples for library usage. -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_SONERO(xbdd_logic_within_feature_test) { - GIVEN("a valid statement is passed") { - // Set up the context - bool givenExecuted = true; - - WHEN("a statement is true") { - // Perform the login action - bool whenExecuted = true; - - THEN("we validate everything was worked") { - // Check the expected outcome - bool thenExecuted = true; - - TEST_EXPECT(givenExecuted, "Given statement should have executed"); - TEST_EXPECT(whenExecuted, "When statement should have executed"); - TEST_EXPECT(thenExecuted, "Then statement should have executed"); - } - } - } -} // end of case - -FOSSIL_SONERO(xbdd_user_account_within_feature) { - GIVEN("a user's account with sufficient balance") { - // Set up the context - float accountBalance = 500.0; - float withdrawalAmount = 200.0; - - WHEN("the user requests a withdrawal of $200") { - // Perform the withdrawal action - if (accountBalance >= withdrawalAmount) { - accountBalance -= withdrawalAmount; - } // end if - THEN("the withdrawal amount should be deducted from the account balance") { - // Check the expected outcome - - // Simulate the scenario - float compareBalance = 500.0; - TEST_EXPECT(accountBalance == (compareBalance - withdrawalAmount), "Account balance should have been deducted by $200"); - } - } - } -} // end of case - -FOSSIL_SONERO(xbdd_empty_cart_within_feature) { - GIVEN("a user with an empty shopping cart") { - // Set up the context - int cartItemCount = 0; - - WHEN("the user adds a product to the cart") { - // Perform the action of adding a product - - THEN("the cart item count should increase by 1") { - // Check the expected outcome - cartItemCount++; - - TEST_EXPECT(cartItemCount == 1, "Cart item count should have increased by 1"); - } - } - } -} // end of case - -FOSSIL_SONERO(xbdd_valid_login_within_feature) { - GIVEN("a registered user with valid credentials") { - // Set up the context - const char* validUsername = "user123"; - const char* validPassword = "pass456"; - - WHEN("the user provides correct username and password") { - // Perform the action of user login - const char* inputUsername = "user123"; - const char* inputPassword = "pass456"; - - THEN("the login should be successful") { - // Check the expected outcome - // Simulate login validation - TEST_EXPECT(strcmp(inputUsername, validUsername) == 0, "Username should match"); - TEST_EXPECT(strcmp(inputPassword, validPassword) == 0, "Password should match"); - } - } - - WHEN("the user provides incorrect password") { - // Perform the action of user login - const char* inputUsername = "user123"; - const char* inputPassword = "wrongpass"; - - THEN("the login should fail with an error message") { - // Check the expected outcome - // Simulate login validation - TEST_EXPECT(strcmp(inputUsername, validUsername) == 0, "Username should match"); - TEST_EXPECT(strcmp(inputPassword, validPassword) != 0, "Password should not match"); - } - } - } -} // end of case - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Pool -// * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_GROUP(feature_test_group) { - ADD_TESTF(xbdd_logic_within_feature_test, sample_feature); - ADD_TESTF(xbdd_user_account_within_feature, sample_feature); - ADD_TESTF(xbdd_empty_cart_within_feature, sample_feature); - ADD_TESTF(xbdd_valid_login_within_feature, sample_feature); -} // end of group diff --git a/code/tests/generate-runner.py b/code/tests/tools/generate-runner.py similarity index 93% rename from code/tests/generate-runner.py rename to code/tests/tools/generate-runner.py index cdc3e069..afa54ff7 100644 --- a/code/tests/generate-runner.py +++ b/code/tests/tools/generate-runner.py @@ -26,7 +26,7 @@ def generate_test_runner(self, test_groups): """ header += """ -#include +#include """ header += """ @@ -47,7 +47,7 @@ def generate_test_runner(self, test_groups): runner += """ int main(int argc, char **argv) { - FOSSIL_TEST_CREATE(argc, argv);\n""" + FOSSIL_TEST_START(argc, argv);\n""" import_pools = "\n".join( [f" FOSSIL_TEST_IMPORT({group});" for group in test_groups] @@ -55,7 +55,8 @@ def generate_test_runner(self, test_groups): footer = """ FOSSIL_TEST_RUN(); - return FOSSIL_TEST_ERASE(); + FOSSIL_TEST_SUMMARY(); + FOSSIL_TEST_END(); } // end of func """ diff --git a/meson.build b/meson.build index 66f836ec..46c5a017 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('Fossil Test', 'c', 'cpp', meson_version: '>=1.3.0', license: 'MPL-2.0', - version: '1.0.6', - default_options: ['c_std=c18', 'cpp_std=c++20']) + version: '1.0.7', + default_options: ['c_std=c11,c18', 'cpp_std=c++20']) subdir('code')