diff --git a/README.md b/README.md index c11cb96c..29582e3d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ To integrate Fossil Test into your project, follow these steps: # ====================== [wrap-git] url = https://github.com/fossillogic/fossil-test.git - revision = v1.0.7 + revision = v1.0.8 [provide] fossil-test = fossil_test_dep diff --git a/code/logic/fossil/test/assume.h b/code/logic/fossil/test/assume.h index f699c264..a30bea53 100644 --- a/code/logic/fossil/test/assume.h +++ b/code/logic/fossil/test/assume.h @@ -2225,71 +2225,6 @@ extern "C" { #define ASSUME_ITS_LENGTH_EQUAL_CSTR(actual, expected_len) \ FOSSIL_TEST_ASSUME(strlen((actual)) == (expected_len), "Expected length of C string " #actual " to be equal to " #expected_len) -// ************************************************** -// -// Array ASSUMEions -// -// ************************************************** - -/** - * @brief Assumes that the given arrays are equal. - * - * @param actual The actual array. - * @param expected The expected array. - * @param length The length of the arrays. - */ -#define ASSUME_ITS_EQUAL_ARRAY(actual, expected, length) \ - for (size_t i = 0; i < (length); i++) { \ - FOSSIL_TEST_ASSUME((actual)[i] == (expected)[i], "Expected array element " #actual " to be equal to " #expected); \ - } - -/** - * @brief Assumes that the given arrays are not equal. - * - * @param actual The actual array. - * @param expected The expected array. - * @param length The length of the arrays. - */ -#define ASSUME_NOT_EQUAL_ARRAY(actual, expected, length) \ - for (size_t i = 0; i < (length); i++) { \ - FOSSIL_TEST_ASSUME((actual)[i] != (expected)[i], "Expected array element " #actual " to not be equal to " #expected); \ - } - -/** - * @brief Assumes that the length of the given arrays are equal. - * - * @param actual_length The actual length of the array. - * @param expected_length The expected length of the array. - */ -#define ASSUME_ITS_LENGTH_EQUAL_ARRAY(actual_length, expected_length) \ - FOSSIL_TEST_ASSUME((actual_length) == (expected_length), "Expected array length " #actual_length " to be equal to " #expected_length) - -/** - * @brief Assumes that the elements of the given array are within the specified range. - * - * @param array The array to be evaluated. - * @param min The minimum value of the range. - * @param max The maximum value of the range. - * @param length The length of the array. - */ -#define ASSUME_ITS_WITHIN_RANGE_ARRAY(array, min, max, length) \ - for (size_t i = 0; i < (length); i++) { \ - FOSSIL_TEST_ASSUME((array)[i] >= (min) && (array)[i] <= (max), "Expected array element " #array " to be within range [" #min ", " #max "]"); \ - } - -/** - * @brief Assumes that the elements of the given array are not within the specified range. - * - * @param array The array to be evaluated. - * @param min The minimum value of the range. - * @param max The maximum value of the range. - * @param length The length of the array. - */ -#define ASSUME_NOT_WITHIN_RANGE_ARRAY(array, min, max, length) \ - for (size_t i = 0; i < (length); i++) { \ - FOSSIL_TEST_ASSUME((array)[i] < (min) || (array)[i] > (max), "Expected array element " #array " to not be within range [" #min ", " #max "]"); \ - } - #ifdef __cplusplus } #endif diff --git a/code/logic/fossil/test/benchmark.h b/code/logic/fossil/test/benchmark.h deleted file mode 100644 index 5cd5efc5..00000000 --- a/code/logic/fossil/test/benchmark.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * Date: 07/01/2024 - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_MARK_BENCHMARK_H -#define FOSSIL_MARK_BENCHMARK_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - const char* name; - clock_t start_time; - clock_t end_time; - int num_samples; - double total_duration; - double min_duration; - double max_duration; - int running; -} fossil_benchmark_t; - -/** - * @brief Initializes a fossil_benchmark_t object with the given name. - * @param benchmark The fossil_benchmark_t object to initialize. - * @param name The name of the benchmark. - */ -void fossil_benchmark_init(fossil_benchmark_t* benchmark, const char* name); - -/** - * @brief Starts the benchmark timer. - * @param benchmark The fossil_benchmark_t object to start. - */ -void fossil_benchmark_start(fossil_benchmark_t* benchmark); - -/** - * @brief Stops the benchmark timer. - * @param benchmark The fossil_benchmark_t object to stop. - */ -void fossil_benchmark_stop(fossil_benchmark_t* benchmark); - -/** - * @brief Returns the total elapsed time in seconds. - * @param benchmark The fossil_benchmark_t object to get the elapsed time from. - * @return The total elapsed time in seconds. - */ -double fossil_benchmark_elapsed_seconds(const fossil_benchmark_t* benchmark); - -/** - * @brief Returns the minimum elapsed time in seconds. - * @param benchmark The fossil_benchmark_t object to get the minimum time from. - * @return The minimum elapsed time in seconds. - */ -double fossil_benchmark_min_time(const fossil_benchmark_t* benchmark); - -/** - * @brief Returns the maximum elapsed time in seconds. - * @param benchmark The fossil_benchmark_t object to get the maximum time from. - * @return The maximum elapsed time in seconds. - */ -double fossil_benchmark_max_time(const fossil_benchmark_t* benchmark); - -/** - * @brief Returns the average elapsed time in seconds. - * @param benchmark The fossil_benchmark_t object to get the average time from. - * @return The average elapsed time in seconds. - */ -double fossil_benchmark_avg_time(const fossil_benchmark_t* benchmark); - -/** - * @brief Resets the benchmark statistics. - * @param benchmark The fossil_benchmark_t object to reset. - */ -void fossil_benchmark_reset(fossil_benchmark_t* benchmark); - -/** - * @brief Prints a report of the benchmark statistics. - * @param benchmark The fossil_benchmark_t object to report. - */ -void fossil_benchmark_report(const fossil_benchmark_t* benchmark); - -typedef struct { - fossil_benchmark_t* benchmark; -} scoped_benchmark_t; - -/** - * @brief Initializes a scoped_benchmark_t object with the given benchmark. - * @param scoped_benchmark The scoped_benchmark_t object to initialize. - * @param benchmark The benchmark to be scoped. - */ -void fossil_scoped_benchmark_init(scoped_benchmark_t* scoped_benchmark, fossil_benchmark_t* benchmark); - -/** - * @brief Destroys a scoped_benchmark_t object. - * @param scoped_benchmark The scoped_benchmark_t object to destroy. - */ -void fossil_scoped_benchmark_destroy(scoped_benchmark_t* scoped_benchmark); - -/** - * Function to test benchmark with specified duration type, expected value, and actual value. - * - * @param duration_type The duration type to test. - * @param expected The expected value. - * @param actual The actual value. - */ -void fossil_test_benchmark(char* duration_type, double expected, double actual); - -/** - * Function to start the benchmark. - */ -void fossil_test_start_benchmark(void); - -/** - * Function to stop the benchmark and return the elapsed time in nanoseconds. - * - * @return The elapsed time in nanoseconds. - */ -uint64_t fossil_test_stop_benchmark(void); - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -namespace fossil { - -} -#endif - -#endif // FOSSIL_MARK_FRAMEWORK_H diff --git a/code/logic/fossil/test/framework.h b/code/logic/fossil/test/framework.h index 4c2d5d32..bcc59a85 100644 --- a/code/logic/fossil/test/framework.h +++ b/code/logic/fossil/test/framework.h @@ -19,9 +19,9 @@ extern "C" { #endif -#include "benchmark.h" -#include "unittest.h" -#include "mockup.h" +#include "marking.h" +#include "testing.h" +#include "mocking.h" #include "assume.h" /** @@ -198,7 +198,8 @@ extern "C" { * * @param list The mock list to initialize. */ -#define MOCK_INIT(list) _MOCK_INIT(list) +#define MOCK_INIT(list) \ + _MOCK_INIT(list) /** * @brief Macro for destroying the mock list. @@ -207,7 +208,8 @@ extern "C" { * * @param list The mock list to destroy. */ -#define MOCK_DESTROY(list) _MOCK_DESTROY(list) +#define MOCK_DESTROY(list) \ + _MOCK_DESTROY(list) /** * @brief Macro for adding a mock function call to the mock list. @@ -219,7 +221,8 @@ extern "C" { * @param args The arguments of the mock function call. * @param num_args The number of arguments in the mock function call. */ -#define MOCK_ADD_CALL(list, func, args, num_args) _MOCK_ADD_CALL(list, func, args, num_args) +#define MOCK_ADD_CALL(list, func, args, num_args) \ + _MOCK_ADD_CALL(list, func, args, num_args) /** * @brief Macro for printing the mock list. @@ -228,7 +231,9 @@ extern "C" { * * @param list The mock list to print. */ -#define MOCK_PRINT(list) _MOCK_PRINT(list) +#define MOCK_PRINT(list) \ + _MOCK_PRINT(list) + /** * @def FOSSIL_MOCK_FUNC * @brief Macro for creating a mock function with the specified return type, name, and parameters. @@ -242,7 +247,8 @@ extern "C" { * @param ... The parameters of the mock function in the format: (type1 param1, type2 param2, ...). * @return The return type specified for the mock function. */ -#define FOSSIL_MOCK_FUNC(return_type, name, ...) _FOSSIL_MOCK_FUNC(return_type, name, __VA_ARGS__) +#define FOSSIL_MOCK_FUNC(return_type, name, ...) \ + _FOSSIL_MOCK_FUNC(return_type, name, __VA_ARGS__) /** * @def FOSSIL_MOCK_ALIAS @@ -253,7 +259,8 @@ extern "C" { * @param new_type The name of the new type alias. * @param existing_type The existing type to create an alias for. */ -#define FOSSIL_MOCK_ALIAS(new_type, existing_type) _FOSSIL_MOCK_ALIAS(new_type, existing_type) +#define FOSSIL_MOCK_ALIAS(new_type, existing_type) \ + _FOSSIL_MOCK_ALIAS(new_type, existing_type) /** * @def FOSSIL_MOCK_STRUCT @@ -265,7 +272,8 @@ extern "C" { * @param name The name of the mock struct. * @param ... The members of the mock struct in the format: (type1 member1, type2 member2, ...). */ -#define FOSSIL_MOCK_STRUCT(name, ...) _FOSSIL_MOCK_STRUCT(name, __VA_ARGS__) +#define FOSSIL_MOCK_STRUCT(name, ...) \ + _FOSSIL_MOCK_STRUCT(name, __VA_ARGS__) // ***************************************************************************** // Benchmark framework @@ -339,7 +347,8 @@ extern "C" { * This macro is used to mark the start of a benchmark. It typically initializes * any necessary resources or variables required for benchmarking. */ -#define TEST_BENCHMARK() fossil_test_start_benchmark() +#define TEST_BENCHMARK() \ + _TEST_BENCHMARK() /** * @brief Define macro for getting the current time. @@ -347,7 +356,8 @@ extern "C" { * This macro is used to retrieve the current time, which is typically used * in conjunction with TEST_BENCHMARK to calculate the elapsed time for a benchmark. */ -#define TEST_CURRENT_TIME() fossil_test_stop_benchmark() +#define TEST_CURRENT_TIME() \ + _TEST_CURRENT_TIME() /** * @brief Define macro for reporting test duration with a given timeout. @@ -360,7 +370,8 @@ extern "C" { * @param elapsed The elapsed time since the benchmark started. * @param actual The actual duration of the test. */ -#define TEST_DURATION(duration, elapsed, actual) fossil_test_benchmark((char*)duration, elapsed, actual) +#define TEST_DURATION(duration, elapsed, actual) \ + _TEST_DURATION(duration, elapsed, actual) /** * @brief Define macro for reporting test duration in minutes. @@ -372,7 +383,8 @@ extern "C" { * @param elapsed The elapsed time since the benchmark started. * @param actual The actual duration of the test. */ -#define TEST_DURATION_MIN(elapsed, actual) TEST_DURATION((char*)"minutes", elapsed, actual) +#define TEST_DURATION_MIN(elapsed, actual) \ + _TEST_DURATION_MIN(elapsed, actual) /** * @brief Define macro for reporting test duration in seconds. @@ -384,7 +396,8 @@ extern "C" { * @param elapsed The elapsed time since the benchmark started. * @param actual The actual duration of the test. */ -#define TEST_DURATION_SEC(elapsed, actual) TEST_DURATION((char*)"seconds", elapsed, actual) +#define TEST_DURATION_SEC(elapsed, actual) \ + _TEST_DURATION_SEC(elapsed, actual) /** * @brief Define macro for reporting test duration in milliseconds. @@ -396,7 +409,8 @@ extern "C" { * @param elapsed The elapsed time since the benchmark started. * @param actual The actual duration of the test. */ -#define TEST_DURATION_MIL(elapsed, actual) TEST_DURATION((char*)"milliseconds", elapsed, actual) +#define TEST_DURATION_MIL(elapsed, actual) \ + _TEST_DURATION_MIL(elapsed, actual) /** * @brief Define macro for reporting test duration in microseconds. @@ -408,7 +422,8 @@ extern "C" { * @param elapsed The elapsed time since the benchmark started. * @param actual The actual duration of the test. */ -#define TEST_DURATION_MIC(elapsed, actual) TEST_DURATION((char*)"microseconds", elapsed, actual) +#define TEST_DURATION_MIC(elapsed, actual) \ + _TEST_DURATION_MIC(elapsed, actual) /** * @brief Define macro for reporting test duration in nanoseconds. @@ -420,7 +435,8 @@ extern "C" { * @param elapsed The elapsed time since the benchmark started. * @param actual The actual duration of the test. */ -#define TEST_DURATION_NAN(elapsed, actual) TEST_DURATION((char*)"nanoseconds", elapsed, actual) +#define TEST_DURATION_NAN(elapsed, actual) \ + _TEST_DURATION_NAN(elapsed, actual) /** * @brief Define macro for reporting test duration in picoseconds. @@ -432,7 +448,8 @@ extern "C" { * @param elapsed The elapsed time since the benchmark started. * @param actual The actual duration of the test. */ -#define TEST_DURATION_PIC(elapsed, actual) TEST_DURATION((char*)"picoseconds", elapsed, actual) +#define TEST_DURATION_PIC(elapsed, actual) \ + _TEST_DURATION_PIC(elapsed, actual) /** * @brief Define macro for reporting test duration in femtoseconds. @@ -444,7 +461,8 @@ extern "C" { * @param elapsed The elapsed time since the benchmark started. * @param actual The actual duration of the test. */ -#define TEST_DURATION_FEM(elapsed, actual) TEST_DURATION((char*)"femtoseconds", elapsed, actual) +#define TEST_DURATION_FEM(elapsed, actual) \ + _TEST_DURATION_FEM(elapsed, actual) /** * @brief Define macro for reporting test duration in attoseconds. @@ -456,7 +474,8 @@ extern "C" { * @param elapsed The elapsed time since the benchmark started. * @param actual The actual duration of the test. */ -#define TEST_DURATION_ATT(elapsed, actual) TEST_DURATION((char*)"attoseconds", elapsed, actual) +#define TEST_DURATION_ATT(elapsed, actual) \ + _TEST_DURATION_ATT(elapsed, actual) /** * @brief Define macro for reporting test duration in zeptoseconds. @@ -468,7 +487,8 @@ extern "C" { * @param elapsed The elapsed time since the benchmark started. * @param actual The actual duration of the test. */ -#define TEST_DURATION_ZEP(elapsed, actual) TEST_DURATION((char*)"zeptoseconds", elapsed, actual) +#define TEST_DURATION_ZEP(elapsed, actual) \ + _TEST_DURATION_ZEP(elapsed, actual) /** * @brief Define macro for reporting test duration in yoctoseconds. @@ -480,7 +500,8 @@ extern "C" { * @param elapsed The elapsed time since the benchmark started. * @param actual The actual duration of the test. */ -#define TEST_DURATION_YOC(elapsed, actual) TEST_DURATION((char*)"yoctoseconds", elapsed, actual) +#define TEST_DURATION_YOC(elapsed, actual) \ + _TEST_DURATION_YOC(elapsed, actual) #ifdef __cplusplus } diff --git a/code/logic/fossil/test/marking.h b/code/logic/fossil/test/marking.h new file mode 100644 index 00000000..04f0212e --- /dev/null +++ b/code/logic/fossil/test/marking.h @@ -0,0 +1,354 @@ +/* + * ----------------------------------------------------------------------------- + * Project: Fossil Logic + * + * This file is part of the Fossil Logic project, which aims to develop high- + * performance, cross-platform applications and libraries. The code contained + * herein is subject to the terms and conditions defined in the project license. + * + * Author: Michael Gene Brockus (Dreamer) + * Date: 07/01/2024 + * + * Copyright (C) 2024 Fossil Logic. All rights reserved. + * ----------------------------------------------------------------------------- + */ +#ifndef FOSSIL_MARK_BENCHMARK_H +#define FOSSIL_MARK_BENCHMARK_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + const char* name; + clock_t start_time; + clock_t end_time; + int num_samples; + double total_duration; + double min_duration; + double max_duration; + int running; +} fossil_benchmark_t; + +/** + * @brief Initializes a fossil_benchmark_t object with the given name. + * @param benchmark The fossil_benchmark_t object to initialize. + * @param name The name of the benchmark. + */ +void fossil_benchmark_init(fossil_benchmark_t* benchmark, const char* name); + +/** + * @brief Starts the benchmark timer. + * @param benchmark The fossil_benchmark_t object to start. + */ +void fossil_benchmark_start(fossil_benchmark_t* benchmark); + +/** + * @brief Stops the benchmark timer. + * @param benchmark The fossil_benchmark_t object to stop. + */ +void fossil_benchmark_stop(fossil_benchmark_t* benchmark); + +/** + * @brief Returns the total elapsed time in seconds. + * @param benchmark The fossil_benchmark_t object to get the elapsed time from. + * @return The total elapsed time in seconds. + */ +double fossil_benchmark_elapsed_seconds(const fossil_benchmark_t* benchmark); + +/** + * @brief Returns the minimum elapsed time in seconds. + * @param benchmark The fossil_benchmark_t object to get the minimum time from. + * @return The minimum elapsed time in seconds. + */ +double fossil_benchmark_min_time(const fossil_benchmark_t* benchmark); + +/** + * @brief Returns the maximum elapsed time in seconds. + * @param benchmark The fossil_benchmark_t object to get the maximum time from. + * @return The maximum elapsed time in seconds. + */ +double fossil_benchmark_max_time(const fossil_benchmark_t* benchmark); + +/** + * @brief Returns the average elapsed time in seconds. + * @param benchmark The fossil_benchmark_t object to get the average time from. + * @return The average elapsed time in seconds. + */ +double fossil_benchmark_avg_time(const fossil_benchmark_t* benchmark); + +/** + * @brief Resets the benchmark statistics. + * @param benchmark The fossil_benchmark_t object to reset. + */ +void fossil_benchmark_reset(fossil_benchmark_t* benchmark); + +/** + * @brief Prints a report of the benchmark statistics. + * @param benchmark The fossil_benchmark_t object to report. + */ +void fossil_benchmark_report(const fossil_benchmark_t* benchmark); + +typedef struct { + fossil_benchmark_t* benchmark; +} scoped_benchmark_t; + +/** + * @brief Initializes a scoped_benchmark_t object with the given benchmark. + * @param scoped_benchmark The scoped_benchmark_t object to initialize. + * @param benchmark The benchmark to be scoped. + */ +void fossil_scoped_benchmark_init(scoped_benchmark_t* scoped_benchmark, fossil_benchmark_t* benchmark); + +/** + * @brief Destroys a scoped_benchmark_t object. + * @param scoped_benchmark The scoped_benchmark_t object to destroy. + */ +void fossil_scoped_benchmark_destroy(scoped_benchmark_t* scoped_benchmark); + +/** + * Function to test benchmark with specified duration type, expected value, and actual value. + * + * @param duration_type The duration type to test. + * @param expected The expected value. + * @param actual The actual value. + */ +void fossil_test_benchmark(char* duration_type, double expected, double actual); + +/** + * Function to start the benchmark. + */ +void fossil_test_start_benchmark(void); + +/** + * Function to stop the benchmark and return the elapsed time in nanoseconds. + * + * @return The elapsed time in nanoseconds. + */ +uint64_t fossil_test_stop_benchmark(void); + +// ***************************************************************************** +// Macro definitions +// ***************************************************************************** + +/** + * @brief Define macro for marking a benchmark. + * + * This macro is used to mark a benchmark with a given name. It initializes + * the benchmark structure and sets the name of the benchmark. + * + * @param name The name of the benchmark. + */ +#define _MARK_BENCHMARK(name) \ + fossil_benchmark_t benchmark_##name; \ + fossil_benchmark_init(&benchmark_##name, #name) + +/** + * @brief Define macro for starting a benchmark. + * + * This macro is used to start a benchmark with a given name. It starts the + * timer for the benchmark. + * + * @param name The name of the benchmark. + */ +#define _MARK_START(name) \ + fossil_benchmark_start(&benchmark_##name) + +/** + * @brief Define macro for stopping a benchmark. + * + * This macro is used to stop a benchmark with a given name. It stops the + * timer for the benchmark. + * + * @param name The name of the benchmark. + */ +#define _MARK_STOP(name) \ + fossil_benchmark_stop(&benchmark_##name) + +/** + * @brief Define macro for reporting a benchmark. + * + * This macro is used to report the results of a benchmark with a given name. + * It prints the benchmark name and the elapsed time. + * + * @param name The name of the benchmark. + */ +#define _MARK_REPORT(name) \ + fossil_benchmark_report(&benchmark_##name) + +/** + * @brief Define macro for scoped benchmarking. + * + * This macro is used to create a scoped benchmark with a given name. It + * initializes the scoped benchmark structure and sets the benchmark to be + * used. + * + * @param name The name of the benchmark. + */ +#define _MARK_SCOPED(name) \ + scoped_benchmark_t scoped_benchmark_##name; \ + fossil_scoped_benchmark_init(&scoped_benchmark_##name, &benchmark_##name) + +// ================================================================= +// Bench specific commands +// ================================================================= + +/** + * @brief Define macro for starting a benchmark. + * + * This macro is used to mark the start of a benchmark. It typically initializes + * any necessary resources or variables required for benchmarking. + */ +#define _TEST_BENCHMARK() fossil_test_start_benchmark() + +/** + * @brief Define macro for getting the current time. + * + * This macro is used to retrieve the current time, which is typically used + * in conjunction with TEST_BENCHMARK to calculate the elapsed time for a benchmark. + */ +#define _TEST_CURRENT_TIME() fossil_test_stop_benchmark() + +/** + * @brief Define macro for reporting test duration with a given timeout. + * + * This macro is used to report the duration of a test with a given timeout. + * It takes the timeout duration, elapsed time, and actual duration as arguments + * and reports the results, typically in the form of logs or console output. + * + * @param duration The duration unit (e.g., "minutes", "seconds"). + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define _TEST_DURATION(duration, elapsed, actual) fossil_test_benchmark((char*)duration, elapsed, actual) + +/** + * @brief Define macro for reporting test duration in minutes. + * + * This macro is a shorthand for reporting test duration in minutes using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in minutes. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define _TEST_DURATION_MIN(elapsed, actual) _TEST_DURATION((char*)"minutes", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in seconds. + * + * This macro is a shorthand for reporting test duration in seconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in seconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define _TEST_DURATION_SEC(elapsed, actual) _TEST_DURATION((char*)"seconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in milliseconds. + * + * This macro is a shorthand for reporting test duration in milliseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in milliseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define _TEST_DURATION_MIL(elapsed, actual) _TEST_DURATION((char*)"milliseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in microseconds. + * + * This macro is a shorthand for reporting test duration in microseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in microseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define _TEST_DURATION_MIC(elapsed, actual) _TEST_DURATION((char*)"microseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in nanoseconds. + * + * This macro is a shorthand for reporting test duration in nanoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in nanoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define _TEST_DURATION_NAN(elapsed, actual) _TEST_DURATION((char*)"nanoseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in picoseconds. + * + * This macro is a shorthand for reporting test duration in picoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in picoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define _TEST_DURATION_PIC(elapsed, actual) _TEST_DURATION((char*)"picoseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in femtoseconds. + * + * This macro is a shorthand for reporting test duration in femtoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in femtoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define _TEST_DURATION_FEM(elapsed, actual) _TEST_DURATION((char*)"femtoseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in attoseconds. + * + * This macro is a shorthand for reporting test duration in attoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in attoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define _TEST_DURATION_ATT(elapsed, actual) _TEST_DURATION((char*)"attoseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in zeptoseconds. + * + * This macro is a shorthand for reporting test duration in zeptoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in zeptoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define _TEST_DURATION_ZEP(elapsed, actual) _TEST_DURATION((char*)"zeptoseconds", elapsed, actual) + +/** + * @brief Define macro for reporting test duration in yoctoseconds. + * + * This macro is a shorthand for reporting test duration in yoctoseconds using TEST_DURATION. + * It takes the elapsed time and actual duration as arguments and reports the results + * in yoctoseconds. + * + * @param elapsed The elapsed time since the benchmark started. + * @param actual The actual duration of the test. + */ +#define _TEST_DURATION_YOC(elapsed, actual) _TEST_DURATION((char*)"yoctoseconds", elapsed, actual) + +#ifdef __cplusplus +} +#endif + +#endif // FOSSIL_MARK_FRAMEWORK_H diff --git a/code/logic/fossil/test/mockup.h b/code/logic/fossil/test/mocking.h similarity index 99% rename from code/logic/fossil/test/mockup.h rename to code/logic/fossil/test/mocking.h index 6242250c..fa3d9c2c 100644 --- a/code/logic/fossil/test/mockup.h +++ b/code/logic/fossil/test/mocking.h @@ -158,10 +158,4 @@ void fossil_mock_print(MockCallList *list); } #endif -#ifdef __cplusplus -namespace fossil { - -} -#endif - #endif // FOSSIL_MOCK_FRAMEWORK_H diff --git a/code/logic/fossil/test/unittest.h b/code/logic/fossil/test/testing.h similarity index 64% rename from code/logic/fossil/test/unittest.h rename to code/logic/fossil/test/testing.h index c3462853..8075c80c 100644 --- a/code/logic/fossil/test/unittest.h +++ b/code/logic/fossil/test/testing.h @@ -208,15 +208,38 @@ void fossil_test_print_stack_trace(stack_frame_t *stack_trace); // Macro definitions // ***************************************************************************** -// Assertion macro to assume a condition is true +/** + * @brief Macro to assume a condition in a test runner. + * This macro is used to assert that a specific condition is true within a test + * runner. If the condition is false, the test runner will output the specified + * message and may abort the execution of the test case or test suite. + */ #define _FOSSIL_TEST_ASSUME(condition, message) \ fossil_test_assert_internal((condition), (message), __FILE__, __LINE__, __func__) -// Macro for defining test data structures +/** + * @brief Macro to define a test case. + * + * This macro is used to define a test case, which is a single unit of testing + * that verifies the correctness of a specific functionality. The test case + * should contain the logic to set up the environment, execute the functionality, + * and verify the results. + * + * @param test_name The name of the test case. + */ #define _FOSSIL_TEST_DATA(name) \ typedef struct name -// Macro for defining a test case +/** + * @brief Macro to define a test case. + * + * This macro is used to define a test case, which is a single unit of testing + * that verifies the correctness of a specific functionality. The test case + * should contain the logic to set up the environment, execute the functionality, + * and verify the results. + * + * @param test_name The name of the test case. + */ #ifdef __cplusplus #define _FOSSIL_TEST_CASE(test_name) \ void test_name##_test_func(void); \ @@ -249,7 +272,15 @@ void fossil_test_print_stack_trace(stack_frame_t *stack_trace); void test_name##_test_func(void) #endif -// Macro to create a test suite with setup and teardown hooks +/** + * @brief Macro to define a test suite. + * + * This macro is used to define a test suite, which is a collection of test cases + * that are related to each other. The test suite can be executed as a whole to + * verify the correctness of a group of functionalities. + * + * @param suite_name The name of the test suite. + */ #ifdef __cplusplus #define _FOSSIL_TEST_SUITE(suite_name) \ void suite_name##_setup_func(void); \ @@ -276,66 +307,164 @@ void fossil_test_print_stack_trace(stack_frame_t *stack_trace); } #endif -// Macro for setting up a test case +/** + * @brief Macro to define a setup function for a test. + * + * This macro is used to declare a setup function that will be executed before + * each test case in a test suite. The setup function should contain the logic + * to initialize the environment or state required for the test cases. + * + * @param name The name of the setup function. + */ #define _FOSSIL_TEST_SETUP(name) \ void name##_setup_func(void) -// Macro for tearing down a test case +/** + * @brief Macro to define a teardown function for a test. + * + * This macro is used to declare a teardown function that will be executed after + * each test case in a test suite. The teardown function should contain the logic + * to clean up the environment or state after the test cases have been executed. + * + * @param name The name of the teardown function. + */ #define _FOSSIL_TEST_TEARDOWN(name) \ void name##_teardown_func(void) -// Macro to register a suite with the test environment +/** + * @brief Macro to register a test suite with the test framework. + * + * This macro is used to register a test suite with the test framework. The test + * suite will be added to the list of test suites that will be executed by the + * test runner. + * + * @param suite The test suite to register. + */ #define _FOSSIL_TEST_REGISTER(suite) \ fossil_test_register_suite(_env, &suite) -// Macro to add a test case to a suite +/** + * @brief Macro to add a test case to a test suite. + * + * This macro is used to add a test case to a test suite. The test case will be + * executed when the test suite is run. + * + * @param suite The test suite to add the test case to. + * @param test The test case to add. + */ #define _FOSSIL_TEST_ADD(suite, test) \ fossil_test_add_case(&suite, &(test##_test_case)) -// Macro to define a test group, grouping tests under a common environment +/** + * @brief Macro to define a test group. + * + * This macro is used to define a test group, which is a collection of test cases + * that are related to each other. The test group can be executed as a whole to + * verify the correctness of a group of functionalities. + * + * @param name The name of the test group. + */ #define _FOSSIL_TEST_GROUP(name) \ void name##_test_group(fossil_test_env_t *_env) -// Macro to export a test group +/** + * @brief Macro to export a test group. + * + * This macro is used to export a test group from a test file. The test group + * will be available to other test files that import it. + * + * @param name The name of the test group to export. + */ #define _FOSSIL_TEST_EXPORT(name) \ void name##_test_group(fossil_test_env_t *_env) -// Macro to import a test group into the environment +/** + * @brief Macro to import a test group. + * + * This macro is used to import a test group into the test runner. The test group + * will be executed when the test runner is run. + * + * @param name The name of the test group to import. + */ #define _FOSSIL_TEST_IMPORT(name) \ name##_test_group(&_env) // Main runner management macros -// Macro to initialize the test environment and handle command-line args +/** + * @brief Macro to start the test runner. + * + * This macro is used to start the test runner, which will initialize the test + * environment and set up the necessary structures for running the test cases. + */ #define _FOSSIL_TEST_START(argc, argv) \ fossil_test_env_t _env; \ fossil_test_init(&_env, argc, argv) -// Macro to run all tests in the environment +/** + * @brief Macro to run all test cases in the test suite. + * + * This macro is used to run all test cases in the test suite. The test cases + * will be executed in the order they were added to the suite. + */ #define _FOSSIL_TEST_RUN() \ fossil_test_run_all(&_env) -// Macro to output a summary of the test results +/** + * @brief Macro to print the test summary. + * + * This macro is used to print the test summary, which includes the number of + * tests that passed, failed, and were skipped. + */ #define _FOSSIL_TEST_SUMMARY() \ fossil_test_summary(&_env) -// Macro to clean up after all tests and exit with appropriate status code +/** + * @brief Macro to end the test runner. + * + * This macro is used to end the test runner, which will clean up the test + * framework and return the appropriate exit code based on the test results. + */ #define _FOSSIL_TEST_END() \ int fail_count = _env.fail_count; \ return fail_count > 0 ? EXIT_FAILURE : EXIT_SUCCESS // Behavior-driven development macros for Given, When, Then structure +/** + * @brief Macro for defining a Given step in a behavior-driven development test. + * + * This macro is used to define a Given step in a behavior-driven development test. + * The Given step is used to specify the initial context of a test case. + * + * @param description The description of the Given step. + */ #define _GIVEN(description) \ if (0) { \ printf(COLOR_BDD "Given %s\n" COLOR_RESET, description); \ } +/** + * @brief Macro for defining a When step in a behavior-driven development test. + * + * This macro is used to define a When step in a behavior-driven development test. + * The When step is used to specify the action that is being tested. + * + * @param description The description of the When step. + */ #define _WHEN(description) \ if (0) { \ printf(COLOR_BDD "When %s\n" COLOR_RESET, description); \ } +/** + * @brief Macro for defining a Then step in a behavior-driven development test. + * + * This macro is used to define a Then step in a behavior-driven development test. + * The Then step is used to specify the expected outcome of a test case. + * + * @param description The description of the Then step. + */ #define _THEN(description) \ if (0) { \ printf(COLOR_BDD "Then %s\n" COLOR_RESET, description); \ @@ -345,10 +474,4 @@ void fossil_test_print_stack_trace(stack_frame_t *stack_trace); } #endif -#ifdef __cplusplus -namespace fossil { - -} // namespace fossil -#endif - #endif diff --git a/code/logic/benchmark.c b/code/logic/marking.c similarity index 99% rename from code/logic/benchmark.c rename to code/logic/marking.c index d4aa9cc5..a3a1d39a 100644 --- a/code/logic/benchmark.c +++ b/code/logic/marking.c @@ -14,7 +14,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include "fossil/test/benchmark.h" +#include "fossil/test/marking.h" #include #include #include diff --git a/code/logic/meson.build b/code/logic/meson.build index 8e23338e..7d39a2e9 100644 --- a/code/logic/meson.build +++ b/code/logic/meson.build @@ -1,6 +1,6 @@ dir = include_directories('.') -test_code = ['mockup.c', 'unittest.c', 'benchmark.c'] +test_code = ['mocking.c', 'testing.c', 'marking.c'] fossil_test_lib = library('fossil-test', test_code, diff --git a/code/logic/mockup.c b/code/logic/mocking.c similarity index 98% rename from code/logic/mockup.c rename to code/logic/mocking.c index f35425bd..2781b731 100644 --- a/code/logic/mockup.c +++ b/code/logic/mocking.c @@ -14,7 +14,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include "fossil/test/mockup.h" +#include "fossil/test/mocking.h" extern char *_custom_fossil_test_strdup(const char *str); diff --git a/code/logic/unittest.c b/code/logic/testing.c similarity index 99% rename from code/logic/unittest.c rename to code/logic/testing.c index 45900969..6c569ef4 100644 --- a/code/logic/unittest.c +++ b/code/logic/testing.c @@ -12,7 +12,7 @@ * Copyright (C) 2024 Fossil Logic. All rights reserved. * ----------------------------------------------------------------------------- */ -#include "fossil/test/unittest.h" +#include "fossil/test/testing.h" #ifdef __WIN32 // Array of messages for each category @@ -138,7 +138,7 @@ void usage_info(void) { void version_info(void) { printf("Fossil Logic Test Framework\n"); - printf("Version: 1.0.7\n"); + printf("Version: 1.0.8\n"); printf("Author: Michael Gene Brockus (Dreamer)\n"); printf("License: Mozila Public License 2.0\n"); } diff --git a/code/tests/cases/test_ddd.c b/code/tests/cases/test_ddd.c new file mode 100644 index 00000000..32654c2c --- /dev/null +++ b/code/tests/cases/test_ddd.c @@ -0,0 +1,202 @@ +/* + * ----------------------------------------------------------------------------- + * Project: Fossil Logic + * + * This file is part of the Fossil Logic project, which aims to develop high- + * performance, cross-platform applications and libraries. The code contained + * herein is subject to the terms and conditions defined in the project license. + * + * Author: Michael Gene Brockus (Dreamer) + * Date: 07/01/2024 + * + * Copyright (C) 2024 Fossil Logic. All rights reserved. + * ----------------------------------------------------------------------------- + */ +#include +#include + +// Define the necessary types and functions for the test cases +typedef struct { + int id; + char name[50]; + int processed; +} Entity; + +typedef struct { + int x; + int y; +} ValueObject; + +typedef struct { + int id; + int child_count; + Entity children[10]; +} AggregateRoot; + +typedef struct { + Entity entities[10]; + int count; +} Repository; + +typedef struct { + bool dummy; +} Service; + +Entity create_entity(int id, const char *name) { + Entity entity; + entity.id = id; + strcpy(entity.name, name); + entity.processed = 0; + return entity; +} + +ValueObject create_value_object(int x, int y) { + ValueObject vo; + vo.x = x; + vo.y = y; + return vo; +} + +int value_object_equals(ValueObject vo1, ValueObject vo2) { + return (vo1.x == vo2.x && vo1.y == vo2.y); +} + +AggregateRoot create_aggregate_root(int id) { + AggregateRoot ar; + ar.id = id; + ar.child_count = 0; + return ar; +} + +void add_child_entity(AggregateRoot *ar, Entity entity) { + if (ar->child_count < 10) { + ar->children[ar->child_count++] = entity; + } +} + +Repository create_repository(void) { + Repository repo; + repo.count = 0; + return repo; +} + +void repository_add(Repository *repo, Entity entity) { + if (repo->count < 10) { + repo->entities[repo->count++] = entity; + } +} + +int repository_count(Repository *repo) { + return repo->count; +} + +Entity repository_get(Repository *repo, int id) { + for (int i = 0; i < repo->count; ++i) { + if (repo->entities[i].id == id) { + return repo->entities[i]; + } + } + Entity empty_entity = {0}; + return empty_entity; +} + +Service create_service(void) { + Service service; + service.dummy = 0; + // Initialize service-specific fields + return service; +} + +void service_process(Service *service, Entity *entity) { + entity->processed = 1; + service->dummy = 1; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * +// * 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_ddd_suite); + +// Setup function for the test suite +FOSSIL_SETUP(c_ddd_suite) { + // Setup code here +} + +// Teardown function for the test suite +FOSSIL_TEARDOWN(c_ddd_suite) { + // Teardown code here +} + +// * * * * * * * * * * * * * * * * * * * * * * * * +// * Fossil Logic Test Cases +// * * * * * * * * * * * * * * * * * * * * * * * * +// The test cases below are provided as samples, showcasing +// Domain-Driven Design (DDD) usage in the Fossil Logic project. +// * * * * * * * * * * * * * * * * * * * * * * * * + +FOSSIL_TEST_CASE(c_ddd_entity_creation) { + // Example of creating an entity + Entity entity = create_entity(42, "Sample Entity"); + + // Test cases + FOSSIL_TEST_ASSUME(entity.id == 42, "Entity ID should be 42"); + FOSSIL_TEST_ASSUME(strcmp(entity.name, "Sample Entity") == 0, "Entity name should be 'Sample Entity'"); +} // end case + +FOSSIL_TEST_CASE(c_ddd_value_object_equality) { + // Example of value object equality + ValueObject vo1 = create_value_object(10, 20); + ValueObject vo2 = create_value_object(10, 20); + + // Test cases + FOSSIL_TEST_ASSUME(value_object_equals(vo1, vo2), "Value objects should be equal"); +} // end case + +FOSSIL_TEST_CASE(c_ddd_aggregate_root_behavior) { + // Example of aggregate root behavior + AggregateRoot ar = create_aggregate_root(1); + add_child_entity(&ar, create_entity(2, "Child Entity")); + + // Test cases + FOSSIL_TEST_ASSUME(ar.child_count == 1, "Aggregate root should have one child entity"); + FOSSIL_TEST_ASSUME(ar.children[0].id == 2, "Child entity ID should be 2"); +} // end case + +FOSSIL_TEST_CASE(c_ddd_repository_usage) { + // Example of repository usage + Repository repo = create_repository(); + Entity entity = create_entity(1, "Repo Entity"); + repository_add(&repo, entity); + + // Test cases + FOSSIL_TEST_ASSUME(repository_count(&repo) == 1, "Repository should contain one entity"); + FOSSIL_TEST_ASSUME(repository_get(&repo, 1).id == 1, "Retrieved entity ID should be 1"); +} // end case + +FOSSIL_TEST_CASE(c_ddd_service_layer) { + // Example of service layer usage + Service service = create_service(); + Entity entity = create_entity(1, "Service Entity"); + service_process(&service, &entity); + + // Test cases + FOSSIL_TEST_ASSUME(entity.processed == true, "Entity should be processed by the service"); +} // end case + +// * * * * * * * * * * * * * * * * * * * * * * * * +// * Fossil Logic Test Pool +// * * * * * * * * * * * * * * * * * * * * * * * * +FOSSIL_TEST_GROUP(c_ddd_test_cases) { + FOSSIL_TEST_ADD(c_ddd_suite, c_ddd_entity_creation); + FOSSIL_TEST_ADD(c_ddd_suite, c_ddd_value_object_equality); + FOSSIL_TEST_ADD(c_ddd_suite, c_ddd_aggregate_root_behavior); + FOSSIL_TEST_ADD(c_ddd_suite, c_ddd_repository_usage); + FOSSIL_TEST_ADD(c_ddd_suite, c_ddd_service_layer); + + FOSSIL_TEST_REGISTER(c_ddd_suite); +} // end of group diff --git a/code/tests/cases/test_ddd.cpp b/code/tests/cases/test_ddd.cpp new file mode 100644 index 00000000..6fec934d --- /dev/null +++ b/code/tests/cases/test_ddd.cpp @@ -0,0 +1,172 @@ +/* + * ----------------------------------------------------------------------------- + * Project: Fossil Logic + * + * This file is part of the Fossil Logic project, which aims to develop high- + * performance, cross-platform applications and libraries. The code contained + * herein is subject to the terms and conditions defined in the project license. + * + * Author: Michael Gene Brockus (Dreamer) + * Date: 07/01/2024 + * + * Copyright (C) 2024 Fossil Logic. All rights reserved. + * ----------------------------------------------------------------------------- + */ +#include +#include +#include + +// Define the necessary types and functions for the test cases +class Entity { +public: + int id; + std::string name; + bool processed; + + Entity(int id, const std::string &name) : id(id), name(name), processed(false) {} +}; + +class ValueObject { +public: + int x, y; + + ValueObject(int x, int y) : x(x), y(y) {} + + bool operator==(const ValueObject &other) const { + return x == other.x && y == other.y; + } +}; + +class AggregateRoot { +public: + int id; + std::vector children; + + AggregateRoot(int id) : id(id) {} + + void addChild(const Entity &entity) { + if (children.size() < 10) { + children.push_back(entity); + } + } +}; + +class Repository { +public: + std::vector entities; + + void add(const Entity &entity) { + if (entities.size() < 10) { + entities.push_back(entity); + } + } + + size_t count() const { + return entities.size(); + } + + Entity get(int id) const { + for (const auto &entity : entities) { + if (entity.id == id) { + return entity; + } + } + return Entity(0, ""); + } +}; + +class Service { +public: + void process(Entity &entity) { + entity.processed = true; + } +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * +// * 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(cpp_ddd_suite); + +// Setup function for the test suite +FOSSIL_SETUP(cpp_ddd_suite) { + // Setup code here +} + +// Teardown function for the test suite +FOSSIL_TEARDOWN(cpp_ddd_suite) { + // Teardown code here +} + +// * * * * * * * * * * * * * * * * * * * * * * * * +// * Fossil Logic Test Cases +// * * * * * * * * * * * * * * * * * * * * * * * * +// The test cases below are provided as samples, showcasing +// Domain-Driven Design (DDD) usage in the Fossil Logic project. +// * * * * * * * * * * * * * * * * * * * * * * * * + +FOSSIL_TEST_CASE(cpp_ddd_entity_creation) { + // Example of creating an entity + Entity entity(42, "Sample Entity"); + + // Test cases + FOSSIL_TEST_ASSUME(entity.id == 42, "Entity ID should be 42"); + FOSSIL_TEST_ASSUME(entity.name == "Sample Entity", "Entity name should be 'Sample Entity'"); +} // end case + +FOSSIL_TEST_CASE(cpp_ddd_value_object_equality) { + // Example of value object equality + ValueObject vo1(10, 20); + ValueObject vo2(10, 20); + + // Test cases + FOSSIL_TEST_ASSUME(vo1 == vo2, "Value objects should be equal"); +} // end case + +FOSSIL_TEST_CASE(cpp_ddd_aggregate_root_behavior) { + // Example of aggregate root behavior + AggregateRoot ar(1); + ar.addChild(Entity(2, "Child Entity")); + + // Test cases + FOSSIL_TEST_ASSUME(ar.children.size() == 1, "Aggregate root should have one child entity"); + FOSSIL_TEST_ASSUME(ar.children[0].id == 2, "Child entity ID should be 2"); +} // end case + +FOSSIL_TEST_CASE(cpp_ddd_repository_usage) { + // Example of repository usage + Repository repo; + Entity entity(1, "Repo Entity"); + repo.add(entity); + + // Test cases + FOSSIL_TEST_ASSUME(repo.count() == 1, "Repository should contain one entity"); + FOSSIL_TEST_ASSUME(repo.get(1).id == 1, "Retrieved entity ID should be 1"); +} // end case + +FOSSIL_TEST_CASE(cpp_ddd_service_layer) { + // Example of service layer usage + Service service; + Entity entity(1, "Service Entity"); + service.process(entity); + + // Test cases + FOSSIL_TEST_ASSUME(entity.processed == true, "Entity should be processed by the service"); +} // end case + +// * * * * * * * * * * * * * * * * * * * * * * * * +// * Fossil Logic Test Pool +// * * * * * * * * * * * * * * * * * * * * * * * * +FOSSIL_TEST_GROUP(cpp_ddd_test_cases) { + FOSSIL_TEST_ADD(cpp_ddd_suite, cpp_ddd_entity_creation); + FOSSIL_TEST_ADD(cpp_ddd_suite, cpp_ddd_value_object_equality); + FOSSIL_TEST_ADD(cpp_ddd_suite, cpp_ddd_aggregate_root_behavior); + FOSSIL_TEST_ADD(cpp_ddd_suite, cpp_ddd_repository_usage); + FOSSIL_TEST_ADD(cpp_ddd_suite, cpp_ddd_service_layer); + + FOSSIL_TEST_REGISTER(cpp_ddd_suite); +} // end of group diff --git a/code/tests/cases/test_tdd.c b/code/tests/cases/test_tdd.c index 3525ef77..1baad2a7 100644 --- a/code/tests/cases/test_tdd.c +++ b/code/tests/cases/test_tdd.c @@ -22,15 +22,15 @@ // * * * * * * * * * * * * * * * * * * * * * * * * // Define the test suite and add test cases -FOSSIL_TEST_SUITE(tdd_suite); +FOSSIL_TEST_SUITE(c_tdd_suite); // Setup function for the test suite -FOSSIL_SETUP(tdd_suite) { +FOSSIL_SETUP(c_tdd_suite) { // Setup code here } // Teardown function for the test suite -FOSSIL_TEARDOWN(tdd_suite) { +FOSSIL_TEARDOWN(c_tdd_suite) { // Teardown code here } @@ -42,7 +42,7 @@ FOSSIL_TEARDOWN(tdd_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(xassume_run_of_int) { +FOSSIL_TEST_CASE(c_assume_run_of_int) { int x = 42; int y = 20; @@ -54,7 +54,7 @@ FOSSIL_TEST_CASE(xassume_run_of_int) { FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); } // end case -FOSSIL_TEST_CASE(xassume_run_of_int8) { +FOSSIL_TEST_CASE(c_assume_run_of_int8) { int8_t x = 42; int8_t y = 20; @@ -66,7 +66,7 @@ FOSSIL_TEST_CASE(xassume_run_of_int8) { FOSSIL_TEST_ASSUME((int8_t)y <= (int8_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST_CASE(xassume_run_of_int16) { +FOSSIL_TEST_CASE(c_assume_run_of_int16) { int16_t x = 42; int16_t y = 20; @@ -78,7 +78,7 @@ FOSSIL_TEST_CASE(xassume_run_of_int16) { FOSSIL_TEST_ASSUME((int16_t)y <= (int16_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST_CASE(xassume_run_of_int32) { +FOSSIL_TEST_CASE(c_assume_run_of_int32) { int32_t x = 42; int32_t y = 20; @@ -90,7 +90,7 @@ FOSSIL_TEST_CASE(xassume_run_of_int32) { FOSSIL_TEST_ASSUME((int32_t)y <= (int32_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST_CASE(xassume_run_of_int64) { +FOSSIL_TEST_CASE(c_assume_run_of_int64) { int64_t x = 42; int64_t y = 20; @@ -102,7 +102,7 @@ FOSSIL_TEST_CASE(xassume_run_of_int64) { FOSSIL_TEST_ASSUME((int64_t)y <= (int64_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST_CASE(xassume_run_of_int8_shortcut) { +FOSSIL_TEST_CASE(c_assume_run_of_int8_shortcut) { int8_t x = 42; int8_t y = 20; @@ -114,7 +114,7 @@ FOSSIL_TEST_CASE(xassume_run_of_int8_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I8((int8_t)y, (int8_t)x); } // end case -FOSSIL_TEST_CASE(xassume_run_of_int16_shortcut) { +FOSSIL_TEST_CASE(c_assume_run_of_int16_shortcut) { int16_t x = 42; int16_t y = 20; @@ -126,7 +126,7 @@ FOSSIL_TEST_CASE(xassume_run_of_int16_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I16((int16_t)y, (int16_t)x); } // end case -FOSSIL_TEST_CASE(xassume_run_of_int32_shortcut) { +FOSSIL_TEST_CASE(c_assume_run_of_int32_shortcut) { int32_t x = 42; int32_t y = 20; @@ -138,7 +138,7 @@ FOSSIL_TEST_CASE(xassume_run_of_int32_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I32((int32_t)y, (int32_t)x); } // end case -FOSSIL_TEST_CASE(xassume_run_of_int64_shortcut) { +FOSSIL_TEST_CASE(c_assume_run_of_int64_shortcut) { int64_t x = 42; int64_t y = 20; @@ -150,19 +150,627 @@ FOSSIL_TEST_CASE(xassume_run_of_int64_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I64((int64_t)y, (int64_t)x); } // end case +FOSSIL_TEST_CASE(c_assume_run_of_uint) { + unsigned int x = 42; + unsigned int y = 20; + + // Test cases + FOSSIL_TEST_ASSUME(x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_uint8) { + uint8_t x = 42; + uint8_t y = 20; + + // Test cases + FOSSIL_TEST_ASSUME((uint8_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint8_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint8_t)x != (uint8_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint8_t)y < (uint8_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint8_t)y <= (uint8_t)x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_uint16) { + uint16_t x = 42; + uint16_t y = 20; + + // Test cases + FOSSIL_TEST_ASSUME((uint16_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint16_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint16_t)x != (uint16_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint16_t)y < (uint16_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint16_t)y <= (uint16_t)x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_uint32) { + uint32_t x = 42; + uint32_t y = 20; + + // Test cases + FOSSIL_TEST_ASSUME((uint32_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint32_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint32_t)x != (uint32_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint32_t)y < (uint32_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint32_t)y <= (uint32_t)x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_uint64) { + uint64_t x = 42; + uint64_t y = 20; + + // Test cases + FOSSIL_TEST_ASSUME((uint64_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint64_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint64_t)x != (uint64_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint64_t)y < (uint64_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint64_t)y <= (uint64_t)x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_uint8_shortcut) { + uint8_t x = 42; + uint8_t y = 20; + + // Test cases + ASSUME_ITS_EQUAL_U8((uint8_t)x, 42); + ASSUME_ITS_EQUAL_U8((uint8_t)y, 20); + ASSUME_NOT_EQUAL_U8((uint8_t)x, (uint8_t)y); + ASSUME_ITS_LESS_THAN_U8((uint8_t)y, (uint8_t)x); + ASSUME_ITS_LESS_OR_EQUAL_U8((uint8_t)y, (uint8_t)x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_uint16_shortcut) { + uint16_t x = 42; + uint16_t y = 20; + + // Test cases + ASSUME_ITS_EQUAL_U16((uint16_t)x, 42); + ASSUME_ITS_EQUAL_U16((uint16_t)y, 20); + ASSUME_NOT_EQUAL_U16((uint16_t)x, (uint16_t)y); + ASSUME_ITS_LESS_THAN_U16((uint16_t)y, (uint16_t)x); + ASSUME_ITS_LESS_OR_EQUAL_U16((uint16_t)y, (uint16_t)x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_uint32_shortcut) { + uint32_t x = 42; + uint32_t y = 20; + + // Test cases + ASSUME_ITS_EQUAL_U32((uint32_t)x, 42); + ASSUME_ITS_EQUAL_U32((uint32_t)y, 20); + ASSUME_NOT_EQUAL_U32((uint32_t)x, (uint32_t)y); + ASSUME_ITS_LESS_THAN_U32((uint32_t)y, (uint32_t)x); + ASSUME_ITS_LESS_OR_EQUAL_U32((uint32_t)y, (uint32_t)x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_uint64_shortcut) { + uint64_t x = 42; + uint64_t y = 20; + + // Test cases + ASSUME_ITS_EQUAL_U64((uint64_t)x, 42); + ASSUME_ITS_EQUAL_U64((uint64_t)y, 20); + ASSUME_NOT_EQUAL_U64((uint64_t)x, (uint64_t)y); + ASSUME_ITS_LESS_THAN_U64((uint64_t)y, (uint64_t)x); + ASSUME_ITS_LESS_OR_EQUAL_U64((uint64_t)y, (uint64_t)x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_hex) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + FOSSIL_TEST_ASSUME(x == 0x2A, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 0x14, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_hex8) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + FOSSIL_TEST_ASSUME(x == 0x2A, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 0x14, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_hex16) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + FOSSIL_TEST_ASSUME(x == 0x2A, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 0x14, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_hex32) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + FOSSIL_TEST_ASSUME(x == 0x2A, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 0x14, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_hex64) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + FOSSIL_TEST_ASSUME(x == 0x2A, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 0x14, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_hex8_shortcut) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + ASSUME_ITS_EQUAL_H8((int)x, 0x2A); + ASSUME_ITS_EQUAL_H8((int)y, 0x14); + ASSUME_NOT_EQUAL_H8((int)x, (int)y); + ASSUME_ITS_LESS_THAN_H8((int)y, (int)x); + ASSUME_ITS_LESS_OR_EQUAL_H8((int)y, (int)x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_hex16_shortcut) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + ASSUME_ITS_EQUAL_H16((int)x, 0x2A); + ASSUME_ITS_EQUAL_H16((int)y, 0x14); + ASSUME_NOT_EQUAL_H16((int)x, (int)y); + ASSUME_ITS_LESS_THAN_H16((int)y, (int)x); + ASSUME_ITS_LESS_OR_EQUAL_H16((int)y, (int)x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_hex32_shortcut) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + ASSUME_ITS_EQUAL_H32((int)x, 0x2A); + ASSUME_ITS_EQUAL_H32((int)y, 0x14); + ASSUME_NOT_EQUAL_H32((int)x, (int)y); + ASSUME_ITS_LESS_THAN_H32((int)y, (int)x); + ASSUME_ITS_LESS_OR_EQUAL_H32((int)y, (int)x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_hex64_shortcut) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + ASSUME_ITS_EQUAL_H64((int)x, 0x2A); + ASSUME_ITS_EQUAL_H64((int)y, 0x14); + ASSUME_NOT_EQUAL_H64((int)x, (int)y); + ASSUME_ITS_LESS_THAN_H64((int)y, (int)x); + ASSUME_ITS_LESS_OR_EQUAL_H64((int)y, (int)x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_octal8_shortcut) { + int8_t x = 052; // Octal for 42 + int8_t y = 024; // Octal for 20 + + // Test cases + ASSUME_ITS_EQUAL_O8(x, 052); + ASSUME_ITS_EQUAL_O8(y, 024); + ASSUME_NOT_EQUAL_O8(x, y); + ASSUME_ITS_LESS_THAN_O8(y, x); + ASSUME_ITS_LESS_OR_EQUAL_O8(y, x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_octal16_shortcut) { + int16_t x = 052; // Octal for 42 + int16_t y = 024; // Octal for 20 + + // Test cases + ASSUME_ITS_EQUAL_O16(x, 052); + ASSUME_ITS_EQUAL_O16(y, 024); + ASSUME_NOT_EQUAL_O16(x, y); + ASSUME_ITS_LESS_THAN_O16(y, x); + ASSUME_ITS_LESS_OR_EQUAL_O16(y, x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_octal32_shortcut) { + int32_t x = 052; // Octal for 42 + int32_t y = 024; // Octal for 20 + + // Test cases + ASSUME_ITS_EQUAL_O32(x, 052); + ASSUME_ITS_EQUAL_O32(y, 024); + ASSUME_NOT_EQUAL_O32(x, y); + ASSUME_ITS_LESS_THAN_O32(y, x); + ASSUME_ITS_LESS_OR_EQUAL_O32(y, x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_octal64_shortcut) { + int64_t x = 052; // Octal for 42 + int64_t y = 024; // Octal for 20 + + // Test cases + ASSUME_ITS_EQUAL_O64(x, 052); + ASSUME_ITS_EQUAL_O64(y, 024); + ASSUME_NOT_EQUAL_O64(x, y); + ASSUME_ITS_LESS_THAN_O64(y, x); + ASSUME_ITS_LESS_OR_EQUAL_O64(y, x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_float32) { + float x = 42.0f; + float y = 20.0f; + + // Test cases + ASSUME_ITS_EQUAL_F32(x, 42.0f, 0.001f); + ASSUME_ITS_EQUAL_F32(y, 20.0f, 0.001f); + ASSUME_NOT_EQUAL_F32(x, y, 0.001f); + ASSUME_ITS_LESS_THAN_F32(y, x); + ASSUME_ITS_LESS_OR_EQUAL_F32(y, x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_float64) { + double x = 42.0; + double y = 20.0; + + // Test cases + ASSUME_ITS_EQUAL_F64(x, 42.0, 0.001); + ASSUME_ITS_EQUAL_F64(y, 20.0, 0.001); + ASSUME_NOT_EQUAL_F64(x, y, 0.001); + ASSUME_ITS_LESS_THAN_F64(y, x); + ASSUME_ITS_LESS_OR_EQUAL_F64(y, x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_boolean_true) { + bool x = true; + bool y = false; + + // Test cases + ASSUME_ITS_TRUE(x); + ASSUME_ITS_FALSE(y); + ASSUME_NOT_TRUE(y); + ASSUME_NOT_FALSE(x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_boolean_false) { + bool x = false; + bool y = true; + + // Test cases + ASSUME_ITS_FALSE(x); + ASSUME_ITS_TRUE(y); + ASSUME_NOT_FALSE(y); + ASSUME_NOT_TRUE(x); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_boolean_expression) { + int a = 5; + int b = 10; + + // Test cases + ASSUME_ITS_TRUE(a < b); + ASSUME_ITS_FALSE(a > b); + ASSUME_NOT_TRUE(a > b); + ASSUME_NOT_FALSE(a < b); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_boolean_expression_negation) { + int a = 5; + int b = 10; + + // Test cases + ASSUME_ITS_TRUE(!(a > b)); + ASSUME_ITS_FALSE(!(a < b)); + ASSUME_NOT_TRUE(!(a < b)); + ASSUME_NOT_FALSE(!(a > b)); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_boolean_complex_expression) { + int a = 5; + int b = 10; + int c = 15; + + // Test cases + ASSUME_ITS_TRUE((a < b) && (b < c)); + ASSUME_ITS_FALSE((a > b) || (b > c)); + ASSUME_NOT_TRUE((a > b) || (b > c)); + ASSUME_NOT_FALSE((a < b) && (b < c)); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_boolean_complex_expression_negation) { + int a = 5; + int b = 10; + int c = 15; + + // Test cases + ASSUME_ITS_TRUE(!((a > b) || (b > c))); + ASSUME_ITS_FALSE(!((a < b) && (b < c))); + ASSUME_NOT_TRUE(!((a < b) && (b < c))); + ASSUME_NOT_FALSE(!((a > b) || (b > c))); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_null_pointer) { + void *ptr = NULL; + + // Test cases + ASSUME_ITS_CNULL(ptr); + ASSUME_NOT_CNULL((void *)0x1); // Assuming a non-null pointer +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_pointer_equality) { + int a = 42; + int *ptr1 = &a; + int *ptr2 = &a; + int *ptr3 = NULL; + + // Test cases + ASSUME_ITS_EQUAL_PTR(ptr1, ptr2); + ASSUME_NOT_EQUAL_PTR(ptr1, ptr3); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_size_equality) { + size_t size1 = 42; + size_t size2 = 42; + size_t size3 = 20; + + // Test cases + ASSUME_ITS_EQUAL_SIZE(size1, size2); + ASSUME_NOT_EQUAL_SIZE(size1, size3); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_size_comparison) { + size_t size1 = 42; + size_t size2 = 20; + + // Test cases + ASSUME_ITS_LESS_THAN_SIZE(size2, size1); + ASSUME_ITS_MORE_THAN_SIZE(size1, size2); + ASSUME_ITS_LESS_OR_EQUAL_SIZE(size2, size1); + ASSUME_ITS_LESS_OR_EQUAL_SIZE(size1, size1); + ASSUME_ITS_MORE_OR_EQUAL_SIZE(size1, size2); + ASSUME_ITS_MORE_OR_EQUAL_SIZE(size1, size1); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range) { + int x = 42; + int y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_u8) { + uint8_t x = 42; + uint8_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_U8(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_U8(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_u16) { + uint16_t x = 42; + uint16_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_U16(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_U16(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_u32) { + uint32_t x = 42; + uint32_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_U32(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_U32(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_u64) { + uint64_t x = 42; + uint64_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_U64(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_U64(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_i8) { + int8_t x = 42; + int8_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_I8(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_I8(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_i16) { + int16_t x = 42; + int16_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_I16(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_I16(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_i32) { + int32_t x = 42; + int32_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_I32(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_I32(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_i64) { + int64_t x = 42; + int64_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_I64(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_I64(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_f32) { + float x = 42.0f; + float y = 20.0f; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_F32(x, 40.0f, 45.0f); + ASSUME_NOT_WITHIN_RANGE_F32(y, 21.0f, 30.0f); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_f64) { + double x = 42.0; + double y = 20.0; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_F64(x, 40.0, 45.0); + ASSUME_NOT_WITHIN_RANGE_F64(y, 21.0, 30.0); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_bchar) { + uint8_t x = 42; + uint8_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_BCHAR(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_BCHAR(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_cchar) { + char x = 'A'; + char y = 'B'; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_CCHAR(x, 'A', 'Z'); + ASSUME_NOT_WITHIN_RANGE_CCHAR(y, 'C', 'Z'); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_within_range_wchar) { + wchar_t x = L'A'; + wchar_t y = L'B'; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_WCHAR(x, L'A', L'Z'); + ASSUME_NOT_WITHIN_RANGE_WCHAR(y, L'C', L'Z'); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_wstr) { + wchar_t *str1 = L"Hello"; + wchar_t *str2 = L"Hello"; + wchar_t *str3 = L"World"; + + // Test cases + ASSUME_ITS_EQUAL_WSTR(str1, str2); + ASSUME_NOT_EQUAL_WSTR(str1, str3); + ASSUME_ITS_LENGTH_EQUAL_WSTR(str1, 5); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_bstr) { + const char *str1 = (const char *)"Hello"; + const char *str2 = (const char *)"Hello"; + const char *str3 = (const char *)"World"; + + // Test cases + ASSUME_ITS_EQUAL_BSTR(str1, str2); + ASSUME_NOT_EQUAL_BSTR(str1, str3); + ASSUME_ITS_LENGTH_EQUAL_BSTR(str1, 5); +} // end case + +FOSSIL_TEST_CASE(c_assume_run_of_cstr) { + const char *str1 = "Hello"; + const char *str2 = "Hello"; + const char *str3 = "World"; + + // Test cases + ASSUME_ITS_EQUAL_CSTR(str1, str2); + ASSUME_NOT_EQUAL_CSTR(str1, str3); + ASSUME_ITS_LENGTH_EQUAL_CSTR(str1, 5); +} // end case + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * FOSSIL_TEST_GROUP(c_tdd_test_cases) { - FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int); - FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int8); - FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int16); - FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int32); - FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int64); - FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int8_shortcut); - FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int16_shortcut); - FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int32_shortcut); - FOSSIL_TEST_ADD(tdd_suite, xassume_run_of_int64_shortcut); - - FOSSIL_TEST_REGISTER(tdd_suite); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_int); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_int8); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_int16); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_int32); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_int64); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_int8_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_int16_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_int32_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_int64_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_uint); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_uint8); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_uint16); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_uint32); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_uint64); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_uint8_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_uint16_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_uint32_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_uint64_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_hex); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_hex8); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_hex16); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_hex32); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_hex64); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_hex8_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_hex16_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_hex32_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_hex64_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_octal8_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_octal16_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_octal32_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_octal64_shortcut); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_float32); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_float64); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_boolean_true); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_boolean_false); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_boolean_expression); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_boolean_expression_negation); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_boolean_complex_expression); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_boolean_complex_expression_negation); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_null_pointer); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_pointer_equality); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_size_equality); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_size_comparison); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_u8); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_u16); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_u32); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_u64); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_i8); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_i16); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_i32); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_i64); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_f32); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_f64); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_bchar); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_cchar); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_within_range_wchar); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_wstr); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_bstr); + FOSSIL_TEST_ADD(c_tdd_suite, c_assume_run_of_cstr); + + FOSSIL_TEST_REGISTER(c_tdd_suite); } // end of group diff --git a/code/tests/cases/test_tdd.cpp b/code/tests/cases/test_tdd.cpp index 6f1e065a..44c3a451 100644 --- a/code/tests/cases/test_tdd.cpp +++ b/code/tests/cases/test_tdd.cpp @@ -42,7 +42,7 @@ FOSSIL_TEARDOWN(cpp_tdd_suite) { // as samples for library usage. // * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_CASE(cpp_xassume_run_of_int) { +FOSSIL_TEST_CASE(cpp_assume_run_of_int) { int x = 42; int y = 20; @@ -54,7 +54,7 @@ FOSSIL_TEST_CASE(cpp_xassume_run_of_int) { FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); } // end case -FOSSIL_TEST_CASE(cpp_xassume_run_of_int8) { +FOSSIL_TEST_CASE(cpp_assume_run_of_int8) { int8_t x = 42; int8_t y = 20; @@ -66,7 +66,7 @@ FOSSIL_TEST_CASE(cpp_xassume_run_of_int8) { FOSSIL_TEST_ASSUME((int8_t)y <= (int8_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST_CASE(cpp_xassume_run_of_int16) { +FOSSIL_TEST_CASE(cpp_assume_run_of_int16) { int16_t x = 42; int16_t y = 20; @@ -78,7 +78,7 @@ FOSSIL_TEST_CASE(cpp_xassume_run_of_int16) { FOSSIL_TEST_ASSUME((int16_t)y <= (int16_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST_CASE(cpp_xassume_run_of_int32) { +FOSSIL_TEST_CASE(cpp_assume_run_of_int32) { int32_t x = 42; int32_t y = 20; @@ -90,7 +90,7 @@ FOSSIL_TEST_CASE(cpp_xassume_run_of_int32) { FOSSIL_TEST_ASSUME((int32_t)y <= (int32_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST_CASE(cpp_xassume_run_of_int64) { +FOSSIL_TEST_CASE(cpp_assume_run_of_int64) { int64_t x = 42; int64_t y = 20; @@ -102,7 +102,7 @@ FOSSIL_TEST_CASE(cpp_xassume_run_of_int64) { FOSSIL_TEST_ASSUME((int64_t)y <= (int64_t)x, "Should have passed the test case"); } // end case -FOSSIL_TEST_CASE(cpp_xassume_run_of_int8_shortcut) { +FOSSIL_TEST_CASE(cpp_assume_run_of_int8_shortcut) { int8_t x = 42; int8_t y = 20; @@ -114,7 +114,7 @@ FOSSIL_TEST_CASE(cpp_xassume_run_of_int8_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I8((int8_t)y, (int8_t)x); } // end case -FOSSIL_TEST_CASE(cpp_xassume_run_of_int16_shortcut) { +FOSSIL_TEST_CASE(cpp_assume_run_of_int16_shortcut) { int16_t x = 42; int16_t y = 20; @@ -126,7 +126,7 @@ FOSSIL_TEST_CASE(cpp_xassume_run_of_int16_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I16((int16_t)y, (int16_t)x); } // end case -FOSSIL_TEST_CASE(cpp_xassume_run_of_int32_shortcut) { +FOSSIL_TEST_CASE(cpp_assume_run_of_int32_shortcut) { int32_t x = 42; int32_t y = 20; @@ -138,7 +138,7 @@ FOSSIL_TEST_CASE(cpp_xassume_run_of_int32_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I32((int32_t)y, (int32_t)x); } // end case -FOSSIL_TEST_CASE(cpp_xassume_run_of_int64_shortcut) { +FOSSIL_TEST_CASE(cpp_assume_run_of_int64_shortcut) { int64_t x = 42; int64_t y = 20; @@ -150,19 +150,627 @@ FOSSIL_TEST_CASE(cpp_xassume_run_of_int64_shortcut) { ASSUME_ITS_LESS_OR_EQUAL_I64((int64_t)y, (int64_t)x); } // end case +FOSSIL_TEST_CASE(cpp_assume_run_of_uint) { + unsigned int x = 42; + unsigned int y = 20; + + // Test cases + FOSSIL_TEST_ASSUME(x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_uint8) { + uint8_t x = 42; + uint8_t y = 20; + + // Test cases + FOSSIL_TEST_ASSUME((uint8_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint8_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint8_t)x != (uint8_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint8_t)y < (uint8_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint8_t)y <= (uint8_t)x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_uint16) { + uint16_t x = 42; + uint16_t y = 20; + + // Test cases + FOSSIL_TEST_ASSUME((uint16_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint16_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint16_t)x != (uint16_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint16_t)y < (uint16_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint16_t)y <= (uint16_t)x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_uint32) { + uint32_t x = 42; + uint32_t y = 20; + + // Test cases + FOSSIL_TEST_ASSUME((uint32_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint32_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint32_t)x != (uint32_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint32_t)y < (uint32_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint32_t)y <= (uint32_t)x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_uint64) { + uint64_t x = 42; + uint64_t y = 20; + + // Test cases + FOSSIL_TEST_ASSUME((uint64_t)x == 42, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint64_t)y == 20, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint64_t)x != (uint64_t)y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint64_t)y < (uint64_t)x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME((uint64_t)y <= (uint64_t)x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_uint8_shortcut) { + uint8_t x = 42; + uint8_t y = 20; + + // Test cases + ASSUME_ITS_EQUAL_U8((uint8_t)x, 42); + ASSUME_ITS_EQUAL_U8((uint8_t)y, 20); + ASSUME_NOT_EQUAL_U8((uint8_t)x, (uint8_t)y); + ASSUME_ITS_LESS_THAN_U8((uint8_t)y, (uint8_t)x); + ASSUME_ITS_LESS_OR_EQUAL_U8((uint8_t)y, (uint8_t)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_uint16_shortcut) { + uint16_t x = 42; + uint16_t y = 20; + + // Test cases + ASSUME_ITS_EQUAL_U16((uint16_t)x, 42); + ASSUME_ITS_EQUAL_U16((uint16_t)y, 20); + ASSUME_NOT_EQUAL_U16((uint16_t)x, (uint16_t)y); + ASSUME_ITS_LESS_THAN_U16((uint16_t)y, (uint16_t)x); + ASSUME_ITS_LESS_OR_EQUAL_U16((uint16_t)y, (uint16_t)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_uint32_shortcut) { + uint32_t x = 42; + uint32_t y = 20; + + // Test cases + ASSUME_ITS_EQUAL_U32((uint32_t)x, 42); + ASSUME_ITS_EQUAL_U32((uint32_t)y, 20); + ASSUME_NOT_EQUAL_U32((uint32_t)x, (uint32_t)y); + ASSUME_ITS_LESS_THAN_U32((uint32_t)y, (uint32_t)x); + ASSUME_ITS_LESS_OR_EQUAL_U32((uint32_t)y, (uint32_t)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_uint64_shortcut) { + uint64_t x = 42; + uint64_t y = 20; + + // Test cases + ASSUME_ITS_EQUAL_U64((uint64_t)x, 42); + ASSUME_ITS_EQUAL_U64((uint64_t)y, 20); + ASSUME_NOT_EQUAL_U64((uint64_t)x, (uint64_t)y); + ASSUME_ITS_LESS_THAN_U64((uint64_t)y, (uint64_t)x); + ASSUME_ITS_LESS_OR_EQUAL_U64((uint64_t)y, (uint64_t)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_hex) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + FOSSIL_TEST_ASSUME(x == 0x2A, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 0x14, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_hex8) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + FOSSIL_TEST_ASSUME(x == 0x2A, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 0x14, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_hex16) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + FOSSIL_TEST_ASSUME(x == 0x2A, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 0x14, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_hex32) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + FOSSIL_TEST_ASSUME(x == 0x2A, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 0x14, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_hex64) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + FOSSIL_TEST_ASSUME(x == 0x2A, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y == 0x14, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(x != y, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y < x, "Should have passed the test case"); + FOSSIL_TEST_ASSUME(y <= x, "Should have passed the test case"); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_hex8_shortcut) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + ASSUME_ITS_EQUAL_H8((int)x, 0x2A); + ASSUME_ITS_EQUAL_H8((int)y, 0x14); + ASSUME_NOT_EQUAL_H8((int)x, (int)y); + ASSUME_ITS_LESS_THAN_H8((int)y, (int)x); + ASSUME_ITS_LESS_OR_EQUAL_H8((int)y, (int)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_hex16_shortcut) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + ASSUME_ITS_EQUAL_H16((int)x, 0x2A); + ASSUME_ITS_EQUAL_H16((int)y, 0x14); + ASSUME_NOT_EQUAL_H16((int)x, (int)y); + ASSUME_ITS_LESS_THAN_H16((int)y, (int)x); + ASSUME_ITS_LESS_OR_EQUAL_H16((int)y, (int)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_hex32_shortcut) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + ASSUME_ITS_EQUAL_H32((int)x, 0x2A); + ASSUME_ITS_EQUAL_H32((int)y, 0x14); + ASSUME_NOT_EQUAL_H32((int)x, (int)y); + ASSUME_ITS_LESS_THAN_H32((int)y, (int)x); + ASSUME_ITS_LESS_OR_EQUAL_H32((int)y, (int)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_hex64_shortcut) { + int x = 0x2A; // Hex for 42 + int y = 0x14; // Hex for 20 + + // Test cases + ASSUME_ITS_EQUAL_H64((int)x, 0x2A); + ASSUME_ITS_EQUAL_H64((int)y, 0x14); + ASSUME_NOT_EQUAL_H64((int)x, (int)y); + ASSUME_ITS_LESS_THAN_H64((int)y, (int)x); + ASSUME_ITS_LESS_OR_EQUAL_H64((int)y, (int)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_octal8_shortcut) { + int8_t x = 042; // Octal for 42 + int8_t y = 020; // Octal for 20 + + // Test cases + ASSUME_ITS_EQUAL_O8((int8_t)x, 042); + ASSUME_ITS_EQUAL_O8((int8_t)y, 020); + ASSUME_NOT_EQUAL_O8((int8_t)x, (int8_t)y); + ASSUME_ITS_LESS_THAN_O8((int8_t)y, (int8_t)x); + ASSUME_ITS_LESS_OR_EQUAL_O8((int8_t)y, (int8_t)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_octal16_shortcut) { + int16_t x = 042; // Octal for 42 + int16_t y = 020; // Octal for 20 + + // Test cases + ASSUME_ITS_EQUAL_O16((int16_t)x, 042); + ASSUME_ITS_EQUAL_O16((int16_t)y, 020); + ASSUME_NOT_EQUAL_O16((int16_t)x, (int16_t)y); + ASSUME_ITS_LESS_THAN_O16((int16_t)y, (int16_t)x); + ASSUME_ITS_LESS_OR_EQUAL_O16((int16_t)y, (int16_t)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_octal32_shortcut) { + int32_t x = 042; // Octal for 42 + int32_t y = 020; // Octal for 20 + + // Test cases + ASSUME_ITS_EQUAL_O32((int32_t)x, 042); + ASSUME_ITS_EQUAL_O32((int32_t)y, 020); + ASSUME_NOT_EQUAL_O32((int32_t)x, (int32_t)y); + ASSUME_ITS_LESS_THAN_O32((int32_t)y, (int32_t)x); + ASSUME_ITS_LESS_OR_EQUAL_O32((int32_t)y, (int32_t)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_octal64_shortcut) { + int64_t x = 042; // Octal for 42 + int64_t y = 020; // Octal for 20 + + // Test cases + ASSUME_ITS_EQUAL_O64((int64_t)x, 042); + ASSUME_ITS_EQUAL_O64((int64_t)y, 020); + ASSUME_NOT_EQUAL_O64((int64_t)x, (int64_t)y); + ASSUME_ITS_LESS_THAN_O64((int64_t)y, (int64_t)x); + ASSUME_ITS_LESS_OR_EQUAL_O64((int64_t)y, (int64_t)x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_float32) { + float x = 42.0f; + float y = 20.0f; + + // Test cases + ASSUME_ITS_EQUAL_F32(x, 42.0f, 0.001f); + ASSUME_ITS_EQUAL_F32(y, 20.0f, 0.001f); + ASSUME_NOT_EQUAL_F32(x, y, 0.001f); + ASSUME_ITS_LESS_THAN_F32(y, x); + ASSUME_ITS_LESS_OR_EQUAL_F32(y, x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_float64) { + double x = 42.0; + double y = 20.0; + + // Test cases + ASSUME_ITS_EQUAL_F64(x, 42.0, 0.001); + ASSUME_ITS_EQUAL_F64(y, 20.0, 0.001); + ASSUME_NOT_EQUAL_F64(x, y, 0.001); + ASSUME_ITS_LESS_THAN_F64(y, x); + ASSUME_ITS_LESS_OR_EQUAL_F64(y, x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_boolean_true) { + bool x = true; + bool y = false; + + // Test cases + ASSUME_ITS_TRUE(x); + ASSUME_ITS_FALSE(y); + ASSUME_NOT_TRUE(y); + ASSUME_NOT_FALSE(x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_boolean_false) { + bool x = false; + bool y = true; + + // Test cases + ASSUME_ITS_FALSE(x); + ASSUME_ITS_TRUE(y); + ASSUME_NOT_FALSE(y); + ASSUME_NOT_TRUE(x); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_boolean_expression) { + int a = 5; + int b = 10; + + // Test cases + ASSUME_ITS_TRUE(a < b); + ASSUME_ITS_FALSE(a > b); + ASSUME_NOT_TRUE(a > b); + ASSUME_NOT_FALSE(a < b); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_boolean_expression_negation) { + int a = 5; + int b = 10; + + // Test cases + ASSUME_ITS_TRUE(!(a > b)); + ASSUME_ITS_FALSE(!(a < b)); + ASSUME_NOT_TRUE(!(a < b)); + ASSUME_NOT_FALSE(!(a > b)); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_boolean_complex_expression) { + int a = 5; + int b = 10; + int c = 15; + + // Test cases + ASSUME_ITS_TRUE((a < b) && (b < c)); + ASSUME_ITS_FALSE((a > b) || (b > c)); + ASSUME_NOT_TRUE((a > b) || (b > c)); + ASSUME_NOT_FALSE((a < b) && (b < c)); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_boolean_complex_expression_negation) { + int a = 5; + int b = 10; + int c = 15; + + // Test cases + ASSUME_ITS_TRUE(!((a > b) || (b > c))); + ASSUME_ITS_FALSE(!((a < b) && (b < c))); + ASSUME_NOT_TRUE(!((a < b) && (b < c))); + ASSUME_NOT_FALSE(!((a > b) || (b > c))); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_null_pointer) { + void *ptr = nullptr; + + // Test cases + ASSUME_ITS_CNULL(ptr); + ASSUME_NOT_CNULL((void *)0x1); // Assuming a non-nullptr pointer +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_pointer_equality) { + int a = 42; + int *ptr1 = &a; + int *ptr2 = &a; + int *ptr3 = nullptr; + + // Test cases + ASSUME_ITS_EQUAL_PTR(ptr1, ptr2); + ASSUME_NOT_EQUAL_PTR(ptr1, ptr3); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_size_equality) { + size_t size1 = 42; + size_t size2 = 42; + size_t size3 = 20; + + // Test cases + ASSUME_ITS_EQUAL_SIZE(size1, size2); + ASSUME_NOT_EQUAL_SIZE(size1, size3); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_size_comparison) { + size_t size1 = 42; + size_t size2 = 20; + + // Test cases + ASSUME_ITS_LESS_THAN_SIZE(size2, size1); + ASSUME_ITS_MORE_THAN_SIZE(size1, size2); + ASSUME_ITS_LESS_OR_EQUAL_SIZE(size2, size1); + ASSUME_ITS_LESS_OR_EQUAL_SIZE(size1, size1); + ASSUME_ITS_MORE_OR_EQUAL_SIZE(size1, size2); + ASSUME_ITS_MORE_OR_EQUAL_SIZE(size1, size1); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range) { + int x = 42; + int y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_u8) { + uint8_t x = 42; + uint8_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_U8(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_U8(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_u16) { + uint16_t x = 42; + uint16_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_U16(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_U16(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_u32) { + uint32_t x = 42; + uint32_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_U32(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_U32(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_u64) { + uint64_t x = 42; + uint64_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_U64(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_U64(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_i8) { + int8_t x = 42; + int8_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_I8(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_I8(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_i16) { + int16_t x = 42; + int16_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_I16(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_I16(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_i32) { + int32_t x = 42; + int32_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_I32(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_I32(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_i64) { + int64_t x = 42; + int64_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_I64(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_I64(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_f32) { + float x = 42.0f; + float y = 20.0f; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_F32(x, 40.0f, 45.0f); + ASSUME_NOT_WITHIN_RANGE_F32(y, 21.0f, 30.0f); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_f64) { + double x = 42.0; + double y = 20.0; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_F64(x, 40.0, 45.0); + ASSUME_NOT_WITHIN_RANGE_F64(y, 21.0, 30.0); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_bchar) { + uint8_t x = 42; + uint8_t y = 20; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_BCHAR(x, 40, 45); + ASSUME_NOT_WITHIN_RANGE_BCHAR(y, 21, 30); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_cchar) { + char x = 'A'; + char y = 'B'; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_CCHAR(x, 'A', 'Z'); + ASSUME_NOT_WITHIN_RANGE_CCHAR(y, 'C', 'Z'); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_within_range_wchar) { + wchar_t x = L'A'; + wchar_t y = L'B'; + + // Test cases + ASSUME_ITS_WITHIN_RANGE_WCHAR(x, L'A', L'Z'); + ASSUME_NOT_WITHIN_RANGE_WCHAR(y, L'C', L'Z'); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_wstr) { + const wchar_t *str1 = L"Hello"; + const wchar_t *str2 = L"Hello"; + const wchar_t *str3 = L"World"; + + // Test cases + ASSUME_ITS_EQUAL_WSTR(str1, str2); + ASSUME_NOT_EQUAL_WSTR(str1, str3); + ASSUME_ITS_LENGTH_EQUAL_WSTR(str1, 5); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_bstr) { + const char *str1 = (const char *)"Hello"; + const char *str2 = (const char *)"Hello"; + const char *str3 = (const char *)"World"; + + // Test cases + ASSUME_ITS_EQUAL_BSTR(str1, str2); + ASSUME_NOT_EQUAL_BSTR(str1, str3); + ASSUME_ITS_LENGTH_EQUAL_BSTR(str1, 5); +} // end case + +FOSSIL_TEST_CASE(cpp_assume_run_of_cstr) { + const char *str1 = "Hello"; + const char *str2 = "Hello"; + const char *str3 = "World"; + + // Test cases + ASSUME_ITS_EQUAL_CSTR(str1, str2); + ASSUME_NOT_EQUAL_CSTR(str1, str3); + ASSUME_ITS_LENGTH_EQUAL_CSTR(str1, 5); +} // end case + // * * * * * * * * * * * * * * * * * * * * * * * * // * Fossil Logic Test Pool // * * * * * * * * * * * * * * * * * * * * * * * * FOSSIL_TEST_GROUP(cpp_tdd_test_cases) { - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_xassume_run_of_int); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_xassume_run_of_int8); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_xassume_run_of_int16); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_xassume_run_of_int32); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_xassume_run_of_int64); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_xassume_run_of_int8_shortcut); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_xassume_run_of_int16_shortcut); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_xassume_run_of_int32_shortcut); - FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_xassume_run_of_int64_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_int); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_int8); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_int16); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_int32); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_int64); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_int8_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_int16_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_int32_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_int64_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_uint); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_uint8); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_uint16); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_uint32); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_uint64); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_uint8_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_uint16_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_uint32_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_uint64_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_hex); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_hex8); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_hex16); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_hex32); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_hex64); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_hex8_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_hex16_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_hex32_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_hex64_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_octal8_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_octal16_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_octal32_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_octal64_shortcut); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_float32); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_float64); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_boolean_true); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_boolean_false); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_boolean_expression); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_boolean_expression_negation); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_boolean_complex_expression); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_boolean_complex_expression_negation); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_null_pointer); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_pointer_equality); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_size_equality); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_size_comparison); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_u8); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_u16); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_u32); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_u64); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_i8); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_i16); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_i32); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_i64); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_f32); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_f64); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_bchar); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_cchar); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_within_range_wchar); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_wstr); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_bstr); + FOSSIL_TEST_ADD(cpp_tdd_suite, cpp_assume_run_of_cstr); FOSSIL_TEST_REGISTER(cpp_tdd_suite); } // end of group diff --git a/code/tests/meson.build b/code/tests/meson.build index 24b31a86..03cb78b2 100644 --- a/code/tests/meson.build +++ b/code/tests/meson.build @@ -4,7 +4,7 @@ if get_option('with_test').enabled() test_c = ['unit_runner.c'] test_cpp = ['unit_runner.cpp'] test_cases = [ - 'sample', 'bdd', 'tdd', + 'sample', 'bdd', 'tdd', 'ddd' ] foreach cases : test_cases diff --git a/code/tests/unit_runner.cpp b/code/tests/unit_runner.cpp deleted file mode 100644 index 314d4cfe..00000000 --- a/code/tests/unit_runner.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// Generated Fossil Logic Test -#include - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test List -// * * * * * * * * * * * * * * * * * * * * * * * * -FOSSIL_TEST_EXPORT(cpp_bdd_test_cases); -FOSSIL_TEST_EXPORT(cpp_sample_test_cases); -FOSSIL_TEST_EXPORT(cpp_tdd_test_cases); -FOSSIL_TEST_EXPORT(c_tdd_test_cases); -FOSSIL_TEST_EXPORT(c_sample_test_cases); -FOSSIL_TEST_EXPORT(c_bdd_test_cases); -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Runner -// * * * * * * * * * * * * * * * * * * * * * * * * -int main(int argc, char **argv) { - FOSSIL_TEST_START(argc, argv); - FOSSIL_TEST_IMPORT(cpp_bdd_test_cases); - FOSSIL_TEST_IMPORT(cpp_sample_test_cases); - FOSSIL_TEST_IMPORT(cpp_tdd_test_cases); - FOSSIL_TEST_IMPORT(c_tdd_test_cases); - FOSSIL_TEST_IMPORT(c_sample_test_cases); - FOSSIL_TEST_IMPORT(c_bdd_test_cases); - FOSSIL_TEST_RUN(); - FOSSIL_TEST_SUMMARY(); - FOSSIL_TEST_END(); -} // end of func diff --git a/meson.build b/meson.build index 46c5a017..d97b8690 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('Fossil Test', 'c', 'cpp', meson_version: '>=1.3.0', license: 'MPL-2.0', - version: '1.0.7', + version: '1.0.8', default_options: ['c_std=c11,c18', 'cpp_std=c++20']) subdir('code')