diff --git a/.github/ciimage/Dockerfile.archlinux b/.github/ciimage/Dockerfile.archlinux index 5adbb71..a3fb67e 100644 --- a/.github/ciimage/Dockerfile.archlinux +++ b/.github/ciimage/Dockerfile.archlinux @@ -11,7 +11,6 @@ RUN pacman -Syu --noconfirm && \ clang \ gdb \ llvm \ - cmake \ wget \ python \ python-pip \ diff --git a/.github/ciimage/Dockerfile.debian b/.github/ciimage/Dockerfile.debian index 86a86b4..bd9c16f 100644 --- a/.github/ciimage/Dockerfile.debian +++ b/.github/ciimage/Dockerfile.debian @@ -15,7 +15,6 @@ RUN apt-get update && \ gdb \ llvm \ libstdc++-8-dev \ - cmake \ wget \ python3 \ python3-pip \ diff --git a/.github/ciimage/Dockerfile.fedora b/.github/ciimage/Dockerfile.fedora index e9cb950..ca44d19 100644 --- a/.github/ciimage/Dockerfile.fedora +++ b/.github/ciimage/Dockerfile.fedora @@ -13,15 +13,13 @@ RUN dnf -y update && \ clang \ gdb \ llvm \ - rust \ - cargo \ wget \ python3 \ python3-pip \ git && \ dnf clean all # Install Meson and Ninja using pip -RUN python3 -m pip install --no-cache-dir cmake meson ninja +RUN python3 -m pip install --no-cache-dir meson ninja # Set environment variables ENV CC=/usr/bin/clang diff --git a/.github/ciimage/Dockerfile.ubuntu b/.github/ciimage/Dockerfile.ubuntu index efd63a3..66eb6f6 100644 --- a/.github/ciimage/Dockerfile.ubuntu +++ b/.github/ciimage/Dockerfile.ubuntu @@ -15,8 +15,6 @@ RUN apt-get update && \ gdb \ llvm \ libstdc++-10-dev \ - rustc \ - cargo \ wget \ python3 \ python3-pip \ @@ -25,7 +23,7 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -RUN python3 -m pip install --no-cache-dir cmake meson ninja +RUN python3 -m pip install --no-cache-dir meson ninja # Set environment variables ENV CC=/usr/bin/gcc diff --git a/code/logic/device.c b/code/logic/device.c deleted file mode 100644 index 61b2b6e..0000000 --- a/code/logic/device.c +++ /dev/null @@ -1,345 +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) - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include "fossil/io/device.h" -#include "fossil/io/output.h" -#include -#include -#include - -#if defined(_WIN32) || defined(_WIN64) - #include - #include -#else - #include - #include - #include - #include // For fd_set, FD_ZERO, FD_SET, select - #include // For struct timeval - #include // For system types -#endif - -#define MAX_KEYBINDS 256 -#define MAX_TOUCHBINDS 256 -#define MAX_MOUSEBINDS 256 - -typedef struct { - fossil_io_mouse_event_t event; - fossil_io_mouse_callback_t callback; -} fossil_io_mouse_binding_t; - -typedef struct { - fossil_io_mouse_binding_t bindings[MAX_MOUSEBINDS]; - size_t count; -} fossil_io_mouse_manager_t; - -typedef struct { - fossil_io_touch_event_t event; - fossil_io_touch_callback_t callback; -} fossil_io_touch_binding_t; - -typedef struct { - fossil_io_touch_binding_t bindings[MAX_TOUCHBINDS]; - size_t count; -} fossil_io_touch_manager_t; - -typedef struct { - fossil_io_keyboard_event_t event; - fossil_io_keyboard_callback_t callback; -} fossil_io_keyboard_binding_t; - -typedef struct { - fossil_io_keyboard_binding_t bindings[MAX_KEYBINDS]; - size_t count; -} fossil_io_keyboard_manager_t; - -static fossil_io_keyboard_manager_t keyboard_manager; -static fossil_io_touch_manager_t touch_manager; -static fossil_io_mouse_manager_t mouse_manager; - - -#if defined(_WIN32) || defined(_WIN64) - -static int fossil_io_keyboard_is_key_pressed(void) { - return _kbhit(); -} - -static fossil_io_keyboard_event_t fossil_io_keyboard_get_event(void) { - fossil_io_keyboard_event_t event = {0}; - int key = _getch(); - - // Check for extended keys (e.g., arrow keys, function keys) - if (key == 0 || key == 224) { - key = _getch(); // Fetch the actual key code - } - - // Check modifiers - event.shift = GetKeyState(VK_SHIFT) & 0x8000; - event.ctrl = GetKeyState(VK_CONTROL) & 0x8000; - event.alt = GetKeyState(VK_MENU) & 0x8000; - event.key = (char)key; - - return event; -} - -#else -static struct termios old_termios, new_termios; - -static void fossil_io_keyboard_enable_raw_mode(void) { - tcgetattr(STDIN_FILENO, &old_termios); - new_termios = old_termios; - new_termios.c_lflag &= ~(ICANON | ECHO); - tcsetattr(STDIN_FILENO, TCSANOW, &new_termios); -} - -static void fossil_io_keyboard_disable_raw_mode(void) { - tcsetattr(STDIN_FILENO, TCSANOW, &old_termios); -} - -static int fossil_io_keyboard_is_key_pressed(void) { - struct timeval timeout = {0L, 0L}; - fd_set fds; - FD_ZERO(&fds); - FD_SET(STDIN_FILENO, &fds); - return select(STDIN_FILENO + 1, &fds, NULL, NULL, &timeout) > 0; -} - -static fossil_io_keyboard_event_t fossil_io_keyboard_get_event(void) { - fossil_io_keyboard_event_t event = {0}; - char c; - read(STDIN_FILENO, &c, 1); - - event.key = c; - - // Modifier keys (POSIX doesn't have direct access to key states; approximation) - if (c == 27) { // Alt key (ESC sequence) - event.alt = 1; - read(STDIN_FILENO, &c, 1); - event.key = c; - } else if (c < 32) { // Ctrl key (control characters) - event.ctrl = 1; - event.key = c + 96; // Map to lowercase ASCII - } else if (c == 127) { // Backspace key with Ctrl - event.ctrl = 1; - event.key = 8; - } - - return event; -} -#endif - -void fossil_io_keyboard_init(void) { - memset(&keyboard_manager, 0, sizeof(keyboard_manager)); -#if defined(_WIN32) || defined(_WIN64) - // Windows doesn't require explicit setup for raw mode. -#else - fossil_io_keyboard_enable_raw_mode(); - atexit(fossil_io_keyboard_disable_raw_mode); -#endif -} - -void fossil_io_keyboard_shutdown(void) { - memset(&keyboard_manager, 0, sizeof(keyboard_manager)); -#if defined(_WIN32) || defined(_WIN64) - // Windows doesn't require explicit cleanup for raw mode. -#else - fossil_io_keyboard_disable_raw_mode(); -#endif -} - -void fossil_io_keyboard_clear_bindings(void) { - keyboard_manager.count = 0; -} - -void fossil_io_keyboard_register_binding(fossil_io_keyboard_event_t event, fossil_io_keyboard_callback_t callback) { - if (keyboard_manager.count < MAX_KEYBINDS) { - keyboard_manager.bindings[keyboard_manager.count].event = event; - keyboard_manager.bindings[keyboard_manager.count].callback = callback; - keyboard_manager.count++; - } else { - fossil_io_fprintf(FOSSIL_STDERR, "Max keybindings reached.\n"); - } -} - -void fossil_io_keyboard_unregister_binding(fossil_io_keyboard_event_t event) { - for (size_t i = 0; i < keyboard_manager.count; ++i) { - if (keyboard_manager.bindings[i].event.key == event.key && - keyboard_manager.bindings[i].event.shift == event.shift && - keyboard_manager.bindings[i].event.ctrl == event.ctrl && - keyboard_manager.bindings[i].event.alt == event.alt) { - for (size_t j = i; j < keyboard_manager.count - 1; ++j) { - keyboard_manager.bindings[j] = keyboard_manager.bindings[j + 1]; - } - keyboard_manager.count--; - return; - } - } - fossil_io_fprintf(FOSSIL_STDERR, "No matching keybinding to unregister.\n"); -} - -void fossil_io_keyboard_poll_events(void) { - if (fossil_io_keyboard_is_key_pressed()) { - fossil_io_keyboard_event_t event = fossil_io_keyboard_get_event(); - - for (size_t i = 0; i < keyboard_manager.count; ++i) { - fossil_io_keyboard_binding_t *binding = &keyboard_manager.bindings[i]; - if (binding->event.key == event.key && - binding->event.shift == event.shift && - binding->event.ctrl == event.ctrl && - binding->event.alt == event.alt) { - if (binding->callback) { - binding->callback(event); - } - break; - } - } - } -} - -// MOUSE -static int fossil_io_mouse_event_match(const fossil_io_mouse_event_t* a, const fossil_io_mouse_event_t* b) { - return (a->button == b->button && - (a->shift == b->shift || a->shift == -1 || b->shift == -1) && - (a->ctrl == b->ctrl || a->ctrl == -1 || b->ctrl == -1) && - (a->alt == b->alt || a->alt == -1 || b->alt == -1)); -} - -// Dummy OS-agnostic implementation for now -static void fossil_io_mouse_get_event(fossil_io_mouse_event_t* event) { - static int toggle = 0; - event->x = 100 + (toggle++ % 10); - event->y = 200 + (toggle % 5); - event->button = toggle % 2; - event->shift = -1; - event->ctrl = -1; - event->alt = -1; -} - -void fossil_io_mouse_register_binding(fossil_io_mouse_event_t event, fossil_io_mouse_callback_t callback) { - if (mouse_manager.count >= MAX_MOUSEBINDS) { - fossil_io_fprintf(FOSSIL_STDERR, "[mouse] Max bindings reached\n"); - return; - } - - mouse_manager.bindings[mouse_manager.count++] = (fossil_io_mouse_binding_t){ event, callback }; -} - -void fossil_io_mouse_unregister_binding(fossil_io_mouse_event_t event) { - for (size_t i = 0; i < mouse_manager.count; ++i) { - if (fossil_io_mouse_event_match(&mouse_manager.bindings[i].event, &event)) { - memmove(&mouse_manager.bindings[i], &mouse_manager.bindings[i + 1], - sizeof(fossil_io_mouse_binding_t) * (mouse_manager.count - i - 1)); - --mouse_manager.count; - return; - } - } - fossil_io_fprintf(FOSSIL_STDERR, "[mouse] Binding not found\n"); -} - -void fossil_io_mouse_poll_events(void) { - fossil_io_mouse_event_t event = {0}; - fossil_io_mouse_get_event(&event); - - for (size_t i = 0; i < mouse_manager.count; ++i) { - if (fossil_io_mouse_event_match(&mouse_manager.bindings[i].event, &event)) { - if (mouse_manager.bindings[i].callback) { - mouse_manager.bindings[i].callback(event); - } - } - } -} - -void fossil_io_mouse_clear_bindings(void) { - mouse_manager.count = 0; - for (size_t i = 0; i < MAX_MOUSEBINDS; ++i) { - mouse_manager.bindings[i].callback = NULL; - } -} - -void fossil_io_mouse_init(void) { - memset(&mouse_manager, 0, sizeof(mouse_manager)); -} - -void fossil_io_mouse_shutdown(void) { - memset(&mouse_manager, 0, sizeof(mouse_manager)); -} - -// TOUCH -static int fossil_io_touch_event_match(const fossil_io_touch_event_t* a, const fossil_io_touch_event_t* b) { - return (a->touch_id == b->touch_id && - a->action == b->action && - (a->shift == b->shift || a->shift == -1 || b->shift == -1) && - (a->ctrl == b->ctrl || a->ctrl == -1 || b->ctrl == -1) && - (a->alt == b->alt || a->alt == -1 || b->alt == -1)); -} - -// Dummy implementation for simulation/testing -static void fossil_io_touch_get_event(fossil_io_touch_event_t* event) { - static int state = 0; - event->x = 320 + (state % 3); - event->y = 240 + (state % 2); - event->touch_id = 1; - event->action = state++ % 3; // 0=start, 1=move, 2=end - event->shift = -1; - event->ctrl = -1; - event->alt = -1; -} - -void fossil_io_touch_register_binding(fossil_io_touch_event_t event, fossil_io_touch_callback_t callback) { - if (touch_manager.count >= MAX_TOUCHBINDS) { - fossil_io_fprintf(FOSSIL_STDERR, "[touch] Max bindings reached\n"); - return; - } - - touch_manager.bindings[touch_manager.count++] = (fossil_io_touch_binding_t){ event, callback }; -} - -void fossil_io_touch_unregister_binding(fossil_io_touch_event_t event) { - for (size_t i = 0; i < touch_manager.count; ++i) { - if (fossil_io_touch_event_match(&touch_manager.bindings[i].event, &event)) { - memmove(&touch_manager.bindings[i], &touch_manager.bindings[i + 1], - sizeof(fossil_io_touch_binding_t) * (touch_manager.count - i - 1)); - --touch_manager.count; - return; - } - } - fossil_io_fprintf(FOSSIL_STDERR, "[touch] Binding not found\n"); -} - -void fossil_io_touch_poll_events(void) { - fossil_io_touch_event_t event = {0}; - fossil_io_touch_get_event(&event); - - for (size_t i = 0; i < touch_manager.count; ++i) { - if (fossil_io_touch_event_match(&touch_manager.bindings[i].event, &event)) { - if (touch_manager.bindings[i].callback) { - touch_manager.bindings[i].callback(event); - } - } - } -} - -void fossil_io_touch_clear_bindings(void) { - touch_manager.count = 0; - for (size_t i = 0; i < MAX_TOUCHBINDS; ++i) { - touch_manager.bindings[i].callback = NULL; - } -} - -void fossil_io_touch_init(void) { - memset(&touch_manager, 0, sizeof(touch_manager)); -} - -void fossil_io_touch_shutdown(void) { - memset(&touch_manager, 0, sizeof(touch_manager)); -} diff --git a/code/logic/fossil/io/device.h b/code/logic/fossil/io/device.h deleted file mode 100644 index e185493..0000000 --- a/code/logic/fossil/io/device.h +++ /dev/null @@ -1,376 +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) - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_IO_DEVICE_H -#define FOSSIL_IO_DEVICE_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - int x; // X position of the mouse - int y; // Y position of the mouse - int button; // Mouse button (0 = left, 1 = right, etc.) - int shift; // 1 if Shift is pressed, 0 otherwise - int ctrl; // 1 if Ctrl is pressed, 0 otherwise - int alt; // 1 if Alt is pressed, 0 otherwise -} fossil_io_mouse_event_t; - -typedef void (*fossil_io_mouse_callback_t)(fossil_io_mouse_event_t event); - -typedef struct { - int x; // X position of the touch - int y; // Y position of the touch - int touch_id; // Unique identifier for the touch (for multi-touch) - int action; // Action: 0 = start, 1 = move, 2 = end - int shift; // 1 if Shift is pressed, 0 otherwise - int ctrl; // 1 if Ctrl is pressed, 0 otherwise - int alt; // 1 if Alt is pressed, 0 otherwise -} fossil_io_touch_event_t; - -typedef void (*fossil_io_touch_callback_t)(fossil_io_touch_event_t event); - -// Define a keyboard event structure -typedef struct { - int shift; // 1 if Shift is pressed, 0 otherwise - int ctrl; // 1 if Ctrl is pressed, 0 otherwise - int alt; // 1 if Alt is pressed, 0 otherwise - char key; // The character of the key pressed -} fossil_io_keyboard_event_t; - -// Define a callback type for key events -typedef void (*fossil_io_keyboard_callback_t)(fossil_io_keyboard_event_t event); - -/** - * Initialize the keyboard library. - * Sets up any platform-specific configurations. - */ -void fossil_io_keyboard_init(void); - -/** - * Shut down the keyboard library. - * Cleans up any platform-specific configurations. - */ -void fossil_io_keyboard_shutdown(void); - -/** - * Clear all keybindings from the library. - */ -void fossil_io_keyboard_clear_bindings(void); - -/** - * Register a keybinding with the library. - * - * @param event The keyboard event to bind to. - * @param callback The callback function to call when the event occurs. - */ -void fossil_io_keyboard_register_binding(fossil_io_keyboard_event_t event, fossil_io_keyboard_callback_t callback); - -/** - * Unregister a keybinding with the library. - * - * @param event The keyboard event to unbind. - */ -void fossil_io_keyboard_unregister_binding(fossil_io_keyboard_event_t event); - -/** - * Poll for keyboard events and trigger any registered callbacks. - * This function should be called in the main loop of the application. - */ -void fossil_io_keyboard_poll_events(void); - -/** @brief Initialize the mouse event library. */ -void fossil_io_mouse_init(void); - -/** @brief Shut down the mouse event library. */ -void fossil_io_mouse_shutdown(void); - -/** @brief Clear all mouse event bindings. */ -void fossil_io_mouse_clear_bindings(void); - -/** - * @brief Register a mouse event binding. - * @param event The mouse event to bind. - * @param callback The callback function to invoke when the event occurs. - */ -void fossil_io_mouse_register_binding(fossil_io_mouse_event_t event, fossil_io_mouse_callback_t callback); - -/** - * @brief Unregister a mouse event binding. - * @param event The mouse event to unbind. - */ -void fossil_io_mouse_unregister_binding(fossil_io_mouse_event_t event); - -/** @brief Poll and dispatch pending mouse events. */ -void fossil_io_mouse_poll_events(void); - -/** @brief Initialize the touch event library. */ -void fossil_io_touch_init(void); - -/** @brief Shut down the touch event library. */ -void fossil_io_touch_shutdown(void); - -/** @brief Clear all touch event bindings. */ -void fossil_io_touch_clear_bindings(void); - -/** - * @brief Register a touch event binding. - * @param event The touch event to bind. - * @param callback The callback function to invoke when the event occurs. - */ -void fossil_io_touch_register_binding(fossil_io_touch_event_t event, fossil_io_touch_callback_t callback); - -/** - * @brief Unregister a touch event binding. - * @param event The touch event to unbind. - */ -void fossil_io_touch_unregister_binding(fossil_io_touch_event_t event); - -/** @brief Poll and dispatch pending touch events. */ -void fossil_io_touch_poll_events(void); - -#ifdef __cplusplus -} - -/** - * C++ wrapper for the SOAP API. - */ -namespace fossil { - - /** - * Namespace for I/O operations. - */ - namespace io { - - /** - * @brief Class for managing keyboard input. - * - * This class provides a high-level interface for handling keyboard input. - * It wraps the underlying C API and manages initialization and cleanup automatically. - */ - class Keyboard { - public: - /** - * @brief Constructor that initializes the keyboard system. - * - * Call this to set up the keyboard event system. - * Automatically prepares the library for receiving and processing keyboard events. - */ - Keyboard() { - fossil_io_keyboard_init(); - } - - /** - * @brief Destructor that shuts down the keyboard system. - * - * Automatically cleans up the keyboard event system on destruction. - * This prevents memory leaks and releases any platform-specific resources. - */ - ~Keyboard() { - fossil_io_keyboard_shutdown(); - } - - /** - * @brief Clear all registered keyboard bindings. - * - * Use this method to remove all current keyboard event bindings. - * This is useful if you want to reset the input state or rebind controls dynamically. - */ - void clear_bindings() { - fossil_io_keyboard_clear_bindings(); - } - - /** - * @brief Register a keyboard event binding. - * - * Binds a specific keyboard event to a callback function. When the event occurs, - * the corresponding callback will be executed. - * - * @param event The keyboard event to listen for. - * @param callback The function to call when the event is triggered. - */ - void register_binding(fossil_io_keyboard_event_t event, fossil_io_keyboard_callback_t callback) { - fossil_io_keyboard_register_binding(event, callback); - } - - /** - * @brief Unregister a specific keyboard event binding. - * - * Removes the callback associated with a particular keyboard event. - * - * @param event The event for which the callback should be removed. - */ - void unregister_binding(fossil_io_keyboard_event_t event) { - fossil_io_keyboard_unregister_binding(event); - } - - /** - * @brief Poll for keyboard events and dispatch callbacks. - * - * Call this in your main loop to process pending keyboard events. - * It will trigger any registered callbacks for events that have occurred. - */ - void poll_events() { - fossil_io_keyboard_poll_events(); - } - }; - - /** - * @brief Class for managing mouse input. - * - * This class provides a modern C++ interface for handling mouse interactions. - * It wraps the underlying mouse system and ensures proper initialization and cleanup. - */ - class Mouse { - public: - /** - * @brief Constructor that initializes the mouse system. - * - * Prepares the internal state for processing mouse input. - * Must be called before polling for events or registering bindings. - */ - Mouse() { - fossil_io_mouse_init(); - } - - /** - * @brief Destructor that shuts down the mouse system. - * - * Cleans up resources associated with mouse input. - * Should not be called manually if you're using stack allocation. - */ - ~Mouse() { - fossil_io_mouse_shutdown(); - } - - /** - * @brief Clear all mouse bindings. - * - * Removes all registered mouse event bindings. - * Use this to reset or reconfigure the input system during runtime. - */ - void clear_bindings() { - fossil_io_mouse_clear_bindings(); - } - - /** - * @brief Register a mouse event binding. - * - * Assigns a callback to a specific mouse event. - * - * @param event The mouse event (e.g., click, movement). - * @param callback The function to invoke when the event occurs. - */ - void register_binding(fossil_io_mouse_event_t event, fossil_io_mouse_callback_t callback) { - fossil_io_mouse_register_binding(event, callback); - } - - /** - * @brief Unregister a mouse event binding. - * - * Detaches a callback from a previously bound mouse event. - * - * @param event The event to unbind. - */ - void unregister_binding(fossil_io_mouse_event_t event) { - fossil_io_mouse_unregister_binding(event); - } - - /** - * @brief Poll for mouse events and invoke callbacks. - * - * Should be called regularly (e.g., in your main loop) to process - * incoming mouse events and dispatch them to registered handlers. - */ - void poll_events() { - fossil_io_mouse_poll_events(); - } - }; - - /** - * @brief Class for managing touch input. - * - * Provides an abstraction layer for working with touchscreen input. - * Ensures the input system is initialized and destroyed cleanly. - */ - class Touch { - public: - /** - * @brief Constructor that initializes the touch system. - * - * Sets up the library to begin listening for touch interactions. - */ - Touch() { - fossil_io_touch_init(); - } - - /** - * @brief Destructor that shuts down the touch system. - * - * Releases any resources used for handling touch input. - */ - ~Touch() { - fossil_io_touch_shutdown(); - } - - /** - * @brief Clear all touch bindings. - * - * Removes all existing event-to-callback mappings for touch input. - */ - void clear_bindings() { - fossil_io_touch_clear_bindings(); - } - - /** - * @brief Register a touch event binding. - * - * Associates a callback with a specific touch event. - * - * @param event The type of touch event to respond to. - * @param callback The function to invoke when the event occurs. - */ - void register_binding(fossil_io_touch_event_t event, fossil_io_touch_callback_t callback) { - fossil_io_touch_register_binding(event, callback); - } - - /** - * @brief Unregister a touch event binding. - * - * Removes the callback associated with the given touch event. - * - * @param event The event whose binding should be removed. - */ - void unregister_binding(fossil_io_touch_event_t event) { - fossil_io_touch_unregister_binding(event); - } - - /** - * @brief Poll for touch events and dispatch them to callbacks. - * - * Should be called frequently to handle active touch events. - */ - void poll_events() { - fossil_io_touch_poll_events(); - } - }; - } -} - -#endif - -#endif /* FOSSIL_IO_FRAMEWORK_H */ diff --git a/code/logic/fossil/io/framework.h b/code/logic/fossil/io/framework.h index bee6985..f6d99e8 100644 --- a/code/logic/fossil/io/framework.h +++ b/code/logic/fossil/io/framework.h @@ -16,7 +16,6 @@ // Include the necessary headers #include "serialize.h" -#include "device.h" #include "network.h" #include "output.h" #include "input.h" diff --git a/code/logic/fossil/io/network.h b/code/logic/fossil/io/network.h index 9b9def6..b5c05a5 100644 --- a/code/logic/fossil/io/network.h +++ b/code/logic/fossil/io/network.h @@ -185,6 +185,15 @@ fossil_nstream_t *fossil_nstream_accept(fossil_nstream_t *server); */ ssize_t fossil_nstream_send(fossil_nstream_t *stream, const void *buffer, size_t size); +/** + * Set the SO_REUSEADDR option on a network stream's underlying socket. + * + * @param stream The network stream to configure. + * @param enable Nonzero to enable SO_REUSEADDR, zero to disable. + * @return 0 on success, or -1 on failure. + */ +int fossil_nstream_set_reuseaddr(fossil_nstream_t *stream, int enable); + /** * Receive data through a network stream. * diff --git a/code/logic/fossil/io/output.h b/code/logic/fossil/io/output.h index 5668aa3..3fdfc29 100644 --- a/code/logic/fossil/io/output.h +++ b/code/logic/fossil/io/output.h @@ -22,7 +22,6 @@ extern "C" { #endif extern int32_t FOSSIL_IO_COLOR_ENABLE; // Flag to enable/disable color output -extern int32_t FOSSIL_IO_ATTR_ENABLE; // Flag to enable/disable attribute output /** * This code provides a robust set of functions for formatting and manipulating terminal output, diff --git a/code/logic/meson.build b/code/logic/meson.build index 3347073..54662b4 100644 --- a/code/logic/meson.build +++ b/code/logic/meson.build @@ -8,8 +8,8 @@ else winsock_dep = [] endif -fossil_io_lib = library('fossil-io', - files('serialize.c', 'parser.c', 'input.c', 'output.c', 'error.c', 'soap.c', 'stream.c', 'device.c', 'network.c', 'cstring.c'), +fossil_io_lib = static_library('fossil-io', + files('serialize.c', 'parser.c', 'input.c', 'output.c', 'error.c', 'soap.c', 'stream.c', 'network.c', 'cstring.c'), install: true, dependencies: [cc.find_library('m', required: false), winsock_dep], include_directories: dir) diff --git a/code/logic/network.c b/code/logic/network.c index eeb2287..e090d03 100644 --- a/code/logic/network.c +++ b/code/logic/network.c @@ -331,6 +331,21 @@ ssize_t fossil_nstream_send(fossil_nstream_t *stream, const void *buffer, size_t return sent_bytes; } +int fossil_nstream_set_reuseaddr(fossil_nstream_t *stream, int enable) { + if (!stream || stream->socket_fd == (socket_t)-1) { + fossil_set_last_error("Invalid stream or socket"); + return -1; + } + + int optval = enable ? 1 : 0; + if (setsockopt(stream->socket_fd, SOL_SOCKET, SO_REUSEADDR, (char *)&optval, sizeof(optval)) < 0) { + fossil_set_last_error("Failed to set SO_REUSEADDR option"); + return -1; + } + + return 0; +} + ssize_t fossil_nstream_recv(fossil_nstream_t *stream, void *buffer, size_t size) { if (!stream || stream->socket_fd == (socket_t)-1) { fossil_set_last_error("Invalid stream or socket"); diff --git a/code/logic/output.c b/code/logic/output.c index 4052e4a..c696cfd 100644 --- a/code/logic/output.c +++ b/code/logic/output.c @@ -19,7 +19,6 @@ #include int32_t FOSSIL_IO_COLOR_ENABLE = 1; // Flag to enable/disable color output -int32_t FOSSIL_IO_ATTR_ENABLE = 1; // Flag to enable/disable attribute output // Define color codes for output #define FOSSIL_IO_COLOR_RESET "\033[0m" @@ -178,9 +177,7 @@ void fossil_io_print_with_attributes(const char *format, ...) { if (FOSSIL_IO_COLOR_ENABLE && color) { fossil_io_apply_color(color); } - if (FOSSIL_IO_ATTR_ENABLE && attribute) { - fossil_io_apply_attribute(attribute); - } + fossil_io_apply_attribute(attribute); } // Move past '}' and continue processing diff --git a/code/tests/cases/test_cstring.c b/code/tests/cases/test_cstring.c index 6ca7959..9ed6c44 100644 --- a/code/tests/cases/test_cstring.c +++ b/code/tests/cases/test_cstring.c @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -24,7 +24,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(c_string_suite); +FOSSIL_SUITE(c_string_suite); fossil_fstream_t c_string; // Setup function for the test suite @@ -45,7 +45,7 @@ FOSSIL_TEARDOWN(c_string_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(c_test_cstring_create_and_free) { +FOSSIL_TEST(c_test_cstring_create_and_free) { const char *init = "Hello, World!"; cstring str = fossil_io_cstring_create(init); ASSUME_NOT_CNULL(str); @@ -53,7 +53,7 @@ FOSSIL_TEST_CASE(c_test_cstring_create_and_free) { fossil_io_cstring_free(str); } -FOSSIL_TEST_CASE(c_test_cstring_copy) { +FOSSIL_TEST(c_test_cstring_copy) { const char *init = "Hello, World!"; cstring str = fossil_io_cstring_create(init); cstring copy = fossil_io_cstring_copy(str); @@ -63,7 +63,7 @@ FOSSIL_TEST_CASE(c_test_cstring_copy) { fossil_io_cstring_free(copy); } -FOSSIL_TEST_CASE(c_test_cstring_concat) { +FOSSIL_TEST(c_test_cstring_concat) { const char *s1 = "Hello, "; const char *s2 = "World!"; cstring result = fossil_io_cstring_concat(s1, s2); @@ -72,13 +72,13 @@ FOSSIL_TEST_CASE(c_test_cstring_concat) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(c_test_cstring_length) { +FOSSIL_TEST(c_test_cstring_length) { const char *str = "Hello, World!"; size_t length = fossil_io_cstring_length(str); ASSUME_ITS_EQUAL_SIZE(strlen(str), length); } -FOSSIL_TEST_CASE(c_test_cstring_compare) { +FOSSIL_TEST(c_test_cstring_compare) { const char *s1 = "Hello"; const char *s2 = "Hello"; const char *s3 = "World"; @@ -87,14 +87,14 @@ FOSSIL_TEST_CASE(c_test_cstring_compare) { ASSUME_ITS_TRUE(fossil_io_cstring_compare(s3, s1) > 0); } -FOSSIL_TEST_CASE(c_test_cstring_trim) { +FOSSIL_TEST(c_test_cstring_trim) { cstring str = fossil_io_cstring_create(" Hello, World! "); fossil_io_cstring_trim(str); ASSUME_ITS_EQUAL_CSTR("Hello, World!", str); fossil_io_cstring_free(str); } -FOSSIL_TEST_CASE(c_test_cstring_split) { +FOSSIL_TEST(c_test_cstring_split) { const char *str = "Hello,World,Test"; size_t count; cstring *result = fossil_io_cstring_split(str, ',', &count); @@ -109,7 +109,7 @@ FOSSIL_TEST_CASE(c_test_cstring_split) { free(result); } -FOSSIL_TEST_CASE(c_test_cstring_replace) { +FOSSIL_TEST(c_test_cstring_replace) { const char *str = "Hello, World!"; const char *old = "World"; const char *new_str = "Fossil"; @@ -119,7 +119,7 @@ FOSSIL_TEST_CASE(c_test_cstring_replace) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(c_test_cstring_to_upper) { +FOSSIL_TEST(c_test_cstring_to_upper) { cstring str = fossil_io_cstring_create("Hello, World!"); cstring result = fossil_io_cstring_to_upper(str); ASSUME_NOT_CNULL(result); @@ -128,7 +128,7 @@ FOSSIL_TEST_CASE(c_test_cstring_to_upper) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(c_test_cstring_to_lower) { +FOSSIL_TEST(c_test_cstring_to_lower) { cstring str = fossil_io_cstring_create("Hello, World!"); cstring result = fossil_io_cstring_to_lower(str); ASSUME_NOT_CNULL(result); @@ -137,19 +137,19 @@ FOSSIL_TEST_CASE(c_test_cstring_to_lower) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(c_test_cstring_starts_with) { +FOSSIL_TEST(c_test_cstring_starts_with) { const char *str = "Hello, World!"; const char *prefix = "Hello"; ASSUME_ITS_TRUE(fossil_io_cstring_starts_with(str, prefix)); } -FOSSIL_TEST_CASE(c_test_cstring_ends_with) { +FOSSIL_TEST(c_test_cstring_ends_with) { const char *str = "Hello, World!"; const char *suffix = "World!"; ASSUME_ITS_TRUE(fossil_io_cstring_ends_with(str, suffix)); } -FOSSIL_TEST_CASE(c_test_cstring_substring) { +FOSSIL_TEST(c_test_cstring_substring) { const char *str = "Hello, World!"; cstring result = fossil_io_cstring_substring(str, 7, 5); ASSUME_NOT_CNULL(result); @@ -157,7 +157,7 @@ FOSSIL_TEST_CASE(c_test_cstring_substring) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(c_test_cstring_reverse) { +FOSSIL_TEST(c_test_cstring_reverse) { cstring str = fossil_io_cstring_create("Hello, World!"); cstring result = fossil_io_cstring_reverse(str); ASSUME_NOT_CNULL(result); @@ -166,13 +166,13 @@ FOSSIL_TEST_CASE(c_test_cstring_reverse) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(c_test_cstring_contains) { +FOSSIL_TEST(c_test_cstring_contains) { const char *str = "Hello, World!"; const char *substr = "World"; ASSUME_ITS_TRUE(fossil_io_cstring_contains(str, substr)); } -FOSSIL_TEST_CASE(c_test_cstring_repeat) { +FOSSIL_TEST(c_test_cstring_repeat) { const char *str = "Hello"; cstring result = fossil_io_cstring_repeat(str, 3); ASSUME_NOT_CNULL(result); @@ -180,7 +180,7 @@ FOSSIL_TEST_CASE(c_test_cstring_repeat) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(c_test_cstring_strip) { +FOSSIL_TEST(c_test_cstring_strip) { const char *str = "!!!Hello, World!!!"; cstring result = fossil_io_cstring_strip(str, '!'); ASSUME_NOT_CNULL(result); @@ -188,14 +188,14 @@ FOSSIL_TEST_CASE(c_test_cstring_strip) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(c_test_cstring_count) { +FOSSIL_TEST(c_test_cstring_count) { const char *str = "Hello, World! Hello, Fossil!"; const char *substr = "Hello"; size_t count = fossil_io_cstring_count(str, substr); ASSUME_ITS_EQUAL_SIZE(2, count); } -FOSSIL_TEST_CASE(c_test_cstring_pad_left) { +FOSSIL_TEST(c_test_cstring_pad_left) { const char *str = "Hello"; cstring result = fossil_io_cstring_pad_left(str, 10, '*'); ASSUME_NOT_CNULL(result); @@ -203,7 +203,7 @@ FOSSIL_TEST_CASE(c_test_cstring_pad_left) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(c_test_cstring_pad_right) { +FOSSIL_TEST(c_test_cstring_pad_right) { const char *str = "Hello"; cstring result = fossil_io_cstring_pad_right(str, 10, '*'); ASSUME_NOT_CNULL(result); @@ -211,13 +211,13 @@ FOSSIL_TEST_CASE(c_test_cstring_pad_right) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(c_test_cstring_stream_create_and_free) { +FOSSIL_TEST(c_test_cstring_stream_create_and_free) { fossil_io_cstring_stream *stream = fossil_io_cstring_stream_create(1024); ASSUME_NOT_CNULL(stream); fossil_io_cstring_stream_free(stream); } -FOSSIL_TEST_CASE(c_test_cstring_stream_write_and_read) { +FOSSIL_TEST(c_test_cstring_stream_write_and_read) { fossil_io_cstring_stream *stream = fossil_io_cstring_stream_create(1024); fossil_io_cstring_stream_write(stream, "Hello, World!"); ccstring result = fossil_io_cstring_stream_read(stream); @@ -226,7 +226,7 @@ FOSSIL_TEST_CASE(c_test_cstring_stream_write_and_read) { fossil_io_cstring_stream_free(stream); } -FOSSIL_TEST_CASE(c_test_cstring_stream_multiple_writes) { +FOSSIL_TEST(c_test_cstring_stream_multiple_writes) { fossil_io_cstring_stream *stream = fossil_io_cstring_stream_create(1024); fossil_io_cstring_stream_write(stream, "Hello, "); fossil_io_cstring_stream_write(stream, "World!"); @@ -236,7 +236,7 @@ FOSSIL_TEST_CASE(c_test_cstring_stream_multiple_writes) { fossil_io_cstring_stream_free(stream); } -FOSSIL_TEST_CASE(c_test_cstring_stream_empty_read) { +FOSSIL_TEST(c_test_cstring_stream_empty_read) { fossil_io_cstring_stream *stream = fossil_io_cstring_stream_create(1024); ccstring result = fossil_io_cstring_stream_read(stream); ASSUME_NOT_CNULL(result); diff --git a/code/tests/cases/test_cstring.cpp b/code/tests/cases/test_cstring.cpp index 6e9c456..c8ed2cd 100644 --- a/code/tests/cases/test_cstring.cpp +++ b/code/tests/cases/test_cstring.cpp @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -24,7 +24,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(cpp_string_suite); +FOSSIL_SUITE(cpp_string_suite); fossil_fstream_t cpp_string; // Setup function for the test suite @@ -45,7 +45,7 @@ FOSSIL_TEARDOWN(cpp_string_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(cpp_test_cstring_create_and_free) { +FOSSIL_TEST(cpp_test_cstring_create_and_free) { const char *init = "Hello, World!"; cstring str = fossil_io_cstring_create(init); ASSUME_NOT_CNULL(str); @@ -53,7 +53,7 @@ FOSSIL_TEST_CASE(cpp_test_cstring_create_and_free) { fossil_io_cstring_free(str); } -FOSSIL_TEST_CASE(cpp_test_cstring_copy) { +FOSSIL_TEST(cpp_test_cstring_copy) { const char *init = "Hello, World!"; cstring str = fossil_io_cstring_create(init); cstring copy = fossil_io_cstring_copy(str); @@ -63,7 +63,7 @@ FOSSIL_TEST_CASE(cpp_test_cstring_copy) { fossil_io_cstring_free(copy); } -FOSSIL_TEST_CASE(cpp_test_cstring_concat) { +FOSSIL_TEST(cpp_test_cstring_concat) { const char *s1 = "Hello, "; const char *s2 = "World!"; cstring result = fossil_io_cstring_concat(s1, s2); @@ -72,13 +72,13 @@ FOSSIL_TEST_CASE(cpp_test_cstring_concat) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(cpp_test_cstring_length) { +FOSSIL_TEST(cpp_test_cstring_length) { const char *str = "Hello, World!"; size_t length = fossil_io_cstring_length(str); ASSUME_ITS_EQUAL_SIZE(strlen(str), length); } -FOSSIL_TEST_CASE(cpp_test_cstring_compare) { +FOSSIL_TEST(cpp_test_cstring_compare) { const char *s1 = "Hello"; const char *s2 = "Hello"; const char *s3 = "World"; @@ -87,14 +87,14 @@ FOSSIL_TEST_CASE(cpp_test_cstring_compare) { ASSUME_ITS_TRUE(fossil_io_cstring_compare(s3, s1) > 0); } -FOSSIL_TEST_CASE(cpp_test_cstring_trim) { +FOSSIL_TEST(cpp_test_cstring_trim) { cstring str = fossil_io_cstring_create(" Hello, World! "); fossil_io_cstring_trim(str); ASSUME_ITS_EQUAL_CSTR("Hello, World!", str); fossil_io_cstring_free(str); } -FOSSIL_TEST_CASE(cpp_test_cstring_split) { +FOSSIL_TEST(cpp_test_cstring_split) { const char *str = "Hello,World,Test"; size_t count; cstring *result = fossil_io_cstring_split(str, ',', &count); @@ -109,7 +109,7 @@ FOSSIL_TEST_CASE(cpp_test_cstring_split) { free(result); } -FOSSIL_TEST_CASE(cpp_test_cstring_replace) { +FOSSIL_TEST(cpp_test_cstring_replace) { const char *str = "Hello, World!"; const char *old = "World"; const char *new_str = "Fossil"; @@ -119,7 +119,7 @@ FOSSIL_TEST_CASE(cpp_test_cstring_replace) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(cpp_test_cstring_to_upper) { +FOSSIL_TEST(cpp_test_cstring_to_upper) { cstring str = fossil_io_cstring_create("Hello, World!"); cstring result = fossil_io_cstring_to_upper(str); ASSUME_NOT_CNULL(result); @@ -128,7 +128,7 @@ FOSSIL_TEST_CASE(cpp_test_cstring_to_upper) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(cpp_test_cstring_to_lower) { +FOSSIL_TEST(cpp_test_cstring_to_lower) { cstring str = fossil_io_cstring_create("Hello, World!"); cstring result = fossil_io_cstring_to_lower(str); ASSUME_NOT_CNULL(result); @@ -137,19 +137,19 @@ FOSSIL_TEST_CASE(cpp_test_cstring_to_lower) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(cpp_test_cstring_starts_with) { +FOSSIL_TEST(cpp_test_cstring_starts_with) { const char *str = "Hello, World!"; const char *prefix = "Hello"; ASSUME_ITS_TRUE(fossil_io_cstring_starts_with(str, prefix)); } -FOSSIL_TEST_CASE(cpp_test_cstring_ends_with) { +FOSSIL_TEST(cpp_test_cstring_ends_with) { const char *str = "Hello, World!"; const char *suffix = "World!"; ASSUME_ITS_TRUE(fossil_io_cstring_ends_with(str, suffix)); } -FOSSIL_TEST_CASE(cpp_test_cstring_substring) { +FOSSIL_TEST(cpp_test_cstring_substring) { const char *str = "Hello, World!"; cstring result = fossil_io_cstring_substring(str, 7, 5); ASSUME_NOT_CNULL(result); @@ -157,7 +157,7 @@ FOSSIL_TEST_CASE(cpp_test_cstring_substring) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(cpp_test_cstring_reverse) { +FOSSIL_TEST(cpp_test_cstring_reverse) { cstring str = fossil_io_cstring_create("Hello, World!"); cstring result = fossil_io_cstring_reverse(str); ASSUME_NOT_CNULL(result); @@ -166,13 +166,13 @@ FOSSIL_TEST_CASE(cpp_test_cstring_reverse) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(cpp_test_cstring_contains) { +FOSSIL_TEST(cpp_test_cstring_contains) { const char *str = "Hello, World!"; const char *substr = "World"; ASSUME_ITS_TRUE(fossil_io_cstring_contains(str, substr)); } -FOSSIL_TEST_CASE(cpp_test_cstring_repeat) { +FOSSIL_TEST(cpp_test_cstring_repeat) { const char *str = "Hello"; cstring result = fossil_io_cstring_repeat(str, 3); ASSUME_NOT_CNULL(result); @@ -180,7 +180,7 @@ FOSSIL_TEST_CASE(cpp_test_cstring_repeat) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(cpp_test_cstring_strip) { +FOSSIL_TEST(cpp_test_cstring_strip) { const char *str = "!!!Hello, World!!!"; cstring result = fossil_io_cstring_strip(str, '!'); ASSUME_NOT_CNULL(result); @@ -188,14 +188,14 @@ FOSSIL_TEST_CASE(cpp_test_cstring_strip) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(cpp_test_cstring_count) { +FOSSIL_TEST(cpp_test_cstring_count) { const char *str = "Hello, World! Hello, Fossil!"; const char *substr = "Hello"; size_t count = fossil_io_cstring_count(str, substr); ASSUME_ITS_EQUAL_SIZE(2, count); } -FOSSIL_TEST_CASE(cpp_test_cstring_pad_left) { +FOSSIL_TEST(cpp_test_cstring_pad_left) { const char *str = "Hello"; cstring result = fossil_io_cstring_pad_left(str, 10, '*'); ASSUME_NOT_CNULL(result); @@ -203,7 +203,7 @@ FOSSIL_TEST_CASE(cpp_test_cstring_pad_left) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(cpp_test_cstring_pad_right) { +FOSSIL_TEST(cpp_test_cstring_pad_right) { const char *str = "Hello"; cstring result = fossil_io_cstring_pad_right(str, 10, '*'); ASSUME_NOT_CNULL(result); @@ -211,13 +211,13 @@ FOSSIL_TEST_CASE(cpp_test_cstring_pad_right) { fossil_io_cstring_free(result); } -FOSSIL_TEST_CASE(cpp_test_cstring_stream_create_and_free) { +FOSSIL_TEST(cpp_test_cstring_stream_create_and_free) { fossil_io_cstring_stream *stream = fossil_io_cstring_stream_create(1024); ASSUME_NOT_CNULL(stream); fossil_io_cstring_stream_free(stream); } -FOSSIL_TEST_CASE(cpp_test_cstring_stream_write_and_read) { +FOSSIL_TEST(cpp_test_cstring_stream_write_and_read) { fossil_io_cstring_stream *stream = fossil_io_cstring_stream_create(1024); fossil_io_cstring_stream_write(stream, "Hello, World!"); ccstring result = fossil_io_cstring_stream_read(stream); @@ -226,7 +226,7 @@ FOSSIL_TEST_CASE(cpp_test_cstring_stream_write_and_read) { fossil_io_cstring_stream_free(stream); } -FOSSIL_TEST_CASE(cpp_test_cstring_stream_multiple_writes) { +FOSSIL_TEST(cpp_test_cstring_stream_multiple_writes) { fossil_io_cstring_stream *stream = fossil_io_cstring_stream_create(1024); fossil_io_cstring_stream_write(stream, "Hello, "); fossil_io_cstring_stream_write(stream, "World!"); @@ -236,7 +236,7 @@ FOSSIL_TEST_CASE(cpp_test_cstring_stream_multiple_writes) { fossil_io_cstring_stream_free(stream); } -FOSSIL_TEST_CASE(cpp_test_cstring_stream_empty_read) { +FOSSIL_TEST(cpp_test_cstring_stream_empty_read) { fossil_io_cstring_stream *stream = fossil_io_cstring_stream_create(1024); ccstring result = fossil_io_cstring_stream_read(stream); ASSUME_NOT_CNULL(result); @@ -244,32 +244,32 @@ FOSSIL_TEST_CASE(cpp_test_cstring_stream_empty_read) { fossil_io_cstring_stream_free(stream); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_create_and_free) { +FOSSIL_TEST(cpp_test_cstring_class_create_and_free) { fossil::io::CString str("Hello, World!"); ASSUME_NOT_CNULL(str.str()); ASSUME_ITS_EQUAL_CSTR("Hello, World!", str.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_copy) { +FOSSIL_TEST(cpp_test_cstring_class_copy) { fossil::io::CString str("Hello, World!"); fossil::io::CString copy = fossil::io::CString::copy("Hello, World!"); ASSUME_NOT_CNULL(copy.str()); ASSUME_ITS_EQUAL_CSTR("Hello, World!", copy.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_concat) { +FOSSIL_TEST(cpp_test_cstring_class_concat) { fossil::io::CString result = fossil::io::CString::concat("Hello, ", "World!"); ASSUME_NOT_CNULL(result.str()); ASSUME_ITS_EQUAL_CSTR("Hello, World!", result.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_length) { +FOSSIL_TEST(cpp_test_cstring_class_length) { fossil::io::CString str("Hello, World!"); size_t length = str.length(); ASSUME_ITS_EQUAL_SIZE(strlen("Hello, World!"), length); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_compare) { +FOSSIL_TEST(cpp_test_cstring_class_compare) { fossil::io::CString s1("Hello"); fossil::io::CString s2("Hello"); fossil::io::CString s3("World"); @@ -278,13 +278,13 @@ FOSSIL_TEST_CASE(cpp_test_cstring_class_compare) { ASSUME_ITS_TRUE(s3.compare("Hello") > 0); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_trim) { +FOSSIL_TEST(cpp_test_cstring_class_trim) { fossil::io::CString str(" Hello, World! "); str.trim(); ASSUME_ITS_EQUAL_CSTR("Hello, World!", str.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_split) { +FOSSIL_TEST(cpp_test_cstring_class_split) { fossil::io::CString str("Hello,World,Test"); size_t count; std::vector result = str.split(',', &count); @@ -294,103 +294,103 @@ FOSSIL_TEST_CASE(cpp_test_cstring_class_split) { ASSUME_ITS_EQUAL_CSTR("Test", result[2].c_str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_replace) { +FOSSIL_TEST(cpp_test_cstring_class_replace) { fossil::io::CString str("Hello, World!"); fossil::io::CString result = str.replace("World", "Fossil"); ASSUME_NOT_CNULL(result.str()); ASSUME_ITS_EQUAL_CSTR("Hello, Fossil!", result.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_to_upper) { +FOSSIL_TEST(cpp_test_cstring_class_to_upper) { fossil::io::CString str("Hello, World!"); fossil::io::CString result = str.to_upper(); ASSUME_NOT_CNULL(result.str()); ASSUME_ITS_EQUAL_CSTR("HELLO, WORLD!", result.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_to_lower) { +FOSSIL_TEST(cpp_test_cstring_class_to_lower) { fossil::io::CString str("Hello, World!"); fossil::io::CString result = str.to_lower(); ASSUME_NOT_CNULL(result.str()); ASSUME_ITS_EQUAL_CSTR("hello, world!", result.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_starts_with) { +FOSSIL_TEST(cpp_test_cstring_class_starts_with) { fossil::io::CString str("Hello, World!"); ASSUME_ITS_TRUE(str.starts_with("Hello")); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_ends_with) { +FOSSIL_TEST(cpp_test_cstring_class_ends_with) { fossil::io::CString str("Hello, World!"); ASSUME_ITS_TRUE(str.ends_with("World!")); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_substring) { +FOSSIL_TEST(cpp_test_cstring_class_substring) { fossil::io::CString str("Hello, World!"); fossil::io::CString result = str.substring(7, 5); ASSUME_NOT_CNULL(result.str()); ASSUME_ITS_EQUAL_CSTR("World", result.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_reverse) { +FOSSIL_TEST(cpp_test_cstring_class_reverse) { fossil::io::CString str("Hello, World!"); fossil::io::CString result = str.reverse(); ASSUME_NOT_CNULL(result.str()); ASSUME_ITS_EQUAL_CSTR("!dlroW ,olleH", result.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_contains) { +FOSSIL_TEST(cpp_test_cstring_class_contains) { fossil::io::CString str("Hello, World!"); ASSUME_ITS_TRUE(str.contains("World")); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_repeat) { +FOSSIL_TEST(cpp_test_cstring_class_repeat) { fossil::io::CString str("Hello"); fossil::io::CString result = str.repeat(3); ASSUME_NOT_CNULL(result.str()); ASSUME_ITS_EQUAL_CSTR("HelloHelloHello", result.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_strip) { +FOSSIL_TEST(cpp_test_cstring_class_strip) { fossil::io::CString str("!!!Hello, World!!!"); fossil::io::CString result = str.strip('!'); ASSUME_NOT_CNULL(result.str()); ASSUME_ITS_EQUAL_CSTR("Hello, World", result.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_count) { +FOSSIL_TEST(cpp_test_cstring_class_count) { fossil::io::CString str("Hello, World! Hello, Fossil!"); size_t count = str.count("Hello"); ASSUME_ITS_EQUAL_SIZE(2, count); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_pad_left) { +FOSSIL_TEST(cpp_test_cstring_class_pad_left) { fossil::io::CString str("Hello"); fossil::io::CString result = str.pad_left(10, '*'); ASSUME_NOT_CNULL(result.str()); ASSUME_ITS_EQUAL_CSTR("*****Hello", result.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_class_pad_right) { +FOSSIL_TEST(cpp_test_cstring_class_pad_right) { fossil::io::CString str("Hello"); fossil::io::CString result = str.pad_right(10, '*'); ASSUME_NOT_CNULL(result.str()); ASSUME_ITS_EQUAL_CSTR("Hello*****", result.str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_stream_class_create_and_free) { +FOSSIL_TEST(cpp_test_cstring_stream_class_create_and_free) { fossil::io::CStringStream stream(1024); ASSUME_NOT_CNULL(stream.read().c_str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_stream_class_write_and_read) { +FOSSIL_TEST(cpp_test_cstring_stream_class_write_and_read) { fossil::io::CStringStream stream(1024); stream.write("Hello, World!"); std::string result = stream.read(); ASSUME_ITS_EQUAL_CSTR("Hello, World!", result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_stream_class_multiple_writes) { +FOSSIL_TEST(cpp_test_cstring_stream_class_multiple_writes) { fossil::io::CStringStream stream(1024); stream.write("Hello, "); stream.write("World!"); @@ -398,7 +398,7 @@ FOSSIL_TEST_CASE(cpp_test_cstring_stream_class_multiple_writes) { ASSUME_ITS_EQUAL_CSTR("Hello, World!", result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_cstring_stream_class_empty_read) { +FOSSIL_TEST(cpp_test_cstring_stream_class_empty_read) { fossil::io::CStringStream stream(1024); std::string result = stream.read(); ASSUME_ITS_EQUAL_CSTR("", result.c_str()); diff --git a/code/tests/cases/test_device.c b/code/tests/cases/test_device.c deleted file mode 100644 index d466cd0..0000000 --- a/code/tests/cases/test_device.c +++ /dev/null @@ -1,134 +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) - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include - -#include "fossil/io/framework.h" - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Utilites -// * * * * * * * * * * * * * * * * * * * * * * * * -// Setup steps for things like test fixtures and -// mock objects are set here. -// * * * * * * * * * * * * * * * * * * * * * * * * - -// Define the test suite and add test cases -FOSSIL_TEST_SUITE(c_device_suite); - -FOSSIL_SETUP(c_device_suite) { - fossil_io_mouse_init(); - fossil_io_touch_init(); -} - -FOSSIL_TEARDOWN(c_device_suite) { - fossil_io_mouse_shutdown(); - fossil_io_touch_shutdown(); -} - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * 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_CASE(c_test_keyboard_register_unregister_binding) { - fossil_io_keyboard_event_t event = { .key = 'a', .shift = 0, .ctrl = 0, .alt = 0 }; - fossil_io_keyboard_callback_t callback = (fossil_io_keyboard_callback_t)1; // Assuming a valid callback function - - fossil_io_keyboard_register_binding(event, callback); - ASSUME_NOT_CNULL(callback); // Assumption on pointer - - fossil_io_keyboard_unregister_binding(event); - ASSUME_NOT_CNULL(callback); // Assumption on pointer -} - -FOSSIL_TEST_CASE(c_test_keyboard_clear_bindings) { - fossil_io_keyboard_event_t event = { .key = 'a', .shift = 0, .ctrl = 0, .alt = 0 }; - fossil_io_keyboard_callback_t callback = (fossil_io_keyboard_callback_t)1; // Assuming a valid callback function - - fossil_io_keyboard_register_binding(event, callback); - fossil_io_keyboard_clear_bindings(); - ASSUME_NOT_CNULL(callback); // Assumption on pointer -} - -FOSSIL_TEST_CASE(c_test_keyboard_poll_events) { - fossil_io_keyboard_event_t event = { .key = 'a', .shift = 0, .ctrl = 0, .alt = 0 }; - fossil_io_keyboard_callback_t callback = (fossil_io_keyboard_callback_t)1; // Assuming a valid callback function - - fossil_io_keyboard_register_binding(event, callback); - fossil_io_keyboard_poll_events(); - ASSUME_NOT_CNULL(callback); // Assumption on pointer - fossil_io_keyboard_unregister_binding(event); -} - -FOSSIL_TEST_CASE(c_test_mouse_register_unregister_binding) { - fossil_io_mouse_event_t event = { .x = 10, .y = 20, .button = 0, .shift = 0, .ctrl = 0, .alt = 0 }; - fossil_io_mouse_callback_t callback = (fossil_io_mouse_callback_t)1; - - fossil_io_mouse_register_binding(event, callback); - ASSUME_NOT_CNULL(callback); - - fossil_io_mouse_unregister_binding(event); - ASSUME_NOT_CNULL(callback); -} - -FOSSIL_TEST_CASE(c_test_mouse_clear_bindings) { - fossil_io_mouse_event_t event = { .x = 10, .y = 20, .button = 0, .shift = 0, .ctrl = 0, .alt = 0 }; - fossil_io_mouse_callback_t callback = (fossil_io_mouse_callback_t)1; - - fossil_io_mouse_register_binding(event, callback); - fossil_io_mouse_clear_bindings(); - ASSUME_NOT_CNULL(callback); -} - -FOSSIL_TEST_CASE(c_test_touch_register_unregister_binding) { - fossil_io_touch_event_t event = { .x = 100, .y = 200, .touch_id = 1, .action = 0, .shift = 0, .ctrl = 0, .alt = 0 }; - fossil_io_touch_callback_t callback = (fossil_io_touch_callback_t)1; - - fossil_io_touch_register_binding(event, callback); - ASSUME_NOT_CNULL(callback); - - fossil_io_touch_unregister_binding(event); - ASSUME_NOT_CNULL(callback); -} - -FOSSIL_TEST_CASE(c_test_touch_clear_bindings) { - fossil_io_touch_event_t event = { .x = 100, .y = 200, .touch_id = 1, .action = 0, .shift = 0, .ctrl = 0, .alt = 0 }; - fossil_io_touch_callback_t callback = (fossil_io_touch_callback_t)1; - - fossil_io_touch_register_binding(event, callback); - fossil_io_touch_clear_bindings(); - ASSUME_NOT_CNULL(callback); -} - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Pool -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST_GROUP(c_keyboard_tests) { - FOSSIL_TEST_ADD(c_device_suite, c_test_keyboard_register_unregister_binding); - FOSSIL_TEST_ADD(c_device_suite, c_test_keyboard_clear_bindings); - FOSSIL_TEST_ADD(c_device_suite, c_test_keyboard_poll_events); - - // Mouse tests - FOSSIL_TEST_ADD(c_device_suite, c_test_mouse_register_unregister_binding); - FOSSIL_TEST_ADD(c_device_suite, c_test_mouse_clear_bindings); - - // Touch tests - FOSSIL_TEST_ADD(c_device_suite, c_test_touch_register_unregister_binding); - FOSSIL_TEST_ADD(c_device_suite, c_test_touch_clear_bindings); - - FOSSIL_TEST_REGISTER(c_device_suite); -} diff --git a/code/tests/cases/test_device.cpp b/code/tests/cases/test_device.cpp deleted file mode 100644 index f7f4761..0000000 --- a/code/tests/cases/test_device.cpp +++ /dev/null @@ -1,223 +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) - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include - -#include "fossil/io/framework.h" - - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Utilities -// * * * * * * * * * * * * * * * * * * * * * * * * -// Setup steps for things like test fixtures and -// mock objects are set here. -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST_SUITE(cpp_device_suite); - -FOSSIL_SETUP(cpp_device_suite) { - // Setup for all device tests (keyboard, mouse, touch) -} - -FOSSIL_TEARDOWN(cpp_device_suite) { - // Teardown for device tests -} - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Cases — Keyboard Class -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST_CASE(cpp_test_keyboard_register_and_unregister) { - fossil::io::Keyboard keyboard; - fossil_io_keyboard_event_t event = { 'a', 0, 0, 0 }; - fossil_io_keyboard_callback_t callback = (fossil_io_keyboard_callback_t)0x1; - - keyboard.register_binding(event, callback); - ASSUME_NOT_CNULL(callback); - - keyboard.unregister_binding(event); - ASSUME_NOT_CNULL(callback); -} - -FOSSIL_TEST_CASE(cpp_test_keyboard_clear_bindings) { - fossil::io::Keyboard keyboard; - fossil_io_keyboard_event_t event = { 'b', 0, 0, 0 }; - fossil_io_keyboard_callback_t callback = (fossil_io_keyboard_callback_t)0x1; - - keyboard.register_binding(event, callback); - keyboard.clear_bindings(); - ASSUME_NOT_CNULL(callback); -} - -FOSSIL_TEST_CASE(cpp_test_keyboard_poll_events) { - fossil::io::Keyboard keyboard; - fossil_io_keyboard_event_t event = { 'c', 0, 0, 0 }; - fossil_io_keyboard_callback_t callback = (fossil_io_keyboard_callback_t)0x1; - - keyboard.register_binding(event, callback); - keyboard.poll_events(); - keyboard.unregister_binding(event); -} - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Cases — Mouse Class -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST_CASE(cpp_test_mouse_register_and_unregister) { - fossil::io::Mouse mouse; - - fossil_io_mouse_event_t event = { - 100, - 200, - 1, - 1, - 0, - 1 - }; - - fossil_io_mouse_callback_t callback = (fossil_io_mouse_callback_t)0x2; - - mouse.register_binding(event, callback); - ASSUME_NOT_CNULL(callback); - - mouse.unregister_binding(event); - ASSUME_NOT_CNULL(callback); -} - -FOSSIL_TEST_CASE(cpp_test_mouse_clear_bindings) { - fossil::io::Mouse mouse; - - fossil_io_mouse_event_t event = { - 150, - 250, - 2, - 0, - 1, - 0 - }; - - fossil_io_mouse_callback_t callback = (fossil_io_mouse_callback_t)0x2; - - mouse.register_binding(event, callback); - mouse.clear_bindings(); - ASSUME_NOT_CNULL(callback); -} - -FOSSIL_TEST_CASE(cpp_test_mouse_poll_events) { - fossil::io::Mouse mouse; - - fossil_io_mouse_event_t event = { - 120, - 180, - 0, - 0, - 0, - 0 - }; - - fossil_io_mouse_callback_t callback = (fossil_io_mouse_callback_t)0x2; - - mouse.register_binding(event, callback); - mouse.poll_events(); - mouse.unregister_binding(event); -} - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Cases — Touch Class -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST_CASE(cpp_test_touch_register_and_unregister) { - fossil::io::Touch touch; - - fossil_io_touch_event_t event = { - 400, - 300, - 1, - 0, - 0, - 1, - 0 - }; - - fossil_io_touch_callback_t callback = (fossil_io_touch_callback_t)0x3; - - touch.register_binding(event, callback); - ASSUME_NOT_CNULL(callback); - - touch.unregister_binding(event); - ASSUME_NOT_CNULL(callback); -} - -FOSSIL_TEST_CASE(cpp_test_touch_clear_bindings) { - fossil::io::Touch touch; - - fossil_io_touch_event_t event = { - 500, - 600, - 2, - 1, - 1, - 0, - 1 - }; - - fossil_io_touch_callback_t callback = (fossil_io_touch_callback_t)0x3; - - touch.register_binding(event, callback); - touch.clear_bindings(); - ASSUME_NOT_CNULL(callback); -} - -FOSSIL_TEST_CASE(cpp_test_touch_poll_events) { - fossil::io::Touch touch; - - fossil_io_touch_event_t event = { - 700, - 800, - 3, - 2, - 1, - 1, - 0 - }; - - fossil_io_touch_callback_t callback = (fossil_io_touch_callback_t)0x3; - - touch.register_binding(event, callback); - touch.poll_events(); - touch.unregister_binding(event); -} - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Pool -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST_GROUP(cpp_device_tests) { - // Keyboard - FOSSIL_TEST_ADD(cpp_device_suite, cpp_test_keyboard_register_and_unregister); - FOSSIL_TEST_ADD(cpp_device_suite, cpp_test_keyboard_clear_bindings); - FOSSIL_TEST_ADD(cpp_device_suite, cpp_test_keyboard_poll_events); - - // Mouse - FOSSIL_TEST_ADD(cpp_device_suite, cpp_test_mouse_register_and_unregister); - FOSSIL_TEST_ADD(cpp_device_suite, cpp_test_mouse_clear_bindings); - FOSSIL_TEST_ADD(cpp_device_suite, cpp_test_mouse_poll_events); - - // Touch - FOSSIL_TEST_ADD(cpp_device_suite, cpp_test_touch_register_and_unregister); - FOSSIL_TEST_ADD(cpp_device_suite, cpp_test_touch_clear_bindings); - FOSSIL_TEST_ADD(cpp_device_suite, cpp_test_touch_poll_events); - - // Register the test suite - FOSSIL_TEST_REGISTER(cpp_device_suite); -} diff --git a/code/tests/cases/test_error.c b/code/tests/cases/test_error.c index c09ae20..e24c86a 100644 --- a/code/tests/cases/test_error.c +++ b/code/tests/cases/test_error.c @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -23,7 +23,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(c_error_suite); +FOSSIL_SUITE(c_error_suite); // Setup function for the test suite FOSSIL_SETUP(c_error_suite) { @@ -43,157 +43,157 @@ FOSSIL_TEARDOWN(c_error_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(c_test_io_what_no_error) { +FOSSIL_TEST(c_test_io_what_no_error) { const char *result = fossil_io_what(FOSSIL_ERROR_OK); ASSUME_ITS_EQUAL_CSTR("No error, operation successful.", result); } -FOSSIL_TEST_CASE(c_test_io_what_CNULL_pointer) { +FOSSIL_TEST(c_test_io_what_CNULL_pointer) { const char *result = fossil_io_what(FOSSIL_ERROR_CNULL_POINTER); ASSUME_ITS_EQUAL_CSTR("Null pointer encountered.", result); } -FOSSIL_TEST_CASE(c_test_io_what_invalid_argument) { +FOSSIL_TEST(c_test_io_what_invalid_argument) { const char *result = fossil_io_what(FOSSIL_ERROR_INVALID_ARGUMENT); ASSUME_ITS_EQUAL_CSTR("Invalid argument provided.", result); } -FOSSIL_TEST_CASE(c_test_io_what_type_mismatch) { +FOSSIL_TEST(c_test_io_what_type_mismatch) { const char *result = fossil_io_what(FOSSIL_ERROR_TYPE_MISMATCH); ASSUME_ITS_EQUAL_CSTR("Type mismatch encountered.", result); } -FOSSIL_TEST_CASE(c_test_io_what_invalid_operation) { +FOSSIL_TEST(c_test_io_what_invalid_operation) { const char *result = fossil_io_what(FOSSIL_ERROR_INVALID_OPERATION); ASSUME_ITS_EQUAL_CSTR("Invalid operation.", result); } -FOSSIL_TEST_CASE(c_test_io_what_unknown) { +FOSSIL_TEST(c_test_io_what_unknown) { const char *result = fossil_io_what(FOSSIL_ERROR_UNKNOWN); ASSUME_ITS_EQUAL_CSTR("Unknown error.", result); } -FOSSIL_TEST_CASE(c_test_io_what_custom) { +FOSSIL_TEST(c_test_io_what_custom) { const char *result = fossil_io_what(FOSSIL_ERROR_CUSTOM); ASSUME_ITS_EQUAL_CSTR("Custom error occurred.", result); } -FOSSIL_TEST_CASE(c_test_io_what_internal) { +FOSSIL_TEST(c_test_io_what_internal) { const char *result = fossil_io_what(FOSSIL_ERROR_INTERNAL); ASSUME_ITS_EQUAL_CSTR("Internal error.", result); } -FOSSIL_TEST_CASE(c_test_io_what_unknown_error_code) { +FOSSIL_TEST(c_test_io_what_unknown_error_code) { const char *result = fossil_io_what(FOSSIL_ERROR_UNKNOWN_ERROR_CODE); ASSUME_ITS_EQUAL_CSTR("Unknown error code.", result); } -FOSSIL_TEST_CASE(c_test_io_what_overflow_int) { +FOSSIL_TEST(c_test_io_what_overflow_int) { const char *result = fossil_io_what(FOSSIL_ERROR_OVERFLOW_INT); ASSUME_ITS_EQUAL_CSTR("Integer overflow.", result); } -FOSSIL_TEST_CASE(c_test_io_what_underflow_int) { +FOSSIL_TEST(c_test_io_what_underflow_int) { const char *result = fossil_io_what(FOSSIL_ERROR_UNDERFLOW_INT); ASSUME_ITS_EQUAL_CSTR("Integer underflow.", result); } -FOSSIL_TEST_CASE(c_test_io_what_overflow_float) { +FOSSIL_TEST(c_test_io_what_overflow_float) { const char *result = fossil_io_what(FOSSIL_ERROR_OVERFLOW_FLOAT); ASSUME_ITS_EQUAL_CSTR("Float overflow.", result); } -FOSSIL_TEST_CASE(c_test_io_what_underflow_float) { +FOSSIL_TEST(c_test_io_what_underflow_float) { const char *result = fossil_io_what(FOSSIL_ERROR_UNDERFLOW_FLOAT); ASSUME_ITS_EQUAL_CSTR("Float underflow.", result); } -FOSSIL_TEST_CASE(c_test_io_what_division_by_zero) { +FOSSIL_TEST(c_test_io_what_division_by_zero) { const char *result = fossil_io_what(FOSSIL_ERROR_DIVISION_BY_ZERO); ASSUME_ITS_EQUAL_CSTR("Division by zero.", result); } -FOSSIL_TEST_CASE(c_test_io_what_invalid_cast) { +FOSSIL_TEST(c_test_io_what_invalid_cast) { const char *result = fossil_io_what(FOSSIL_ERROR_INVALID_CAST); ASSUME_ITS_EQUAL_CSTR("Invalid type cast.", result); } -FOSSIL_TEST_CASE(c_test_io_what_out_of_memory) { +FOSSIL_TEST(c_test_io_what_out_of_memory) { const char *result = fossil_io_what(FOSSIL_ERROR_OUT_OF_MEMORY); ASSUME_ITS_EQUAL_CSTR("Out of memory.", result); } -FOSSIL_TEST_CASE(c_test_io_what_memory_corruption) { +FOSSIL_TEST(c_test_io_what_memory_corruption) { const char *result = fossil_io_what(FOSSIL_ERROR_MEMORY_CORRUPTION); ASSUME_ITS_EQUAL_CSTR("Memory corruption detected.", result); } -FOSSIL_TEST_CASE(c_test_io_what_buffer_overflow) { +FOSSIL_TEST(c_test_io_what_buffer_overflow) { const char *result = fossil_io_what(FOSSIL_ERROR_BUFFER_OVERFLOW); ASSUME_ITS_EQUAL_CSTR("Buffer overflow.", result); } -FOSSIL_TEST_CASE(c_test_io_what_buffer_underflow) { +FOSSIL_TEST(c_test_io_what_buffer_underflow) { const char *result = fossil_io_what(FOSSIL_ERROR_BUFFER_UNDERFLOW); ASSUME_ITS_EQUAL_CSTR("Buffer underflow.", result); } -FOSSIL_TEST_CASE(c_test_io_what_file_not_found) { +FOSSIL_TEST(c_test_io_what_file_not_found) { const char *result = fossil_io_what(FOSSIL_ERROR_FILE_NOT_FOUND); ASSUME_ITS_EQUAL_CSTR("File not found.", result); } -FOSSIL_TEST_CASE(c_test_io_what_permission_denied) { +FOSSIL_TEST(c_test_io_what_permission_denied) { const char *result = fossil_io_what(FOSSIL_ERROR_PERMISSION_DENIED); ASSUME_ITS_EQUAL_CSTR("Permission denied.", result); } -FOSSIL_TEST_CASE(c_test_io_what_network_failure) { +FOSSIL_TEST(c_test_io_what_network_failure) { const char *result = fossil_io_what(FOSSIL_ERROR_NETWORK_FAILURE); ASSUME_ITS_EQUAL_CSTR("Network failure.", result); } -FOSSIL_TEST_CASE(c_test_io_what_timeout) { +FOSSIL_TEST(c_test_io_what_timeout) { const char *result = fossil_io_what(FOSSIL_ERROR_TIMEOUT); ASSUME_ITS_EQUAL_CSTR("Network timeout.", result); } -FOSSIL_TEST_CASE(c_test_io_what_unknown_host) { +FOSSIL_TEST(c_test_io_what_unknown_host) { const char *result = fossil_io_what(FOSSIL_ERROR_UNKNOWN_HOST); ASSUME_ITS_EQUAL_CSTR("Unknown host.", result); } -FOSSIL_TEST_CASE(c_test_io_what_connection_refused) { +FOSSIL_TEST(c_test_io_what_connection_refused) { const char *result = fossil_io_what(FOSSIL_ERROR_CONNECTION_REFUSED); ASSUME_ITS_EQUAL_CSTR("Connection refused.", result); } -FOSSIL_TEST_CASE(c_test_io_what_sql_injection) { +FOSSIL_TEST(c_test_io_what_sql_injection) { const char *result = fossil_io_what(FOSSIL_ERROR_SQL_INJECTION); ASSUME_ITS_EQUAL_CSTR("SQL injection attempt detected.", result); } -FOSSIL_TEST_CASE(c_test_io_what_xss_attack) { +FOSSIL_TEST(c_test_io_what_xss_attack) { const char *result = fossil_io_what(FOSSIL_ERROR_XSS_ATTACK); ASSUME_ITS_EQUAL_CSTR("Cross-site scripting attack detected.", result); } -FOSSIL_TEST_CASE(c_test_io_what_csrf_attack) { +FOSSIL_TEST(c_test_io_what_csrf_attack) { const char *result = fossil_io_what(FOSSIL_ERROR_CSRF_ATTACK); ASSUME_ITS_EQUAL_CSTR("Cross-site request forgery attack detected.", result); } -FOSSIL_TEST_CASE(c_test_io_what_user_abort) { +FOSSIL_TEST(c_test_io_what_user_abort) { const char *result = fossil_io_what(FOSSIL_ERROR_USER_ABORT); ASSUME_ITS_EQUAL_CSTR("User aborted operation.", result); } -FOSSIL_TEST_CASE(c_test_io_what_database_connection_failed) { +FOSSIL_TEST(c_test_io_what_database_connection_failed) { const char *result = fossil_io_what(FOSSIL_ERROR_DATABASE_CONNECTION_FAILED); ASSUME_ITS_EQUAL_CSTR("Database connection failed.", result); } -FOSSIL_TEST_CASE(c_test_io_what_serialization_failed) { +FOSSIL_TEST(c_test_io_what_serialization_failed) { const char *result = fossil_io_what(FOSSIL_ERROR_SERIALIZATION_FAILED); ASSUME_ITS_EQUAL_CSTR("Serialization failed.", result); } diff --git a/code/tests/cases/test_error.cpp b/code/tests/cases/test_error.cpp index b02c840..721bdd2 100644 --- a/code/tests/cases/test_error.cpp +++ b/code/tests/cases/test_error.cpp @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -23,7 +23,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(cpp_error_suite); +FOSSIL_SUITE(cpp_error_suite); // Setup function for the test suite FOSSIL_SETUP(cpp_error_suite) { @@ -43,162 +43,162 @@ FOSSIL_TEARDOWN(cpp_error_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(cpp_test_io_what_no_error) { +FOSSIL_TEST(cpp_test_io_what_no_error) { const char *result = fossil_io_what(FOSSIL_ERROR_OK); ASSUME_ITS_EQUAL_CSTR("No error, operation successful.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_CNULL_pointer) { +FOSSIL_TEST(cpp_test_io_what_CNULL_pointer) { const char *result = fossil_io_what(FOSSIL_ERROR_CNULL_POINTER); ASSUME_ITS_EQUAL_CSTR("Null pointer encountered.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_invalid_argument) { +FOSSIL_TEST(cpp_test_io_what_invalid_argument) { const char *result = fossil_io_what(FOSSIL_ERROR_INVALID_ARGUMENT); ASSUME_ITS_EQUAL_CSTR("Invalid argument provided.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_type_mismatch) { +FOSSIL_TEST(cpp_test_io_what_type_mismatch) { const char *result = fossil_io_what(FOSSIL_ERROR_TYPE_MISMATCH); ASSUME_ITS_EQUAL_CSTR("Type mismatch encountered.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_invalid_operation) { +FOSSIL_TEST(cpp_test_io_what_invalid_operation) { const char *result = fossil_io_what(FOSSIL_ERROR_INVALID_OPERATION); ASSUME_ITS_EQUAL_CSTR("Invalid operation.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_unknown) { +FOSSIL_TEST(cpp_test_io_what_unknown) { const char *result = fossil_io_what(FOSSIL_ERROR_UNKNOWN); ASSUME_ITS_EQUAL_CSTR("Unknown error.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_custom) { +FOSSIL_TEST(cpp_test_io_what_custom) { const char *result = fossil_io_what(FOSSIL_ERROR_CUSTOM); ASSUME_ITS_EQUAL_CSTR("Custom error occurred.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_internal) { +FOSSIL_TEST(cpp_test_io_what_internal) { const char *result = fossil_io_what(FOSSIL_ERROR_INTERNAL); ASSUME_ITS_EQUAL_CSTR("Internal error.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_unknown_error_code) { +FOSSIL_TEST(cpp_test_io_what_unknown_error_code) { const char *result = fossil_io_what(FOSSIL_ERROR_UNKNOWN_ERROR_CODE); ASSUME_ITS_EQUAL_CSTR("Unknown error code.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_overflow_int) { +FOSSIL_TEST(cpp_test_io_what_overflow_int) { const char *result = fossil_io_what(FOSSIL_ERROR_OVERFLOW_INT); ASSUME_ITS_EQUAL_CSTR("Integer overflow.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_underflow_int) { +FOSSIL_TEST(cpp_test_io_what_underflow_int) { const char *result = fossil_io_what(FOSSIL_ERROR_UNDERFLOW_INT); ASSUME_ITS_EQUAL_CSTR("Integer underflow.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_overflow_float) { +FOSSIL_TEST(cpp_test_io_what_overflow_float) { const char *result = fossil_io_what(FOSSIL_ERROR_OVERFLOW_FLOAT); ASSUME_ITS_EQUAL_CSTR("Float overflow.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_underflow_float) { +FOSSIL_TEST(cpp_test_io_what_underflow_float) { const char *result = fossil_io_what(FOSSIL_ERROR_UNDERFLOW_FLOAT); ASSUME_ITS_EQUAL_CSTR("Float underflow.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_division_by_zero) { +FOSSIL_TEST(cpp_test_io_what_division_by_zero) { const char *result = fossil_io_what(FOSSIL_ERROR_DIVISION_BY_ZERO); ASSUME_ITS_EQUAL_CSTR("Division by zero.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_invalid_cast) { +FOSSIL_TEST(cpp_test_io_what_invalid_cast) { const char *result = fossil_io_what(FOSSIL_ERROR_INVALID_CAST); ASSUME_ITS_EQUAL_CSTR("Invalid type cast.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_out_of_memory) { +FOSSIL_TEST(cpp_test_io_what_out_of_memory) { const char *result = fossil_io_what(FOSSIL_ERROR_OUT_OF_MEMORY); ASSUME_ITS_EQUAL_CSTR("Out of memory.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_memory_corruption) { +FOSSIL_TEST(cpp_test_io_what_memory_corruption) { const char *result = fossil_io_what(FOSSIL_ERROR_MEMORY_CORRUPTION); ASSUME_ITS_EQUAL_CSTR("Memory corruption detected.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_buffer_overflow) { +FOSSIL_TEST(cpp_test_io_what_buffer_overflow) { const char *result = fossil_io_what(FOSSIL_ERROR_BUFFER_OVERFLOW); ASSUME_ITS_EQUAL_CSTR("Buffer overflow.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_buffer_underflow) { +FOSSIL_TEST(cpp_test_io_what_buffer_underflow) { const char *result = fossil_io_what(FOSSIL_ERROR_BUFFER_UNDERFLOW); ASSUME_ITS_EQUAL_CSTR("Buffer underflow.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_file_not_found) { +FOSSIL_TEST(cpp_test_io_what_file_not_found) { const char *result = fossil_io_what(FOSSIL_ERROR_FILE_NOT_FOUND); ASSUME_ITS_EQUAL_CSTR("File not found.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_permission_denied) { +FOSSIL_TEST(cpp_test_io_what_permission_denied) { const char *result = fossil_io_what(FOSSIL_ERROR_PERMISSION_DENIED); ASSUME_ITS_EQUAL_CSTR("Permission denied.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_network_failure) { +FOSSIL_TEST(cpp_test_io_what_network_failure) { const char *result = fossil_io_what(FOSSIL_ERROR_NETWORK_FAILURE); ASSUME_ITS_EQUAL_CSTR("Network failure.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_timeout) { +FOSSIL_TEST(cpp_test_io_what_timeout) { const char *result = fossil_io_what(FOSSIL_ERROR_TIMEOUT); ASSUME_ITS_EQUAL_CSTR("Network timeout.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_unknown_host) { +FOSSIL_TEST(cpp_test_io_what_unknown_host) { const char *result = fossil_io_what(FOSSIL_ERROR_UNKNOWN_HOST); ASSUME_ITS_EQUAL_CSTR("Unknown host.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_connection_refused) { +FOSSIL_TEST(cpp_test_io_what_connection_refused) { const char *result = fossil_io_what(FOSSIL_ERROR_CONNECTION_REFUSED); ASSUME_ITS_EQUAL_CSTR("Connection refused.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_sql_injection) { +FOSSIL_TEST(cpp_test_io_what_sql_injection) { const char *result = fossil_io_what(FOSSIL_ERROR_SQL_INJECTION); ASSUME_ITS_EQUAL_CSTR("SQL injection attempt detected.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_xss_attack) { +FOSSIL_TEST(cpp_test_io_what_xss_attack) { const char *result = fossil_io_what(FOSSIL_ERROR_XSS_ATTACK); ASSUME_ITS_EQUAL_CSTR("Cross-site scripting attack detected.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_csrf_attack) { +FOSSIL_TEST(cpp_test_io_what_csrf_attack) { const char *result = fossil_io_what(FOSSIL_ERROR_CSRF_ATTACK); ASSUME_ITS_EQUAL_CSTR("Cross-site request forgery attack detected.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_user_abort) { +FOSSIL_TEST(cpp_test_io_what_user_abort) { const char *result = fossil_io_what(FOSSIL_ERROR_USER_ABORT); ASSUME_ITS_EQUAL_CSTR("User aborted operation.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_database_connection_failed) { +FOSSIL_TEST(cpp_test_io_what_database_connection_failed) { const char *result = fossil_io_what(FOSSIL_ERROR_DATABASE_CONNECTION_FAILED); ASSUME_ITS_EQUAL_CSTR("Database connection failed.", result); } -FOSSIL_TEST_CASE(cpp_test_io_what_serialization_failed) { +FOSSIL_TEST(cpp_test_io_what_serialization_failed) { const char *result = fossil_io_what(FOSSIL_ERROR_SERIALIZATION_FAILED); ASSUME_ITS_EQUAL_CSTR("Serialization failed.", result); } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_no_error) { +FOSSIL_TEST(cpp_test_io_error_exception_no_error) { try { throw fossil::io::Error(fossil::io::ErrorCode::OK); } catch (const fossil::io::Error& e) { @@ -207,7 +207,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_no_error) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_CNULL_pointer) { +FOSSIL_TEST(cpp_test_io_error_exception_CNULL_pointer) { try { throw fossil::io::Error(fossil::io::ErrorCode::NULL_POINTER); } catch (const fossil::io::Error& e) { @@ -216,7 +216,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_CNULL_pointer) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_invalid_argument) { +FOSSIL_TEST(cpp_test_io_error_exception_invalid_argument) { try { throw fossil::io::Error(fossil::io::ErrorCode::INVALID_ARGUMENT); } catch (const fossil::io::Error& e) { @@ -225,7 +225,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_invalid_argument) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_type_mismatch) { +FOSSIL_TEST(cpp_test_io_error_exception_type_mismatch) { try { throw fossil::io::Error(fossil::io::ErrorCode::TYPE_MISMATCH); } catch (const fossil::io::Error& e) { @@ -234,7 +234,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_type_mismatch) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_invalid_operation) { +FOSSIL_TEST(cpp_test_io_error_exception_invalid_operation) { try { throw fossil::io::Error(fossil::io::ErrorCode::INVALID_OPERATION); } catch (const fossil::io::Error& e) { @@ -243,7 +243,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_invalid_operation) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_unknown) { +FOSSIL_TEST(cpp_test_io_error_exception_unknown) { try { throw fossil::io::Error(fossil::io::ErrorCode::UNKNOWN); } catch (const fossil::io::Error& e) { @@ -252,7 +252,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_unknown) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_custom) { +FOSSIL_TEST(cpp_test_io_error_exception_custom) { try { throw fossil::io::Error(fossil::io::ErrorCode::CUSTOM); } catch (const fossil::io::Error& e) { @@ -261,7 +261,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_custom) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_internal) { +FOSSIL_TEST(cpp_test_io_error_exception_internal) { try { throw fossil::io::Error(fossil::io::ErrorCode::INTERNAL); } catch (const fossil::io::Error& e) { @@ -270,7 +270,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_internal) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_unknown_error_code) { +FOSSIL_TEST(cpp_test_io_error_exception_unknown_error_code) { try { throw fossil::io::Error(fossil::io::ErrorCode::UNKNOWN_ERROR_CODE); } catch (const fossil::io::Error& e) { @@ -279,7 +279,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_unknown_error_code) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_overflow_int) { +FOSSIL_TEST(cpp_test_io_error_exception_overflow_int) { try { throw fossil::io::Error(fossil::io::ErrorCode::OVERFLOW_INT); } catch (const fossil::io::Error& e) { @@ -288,7 +288,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_overflow_int) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_underflow_int) { +FOSSIL_TEST(cpp_test_io_error_exception_underflow_int) { try { throw fossil::io::Error(fossil::io::ErrorCode::UNDERFLOW_INT); } catch (const fossil::io::Error& e) { @@ -297,7 +297,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_underflow_int) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_overflow_float) { +FOSSIL_TEST(cpp_test_io_error_exception_overflow_float) { try { throw fossil::io::Error(fossil::io::ErrorCode::OVERFLOW_FLOAT); } catch (const fossil::io::Error& e) { @@ -306,7 +306,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_overflow_float) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_underflow_float) { +FOSSIL_TEST(cpp_test_io_error_exception_underflow_float) { try { throw fossil::io::Error(fossil::io::ErrorCode::UNDERFLOW_FLOAT); } catch (const fossil::io::Error& e) { @@ -315,7 +315,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_underflow_float) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_division_by_zero) { +FOSSIL_TEST(cpp_test_io_error_exception_division_by_zero) { try { throw fossil::io::Error(fossil::io::ErrorCode::DIVISION_BY_ZERO); } catch (const fossil::io::Error& e) { @@ -324,7 +324,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_division_by_zero) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_invalid_cast) { +FOSSIL_TEST(cpp_test_io_error_exception_invalid_cast) { try { throw fossil::io::Error(fossil::io::ErrorCode::INVALID_CAST); } catch (const fossil::io::Error& e) { @@ -333,7 +333,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_invalid_cast) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_out_of_memory) { +FOSSIL_TEST(cpp_test_io_error_exception_out_of_memory) { try { throw fossil::io::Error(fossil::io::ErrorCode::OUT_OF_MEMORY); } catch (const fossil::io::Error& e) { @@ -342,7 +342,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_out_of_memory) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_memory_corruption) { +FOSSIL_TEST(cpp_test_io_error_exception_memory_corruption) { try { throw fossil::io::Error(fossil::io::ErrorCode::MEMORY_CORRUPTION); } catch (const fossil::io::Error& e) { @@ -351,7 +351,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_memory_corruption) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_buffer_overflow) { +FOSSIL_TEST(cpp_test_io_error_exception_buffer_overflow) { try { throw fossil::io::Error(fossil::io::ErrorCode::BUFFER_OVERFLOW); } catch (const fossil::io::Error& e) { @@ -360,7 +360,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_buffer_overflow) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_buffer_underflow) { +FOSSIL_TEST(cpp_test_io_error_exception_buffer_underflow) { try { throw fossil::io::Error(fossil::io::ErrorCode::BUFFER_UNDERFLOW); } catch (const fossil::io::Error& e) { @@ -369,7 +369,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_buffer_underflow) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_file_not_found) { +FOSSIL_TEST(cpp_test_io_error_exception_file_not_found) { try { throw fossil::io::Error(fossil::io::ErrorCode::FILE_NOT_FOUND); } catch (const fossil::io::Error& e) { @@ -378,7 +378,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_file_not_found) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_permission_denied) { +FOSSIL_TEST(cpp_test_io_error_exception_permission_denied) { try { throw fossil::io::Error(fossil::io::ErrorCode::PERMISSION_DENIED); } catch (const fossil::io::Error& e) { @@ -387,7 +387,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_permission_denied) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_network_failure) { +FOSSIL_TEST(cpp_test_io_error_exception_network_failure) { try { throw fossil::io::Error(fossil::io::ErrorCode::NETWORK_FAILURE); } catch (const fossil::io::Error& e) { @@ -396,7 +396,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_network_failure) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_timeout) { +FOSSIL_TEST(cpp_test_io_error_exception_timeout) { try { throw fossil::io::Error(fossil::io::ErrorCode::TIMEOUT); } catch (const fossil::io::Error& e) { @@ -405,7 +405,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_timeout) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_unknown_host) { +FOSSIL_TEST(cpp_test_io_error_exception_unknown_host) { try { throw fossil::io::Error(fossil::io::ErrorCode::UNKNOWN_HOST); } catch (const fossil::io::Error& e) { @@ -414,7 +414,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_unknown_host) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_connection_refused) { +FOSSIL_TEST(cpp_test_io_error_exception_connection_refused) { try { throw fossil::io::Error(fossil::io::ErrorCode::CONNECTION_REFUSED); } catch (const fossil::io::Error& e) { @@ -423,7 +423,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_connection_refused) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_sql_injection) { +FOSSIL_TEST(cpp_test_io_error_exception_sql_injection) { try { throw fossil::io::Error(fossil::io::ErrorCode::SQL_INJECTION); } catch (const fossil::io::Error& e) { @@ -432,7 +432,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_sql_injection) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_xss_attack) { +FOSSIL_TEST(cpp_test_io_error_exception_xss_attack) { try { throw fossil::io::Error(fossil::io::ErrorCode::XSS_ATTACK); } catch (const fossil::io::Error& e) { @@ -441,7 +441,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_xss_attack) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_csrf_attack) { +FOSSIL_TEST(cpp_test_io_error_exception_csrf_attack) { try { throw fossil::io::Error(fossil::io::ErrorCode::CSRF_ATTACK); } catch (const fossil::io::Error& e) { @@ -450,7 +450,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_csrf_attack) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_user_abort) { +FOSSIL_TEST(cpp_test_io_error_exception_user_abort) { try { throw fossil::io::Error(fossil::io::ErrorCode::USER_ABORT); } catch (const fossil::io::Error& e) { @@ -459,7 +459,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_user_abort) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_database_connection_failed) { +FOSSIL_TEST(cpp_test_io_error_exception_database_connection_failed) { try { throw fossil::io::Error(fossil::io::ErrorCode::DATABASE_CONNECTION_FAILED); } catch (const fossil::io::Error& e) { @@ -468,7 +468,7 @@ FOSSIL_TEST_CASE(cpp_test_io_error_exception_database_connection_failed) { } } -FOSSIL_TEST_CASE(cpp_test_io_error_exception_serialization_failed) { +FOSSIL_TEST(cpp_test_io_error_exception_serialization_failed) { try { throw fossil::io::Error(fossil::io::ErrorCode::SERIALIZATION_FAILED); } catch (const fossil::io::Error& e) { diff --git a/code/tests/cases/test_input.c b/code/tests/cases/test_input.c index de34abc..72ef949 100644 --- a/code/tests/cases/test_input.c +++ b/code/tests/cases/test_input.c @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -23,7 +23,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(c_input_suite); +FOSSIL_SUITE(c_input_suite); // Setup function for the test suite FOSSIL_SETUP(c_input_suite) { @@ -43,7 +43,7 @@ FOSSIL_TEARDOWN(c_input_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(c_test_io_gets_from_stream) { +FOSSIL_TEST(c_test_io_gets_from_stream) { const char *input_data = "test input\n"; fossil_fstream_t input_stream = {tmpfile(), "tempfile"}; fwrite(input_data, 1, strlen(input_data), input_stream.file); @@ -56,7 +56,7 @@ FOSSIL_TEST_CASE(c_test_io_gets_from_stream) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(c_test_io_gets_from_stream_no_offensive) { +FOSSIL_TEST(c_test_io_gets_from_stream_no_offensive) { char input[] = "This is a clean sentence.\n"; char expected[] = "This is a clean sentence."; char buffer[256]; @@ -70,7 +70,7 @@ FOSSIL_TEST_CASE(c_test_io_gets_from_stream_no_offensive) { ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(c_test_io_gets_from_stream_with_punctuation) { +FOSSIL_TEST(c_test_io_gets_from_stream_with_punctuation) { char input[] = "This is a test with punctuation, and special characters!\n"; char expected[] = "This is a test with punctuation, and special characters!"; char buffer[256]; @@ -84,7 +84,7 @@ FOSSIL_TEST_CASE(c_test_io_gets_from_stream_with_punctuation) { ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(c_test_io_gets_from_stream_empty_input) { +FOSSIL_TEST(c_test_io_gets_from_stream_empty_input) { const char *input_data = "\n"; fossil_fstream_t input_stream = {tmpfile(), "tempfile"}; fwrite(input_data, 1, strlen(input_data), input_stream.file); @@ -97,7 +97,7 @@ FOSSIL_TEST_CASE(c_test_io_gets_from_stream_empty_input) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(c_test_io_gets_from_stream_only_whitespace) { +FOSSIL_TEST(c_test_io_gets_from_stream_only_whitespace) { const char *input_data = " \n"; fossil_fstream_t input_stream = {tmpfile(), "tempfile"}; fwrite(input_data, 1, strlen(input_data), input_stream.file); @@ -110,7 +110,7 @@ FOSSIL_TEST_CASE(c_test_io_gets_from_stream_only_whitespace) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(c_test_io_gets_from_stream_long_input) { +FOSSIL_TEST(c_test_io_gets_from_stream_long_input) { const char *input_data = "This is a very long input string that exceeds the buffer size\n"; fossil_fstream_t input_stream = {tmpfile(), "tempfile"}; fwrite(input_data, 1, strlen(input_data), input_stream.file); @@ -123,7 +123,7 @@ FOSSIL_TEST_CASE(c_test_io_gets_from_stream_long_input) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(c_test_io_gets_from_stream_ex) { +FOSSIL_TEST(c_test_io_gets_from_stream_ex) { const char *input_data = "test input\n"; fossil_fstream_t input_stream = {tmpfile(), "tempfile"}; fwrite(input_data, 1, strlen(input_data), input_stream.file); @@ -137,7 +137,7 @@ FOSSIL_TEST_CASE(c_test_io_gets_from_stream_ex) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(c_test_io_gets_utf8) { +FOSSIL_TEST(c_test_io_gets_utf8) { const char *input_data = "test input\n"; fossil_fstream_t input_stream = {tmpfile(), "tempfile"}; fwrite(input_data, 1, strlen(input_data), input_stream.file); @@ -150,7 +150,7 @@ FOSSIL_TEST_CASE(c_test_io_gets_utf8) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(c_test_io_validate_is_int_valid) { +FOSSIL_TEST(c_test_io_validate_is_int_valid) { const char *input = "12345"; int output; int result = fossil_io_validate_is_int(input, &output); @@ -158,57 +158,57 @@ FOSSIL_TEST_CASE(c_test_io_validate_is_int_valid) { ASSUME_ITS_EQUAL_I32(12345, output); } -FOSSIL_TEST_CASE(c_test_io_validate_is_int_invalid) { +FOSSIL_TEST(c_test_io_validate_is_int_invalid) { const char *input = "123abc"; int output; int result = fossil_io_validate_is_int(input, &output); ASSUME_ITS_FALSE(result); } -FOSSIL_TEST_CASE(c_test_io_validate_is_float_invalid) { +FOSSIL_TEST(c_test_io_validate_is_float_invalid) { const char *input = "123.abc"; float output; int result = fossil_io_validate_is_float(input, &output); ASSUME_ITS_FALSE(result); } -FOSSIL_TEST_CASE(c_test_io_validate_is_alnum_valid) { +FOSSIL_TEST(c_test_io_validate_is_alnum_valid) { const char *input = "abc123"; int result = fossil_io_validate_is_alnum(input); ASSUME_ITS_TRUE(result); } -FOSSIL_TEST_CASE(c_test_io_validate_is_alnum_invalid) { +FOSSIL_TEST(c_test_io_validate_is_alnum_invalid) { const char *input = "abc 123"; int result = fossil_io_validate_is_alnum(input); ASSUME_ITS_FALSE(result); } -FOSSIL_TEST_CASE(c_test_io_validate_is_email_valid) { +FOSSIL_TEST(c_test_io_validate_is_email_valid) { const char *input = "test@gmail.com"; // now checks for valid email providers like gmail.com int result = fossil_io_validate_is_email(input); ASSUME_ITS_TRUE(result); } -FOSSIL_TEST_CASE(c_test_io_validate_is_email_invalid) { +FOSSIL_TEST(c_test_io_validate_is_email_invalid) { const char *input = "test@com"; int result = fossil_io_validate_is_email(input); ASSUME_ITS_FALSE(result); } -FOSSIL_TEST_CASE(c_test_io_validate_is_length_valid) { +FOSSIL_TEST(c_test_io_validate_is_length_valid) { const char *input = "short"; int result = fossil_io_validate_is_length(input, 10); ASSUME_ITS_TRUE(result); } -FOSSIL_TEST_CASE(c_test_io_validate_is_length_invalid) { +FOSSIL_TEST(c_test_io_validate_is_length_invalid) { const char *input = "this is a very long string"; int result = fossil_io_validate_is_length(input, 10); ASSUME_ITS_FALSE(result); } -FOSSIL_TEST_CASE(c_test_io_getc) { +FOSSIL_TEST(c_test_io_getc) { const char *input_data = "test input\n"; fossil_fstream_t input_stream = {tmpfile(), "tempfile"}; fwrite(input_data, 1, strlen(input_data), input_stream.file); diff --git a/code/tests/cases/test_input.cpp b/code/tests/cases/test_input.cpp index 7d10bcc..98c6646 100644 --- a/code/tests/cases/test_input.cpp +++ b/code/tests/cases/test_input.cpp @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -23,7 +23,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(cpp_input_suite); +FOSSIL_SUITE(cpp_input_suite); // Setup function for the test suite FOSSIL_SETUP(cpp_input_suite) { @@ -43,7 +43,7 @@ FOSSIL_TEARDOWN(cpp_input_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream) { +FOSSIL_TEST(cpp_test_io_gets_from_stream) { const char *input_data = "test input\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -59,7 +59,7 @@ FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_no_offensive) { +FOSSIL_TEST(cpp_test_io_gets_from_stream_no_offensive) { char input[] = "This is a clean sentence.\n"; char expected[] = "This is a clean sentence."; char buffer[256]; @@ -76,7 +76,7 @@ FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_no_offensive) { ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_with_punctuation) { +FOSSIL_TEST(cpp_test_io_gets_from_stream_with_punctuation) { char input[] = "This is a test with punctuation, and special characters!\n"; char expected[] = "This is a test with punctuation, and special characters!"; char buffer[256]; @@ -93,7 +93,7 @@ FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_with_punctuation) { ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_empty_input) { +FOSSIL_TEST(cpp_test_io_gets_from_stream_empty_input) { const char *input_data = "\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -109,7 +109,7 @@ FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_empty_input) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_only_whitespace) { +FOSSIL_TEST(cpp_test_io_gets_from_stream_only_whitespace) { const char *input_data = " \n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -125,7 +125,7 @@ FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_only_whitespace) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_long_input) { +FOSSIL_TEST(cpp_test_io_gets_from_stream_long_input) { const char *input_data = "This is a very long input string that exceeds the buffer size\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -141,7 +141,7 @@ FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_long_input) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_ex) { +FOSSIL_TEST(cpp_test_io_gets_from_stream_ex) { const char *input_data = "test input\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -158,7 +158,7 @@ FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_ex) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_gets_utf8) { +FOSSIL_TEST(cpp_test_io_gets_utf8) { const char *input_data = "test input\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -174,7 +174,7 @@ FOSSIL_TEST_CASE(cpp_test_io_gets_utf8) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_class) { +FOSSIL_TEST(cpp_test_io_gets_from_stream_class) { const char *input_data = "test input\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -190,7 +190,7 @@ FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_class) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_ex_class) { +FOSSIL_TEST(cpp_test_io_gets_from_stream_ex_class) { const char *input_data = "test input\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -207,14 +207,14 @@ FOSSIL_TEST_CASE(cpp_test_io_gets_from_stream_ex_class) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_validate_input_buffer_class) { +FOSSIL_TEST(cpp_test_io_validate_input_buffer_class) { const char *buf = "test buffer"; size_t size = strlen(buf); int result = fossil::io::Input::validate_input_buffer(buf, size); ASSUME_ITS_EQUAL_I32(1, result); } -FOSSIL_TEST_CASE(cpp_test_io_gets_utf8_class) { +FOSSIL_TEST(cpp_test_io_gets_utf8_class) { const char *input_data = "test input\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -230,7 +230,7 @@ FOSSIL_TEST_CASE(cpp_test_io_gets_utf8_class) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_validate_is_int_valid) { +FOSSIL_TEST(cpp_test_io_validate_is_int_valid) { const char *input = "12345"; int output; int result = fossil_io_validate_is_int(input, &output); @@ -238,57 +238,57 @@ FOSSIL_TEST_CASE(cpp_test_io_validate_is_int_valid) { ASSUME_ITS_EQUAL_I32(12345, output); } -FOSSIL_TEST_CASE(cpp_test_io_validate_is_int_invalid) { +FOSSIL_TEST(cpp_test_io_validate_is_int_invalid) { const char *input = "123abc"; int output; int result = fossil_io_validate_is_int(input, &output); ASSUME_ITS_FALSE(result); } -FOSSIL_TEST_CASE(cpp_test_io_validate_is_float_invalid) { +FOSSIL_TEST(cpp_test_io_validate_is_float_invalid) { const char *input = "123.abc"; float output; int result = fossil_io_validate_is_float(input, &output); ASSUME_ITS_FALSE(result); } -FOSSIL_TEST_CASE(cpp_test_io_validate_is_alnum_valid) { +FOSSIL_TEST(cpp_test_io_validate_is_alnum_valid) { const char *input = "abc123"; int result = fossil_io_validate_is_alnum(input); ASSUME_ITS_TRUE(result); } -FOSSIL_TEST_CASE(cpp_test_io_validate_is_alnum_invalid) { +FOSSIL_TEST(cpp_test_io_validate_is_alnum_invalid) { const char *input = "abc 123"; int result = fossil_io_validate_is_alnum(input); ASSUME_ITS_FALSE(result); } -FOSSIL_TEST_CASE(cpp_test_io_validate_is_email_valid) { +FOSSIL_TEST(cpp_test_io_validate_is_email_valid) { const char *input = "test@icloud.com"; int result = fossil_io_validate_is_email(input); ASSUME_ITS_TRUE(result); } -FOSSIL_TEST_CASE(cpp_test_io_validate_is_email_invalid) { +FOSSIL_TEST(cpp_test_io_validate_is_email_invalid) { const char *input = "test@com"; int result = fossil_io_validate_is_email(input); ASSUME_ITS_FALSE(result); } -FOSSIL_TEST_CASE(cpp_test_io_validate_is_length_valid) { +FOSSIL_TEST(cpp_test_io_validate_is_length_valid) { const char *input = "short"; int result = fossil_io_validate_is_length(input, 10); ASSUME_ITS_TRUE(result); } -FOSSIL_TEST_CASE(cpp_test_io_validate_is_length_invalid) { +FOSSIL_TEST(cpp_test_io_validate_is_length_invalid) { const char *input = "this is a very long string"; int result = fossil_io_validate_is_length(input, 10); ASSUME_ITS_FALSE(result); } -FOSSIL_TEST_CASE(cpp_test_io_input_class_gets_from_stream) { +FOSSIL_TEST(cpp_test_io_input_class_gets_from_stream) { const char *input_data = "input data\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -304,7 +304,7 @@ FOSSIL_TEST_CASE(cpp_test_io_input_class_gets_from_stream) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_input_class_gets_from_stream_ex) { +FOSSIL_TEST(cpp_test_io_input_class_gets_from_stream_ex) { const char *input_data = "input data\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -321,21 +321,21 @@ FOSSIL_TEST_CASE(cpp_test_io_input_class_gets_from_stream_ex) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_input_class_validate_input_buffer_valid) { +FOSSIL_TEST(cpp_test_io_input_class_validate_input_buffer_valid) { const char *buf = "valid buffer"; size_t size = strlen(buf); int result = fossil::io::Input::validate_input_buffer(buf, size); ASSUME_ITS_EQUAL_I32(1, result); } -FOSSIL_TEST_CASE(cpp_test_io_input_class_validate_input_buffer_invalid) { +FOSSIL_TEST(cpp_test_io_input_class_validate_input_buffer_invalid) { const char *buf = nullptr; size_t size = 0; int result = fossil::io::Input::validate_input_buffer(buf, size); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_io_input_class_gets_utf8_valid) { +FOSSIL_TEST(cpp_test_io_input_class_gets_utf8_valid) { const char *input_data = "utf8 valid input\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -351,7 +351,7 @@ FOSSIL_TEST_CASE(cpp_test_io_input_class_gets_utf8_valid) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_input_class_gets_from_stream_empty) { +FOSSIL_TEST(cpp_test_io_input_class_gets_from_stream_empty) { const char *input_data = "\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -367,7 +367,7 @@ FOSSIL_TEST_CASE(cpp_test_io_input_class_gets_from_stream_empty) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_input_class_gets_from_stream_whitespace_only) { +FOSSIL_TEST(cpp_test_io_input_class_gets_from_stream_whitespace_only) { const char *input_data = " \n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); @@ -383,7 +383,7 @@ FOSSIL_TEST_CASE(cpp_test_io_input_class_gets_from_stream_whitespace_only) { fclose(input_stream.file); } -FOSSIL_TEST_CASE(cpp_test_io_getc) { +FOSSIL_TEST(cpp_test_io_getc) { const char *input_data = "test input\n"; fossil_fstream_t input_stream; input_stream.file = tmpfile(); diff --git a/code/tests/cases/test_network.c b/code/tests/cases/test_network.c index 39f585a..1b2a93a 100644 --- a/code/tests/cases/test_network.c +++ b/code/tests/cases/test_network.c @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" // * * * * * * * * * * * * * * * * * * * * * * * * @@ -21,7 +21,7 @@ // mock objects are set here. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_SUITE(c_network_suite); +FOSSIL_SUITE(c_network_suite); // Setup function for the test suite FOSSIL_SETUP(c_network_suite) { @@ -37,7 +37,7 @@ FOSSIL_TEARDOWN(c_network_suite) { // * Fossil Logic Test Cases // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(c_test_nstream_create_and_destroy) { +FOSSIL_TEST(c_test_nstream_create_and_destroy) { const char *protocols[] = {"tcp", "udp", "raw", "icmp", "sctp", "http", "https", "ftp", "ssh", "dns", "ntp", "smtp", "pop3", "imap", "ldap", "mqtt"}; const char *clients[] = {"mail-server", "server", "mail-client", "client", "mail-bot", "bot", "multicast", "broadcast"}; @@ -50,7 +50,7 @@ FOSSIL_TEST_CASE(c_test_nstream_create_and_destroy) { } } -FOSSIL_TEST_CASE(c_test_nstream_connect_invalid_host) { +FOSSIL_TEST(c_test_nstream_connect_invalid_host) { fossil_nstream_t *stream = fossil_nstream_create("tcp", "client"); ASSUME_NOT_CNULL(stream); @@ -59,10 +59,14 @@ FOSSIL_TEST_CASE(c_test_nstream_connect_invalid_host) { fossil_nstream_destroy(stream); } -FOSSIL_TEST_CASE(c_test_nstream_listen_and_accept) { +#if !defined(_WIN32) && !defined(_WIN64) +FOSSIL_TEST(c_test_nstream_listen_and_accept) { fossil_nstream_t *server = fossil_nstream_create("tcp", "server"); ASSUME_NOT_CNULL(server); + // Set SO_REUSEADDR before binding/listening to avoid bind failures + ASSUME_ITS_EQUAL_I32(0, fossil_nstream_set_reuseaddr(server, 1)); + // Start listening on a local port ASSUME_ITS_EQUAL_I32(0, fossil_nstream_listen(server, "127.0.0.1", 12345)); @@ -81,10 +85,13 @@ FOSSIL_TEST_CASE(c_test_nstream_listen_and_accept) { fossil_nstream_destroy(server); } -FOSSIL_TEST_CASE(c_test_nstream_send_and_receive) { +FOSSIL_TEST(c_test_nstream_send_and_receive) { fossil_nstream_t *server = fossil_nstream_create("tcp", "server"); ASSUME_NOT_CNULL(server); + // Set SO_REUSEADDR before binding/listening + ASSUME_ITS_EQUAL_I32(0, fossil_nstream_set_reuseaddr(server, 1)); + // Start listening on a local port ASSUME_ITS_EQUAL_I32(0, fossil_nstream_listen(server, "127.0.0.1", 12345)); @@ -110,8 +117,9 @@ FOSSIL_TEST_CASE(c_test_nstream_send_and_receive) { fossil_nstream_destroy(accepted_client); fossil_nstream_destroy(server); } +#endif -FOSSIL_TEST_CASE(c_test_nstream_protocols) { +FOSSIL_TEST(c_test_nstream_protocols) { const char *protocols[] = {"tcp", "udp", "raw", "icmp", "sctp", "http", "https", "ftp", "ssh", "dns", "ntp", "smtp", "pop3", "imap", "ldap", "mqtt"}; for (size_t i = 0; i < sizeof(protocols) / sizeof(protocols[0]); i++) { @@ -121,7 +129,7 @@ FOSSIL_TEST_CASE(c_test_nstream_protocols) { } } -FOSSIL_TEST_CASE(c_test_nstream_client_types) { +FOSSIL_TEST(c_test_nstream_client_types) { const char *clients[] = {"mail-server", "server", "mail-client", "client", "mail-bot", "bot", "multicast", "broadcast"}; for (size_t i = 0; i < sizeof(clients) / sizeof(clients[0]); i++) { @@ -138,8 +146,11 @@ FOSSIL_TEST_CASE(c_test_nstream_client_types) { FOSSIL_TEST_GROUP(c_network_tests) { FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_create_and_destroy); FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_connect_invalid_host); - FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_listen_and_accept); - FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_send_and_receive); + #if !defined(_WIN32) && !defined(_WIN64) + FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_listen_and_accept); + FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_send_and_receive); + #endif + FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_protocols); FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_client_types); diff --git a/code/tests/cases/test_network.cpp b/code/tests/cases/test_network.cpp index f4965e5..aaf2caf 100644 --- a/code/tests/cases/test_network.cpp +++ b/code/tests/cases/test_network.cpp @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" // * * * * * * * * * * * * * * * * * * * * * * * * @@ -21,7 +21,7 @@ // mock objects are set here. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_SUITE(cpp_network_suite); +FOSSIL_SUITE(cpp_network_suite); // Setup function for the test suite FOSSIL_SETUP(cpp_network_suite) { @@ -37,7 +37,7 @@ FOSSIL_TEARDOWN(cpp_network_suite) { // * Fossil Logic Test Cases // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(cpp_test_nstream_create_and_destroy) { +FOSSIL_TEST(cpp_test_nstream_create_and_destroy) { const char *protocols[] = {"tcp", "udp", "raw", "icmp", "sctp", "http", "https", "ftp", "ssh", "dns", "ntp", "smtp", "pop3", "imap", "ldap", "mqtt"}; const char *clients[] = {"mail-server", "server", "mail-client", "client", "mail-bot", "bot", "multicast", "broadcast"}; @@ -50,7 +50,7 @@ FOSSIL_TEST_CASE(cpp_test_nstream_create_and_destroy) { } } -FOSSIL_TEST_CASE(cpp_test_nstream_connect_invalid_host) { +FOSSIL_TEST(cpp_test_nstream_connect_invalid_host) { fossil_nstream_t *stream = fossil_nstream_create("tcp", "client"); ASSUME_NOT_CNULL(stream); @@ -59,17 +59,24 @@ FOSSIL_TEST_CASE(cpp_test_nstream_connect_invalid_host) { fossil_nstream_destroy(stream); } -FOSSIL_TEST_CASE(cpp_test_nstream_listen_and_accept) { +#ifndef _WIN32 +FOSSIL_TEST(cpp_test_nstream_listen_and_accept) { fossil_nstream_t *server = fossil_nstream_create("tcp", "server"); ASSUME_NOT_CNULL(server); + // Set SO_REUSEADDR to avoid bind fail on rapid test reruns + fossil_nstream_set_reuseaddr(server, 1); + + // Use a unique port for this test to avoid bind conflicts + const int test_port = 12346; + // Start listening on a local port - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_listen(server, "127.0.0.1", 12345)); + ASSUME_ITS_EQUAL_I32(0, fossil_nstream_listen(server, "127.0.0.1", test_port)); // Simulate a client connecting fossil_nstream_t *client = fossil_nstream_create("tcp", "client"); ASSUME_NOT_CNULL(client); - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_connect(client, "127.0.0.1", 12345)); + ASSUME_ITS_EQUAL_I32(0, fossil_nstream_connect(client, "127.0.0.1", test_port)); // Accept the client connection fossil_nstream_t *accepted_client = fossil_nstream_accept(server); @@ -81,17 +88,23 @@ FOSSIL_TEST_CASE(cpp_test_nstream_listen_and_accept) { fossil_nstream_destroy(server); } -FOSSIL_TEST_CASE(cpp_test_nstream_send_and_receive) { +FOSSIL_TEST(cpp_test_nstream_send_and_receive) { fossil_nstream_t *server = fossil_nstream_create("tcp", "server"); ASSUME_NOT_CNULL(server); + // Set SO_REUSEADDR to avoid bind fail on rapid test reruns + fossil_nstream_set_reuseaddr(server, 1); + + // Use a unique port for this test to avoid bind conflicts + const int test_port = 12347; + // Start listening on a local port - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_listen(server, "127.0.0.1", 12345)); + ASSUME_ITS_EQUAL_I32(0, fossil_nstream_listen(server, "127.0.0.1", test_port)); // Simulate a client connecting fossil_nstream_t *client = fossil_nstream_create("tcp", "client"); ASSUME_NOT_CNULL(client); - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_connect(client, "127.0.0.1", 12345)); + ASSUME_ITS_EQUAL_I32(0, fossil_nstream_connect(client, "127.0.0.1", test_port)); // Accept the client connection fossil_nstream_t *accepted_client = fossil_nstream_accept(server); @@ -110,8 +123,9 @@ FOSSIL_TEST_CASE(cpp_test_nstream_send_and_receive) { fossil_nstream_destroy(accepted_client); fossil_nstream_destroy(server); } +#endif -FOSSIL_TEST_CASE(cpp_test_nstream_protocols) { +FOSSIL_TEST(cpp_test_nstream_protocols) { const char *protocols[] = {"tcp", "udp", "raw", "icmp", "sctp", "http", "https", "ftp", "ssh", "dns", "ntp", "smtp", "pop3", "imap", "ldap", "mqtt"}; for (size_t i = 0; i < sizeof(protocols) / sizeof(protocols[0]); i++) { @@ -121,7 +135,7 @@ FOSSIL_TEST_CASE(cpp_test_nstream_protocols) { } } -FOSSIL_TEST_CASE(cpp_test_nstream_client_types) { +FOSSIL_TEST(cpp_test_nstream_client_types) { const char *clients[] = {"mail-server", "server", "mail-client", "client", "mail-bot", "bot", "multicast", "broadcast"}; for (size_t i = 0; i < sizeof(clients) / sizeof(clients[0]); i++) { @@ -131,7 +145,7 @@ FOSSIL_TEST_CASE(cpp_test_nstream_client_types) { } } -FOSSIL_TEST_CASE(cpp_test_nstream_class_create_and_destroy) { +FOSSIL_TEST(cpp_test_nstream_class_create_and_destroy) { using namespace fossil::io; const std::string protocols[] = {"tcp", "udp", "raw", "icmp", "sctp", "http", "https", "ftp", "ssh", "dns", "ntp", "smtp", "pop3", "imap", "ldap", "mqtt"}; @@ -144,7 +158,7 @@ FOSSIL_TEST_CASE(cpp_test_nstream_class_create_and_destroy) { } } -FOSSIL_TEST_CASE(cpp_test_nstream_class_connect_invalid_host) { +FOSSIL_TEST(cpp_test_nstream_class_connect_invalid_host) { using namespace fossil::io; try { @@ -156,7 +170,8 @@ FOSSIL_TEST_CASE(cpp_test_nstream_class_connect_invalid_host) { } } -FOSSIL_TEST_CASE(cpp_test_nstream_class_listen_and_accept) { +#ifndef _WIN32 +FOSSIL_TEST(cpp_test_nstream_class_listen_and_accept) { using namespace fossil::io; NStream server("tcp", "server"); @@ -171,7 +186,7 @@ FOSSIL_TEST_CASE(cpp_test_nstream_class_listen_and_accept) { delete accepted_client; } -FOSSIL_TEST_CASE(cpp_test_nstream_class_send_and_receive) { +FOSSIL_TEST(cpp_test_nstream_class_send_and_receive) { using namespace fossil::io; NStream server("tcp", "server"); @@ -193,6 +208,7 @@ FOSSIL_TEST_CASE(cpp_test_nstream_class_send_and_receive) { delete accepted_client; } +#endif // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool @@ -201,15 +217,19 @@ FOSSIL_TEST_CASE(cpp_test_nstream_class_send_and_receive) { FOSSIL_TEST_GROUP(cpp_network_tests) { FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_create_and_destroy); FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_connect_invalid_host); - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_listen_and_accept); - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_send_and_receive); + #ifndef _WIN32 + FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_listen_and_accept); + FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_send_and_receive); + #endif FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_protocols); FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_client_types); FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_class_create_and_destroy); FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_class_connect_invalid_host); - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_class_listen_and_accept); - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_class_send_and_receive); + #ifndef _WIN32 + FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_class_listen_and_accept); + FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_class_send_and_receive); + #endif FOSSIL_TEST_REGISTER(cpp_network_suite); } diff --git a/code/tests/cases/test_parser.c b/code/tests/cases/test_parser.c index 635203d..2775d85 100644 --- a/code/tests/cases/test_parser.c +++ b/code/tests/cases/test_parser.c @@ -12,7 +12,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include @@ -24,7 +24,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(c_parser_suite); +FOSSIL_SUITE(c_parser_suite); // Setup function for the test suite FOSSIL_SETUP(c_parser_suite) { @@ -44,7 +44,7 @@ FOSSIL_TEARDOWN(c_parser_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(c_create_palette) { +FOSSIL_TEST(c_create_palette) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); FOSSIL_TEST_ASSUME(palette != NULL, "Palette should be created"); FOSSIL_TEST_ASSUME(strcmp(palette->name, "test_palette") == 0, "Palette name should be 'test_palette'"); @@ -54,7 +54,7 @@ FOSSIL_TEST_CASE(c_create_palette) { palette = NULL; } // end case -FOSSIL_TEST_CASE(c_add_command) { +FOSSIL_TEST(c_add_command) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); FOSSIL_TEST_ASSUME(command != NULL, "Command should be added"); @@ -65,7 +65,7 @@ FOSSIL_TEST_CASE(c_add_command) { fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(c_add_argument) { +FOSSIL_TEST(c_add_argument) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); fossil_io_parser_argument_t *argument = fossil_io_parser_add_argument(command, "test_arg", FOSSIL_IO_PARSER_STRING, NULL, 0); @@ -77,7 +77,7 @@ FOSSIL_TEST_CASE(c_add_argument) { fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(c_parse_command) { +FOSSIL_TEST(c_parse_command) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); fossil_io_parser_add_argument(command, "test_arg", FOSSIL_IO_PARSER_STRING, NULL, 0); @@ -89,7 +89,7 @@ FOSSIL_TEST_CASE(c_parse_command) { fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(c_free_palette) { +FOSSIL_TEST(c_free_palette) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); ASSUME_NOT_CNULL(palette); fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); @@ -97,7 +97,7 @@ FOSSIL_TEST_CASE(c_free_palette) { // No explicit assumptions here, just ensuring no memory leaks or crashes } // end case -FOSSIL_TEST_CASE(c_argument_types) { +FOSSIL_TEST(c_argument_types) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); @@ -139,20 +139,20 @@ FOSSIL_TEST_CASE(c_argument_types) { fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(c_null_palette) { +FOSSIL_TEST(c_null_palette) { fossil_io_parser_palette_t *palette = NULL; FOSSIL_TEST_ASSUME(fossil_io_parser_add_command(palette, "test_command", "Test Command Description") == NULL, "Adding command to NULL palette should return NULL"); fossil_io_parser_parse(palette, 0, NULL); } // end case -FOSSIL_TEST_CASE(c_empty_command_name) { +FOSSIL_TEST(c_empty_command_name) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "", "Empty Command Name Description"); FOSSIL_TEST_ASSUME(command == NULL, "Command with empty name should not be added"); fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(c_duplicate_command_name) { +FOSSIL_TEST(c_duplicate_command_name) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); fossil_io_parser_command_t *duplicate = fossil_io_parser_add_command(palette, "test_command", "Duplicate Command Description"); @@ -160,7 +160,7 @@ FOSSIL_TEST_CASE(c_duplicate_command_name) { fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(c_null_argument_name) { +FOSSIL_TEST(c_null_argument_name) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); fossil_io_parser_argument_t *argument = fossil_io_parser_add_argument(command, NULL, FOSSIL_IO_PARSER_STRING, NULL, 0); @@ -168,7 +168,7 @@ FOSSIL_TEST_CASE(c_null_argument_name) { fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(c_invalid_argument_type) { +FOSSIL_TEST(c_invalid_argument_type) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); fossil_io_parser_argument_t *argument = fossil_io_parser_add_argument(command, "invalid_arg", FOSSIL_IO_PARSER_INVALID, NULL, 0); diff --git a/code/tests/cases/test_parser.cpp b/code/tests/cases/test_parser.cpp index faf9d73..048b111 100644 --- a/code/tests/cases/test_parser.cpp +++ b/code/tests/cases/test_parser.cpp @@ -12,7 +12,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include #include #include @@ -26,7 +26,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(cpp_parser_suite); +FOSSIL_SUITE(cpp_parser_suite); // Setup function for the test suite FOSSIL_SETUP(cpp_parser_suite) { @@ -46,7 +46,7 @@ FOSSIL_TEARDOWN(cpp_parser_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(cpp_create_palette) { +FOSSIL_TEST(cpp_create_palette) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); FOSSIL_TEST_ASSUME(palette != NULL, "Palette should be created"); FOSSIL_TEST_ASSUME(strcmp(palette->name, "test_palette") == 0, "Palette name should be 'test_palette'"); @@ -55,7 +55,7 @@ FOSSIL_TEST_CASE(cpp_create_palette) { fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(cpp_add_command) { +FOSSIL_TEST(cpp_add_command) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); FOSSIL_TEST_ASSUME(command != NULL, "Command should be added"); @@ -66,7 +66,7 @@ FOSSIL_TEST_CASE(cpp_add_command) { fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(cpp_add_argument) { +FOSSIL_TEST(cpp_add_argument) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); fossil_io_parser_argument_t *argument = fossil_io_parser_add_argument(command, "test_arg", FOSSIL_IO_PARSER_STRING, NULL, 0); @@ -78,7 +78,7 @@ FOSSIL_TEST_CASE(cpp_add_argument) { fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(cpp_argument_types) { +FOSSIL_TEST(cpp_argument_types) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); @@ -120,7 +120,7 @@ FOSSIL_TEST_CASE(cpp_argument_types) { fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(cpp_parse_command) { +FOSSIL_TEST(cpp_parse_command) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); fossil_io_parser_command_t *command = fossil_io_parser_add_command(palette, "test_command", "Test Command Description"); fossil_io_parser_add_argument(command, "test_arg", FOSSIL_IO_PARSER_STRING, NULL, 0); @@ -136,7 +136,7 @@ FOSSIL_TEST_CASE(cpp_parse_command) { fossil_io_parser_free(palette); } // end case -FOSSIL_TEST_CASE(cpp_free_palette) { +FOSSIL_TEST(cpp_free_palette) { fossil_io_parser_palette_t *palette = fossil_io_parser_create_palette("test_palette", "Test Description"); ASSUME_NOT_CNULL(palette); @@ -145,7 +145,7 @@ FOSSIL_TEST_CASE(cpp_free_palette) { // No explicit assumptions here, just ensuring no memory leaks or crashes } // end case -FOSSIL_TEST_CASE(cpp_wrapper_create_palette) { +FOSSIL_TEST(cpp_wrapper_create_palette) { fossil::io::Parser parser; fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description"); FOSSIL_TEST_ASSUME(palette != NULL, "Palette should be created"); @@ -155,7 +155,7 @@ FOSSIL_TEST_CASE(cpp_wrapper_create_palette) { parser.free(palette); } // end case -FOSSIL_TEST_CASE(cpp_wrapper_add_command) { +FOSSIL_TEST(cpp_wrapper_add_command) { fossil::io::Parser parser; fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description"); fossil_io_parser_command_t *command = parser.add_command(palette, "wrapper_command", "Wrapper Command Description"); @@ -167,7 +167,7 @@ FOSSIL_TEST_CASE(cpp_wrapper_add_command) { parser.free(palette); } // end case -FOSSIL_TEST_CASE(cpp_wrapper_add_argument) { +FOSSIL_TEST(cpp_wrapper_add_argument) { fossil::io::Parser parser; fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description"); fossil_io_parser_command_t *command = parser.add_command(palette, "wrapper_command", "Wrapper Command Description"); @@ -180,7 +180,7 @@ FOSSIL_TEST_CASE(cpp_wrapper_add_argument) { parser.free(palette); } // end case -FOSSIL_TEST_CASE(cpp_wrapper_parse_command) { +FOSSIL_TEST(cpp_wrapper_parse_command) { fossil::io::Parser parser; fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description"); fossil_io_parser_command_t *command = parser.add_command(palette, "wrapper_command", "Wrapper Command Description"); @@ -197,7 +197,7 @@ FOSSIL_TEST_CASE(cpp_wrapper_parse_command) { parser.free(palette); } // end case -FOSSIL_TEST_CASE(cpp_wrapper_free_palette) { +FOSSIL_TEST(cpp_wrapper_free_palette) { fossil::io::Parser parser; fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description"); @@ -207,7 +207,7 @@ FOSSIL_TEST_CASE(cpp_wrapper_free_palette) { // No explicit assumptions here, just ensuring no memory leaks or crashes } // end case -FOSSIL_TEST_CASE(cpp_wrapper_argument_types) { +FOSSIL_TEST(cpp_wrapper_argument_types) { fossil::io::Parser parser; fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description"); fossil_io_parser_command_t *command = parser.add_command(palette, "wrapper_command", "Wrapper Command Description"); @@ -249,14 +249,14 @@ FOSSIL_TEST_CASE(cpp_wrapper_argument_types) { parser.free(palette); } // end case -FOSSIL_TEST_CASE(cpp_wrapper_null_palette) { +FOSSIL_TEST(cpp_wrapper_null_palette) { fossil::io::Parser parser; fossil_io_parser_palette_t *palette = NULL; FOSSIL_TEST_ASSUME(parser.add_command(palette, "test_command", "Test Command Description") == NULL, "Adding command to NULL palette should return NULL"); parser.parse(palette, 0, NULL); } // end case -FOSSIL_TEST_CASE(cpp_wrapper_empty_command_name) { +FOSSIL_TEST(cpp_wrapper_empty_command_name) { fossil::io::Parser parser; fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description"); fossil_io_parser_command_t *command = parser.add_command(palette, "", "Empty Command Name Description"); @@ -264,7 +264,7 @@ FOSSIL_TEST_CASE(cpp_wrapper_empty_command_name) { parser.free(palette); } // end case -FOSSIL_TEST_CASE(cpp_wrapper_duplicate_command_name) { +FOSSIL_TEST(cpp_wrapper_duplicate_command_name) { fossil::io::Parser parser; fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description"); parser.add_command(palette, "wrapper_command", "Wrapper Command Description"); @@ -273,7 +273,7 @@ FOSSIL_TEST_CASE(cpp_wrapper_duplicate_command_name) { parser.free(palette); } // end case -FOSSIL_TEST_CASE(cpp_wrapper_null_argument_name) { +FOSSIL_TEST(cpp_wrapper_null_argument_name) { fossil::io::Parser parser; fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description"); fossil_io_parser_command_t *command = parser.add_command(palette, "wrapper_command", "Wrapper Command Description"); @@ -282,7 +282,7 @@ FOSSIL_TEST_CASE(cpp_wrapper_null_argument_name) { parser.free(palette); } // end case -FOSSIL_TEST_CASE(cpp_wrapper_invalid_argument_type) { +FOSSIL_TEST(cpp_wrapper_invalid_argument_type) { fossil::io::Parser parser; fossil_io_parser_palette_t *palette = parser.create_palette("wrapper_palette", "Wrapper Test Description"); fossil_io_parser_command_t *command = parser.add_command(palette, "wrapper_command", "Wrapper Command Description"); diff --git a/code/tests/cases/test_serialize.c b/code/tests/cases/test_serialize.c index 3d041c6..0d33933 100644 --- a/code/tests/cases/test_serialize.c +++ b/code/tests/cases/test_serialize.c @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -23,7 +23,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(c_serialize_suite); +FOSSIL_SUITE(c_serialize_suite); // Setup function for the test suite FOSSIL_SETUP(c_serialize_suite) { @@ -43,14 +43,14 @@ FOSSIL_TEARDOWN(c_serialize_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(c_test_io_serialize_create) { +FOSSIL_TEST(c_test_io_serialize_create) { fossil_io_serialize_buffer_t buf; int result = fossil_io_serialize_create(&buf, 1024); ASSUME_ITS_EQUAL_I32(0, result); fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_expand) { +FOSSIL_TEST(c_test_io_serialize_expand) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_expand(&buf, 512); @@ -58,7 +58,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_expand) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_i8) { +FOSSIL_TEST(c_test_io_serialize_i8) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_i8(&buf, 127); @@ -66,7 +66,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_i8) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_i16) { +FOSSIL_TEST(c_test_io_serialize_i16) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_i16(&buf, 32767); @@ -74,7 +74,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_i16) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_i32) { +FOSSIL_TEST(c_test_io_serialize_i32) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_i32(&buf, 2147483647); @@ -82,7 +82,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_i32) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_i64) { +FOSSIL_TEST(c_test_io_serialize_i64) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_i64(&buf, 9223372036854775807LL); @@ -90,7 +90,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_i64) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_u8) { +FOSSIL_TEST(c_test_io_serialize_u8) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_u8(&buf, 255); @@ -98,7 +98,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_u8) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_u16) { +FOSSIL_TEST(c_test_io_serialize_u16) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_u16(&buf, 65535); @@ -106,7 +106,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_u16) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_u32) { +FOSSIL_TEST(c_test_io_serialize_u32) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_u32(&buf, 4294967295U); @@ -114,7 +114,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_u32) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_u64) { +FOSSIL_TEST(c_test_io_serialize_u64) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_u64(&buf, 18446744073709551615ULL); @@ -122,7 +122,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_u64) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_cstr) { +FOSSIL_TEST(c_test_io_serialize_cstr) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_cstr(&buf, "test string"); @@ -130,7 +130,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_cstr) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_bool) { +FOSSIL_TEST(c_test_io_serialize_bool) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_bool(&buf, 1); @@ -138,7 +138,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_bool) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_deserialize_i8) { +FOSSIL_TEST(c_test_io_deserialize_i8) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_i8(&buf, 127); @@ -150,7 +150,7 @@ FOSSIL_TEST_CASE(c_test_io_deserialize_i8) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_deserialize_i16) { +FOSSIL_TEST(c_test_io_deserialize_i16) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_i16(&buf, 32767); @@ -162,7 +162,7 @@ FOSSIL_TEST_CASE(c_test_io_deserialize_i16) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_deserialize_i32) { +FOSSIL_TEST(c_test_io_deserialize_i32) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_i32(&buf, 2147483647); @@ -174,7 +174,7 @@ FOSSIL_TEST_CASE(c_test_io_deserialize_i32) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_deserialize_i64) { +FOSSIL_TEST(c_test_io_deserialize_i64) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_i64(&buf, 9223372036854775807LL); @@ -186,7 +186,7 @@ FOSSIL_TEST_CASE(c_test_io_deserialize_i64) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_deserialize_u8) { +FOSSIL_TEST(c_test_io_deserialize_u8) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_u8(&buf, 255); @@ -198,7 +198,7 @@ FOSSIL_TEST_CASE(c_test_io_deserialize_u8) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_deserialize_u16) { +FOSSIL_TEST(c_test_io_deserialize_u16) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_u16(&buf, 65535); @@ -210,7 +210,7 @@ FOSSIL_TEST_CASE(c_test_io_deserialize_u16) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_deserialize_u32) { +FOSSIL_TEST(c_test_io_deserialize_u32) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_u32(&buf, 4294967295U); @@ -222,7 +222,7 @@ FOSSIL_TEST_CASE(c_test_io_deserialize_u32) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_deserialize_u64) { +FOSSIL_TEST(c_test_io_deserialize_u64) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_u64(&buf, 18446744073709551615ULL); @@ -235,7 +235,7 @@ FOSSIL_TEST_CASE(c_test_io_deserialize_u64) { } -FOSSIL_TEST_CASE(c_test_io_deserialize_cstr) { +FOSSIL_TEST(c_test_io_deserialize_cstr) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_cstr(&buf, "test string"); @@ -247,7 +247,7 @@ FOSSIL_TEST_CASE(c_test_io_deserialize_cstr) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_deserialize_bool) { +FOSSIL_TEST(c_test_io_deserialize_bool) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_bool(&buf, 1); @@ -259,7 +259,7 @@ FOSSIL_TEST_CASE(c_test_io_deserialize_bool) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(c_test_io_serialize_to_file) { +FOSSIL_TEST(c_test_io_serialize_to_file) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_cstr(&buf, "test string"); @@ -269,7 +269,7 @@ FOSSIL_TEST_CASE(c_test_io_serialize_to_file) { remove("test_file.bin"); } -FOSSIL_TEST_CASE(c_test_io_deserialize_from_file) { +FOSSIL_TEST(c_test_io_deserialize_from_file) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_cstr(&buf, "test string"); @@ -302,6 +302,8 @@ FOSSIL_TEST_GROUP(c_serialize_tests) { FOSSIL_TEST_ADD(c_serialize_suite, c_test_io_serialize_u16); FOSSIL_TEST_ADD(c_serialize_suite, c_test_io_serialize_u32); FOSSIL_TEST_ADD(c_serialize_suite, c_test_io_serialize_u64); + FOSSIL_TEST_ADD(c_serialize_suite, c_test_io_serialize_cstr); + FOSSIL_TEST_ADD(c_serialize_suite, c_test_io_serialize_bool); FOSSIL_TEST_ADD(c_serialize_suite, c_test_io_deserialize_i8); FOSSIL_TEST_ADD(c_serialize_suite, c_test_io_deserialize_i16); FOSSIL_TEST_ADD(c_serialize_suite, c_test_io_deserialize_i32); diff --git a/code/tests/cases/test_serialize.cpp b/code/tests/cases/test_serialize.cpp index a776ce6..0eb40af 100644 --- a/code/tests/cases/test_serialize.cpp +++ b/code/tests/cases/test_serialize.cpp @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -23,7 +23,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(cpp_serialize_suite); +FOSSIL_SUITE(cpp_serialize_suite); // Setup function for the test suite FOSSIL_SETUP(cpp_serialize_suite) { @@ -43,14 +43,14 @@ FOSSIL_TEARDOWN(cpp_serialize_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(cpp_test_io_serialize_create) { +FOSSIL_TEST(cpp_test_io_serialize_create) { fossil_io_serialize_buffer_t buf; int result = fossil_io_serialize_create(&buf, 1024); ASSUME_ITS_EQUAL_I32(0, result); fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_expand) { +FOSSIL_TEST(cpp_test_io_serialize_expand) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_expand(&buf, 512); @@ -58,7 +58,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_expand) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_i8) { +FOSSIL_TEST(cpp_test_io_serialize_i8) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_i8(&buf, 127); @@ -66,7 +66,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_i8) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_i16) { +FOSSIL_TEST(cpp_test_io_serialize_i16) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_i16(&buf, 32767); @@ -74,7 +74,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_i16) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_i32) { +FOSSIL_TEST(cpp_test_io_serialize_i32) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_i32(&buf, 2147483647); @@ -82,7 +82,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_i32) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_i64) { +FOSSIL_TEST(cpp_test_io_serialize_i64) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_i64(&buf, 9223372036854775807LL); @@ -90,7 +90,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_i64) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_u8) { +FOSSIL_TEST(cpp_test_io_serialize_u8) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_u8(&buf, 255); @@ -98,7 +98,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_u8) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_u16) { +FOSSIL_TEST(cpp_test_io_serialize_u16) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_u16(&buf, 65535); @@ -106,7 +106,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_u16) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_u32) { +FOSSIL_TEST(cpp_test_io_serialize_u32) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_u32(&buf, 4294967295U); @@ -114,7 +114,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_u32) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_u64) { +FOSSIL_TEST(cpp_test_io_serialize_u64) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_u64(&buf, 18446744073709551615ULL); @@ -122,7 +122,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_u64) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_cstr) { +FOSSIL_TEST(cpp_test_io_serialize_cstr) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_cstr(&buf, "test string"); @@ -130,7 +130,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_cstr) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_bool) { +FOSSIL_TEST(cpp_test_io_serialize_bool) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); int result = fossil_io_serialize_bool(&buf, 1); @@ -138,7 +138,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_bool) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_deserialize_i8) { +FOSSIL_TEST(cpp_test_io_deserialize_i8) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_i8(&buf, 127); @@ -150,7 +150,7 @@ FOSSIL_TEST_CASE(cpp_test_io_deserialize_i8) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_deserialize_i16) { +FOSSIL_TEST(cpp_test_io_deserialize_i16) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_i16(&buf, 32767); @@ -162,7 +162,7 @@ FOSSIL_TEST_CASE(cpp_test_io_deserialize_i16) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_deserialize_i32) { +FOSSIL_TEST(cpp_test_io_deserialize_i32) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_i32(&buf, 2147483647); @@ -174,7 +174,7 @@ FOSSIL_TEST_CASE(cpp_test_io_deserialize_i32) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_deserialize_i64) { +FOSSIL_TEST(cpp_test_io_deserialize_i64) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_i64(&buf, 9223372036854775807LL); @@ -186,7 +186,7 @@ FOSSIL_TEST_CASE(cpp_test_io_deserialize_i64) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_deserialize_u8) { +FOSSIL_TEST(cpp_test_io_deserialize_u8) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_u8(&buf, 255); @@ -198,7 +198,7 @@ FOSSIL_TEST_CASE(cpp_test_io_deserialize_u8) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_deserialize_u16) { +FOSSIL_TEST(cpp_test_io_deserialize_u16) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_u16(&buf, 65535); @@ -210,7 +210,7 @@ FOSSIL_TEST_CASE(cpp_test_io_deserialize_u16) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_deserialize_u32) { +FOSSIL_TEST(cpp_test_io_deserialize_u32) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_u32(&buf, 4294967295U); @@ -222,7 +222,7 @@ FOSSIL_TEST_CASE(cpp_test_io_deserialize_u32) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_deserialize_u64) { +FOSSIL_TEST(cpp_test_io_deserialize_u64) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_u64(&buf, 18446744073709551615ULL); @@ -234,7 +234,7 @@ FOSSIL_TEST_CASE(cpp_test_io_deserialize_u64) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_deserialize_cstr) { +FOSSIL_TEST(cpp_test_io_deserialize_cstr) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_cstr(&buf, "test string"); @@ -246,7 +246,7 @@ FOSSIL_TEST_CASE(cpp_test_io_deserialize_cstr) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_deserialize_bool) { +FOSSIL_TEST(cpp_test_io_deserialize_bool) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_bool(&buf, 1); @@ -258,7 +258,7 @@ FOSSIL_TEST_CASE(cpp_test_io_deserialize_bool) { fossil_io_serialize_destroy(&buf); } -FOSSIL_TEST_CASE(cpp_test_io_serialize_to_file) { +FOSSIL_TEST(cpp_test_io_serialize_to_file) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_cstr(&buf, "test string"); @@ -268,7 +268,7 @@ FOSSIL_TEST_CASE(cpp_test_io_serialize_to_file) { remove("test_file.bin"); } -FOSSIL_TEST_CASE(cpp_test_io_deserialize_from_file) { +FOSSIL_TEST(cpp_test_io_deserialize_from_file) { fossil_io_serialize_buffer_t buf; fossil_io_serialize_create(&buf, 1024); fossil_io_serialize_cstr(&buf, "test string"); @@ -286,73 +286,73 @@ FOSSIL_TEST_CASE(cpp_test_io_deserialize_from_file) { remove("test_file.bin"); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_expand) { +FOSSIL_TEST(cpp_test_serialize_class_expand) { fossil::io::Serialize serializer(1024); int result = serializer.expand(512); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_i8) { +FOSSIL_TEST(cpp_test_serialize_class_i8) { fossil::io::Serialize serializer(1024); int result = serializer.serialize_i8(127); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_i16) { +FOSSIL_TEST(cpp_test_serialize_class_i16) { fossil::io::Serialize serializer(1024); int result = serializer.serialize_i16(32767); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_i32) { +FOSSIL_TEST(cpp_test_serialize_class_i32) { fossil::io::Serialize serializer(1024); int result = serializer.serialize_i32(2147483647); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_i64) { +FOSSIL_TEST(cpp_test_serialize_class_i64) { fossil::io::Serialize serializer(1024); int result = serializer.serialize_i64(9223372036854775807LL); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_u8) { +FOSSIL_TEST(cpp_test_serialize_class_u8) { fossil::io::Serialize serializer(1024); int result = serializer.serialize_u8(255); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_u16) { +FOSSIL_TEST(cpp_test_serialize_class_u16) { fossil::io::Serialize serializer(1024); int result = serializer.serialize_u16(65535); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_u32) { +FOSSIL_TEST(cpp_test_serialize_class_u32) { fossil::io::Serialize serializer(1024); int result = serializer.serialize_u32(4294967295U); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_u64) { +FOSSIL_TEST(cpp_test_serialize_class_u64) { fossil::io::Serialize serializer(1024); int result = serializer.serialize_u64(18446744073709551615ULL); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_cstr) { +FOSSIL_TEST(cpp_test_serialize_class_cstr) { fossil::io::Serialize serializer(1024); int result = serializer.serialize_cstr("test string"); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_bool) { +FOSSIL_TEST(cpp_test_serialize_class_bool) { fossil::io::Serialize serializer(1024); int result = serializer.serialize_bool(1); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_deserialize_class_i8) { +FOSSIL_TEST(cpp_test_deserialize_class_i8) { fossil::io::Serialize serializer(1024); serializer.serialize_i8(127); size_t offset = 0; @@ -362,7 +362,7 @@ FOSSIL_TEST_CASE(cpp_test_deserialize_class_i8) { ASSUME_ITS_EQUAL_I32(127, value); } -FOSSIL_TEST_CASE(cpp_test_deserialize_class_i16) { +FOSSIL_TEST(cpp_test_deserialize_class_i16) { fossil::io::Serialize serializer(1024); serializer.serialize_i16(32767); size_t offset = 0; @@ -372,7 +372,7 @@ FOSSIL_TEST_CASE(cpp_test_deserialize_class_i16) { ASSUME_ITS_EQUAL_I32(32767, value); } -FOSSIL_TEST_CASE(cpp_test_deserialize_class_i32) { +FOSSIL_TEST(cpp_test_deserialize_class_i32) { fossil::io::Serialize serializer(1024); serializer.serialize_i32(2147483647); size_t offset = 0; @@ -382,7 +382,7 @@ FOSSIL_TEST_CASE(cpp_test_deserialize_class_i32) { ASSUME_ITS_EQUAL_I32(2147483647, value); } -FOSSIL_TEST_CASE(cpp_test_deserialize_class_i64) { +FOSSIL_TEST(cpp_test_deserialize_class_i64) { fossil::io::Serialize serializer(1024); serializer.serialize_i64(9223372036854775807LL); size_t offset = 0; @@ -392,7 +392,7 @@ FOSSIL_TEST_CASE(cpp_test_deserialize_class_i64) { ASSUME_ITS_EQUAL_I32(9223372036854775807LL, value); } -FOSSIL_TEST_CASE(cpp_test_deserialize_class_u8) { +FOSSIL_TEST(cpp_test_deserialize_class_u8) { fossil::io::Serialize serializer(1024); serializer.serialize_u8(255); size_t offset = 0; @@ -402,7 +402,7 @@ FOSSIL_TEST_CASE(cpp_test_deserialize_class_u8) { ASSUME_ITS_EQUAL_I32(255, value); } -FOSSIL_TEST_CASE(cpp_test_deserialize_class_u16) { +FOSSIL_TEST(cpp_test_deserialize_class_u16) { fossil::io::Serialize serializer(1024); serializer.serialize_u16(65535); size_t offset = 0; @@ -412,7 +412,7 @@ FOSSIL_TEST_CASE(cpp_test_deserialize_class_u16) { ASSUME_ITS_EQUAL_I32(65535, value); } -FOSSIL_TEST_CASE(cpp_test_deserialize_class_u32) { +FOSSIL_TEST(cpp_test_deserialize_class_u32) { fossil::io::Serialize serializer(1024); serializer.serialize_u32(4294967295U); size_t offset = 0; @@ -422,7 +422,7 @@ FOSSIL_TEST_CASE(cpp_test_deserialize_class_u32) { ASSUME_ITS_EQUAL_I32(4294967295U, value); } -FOSSIL_TEST_CASE(cpp_test_deserialize_class_u64) { +FOSSIL_TEST(cpp_test_deserialize_class_u64) { fossil::io::Serialize serializer(1024); serializer.serialize_u64(18446744073709551615ULL); size_t offset = 0; @@ -432,7 +432,7 @@ FOSSIL_TEST_CASE(cpp_test_deserialize_class_u64) { ASSUME_ITS_EQUAL_I32(18446744073709551615ULL, value); } -FOSSIL_TEST_CASE(cpp_test_deserialize_class_cstr) { +FOSSIL_TEST(cpp_test_deserialize_class_cstr) { fossil::io::Serialize serializer(1024); serializer.serialize_cstr("test string"); size_t offset = 0; @@ -442,7 +442,7 @@ FOSSIL_TEST_CASE(cpp_test_deserialize_class_cstr) { ASSUME_ITS_EQUAL_CSTR("test string", out); } -FOSSIL_TEST_CASE(cpp_test_deserialize_class_bool) { +FOSSIL_TEST(cpp_test_deserialize_class_bool) { fossil::io::Serialize serializer(1024); serializer.serialize_bool(1); size_t offset = 0; @@ -452,7 +452,7 @@ FOSSIL_TEST_CASE(cpp_test_deserialize_class_bool) { ASSUME_ITS_EQUAL_I32(1, value); } -FOSSIL_TEST_CASE(cpp_test_serialize_class_to_file) { +FOSSIL_TEST(cpp_test_serialize_class_to_file) { fossil::io::Serialize serializer(1024); serializer.serialize_cstr("test string"); int result = serializer.serialize_to_file("test_file.bin"); @@ -460,7 +460,7 @@ FOSSIL_TEST_CASE(cpp_test_serialize_class_to_file) { remove("test_file.bin"); } -FOSSIL_TEST_CASE(cpp_test_deserialize_class_from_file) { +FOSSIL_TEST(cpp_test_deserialize_class_from_file) { fossil::io::Serialize serializer(1024); serializer.serialize_cstr("test string"); serializer.serialize_to_file("test_file.bin"); diff --git a/code/tests/cases/test_soap.c b/code/tests/cases/test_soap.c index da2830b..09e3c3b 100644 --- a/code/tests/cases/test_soap.c +++ b/code/tests/cases/test_soap.c @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -23,7 +23,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(c_soap_suite); +FOSSIL_SUITE(c_soap_suite); // Setup function for the test suite FOSSIL_SETUP(c_soap_suite) { @@ -43,7 +43,7 @@ FOSSIL_TEARDOWN(c_soap_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(c_test_io_soap_sanitize) { +FOSSIL_TEST(c_test_io_soap_sanitize) { const char *input = "This is a rot-brain sentence."; const char *expected = "This is a stupid sentence."; char *result = fossil_io_soap_sanitize(input); @@ -51,7 +51,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_sanitize) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_sanitize_no_offensive) { +FOSSIL_TEST(c_test_io_soap_sanitize_no_offensive) { const char *input = "This is a clean sentence."; const char *expected = "This is a clean sentence."; char *result = fossil_io_soap_sanitize(input); @@ -59,7 +59,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_sanitize_no_offensive) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_sanitize_with_punctuation) { +FOSSIL_TEST(c_test_io_soap_sanitize_with_punctuation) { const char *input = "This is a test with punctuation, and special characters!"; const char *expected = "This is a test with punctuation, and special characters!"; char *result = fossil_io_soap_sanitize(input); @@ -67,7 +67,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_sanitize_with_punctuation) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_sanitize_empty_input) { +FOSSIL_TEST(c_test_io_soap_sanitize_empty_input) { const char *input = ""; const char *expected = ""; char *result = fossil_io_soap_sanitize(input); @@ -75,7 +75,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_sanitize_empty_input) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_sanitize_only_whitespace) { +FOSSIL_TEST(c_test_io_soap_sanitize_only_whitespace) { const char *input = " "; const char *expected = " "; char *result = fossil_io_soap_sanitize(input); @@ -83,7 +83,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_sanitize_only_whitespace) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_sanitize_long_input) { +FOSSIL_TEST(c_test_io_soap_sanitize_long_input) { const char *input = "This is an extremely lengthy input string that surpasses the buffer limit"; const char *expected = "This is an extremely lengthy input string that surpasses the buffer limit"; char *result = fossil_io_soap_sanitize(input); @@ -91,7 +91,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_sanitize_long_input) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_suggest) { +FOSSIL_TEST(c_test_io_soap_suggest) { const char *input = "This is a rot-brain sentence."; const char *expected = "This is a stupid sentence."; char *result = fossil_io_soap_suggest(input); @@ -99,7 +99,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_suggest) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_suggest_no_offensive) { +FOSSIL_TEST(c_test_io_soap_suggest_no_offensive) { const char *input = "This is a clean sentence."; const char *expected = "This is a clean sentence."; char *result = fossil_io_soap_suggest(input); @@ -107,34 +107,34 @@ FOSSIL_TEST_CASE(c_test_io_soap_suggest_no_offensive) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_add_custom_filter) { +FOSSIL_TEST(c_test_io_soap_add_custom_filter) { const char *phrase = "custom"; int result = fossil_io_soap_add_custom_filter(phrase); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(c_test_io_soap_detect_tone_sarcastic) { +FOSSIL_TEST(c_test_io_soap_detect_tone_sarcastic) { const char *input = "Oh, great. Another meeting."; const char *expected = "sarcastic"; const char *result = fossil_io_soap_detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(c_test_io_soap_detect_tone_formal) { +FOSSIL_TEST(c_test_io_soap_detect_tone_formal) { const char *input = "Dear Sir or Madam,"; const char *expected = "formal"; const char *result = fossil_io_soap_detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(c_test_io_soap_detect_tone_casual) { +FOSSIL_TEST(c_test_io_soap_detect_tone_casual) { const char *input = "Hey, what's up?"; const char *expected = "casual"; const char *result = fossil_io_soap_detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(c_test_io_soap_sanitize_leetspeak) { +FOSSIL_TEST(c_test_io_soap_sanitize_leetspeak) { const char *input = "Th1s 1s 4 l33tspeak s3nt3nc3."; const char *expected = "This is a leetspeak sentence."; char *result = fossil_io_soap_sanitize(input); @@ -142,7 +142,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_sanitize_leetspeak) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_sanitize_mixed_case) { +FOSSIL_TEST(c_test_io_soap_sanitize_mixed_case) { const char *input = "This Is A Rot-Brain Sentence."; const char *expected = "This Is A stupid Sentence."; char *result = fossil_io_soap_sanitize(input); @@ -150,7 +150,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_sanitize_mixed_case) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_sanitize_with_special_chars) { +FOSSIL_TEST(c_test_io_soap_sanitize_with_special_chars) { const char *input = "This is a test with special chars #$%^&*!"; const char *expected = "This is a test with special chars #$%^&*!"; char *result = fossil_io_soap_sanitize(input); @@ -158,7 +158,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_sanitize_with_special_chars) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_sanitize_with_newlines) { +FOSSIL_TEST(c_test_io_soap_sanitize_with_newlines) { const char *input = "This is a test\nwith newlines."; const char *expected = "This is a test\nwith newlines."; char *result = fossil_io_soap_sanitize(input); @@ -166,7 +166,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_sanitize_with_newlines) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_sanitize_with_tabs) { +FOSSIL_TEST(c_test_io_soap_sanitize_with_tabs) { const char *input = "This is a test\twith tabs."; const char *expected = "This is a test\twith tabs."; char *result = fossil_io_soap_sanitize(input); @@ -174,7 +174,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_sanitize_with_tabs) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_suggest_leetspeak) { +FOSSIL_TEST(c_test_io_soap_suggest_leetspeak) { const char *input = "Th1s 1s 4 l33tspeak s3nt3nc3."; const char *expected = "This is a leetspeak sentence."; char *result = fossil_io_soap_suggest(input); @@ -182,7 +182,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_suggest_leetspeak) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_suggest_mixed_case) { +FOSSIL_TEST(c_test_io_soap_suggest_mixed_case) { const char *input = "This Is A Rot-Brain Sentence."; const char *expected = "This Is A stupid Sentence."; char *result = fossil_io_soap_suggest(input); @@ -191,7 +191,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_suggest_mixed_case) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_suggest_with_special_chars) { +FOSSIL_TEST(c_test_io_soap_suggest_with_special_chars) { const char *input = "This is a test with special chars #$%^&*!"; const char *expected = "This is a test with special chars #$%^&*!"; char *result = fossil_io_soap_suggest(input); @@ -199,7 +199,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_suggest_with_special_chars) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_suggest_with_newlines) { +FOSSIL_TEST(c_test_io_soap_suggest_with_newlines) { const char *input = "This is a test\nwith newlines."; const char *expected = "This is a test\nwith newlines."; char *result = fossil_io_soap_suggest(input); @@ -207,7 +207,7 @@ FOSSIL_TEST_CASE(c_test_io_soap_suggest_with_newlines) { free(result); } -FOSSIL_TEST_CASE(c_test_io_soap_suggest_with_tabs) { +FOSSIL_TEST(c_test_io_soap_suggest_with_tabs) { const char *input = "This is a test\twith tabs."; const char *expected = "This is a test\twith tabs."; char *result = fossil_io_soap_suggest(input); diff --git a/code/tests/cases/test_soap.cpp b/code/tests/cases/test_soap.cpp index dc94b52..56306ec 100644 --- a/code/tests/cases/test_soap.cpp +++ b/code/tests/cases/test_soap.cpp @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -23,7 +23,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(cpp_soap_suite); +FOSSIL_SUITE(cpp_soap_suite); // Setup function for the test suite FOSSIL_SETUP(cpp_soap_suite) { @@ -43,7 +43,7 @@ FOSSIL_TEARDOWN(cpp_soap_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize) { +FOSSIL_TEST(cpp_test_io_soap_sanitize) { const char *input = "This is a rot-brain sentence."; const char *expected = "This is a stupid sentence."; char *result = fossil_io_soap_sanitize(input); @@ -51,7 +51,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_no_offensive) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_no_offensive) { const char *input = "This is a clean sentence."; const char *expected = "This is a clean sentence."; char *result = fossil_io_soap_sanitize(input); @@ -59,7 +59,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_no_offensive) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_punctuation) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_punctuation) { const char *input = "This is a test with punctuation, and special characters!"; const char *expected = "This is a test with punctuation, and special characters!"; char *result = fossil_io_soap_sanitize(input); @@ -67,7 +67,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_punctuation) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_empty_input) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_empty_input) { const char *input = ""; const char *expected = ""; char *result = fossil_io_soap_sanitize(input); @@ -75,7 +75,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_empty_input) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_only_whitespace) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_only_whitespace) { const char *input = " "; const char *expected = " "; char *result = fossil_io_soap_sanitize(input); @@ -83,7 +83,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_only_whitespace) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_long_input) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_long_input) { const char *input = "This is a very long input string that exceeds the buffer size"; const char *expected = "This is a very long input string that exceeds the buffer size"; char *result = fossil_io_soap_sanitize(input); @@ -91,7 +91,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_long_input) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest) { +FOSSIL_TEST(cpp_test_io_soap_suggest) { const char *input = "This is a rot-brain sentence."; const char *expected = "This is a stupid sentence."; char *result = fossil_io_soap_suggest(input); @@ -99,7 +99,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_no_offensive) { +FOSSIL_TEST(cpp_test_io_soap_suggest_no_offensive) { const char *input = "This is a clean sentence."; const char *expected = "This is a clean sentence."; char *result = fossil_io_soap_suggest(input); @@ -107,34 +107,34 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_no_offensive) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_add_custom_filter) { +FOSSIL_TEST(cpp_test_io_soap_add_custom_filter) { const char *phrase = "custom"; int result = fossil_io_soap_add_custom_filter(phrase); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_detect_tone_sarcastic) { +FOSSIL_TEST(cpp_test_io_soap_detect_tone_sarcastic) { const char *input = "Oh, great. Another meeting."; const char *expected = "sarcastic"; const char *result = fossil_io_soap_detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_detect_tone_formal) { +FOSSIL_TEST(cpp_test_io_soap_detect_tone_formal) { const char *input = "Dear Sir or Madam,"; const char *expected = "formal"; const char *result = fossil_io_soap_detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_detect_tone_casual) { +FOSSIL_TEST(cpp_test_io_soap_detect_tone_casual) { const char *input = "Hey, what's up?"; const char *expected = "casual"; const char *result = fossil_io_soap_detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_leetspeak) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_leetspeak) { const char *input = "Th1s 1s 4 l33tspeak s3nt3nc3."; const char *expected = "This is a leetspeak sentence."; char *result = fossil_io_soap_sanitize(input); @@ -142,7 +142,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_leetspeak) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_mixed_case) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_mixed_case) { const char *input = "This Is A Rot-Brain Sentence."; const char *expected = "This Is A stupid Sentence."; char *result = fossil_io_soap_sanitize(input); @@ -150,7 +150,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_mixed_case) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_special_chars) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_special_chars) { const char *input = "This is a test with special chars #$%^&*!"; const char *expected = "This is a test with special chars #$%^&*!"; char *result = fossil_io_soap_sanitize(input); @@ -158,7 +158,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_special_chars) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_newlines) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_newlines) { const char *input = "This is a test\nwith newlines."; const char *expected = "This is a test\nwith newlines."; char *result = fossil_io_soap_sanitize(input); @@ -166,7 +166,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_newlines) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_tabs) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_tabs) { const char *input = "This is a test\twith tabs."; const char *expected = "This is a test\twith tabs."; char *result = fossil_io_soap_sanitize(input); @@ -174,7 +174,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_tabs) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_leetspeak) { +FOSSIL_TEST(cpp_test_io_soap_suggest_leetspeak) { const char *input = "Th1s 1s 4 l33tspeak s3nt3nc3."; const char *expected = "This is a leetspeak sentence."; char *result = fossil_io_soap_suggest(input); @@ -182,7 +182,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_leetspeak) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_mixed_case) { +FOSSIL_TEST(cpp_test_io_soap_suggest_mixed_case) { const char *input = "This Is A Rot-Brain Sentence."; const char *expected = "This Is A stupid Sentence."; char *result = fossil_io_soap_suggest(input); @@ -191,7 +191,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_mixed_case) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_special_chars) { +FOSSIL_TEST(cpp_test_io_soap_suggest_with_special_chars) { const char *input = "This is a test with special chars #$%^&*!"; const char *expected = "This is a test with special chars #$%^&*!"; char *result = fossil_io_soap_suggest(input); @@ -199,7 +199,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_special_chars) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_newlines) { +FOSSIL_TEST(cpp_test_io_soap_suggest_with_newlines) { const char *input = "This is a test\nwith newlines."; const char *expected = "This is a test\nwith newlines."; char *result = fossil_io_soap_suggest(input); @@ -207,7 +207,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_newlines) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_tabs) { +FOSSIL_TEST(cpp_test_io_soap_suggest_with_tabs) { const char *input = "This is a test\twith tabs."; const char *expected = "This is a test\twith tabs."; char *result = fossil_io_soap_suggest(input); @@ -215,160 +215,160 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_tabs) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_stl) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_stl) { std::string input = "This is a rot-brain sentence."; std::string expected = "This is a stupid sentence."; std::string result = fossil::io::Soap::sanitize(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_no_offensive_stl) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_no_offensive_stl) { std::string input = "This is a clean sentence."; std::string expected = "This is a clean sentence."; std::string result = fossil::io::Soap::sanitize(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_punctuation_stl) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_punctuation_stl) { std::string input = "This is a test with punctuation, and special characters!"; std::string expected = "This is a test with punctuation, and special characters!"; std::string result = fossil::io::Soap::sanitize(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_empty_input_stl) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_empty_input_stl) { std::string input = ""; std::string expected = ""; std::string result = fossil::io::Soap::sanitize(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_only_whitespace_stl) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_only_whitespace_stl) { std::string input = " "; std::string expected = " "; std::string result = fossil::io::Soap::sanitize(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_long_input_stl) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_long_input_stl) { std::string input = "This is a very long input string that exceeds the buffer size"; std::string expected = "This is a very long input string that exceeds the buffer size"; std::string result = fossil::io::Soap::sanitize(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_stl) { +FOSSIL_TEST(cpp_test_io_soap_suggest_stl) { std::string input = "This is a rot-brain sentence."; std::string expected = "This is a stupid sentence."; std::string result = fossil::io::Soap::suggest(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_no_offensive_stl) { +FOSSIL_TEST(cpp_test_io_soap_suggest_no_offensive_stl) { std::string input = "This is a clean sentence."; std::string expected = "This is a clean sentence."; std::string result = fossil::io::Soap::suggest(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_add_custom_filter_stl) { +FOSSIL_TEST(cpp_test_io_soap_add_custom_filter_stl) { std::string phrase = "custom"; int result = fossil::io::Soap::add_custom_filter(phrase); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_detect_tone_sarcastic_stl) { +FOSSIL_TEST(cpp_test_io_soap_detect_tone_sarcastic_stl) { std::string input = "Oh, great. Another meeting."; std::string expected = "sarcastic"; std::string result = fossil::io::Soap::detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_detect_tone_formal_stl) { +FOSSIL_TEST(cpp_test_io_soap_detect_tone_formal_stl) { std::string input = "Dear Sir or Madam,"; std::string expected = "formal"; std::string result = fossil::io::Soap::detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_detect_tone_casual_stl) { +FOSSIL_TEST(cpp_test_io_soap_detect_tone_casual_stl) { std::string input = "Hey, what's up?"; std::string expected = "casual"; std::string result = fossil::io::Soap::detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_leetspeak_stl) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_leetspeak_stl) { std::string input = "Th1s 1s 4 l33tspeak s3nt3nc3."; std::string expected = "This is a leetspeak sentence."; std::string result = fossil::io::Soap::sanitize(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_mixed_case_stl) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_mixed_case_stl) { std::string input = "This Is A Rot-Brain Sentence."; std::string expected = "This Is A stupid Sentence."; std::string result = fossil::io::Soap::sanitize(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_special_chars_stl) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_special_chars_stl) { std::string input = "This is a test with special chars #$%^&*!"; std::string expected = "This is a test with special chars #$%^&*!"; std::string result = fossil::io::Soap::sanitize(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_newlines_stl) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_newlines_stl) { std::string input = "This is a test\nwith newlines."; std::string expected = "This is a test\nwith newlines."; std::string result = fossil::io::Soap::sanitize(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_tabs_stl) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_tabs_stl) { std::string input = "This is a test\twith tabs."; std::string expected = "This is a test\twith tabs."; std::string result = fossil::io::Soap::sanitize(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_leetspeak_stl) { +FOSSIL_TEST(cpp_test_io_soap_suggest_leetspeak_stl) { std::string input = "Th1s 1s 4 l33tspeak s3nt3nc3."; std::string expected = "This is a leetspeak sentence."; std::string result = fossil::io::Soap::suggest(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_mixed_case_stl) { +FOSSIL_TEST(cpp_test_io_soap_suggest_mixed_case_stl) { std::string input = "This Is A Rot-Brain Sentence."; std::string expected = "This Is A stupid Sentence."; std::string result = fossil::io::Soap::suggest(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_special_chars_stl) { +FOSSIL_TEST(cpp_test_io_soap_suggest_with_special_chars_stl) { std::string input = "This is a test with special chars #$%^&*!"; std::string expected = "This is a test with special chars #$%^&*!"; std::string result = fossil::io::Soap::suggest(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_newlines_stl) { +FOSSIL_TEST(cpp_test_io_soap_suggest_with_newlines_stl) { std::string input = "This is a test\nwith newlines."; std::string expected = "This is a test\nwith newlines."; std::string result = fossil::io::Soap::suggest(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_tabs_stl) { +FOSSIL_TEST(cpp_test_io_soap_suggest_with_tabs_stl) { std::string input = "This is a test\twith tabs."; std::string expected = "This is a test\twith tabs."; std::string result = fossil::io::Soap::suggest(input); ASSUME_ITS_EQUAL_CSTR(expected.c_str(), result.c_str()); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_cstr) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_cstr) { const char *input = "This is a rot-brain sentence."; const char *expected = "This is a stupid sentence."; char *result = fossil::io::Soap::sanitize(input); @@ -376,7 +376,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_no_offensive_cstr) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_no_offensive_cstr) { const char *input = "This is a clean sentence."; const char *expected = "This is a clean sentence."; char *result = fossil::io::Soap::sanitize(input); @@ -384,7 +384,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_no_offensive_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_punctuation_cstr) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_punctuation_cstr) { const char *input = "This is a test with punctuation, and special characters!"; const char *expected = "This is a test with punctuation, and special characters!"; char *result = fossil::io::Soap::sanitize(input); @@ -392,7 +392,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_punctuation_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_empty_input_cstr) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_empty_input_cstr) { const char *input = ""; const char *expected = ""; char *result = fossil::io::Soap::sanitize(input); @@ -400,7 +400,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_empty_input_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_only_whitespace_cstr) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_only_whitespace_cstr) { const char *input = " "; const char *expected = " "; char *result = fossil::io::Soap::sanitize(input); @@ -408,7 +408,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_only_whitespace_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_long_input_cstr) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_long_input_cstr) { const char *input = "This is a very long input string that exceeds the buffer size"; const char *expected = "This is a very long input string that exceeds the buffer size"; char *result = fossil::io::Soap::sanitize(input); @@ -416,7 +416,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_long_input_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_cstr) { +FOSSIL_TEST(cpp_test_io_soap_suggest_cstr) { const char *input = "This is a rot-brain sentence."; const char *expected = "This is a stupid sentence."; char *result = fossil::io::Soap::suggest(input); @@ -424,7 +424,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_no_offensive_cstr) { +FOSSIL_TEST(cpp_test_io_soap_suggest_no_offensive_cstr) { const char *input = "This is a clean sentence."; const char *expected = "This is a clean sentence."; char *result = fossil::io::Soap::suggest(input); @@ -432,34 +432,34 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_no_offensive_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_add_custom_filter_cstr) { +FOSSIL_TEST(cpp_test_io_soap_add_custom_filter_cstr) { const char *phrase = "custom"; int result = fossil::io::Soap::add_custom_filter(phrase); ASSUME_ITS_EQUAL_I32(0, result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_detect_tone_sarcastic_cstr) { +FOSSIL_TEST(cpp_test_io_soap_detect_tone_sarcastic_cstr) { const char *input = "Oh, great. Another meeting."; const char *expected = "sarcastic"; const char *result = fossil::io::Soap::detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_detect_tone_formal_cstr) { +FOSSIL_TEST(cpp_test_io_soap_detect_tone_formal_cstr) { const char *input = "Dear Sir or Madam,"; const char *expected = "formal"; const char *result = fossil::io::Soap::detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_detect_tone_casual_cstr) { +FOSSIL_TEST(cpp_test_io_soap_detect_tone_casual_cstr) { const char *input = "Hey, what's up?"; const char *expected = "casual"; const char *result = fossil::io::Soap::detect_tone(input); ASSUME_ITS_EQUAL_CSTR(expected, result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_leetspeak_cstr) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_leetspeak_cstr) { const char *input = "Th1s 1s 4 l33tspeak s3nt3nc3."; const char *expected = "This is a leetspeak sentence."; char *result = fossil::io::Soap::sanitize(input); @@ -467,7 +467,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_leetspeak_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_mixed_case_cstr) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_mixed_case_cstr) { const char *input = "This Is A Rot-Brain Sentence."; const char *expected = "This Is A stupid Sentence."; char *result = fossil::io::Soap::sanitize(input); @@ -475,7 +475,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_mixed_case_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_special_chars_cstr) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_special_chars_cstr) { const char *input = "This is a test with special chars #$%^&*!"; const char *expected = "This is a test with special chars #$%^&*!"; char *result = fossil::io::Soap::sanitize(input); @@ -483,7 +483,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_special_chars_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_newlines_cstr) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_newlines_cstr) { const char *input = "This is a test\nwith newlines."; const char *expected = "This is a test\nwith newlines."; char *result = fossil::io::Soap::sanitize(input); @@ -491,7 +491,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_newlines_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_tabs_cstr) { +FOSSIL_TEST(cpp_test_io_soap_sanitize_with_tabs_cstr) { const char *input = "This is a test\twith tabs."; const char *expected = "This is a test\twith tabs."; char *result = fossil::io::Soap::sanitize(input); @@ -499,7 +499,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_sanitize_with_tabs_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_leetspeak_cstr) { +FOSSIL_TEST(cpp_test_io_soap_suggest_leetspeak_cstr) { const char *input = "Th1s 1s 4 l33tspeak s3nt3nc3."; const char *expected = "This is a leetspeak sentence."; char *result = fossil::io::Soap::suggest(input); @@ -507,7 +507,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_leetspeak_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_mixed_case_cstr) { +FOSSIL_TEST(cpp_test_io_soap_suggest_mixed_case_cstr) { const char *input = "This Is A Rot-Brain Sentence."; const char *expected = "This Is A stupid Sentence."; char *result = fossil::io::Soap::suggest(input); @@ -515,7 +515,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_mixed_case_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_special_chars_cstr) { +FOSSIL_TEST(cpp_test_io_soap_suggest_with_special_chars_cstr) { const char *input = "This is a test with special chars #$%^&*!"; const char *expected = "This is a test with special chars #$%^&*!"; char *result = fossil::io::Soap::suggest(input); @@ -523,7 +523,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_special_chars_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_newlines_cstr) { +FOSSIL_TEST(cpp_test_io_soap_suggest_with_newlines_cstr) { const char *input = "This is a test\nwith newlines."; const char *expected = "This is a test\nwith newlines."; char *result = fossil::io::Soap::suggest(input); @@ -531,7 +531,7 @@ FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_newlines_cstr) { free(result); } -FOSSIL_TEST_CASE(cpp_test_io_soap_suggest_with_tabs_cstr) { +FOSSIL_TEST(cpp_test_io_soap_suggest_with_tabs_cstr) { const char *input = "This is a test\twith tabs."; const char *expected = "This is a test\twith tabs."; char *result = fossil::io::Soap::suggest(input); diff --git a/code/tests/cases/test_stream.c b/code/tests/cases/test_stream.c index 877c65d..502c2cd 100644 --- a/code/tests/cases/test_stream.c +++ b/code/tests/cases/test_stream.c @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -24,7 +24,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(c_stream_suite); +FOSSIL_SUITE(c_stream_suite); fossil_fstream_t c_stream; // Setup function for the test suite @@ -45,7 +45,7 @@ FOSSIL_TEARDOWN(c_stream_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(c_test_stream_tempfile_creation) { +FOSSIL_TEST(c_test_stream_tempfile_creation) { // Create a temporary file fossil_fstream_t temp_stream = fossil_fstream_tempfile(); @@ -56,7 +56,7 @@ FOSSIL_TEST_CASE(c_test_stream_tempfile_creation) { fossil_fstream_close(&temp_stream); } -FOSSIL_TEST_CASE(c_test_stream_tempfile_cleanup) { +FOSSIL_TEST(c_test_stream_tempfile_cleanup) { // Create a temporary file fossil_fstream_t temp_stream = fossil_fstream_tempfile(); @@ -70,7 +70,7 @@ FOSSIL_TEST_CASE(c_test_stream_tempfile_cleanup) { ASSUME_NOT_EQUAL_I32(0, fossil_fstream_file_exists(temp_filename)); } -FOSSIL_TEST_CASE(c_test_stream_let_write_and_read_file) { +FOSSIL_TEST(c_test_stream_let_write_and_read_file) { const char *filename = "testfile.txt"; const char *content = "This is a test."; @@ -86,7 +86,7 @@ FOSSIL_TEST_CASE(c_test_stream_let_write_and_read_file) { fossil_fstream_close(&c_stream); } -FOSSIL_TEST_CASE(c_test_stream_redirect_to_devnull) { +FOSSIL_TEST(c_test_stream_redirect_to_devnull) { const char *filename = "testfile_redirect.txt"; const char *content = "This is a test."; @@ -114,7 +114,7 @@ FOSSIL_TEST_CASE(c_test_stream_redirect_to_devnull) { } -FOSSIL_TEST_CASE(c_test_stream_let_open_and_close_file) { +FOSSIL_TEST(c_test_stream_let_open_and_close_file) { const char *filename = "testfile.txt"; // Open the file @@ -122,7 +122,7 @@ FOSSIL_TEST_CASE(c_test_stream_let_open_and_close_file) { fossil_fstream_close(&c_stream); } -FOSSIL_TEST_CASE(c_test_stream_multiple_files) { +FOSSIL_TEST(c_test_stream_multiple_files) { const char *filename1 = "testfile1.txt"; const char *filename2 = "testfile2.txt"; @@ -135,7 +135,7 @@ FOSSIL_TEST_CASE(c_test_stream_multiple_files) { fossil_fstream_close(&c_stream); } -FOSSIL_TEST_CASE(c_test_stream_seek_and_tell) { +FOSSIL_TEST(c_test_stream_seek_and_tell) { const char *filename = "testfile.txt"; const char *content = "This is a test."; @@ -159,7 +159,7 @@ FOSSIL_TEST_CASE(c_test_stream_seek_and_tell) { fossil_fstream_close(&c_stream); } -FOSSIL_TEST_CASE(c_test_stream_get_type) { +FOSSIL_TEST(c_test_stream_get_type) { const char *filename = "testfile_type.txt"; // Create the file @@ -170,7 +170,7 @@ FOSSIL_TEST_CASE(c_test_stream_get_type) { ASSUME_ITS_EQUAL_I32(2, fossil_fstream_get_type(filename)); // Regular file } -FOSSIL_TEST_CASE(c_test_stream_is_readable) { +FOSSIL_TEST(c_test_stream_is_readable) { const char *filename = "testfile_readable.txt"; // Create the file @@ -181,7 +181,7 @@ FOSSIL_TEST_CASE(c_test_stream_is_readable) { ASSUME_ITS_EQUAL_I32(1, fossil_fstream_is_readable(filename)); } -FOSSIL_TEST_CASE(c_test_stream_is_writable) { +FOSSIL_TEST(c_test_stream_is_writable) { const char *filename = "testfile_writable.txt"; // Create the file @@ -192,7 +192,7 @@ FOSSIL_TEST_CASE(c_test_stream_is_writable) { ASSUME_ITS_EQUAL_I32(1, fossil_fstream_is_writable(filename)); } -FOSSIL_TEST_CASE(c_test_stream_is_executable) { +FOSSIL_TEST(c_test_stream_is_executable) { const char *filename = "testfile_executable.txt"; // Create the file @@ -203,7 +203,7 @@ FOSSIL_TEST_CASE(c_test_stream_is_executable) { ASSUME_ITS_EQUAL_I32(0, fossil_fstream_is_executable(filename)); } -FOSSIL_TEST_CASE(c_test_stream_set_permissions) { +FOSSIL_TEST(c_test_stream_set_permissions) { const char *filename = "testfile_permissions.txt"; // Create the file @@ -218,7 +218,7 @@ FOSSIL_TEST_CASE(c_test_stream_set_permissions) { ASSUME_ITS_EQUAL_I32(1, fossil_fstream_is_writable(filename)); } -FOSSIL_TEST_CASE(c_test_stream_get_permissions) { +FOSSIL_TEST(c_test_stream_get_permissions) { const char *filename = "testfile_get_permissions.txt"; int32_t mode; @@ -233,7 +233,7 @@ FOSSIL_TEST_CASE(c_test_stream_get_permissions) { ASSUME_ITS_EQUAL_I32(0, fossil_fstream_get_permissions(filename, &mode)); } -FOSSIL_TEST_CASE(c_test_stream_remove_file) { +FOSSIL_TEST(c_test_stream_remove_file) { const char *filename = "testfile_remove.txt"; const char *content = "This is a test."; @@ -249,7 +249,7 @@ FOSSIL_TEST_CASE(c_test_stream_remove_file) { ASSUME_ITS_EQUAL_I32(0, fossil_fstream_file_exists(filename)); } -FOSSIL_TEST_CASE(c_test_stream_flush_file) { +FOSSIL_TEST(c_test_stream_flush_file) { const char *filename = "testfile_flush.txt"; const char *content = "This is a test."; @@ -262,7 +262,7 @@ FOSSIL_TEST_CASE(c_test_stream_flush_file) { fossil_fstream_close(&c_stream); } -FOSSIL_TEST_CASE(c_test_stream_setpos_and_getpos) { +FOSSIL_TEST(c_test_stream_setpos_and_getpos) { const char *filename = "testfile_setpos_getpos.txt"; const char *content = "This is a test."; int32_t pos; diff --git a/code/tests/cases/test_stream.cpp b/code/tests/cases/test_stream.cpp index fd6de15..55aaf5a 100644 --- a/code/tests/cases/test_stream.cpp +++ b/code/tests/cases/test_stream.cpp @@ -11,7 +11,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include +#include #include "fossil/io/framework.h" @@ -24,7 +24,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(cpp_stream_suite); +FOSSIL_SUITE(cpp_stream_suite); fossil_fstream_t cpp_stream; // Setup function for the test suite @@ -45,7 +45,7 @@ FOSSIL_TEARDOWN(cpp_stream_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(cpp_test_stream_tempfile_creation) { +FOSSIL_TEST(cpp_test_stream_tempfile_creation) { // Create a temporary file fossil_fstream_t temp_stream = fossil_fstream_tempfile(); @@ -56,7 +56,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_tempfile_creation) { fossil_fstream_close(&temp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_tempfile_cleanup) { +FOSSIL_TEST(cpp_test_stream_tempfile_cleanup) { // Create a temporary file fossil_fstream_t temp_stream = fossil_fstream_tempfile(); @@ -70,7 +70,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_tempfile_cleanup) { ASSUME_NOT_EQUAL_I32(0, fossil_fstream_file_exists(temp_filename)); } -FOSSIL_TEST_CASE(cpp_test_stream_let_write_and_read_file) { +FOSSIL_TEST(cpp_test_stream_let_write_and_read_file) { const char *filename = "testfile.txt"; const char *content = "This is a test."; @@ -86,7 +86,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_let_write_and_read_file) { fossil_fstream_close(&cpp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_let_open_and_close_file) { +FOSSIL_TEST(cpp_test_stream_let_open_and_close_file) { const char *filename = "testfile.txt"; // Open the file @@ -94,7 +94,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_let_open_and_close_file) { fossil_fstream_close(&cpp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_multiple_files) { +FOSSIL_TEST(cpp_test_stream_multiple_files) { const char *filename1 = "testfile1.txt"; const char *filename2 = "testfile2.txt"; @@ -107,7 +107,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_multiple_files) { fossil_fstream_close(&cpp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_seek_and_tell) { +FOSSIL_TEST(cpp_test_stream_seek_and_tell) { const char *filename = "testfile.txt"; const char *content = "This is a test."; @@ -131,7 +131,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_seek_and_tell) { fossil_fstream_close(&cpp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_get_type) { +FOSSIL_TEST(cpp_test_stream_get_type) { const char *filename = "testfile_type.txt"; // Create the file @@ -142,7 +142,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_get_type) { ASSUME_ITS_EQUAL_I32(2, fossil_fstream_get_type(filename)); // Regular file } -FOSSIL_TEST_CASE(cpp_test_stream_is_readable) { +FOSSIL_TEST(cpp_test_stream_is_readable) { const char *filename = "testfile_readable.txt"; // Create the file @@ -153,7 +153,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_is_readable) { ASSUME_ITS_EQUAL_I32(1, fossil_fstream_is_readable(filename)); } -FOSSIL_TEST_CASE(cpp_test_stream_is_writable) { +FOSSIL_TEST(cpp_test_stream_is_writable) { const char *filename = "testfile_writable.txt"; // Create the file @@ -164,7 +164,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_is_writable) { ASSUME_ITS_EQUAL_I32(1, fossil_fstream_is_writable(filename)); } -FOSSIL_TEST_CASE(cpp_test_stream_is_executable) { +FOSSIL_TEST(cpp_test_stream_is_executable) { const char *filename = "testfile_executable.txt"; // Create the file @@ -175,7 +175,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_is_executable) { ASSUME_ITS_EQUAL_I32(0, fossil_fstream_is_executable(filename)); } -FOSSIL_TEST_CASE(cpp_test_stream_set_permissions) { +FOSSIL_TEST(cpp_test_stream_set_permissions) { const char *filename = "testfile_permissions.txt"; // Create the file @@ -190,7 +190,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_set_permissions) { ASSUME_ITS_EQUAL_I32(1, fossil_fstream_is_writable(filename)); } -FOSSIL_TEST_CASE(cpp_test_stream_get_permissions) { +FOSSIL_TEST(cpp_test_stream_get_permissions) { const char *filename = "testfile_get_permissions.txt"; int32_t mode; @@ -205,7 +205,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_get_permissions) { ASSUME_ITS_EQUAL_I32(0, fossil_fstream_get_permissions(filename, &mode)); } -FOSSIL_TEST_CASE(cpp_test_stream_remove_file) { +FOSSIL_TEST(cpp_test_stream_remove_file) { const char *filename = "testfile_remove.txt"; const char *content = "This is a test."; @@ -221,7 +221,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_remove_file) { ASSUME_ITS_EQUAL_I32(0, fossil_fstream_file_exists(filename)); } -FOSSIL_TEST_CASE(cpp_test_stream_flush_file) { +FOSSIL_TEST(cpp_test_stream_flush_file) { const char *filename = "testfile_flush.txt"; const char *content = "This is a test."; @@ -234,7 +234,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_flush_file) { fossil_fstream_close(&cpp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_setpos_and_getpos) { +FOSSIL_TEST(cpp_test_stream_setpos_and_getpos) { const char *filename = "testfile_setpos_getpos.txt"; const char *content = "This is a test."; int32_t pos; @@ -258,7 +258,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_setpos_and_getpos) { fossil_fstream_close(&cpp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_class_tempfile_creation) { +FOSSIL_TEST(cpp_test_stream_class_tempfile_creation) { // Create a temporary file using the class method fossil_fstream_t temp_stream = fossil::io::Stream::tempfile(); @@ -269,7 +269,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_tempfile_creation) { fossil::io::Stream::close(&temp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_class_tempfile_cleanup) { +FOSSIL_TEST(cpp_test_stream_class_tempfile_cleanup) { // Create a temporary file using the class method fossil_fstream_t temp_stream = fossil::io::Stream::tempfile(); @@ -283,7 +283,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_tempfile_cleanup) { ASSUME_NOT_EQUAL_I32(0, fossil::io::Stream::file_exists(temp_filename)); } -FOSSIL_TEST_CASE(cpp_test_stream_class_write_and_read_file) { +FOSSIL_TEST(cpp_test_stream_class_write_and_read_file) { const char *filename = "testfile.txt"; const char *content = "This is a test."; @@ -299,7 +299,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_write_and_read_file) { fossil::io::Stream::close(&cpp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_class_open_and_close_file) { +FOSSIL_TEST(cpp_test_stream_class_open_and_close_file) { const char *filename = "testfile.txt"; // Open the file @@ -307,7 +307,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_open_and_close_file) { fossil::io::Stream::close(&cpp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_class_multiple_files) { +FOSSIL_TEST(cpp_test_stream_class_multiple_files) { const char *filename1 = "testfile1.txt"; const char *filename2 = "testfile2.txt"; @@ -320,7 +320,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_multiple_files) { fossil::io::Stream::close(&cpp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_class_seek_and_tell) { +FOSSIL_TEST(cpp_test_stream_class_seek_and_tell) { const char *filename = "testfile.txt"; const char *content = "This is a test."; @@ -344,7 +344,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_seek_and_tell) { fossil::io::Stream::close(&cpp_stream); } -FOSSIL_TEST_CASE(cpp_test_stream_class_get_type) { +FOSSIL_TEST(cpp_test_stream_class_get_type) { const char *filename = "testfile_type.txt"; // Create the file @@ -355,7 +355,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_get_type) { ASSUME_ITS_EQUAL_I32(2, fossil::io::Stream::get_type(filename)); // Regular file } -FOSSIL_TEST_CASE(cpp_test_stream_class_is_readable) { +FOSSIL_TEST(cpp_test_stream_class_is_readable) { const char *filename = "testfile_readable_class.txt"; // Create the file @@ -366,7 +366,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_is_readable) { ASSUME_ITS_EQUAL_I32(1, fossil::io::Stream::is_readable(filename)); } -FOSSIL_TEST_CASE(cpp_test_stream_class_is_writable) { +FOSSIL_TEST(cpp_test_stream_class_is_writable) { const char *filename = "testfile_writable_class.txt"; // Create the file @@ -377,7 +377,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_is_writable) { ASSUME_ITS_EQUAL_I32(1, fossil::io::Stream::is_writable(filename)); } -FOSSIL_TEST_CASE(cpp_test_stream_class_is_executable) { +FOSSIL_TEST(cpp_test_stream_class_is_executable) { const char *filename = "testfile_executable_class.txt"; // Create the file @@ -388,7 +388,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_is_executable) { ASSUME_ITS_EQUAL_I32(0, fossil::io::Stream::is_executable(filename)); } -FOSSIL_TEST_CASE(cpp_test_stream_class_set_permissions) { +FOSSIL_TEST(cpp_test_stream_class_set_permissions) { const char *filename = "testfile_permissions_class.txt"; // Create the file @@ -403,7 +403,7 @@ FOSSIL_TEST_CASE(cpp_test_stream_class_set_permissions) { ASSUME_ITS_EQUAL_I32(1, fossil::io::Stream::is_writable(filename)); } -FOSSIL_TEST_CASE(cpp_test_stream_class_get_permissions) { +FOSSIL_TEST(cpp_test_stream_class_get_permissions) { const char *filename = "testfile_get_permissions_class.txt"; int32_t mode; diff --git a/code/tests/meson.build b/code/tests/meson.build index 7ae3386..b038a59 100644 --- a/code/tests/meson.build +++ b/code/tests/meson.build @@ -1,16 +1,11 @@ if get_option('with_test').enabled() run_command(['python3', 'tools' / 'generate-runner.py'], check: true) + cards = run_command(['python3', 'tools' / 'wildcard.py'], check: true) - test_c = ['unit_runner.c'] - test_cases = ['parser', 'stream', 'soap', 'input', 'error', 'device', 'network', 'serialize', 'cstring'] + test_cases = ['unit_runner.c', cards.stdout().strip().split('\n')] - foreach cases : test_cases - test_c += ['cases' / 'test_' + cases + '.c'] - test_c += ['cases' / 'test_' + cases + '.cpp'] - endforeach - - pizza_c = executable('testbed-c', test_c, include_directories: dir, - dependencies: [subproject('fossil-test').get_variable('fossil_test_dep'), fossil_io_dep]) + pizza_c = executable('pizza', test_cases, include_directories: dir, + dependencies: [dependency('fossil-test'), fossil_io_dep]) test('fossil testing C', pizza_c) -endif +endif \ No newline at end of file diff --git a/code/tests/tools/generate-note.py b/code/tests/tools/generate-note.py new file mode 100644 index 0000000..a9fef99 --- /dev/null +++ b/code/tests/tools/generate-note.py @@ -0,0 +1,129 @@ +import argparse +import requests +import os +from datetime import datetime + +GITHUB_API = "https://api.github.com" + +def fetch_milestone_issues(owner, repo, milestone_title, token=None): + headers = {"Authorization": f"token {token}"} if token else {} + + # Find milestone ID + milestone_url = f"{GITHUB_API}/repos/{owner}/{repo}/milestones" + milestone_resp = requests.get(milestone_url, headers=headers).json() + milestone_id = next((m['number'] for m in milestone_resp if m['title'] == milestone_title), None) + if milestone_id is None: + raise ValueError(f"Milestone '{milestone_title}' not found.") + + # Fetch issues + issues_url = f"{GITHUB_API}/repos/{owner}/{repo}/issues" + issues = [] + page = 1 + while True: + params = { + "milestone": milestone_id, + "state": "closed", + "per_page": 100, + "page": page + } + page_issues = requests.get(issues_url, headers=headers, params=params).json() + if not page_issues: + break + issues.extend(page_issues) + page += 1 + + return issues + +def group_issues_by_label(issues): + grouped = {"feature": [], "bug": [], "enhancement": [], "other": []} + for issue in issues: + labels = [label["name"] for label in issue["labels"]] + added = False + for key in grouped: + if key in labels: + grouped[key].append(issue) + added = True + break + if not added: + grouped["other"].append(issue) + return grouped + +def fetch_repo_description(owner, repo, token=None): + headers = {"Authorization": f"token {token}"} if token else {} + url = f"{GITHUB_API}/repos/{owner}/{repo}" + resp = requests.get(url, headers=headers).json() + return resp.get("description", "") + +def generate_markdown(milestone, grouped_issues, repo_description=""): + today = datetime.today().strftime("%Y-%m-%d") + output = [f"# 📦 Release Notes for `{milestone}`", f"_Date: {today}_"] + + if repo_description: + output.append(f"\n> {repo_description}\n") + + output.append(f"\n## [{milestone}] – {today}") + + if grouped_issues["feature"]: + output.append("\n### 🚀 Features") + for issue in grouped_issues["feature"]: + output.append(f"- {issue['title']} (#{issue['number']})") + + if grouped_issues["bug"]: + output.append("\n### 🐞 Bug Fixes") + for issue in grouped_issues["bug"]: + output.append(f"- {issue['title']} (#{issue['number']})") + + if grouped_issues["enhancement"]: + output.append("\n### 🛠 Enhancements") + for issue in grouped_issues["enhancement"]: + output.append(f"- {issue['title']} (#{issue['number']})") + + if grouped_issues["other"]: + output.append("\n### 📦 Other") + for issue in grouped_issues["other"]: + output.append(f"- {issue['title']} (#{issue['number']})") + + # 🧩 WrapDB Git Definition + output.append("\n### 🧩 WrapDB Git Definition") + output.append("```ini") + output.append("# ======================") + output.append("# Git Wrap package definition") + output.append("# ======================") + output.append("[wrap-git]") + output.append("url = https://github.com/fossillogic/fossil-io.git") + output.append(f"revision = v{milestone}") + output.append("") + output.append("[provide]") + output.append("fossil-io = fossil_io_dep") + output.append("```") + + return "\n".join(output) + +def save_to_file(content, filename): + with open(filename, "a") as f: + f.write("\n\n" + content.strip() + "\n") + +def main(): + parser = argparse.ArgumentParser(description="Pizza Changelog and Release Note Generator") + parser.add_argument("--owner", required=True, help="GitHub repository owner") + parser.add_argument("--repo", required=True, help="GitHub repository name") + parser.add_argument("--milestone", required=True, help="Milestone title") + parser.add_argument("--token", help="GitHub personal access token (optional)") + parser.add_argument("--out", default="CHANGELOG.md", help="Output changelog file") + parser.add_argument("--release-file", action="store_true", help="Also save to release_notes_.md") + args = parser.parse_args() + + issues = fetch_milestone_issues(args.owner, args.repo, args.milestone, args.token) + grouped = group_issues_by_label(issues) + markdown = generate_markdown(args.milestone, grouped, fetch_repo_description(args.owner, args.repo, args.token)) + + save_to_file(markdown, args.out) + print(f"✅ Changelog updated: {args.out}") + + if args.release_file: + rel_file = f"release_notes_{args.milestone.replace('.', '_')}.md" + save_to_file(markdown, rel_file) + print(f"📝 Release note saved: {rel_file}") + +if __name__ == "__main__": + main() diff --git a/code/tests/tools/generate-runner.py b/code/tests/tools/generate-runner.py index 848b24e..0b64537 100644 --- a/code/tests/tools/generate-runner.py +++ b/code/tests/tools/generate-runner.py @@ -27,7 +27,7 @@ def generate_c_runner(self, test_groups): # Prepare header content for the test runner header = """ // Generated Fossil Logic Test Runner -#include +#include // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test List @@ -54,9 +54,9 @@ def generate_c_runner(self, test_groups): # Complete with footer footer = """\n - FOSSIL_TEST_RUN(); - FOSSIL_TEST_SUMMARY(); - FOSSIL_TEST_END(); + FOSSIL_RUN_ALL(); + FOSSIL_SUMMARY(); + return FOSSIL_END(); } // end of main """ @@ -74,4 +74,4 @@ def generate_c_runner(self, test_groups): test_groups = generator.find_test_groups() # Generate the test runner for C and C++ tests -generator.generate_c_runner(test_groups) +generator.generate_c_runner(test_groups) \ No newline at end of file diff --git a/code/tests/tools/wildcard.py b/code/tests/tools/wildcard.py new file mode 100644 index 0000000..16bb1c3 --- /dev/null +++ b/code/tests/tools/wildcard.py @@ -0,0 +1,11 @@ +import glob + +# Collect all .c and .cpp files directly in the cases directory (not subdirectories) +source_files = glob.glob("cases/*.c") + glob.glob("cases/*.cpp") + +# Sort files from a to z +source_files.sort() + +# Print each file name with "cases/" prefix +for file in source_files: + print(file) \ No newline at end of file diff --git a/subprojects/fossil-test.wrap b/subprojects/fossil-test.wrap index 911bc5a..4d28ea5 100644 --- a/subprojects/fossil-test.wrap +++ b/subprojects/fossil-test.wrap @@ -3,7 +3,7 @@ # ====================== [wrap-git] url = https://github.com/fossillogic/fossil-test.git -revision = v1.2.0 +revision = v1.2.3 [provide] fossil-test = fossil_test_dep