diff --git a/src/utl/assert.h b/src/utl/assert.h index 80540f2..7896364 100644 --- a/src/utl/assert.h +++ b/src/utl/assert.h @@ -23,7 +23,7 @@ * - cmc_assert_in_range * - cmc_assert_not_in_range * - * Data types include: + * Data types (dtype) include: * - int8_t * - int16_t * - int32_t @@ -37,8 +37,8 @@ * - size_t * - float * - double - * - ptr - * - bool (only for equals and not_equals) + * - ptr (only equals and not_equals) + * - bool (only equals and not_equals) * * Specialized assertions that work with any data type: * @@ -53,7 +53,6 @@ #include #include -#include #include #include @@ -105,25 +104,25 @@ static bool cmc_assert_state = true; /** * dtype : One of the data types listed at the beggining of this file - * (excluding ptr). boundary : Expected lowest possible value (excluded). actual - * : Actual value tested against the given boundary. + * boundary : Expected lowest possible value (excluded). + * actual : Actual value tested against the given boundary. */ #define cmc_assert_greater(dtype, boundary, actual) \ CMC_ASSERT_GLUE(dtype, greater) \ (boundary, actual) /** - * dtype : One of the data types listed at the beggining of this file - * (excluding ptr). boundary : Expected lowest possible value (included). actual - * : Actual value tested against the given boundary. + * dtype : One of the data types listed at the beggining of this file. + * boundary : Expected lowest possible value (included). + * actual : Actual value tested against the given boundary. */ #define cmc_assert_greater_equals(dtype, boundary, actual) \ CMC_ASSERT_GLUE(dtype, greater_equals) \ (boundary, actual) /** - * dtype : One of the data types listed at the beggining of this file - * (excluding ptr). boundary : Expected highest possible value (excluded). + * dtype : One of the data types listed at the beggining of this file. + * boundary : Expected highest possible value (excluded). * actual : Actual value tested against the given boundary. */ #define cmc_assert_lesser(dtype, boundary, actual) \ @@ -131,8 +130,8 @@ static bool cmc_assert_state = true; (boundary, actual) /** - * dtype : One of the data types listed at the beggining of this file - * (excluding ptr). boundary : Expected highest possible value (included). + * dtype : One of the data types listed at the beggining of this file. + * boundary : Expected highest possible value (included). * actual : Actual value tested against the given boundary. */ #define cmc_assert_lesser_equals(dtype, boundary, actual) \ @@ -140,8 +139,8 @@ static bool cmc_assert_state = true; (boundary, actual) /** - * dtype : One of the data types listed at the beggining of this file - * (excluding ptr). lower_bound : Smallest value of the expected range. + * dtype : One of the data types listed at the beggining of this file. + * lower_bound : Smallest value of the expected range. * upper_bound : Highest value of the expected range. * actual : Actual value tested against the given range. * @@ -152,8 +151,8 @@ static bool cmc_assert_state = true; (lower_bound, upper_bound, actual) /** - * dtype : One of the data types listed at the beggining of this file - * (excluding ptr). lower_bound : Smallest value of the not expected range. + * dtype : One of the data types listed at the beggining of this file. + * lower_bound : Smallest value of the not expected range. * upper_bound : Highest value of the not expected range. * actual : Actual value tested against the given range. * @@ -260,13 +259,14 @@ static bool cmc_assert_state = true; } while (0) /** - * Assert that each element in the array are within bounds. + * Assert that each element in the array are out of bounds. * * dtype : The type of the array. - * array : Array to be checked if its elements are outside of a given - * range comparator : A function that has two 'dtype' arguments and returns -1 - * if the first is less then the second, 0 if both are equal or 1 if the first - * is greater then the second. lower_bound : Smallest value of the given range. + * array : Array to be checked if its elements are outside a given range. + * comparator : A function that has two 'dtype' arguments and returns -1 if the + * first is less then the second, 0 if both are equal or 1 if the + * first is greater then the second. + * lower_bound : Smallest value of the given range. * upper_bound : Highest value of the given range. * from_index : First index from the array to compare (inclusive). * to_index : Last index from the array to compare (inclusive). diff --git a/src/utl/foreach.h b/src/utl/foreach.h index 11362cd..52e7c89 100644 --- a/src/utl/foreach.h +++ b/src/utl/foreach.h @@ -8,6 +8,15 @@ * */ +/** + * For-Each macros that work with all Collections within the library. + * + * PFX - Functions prefix + * SNAME - Struct name + * ITERNAME - Iterator variable name + * TARGET - Target variable + */ + #ifndef CMC_FOR_EACH_H #define CMC_FOR_EACH_H diff --git a/src/utl/log.h b/src/utl/log.h index 2f05e68..a843f4c 100644 --- a/src/utl/log.h +++ b/src/utl/log.h @@ -18,11 +18,11 @@ */ /** - * What each error code means + * What each error code means inside the DEV Collections * * TRACE - Trace is used to describe the inner workings of the function or an * algorithm. It can be useful when trying to find for an error in the - * algorithm or an untreated case. + * algorithm or corner cases. * DEBUG - Mainly used for debugging, tracking certain variables or anything * useful to help visualizing what your program is doing. * INFO - Info can be used as a heads up. It is also used to track the main @@ -31,7 +31,7 @@ * from and they are usually treated by it. In most cases the user can * treat these warnings himself. * ERROR - Something really bad happened. Your program will not crash yet but - * depending on what comes next, it might crash indeed. + * depending on what comes next, it will. * FATAL - This will probably be the last logging message before your program * crashes or goes into madness. Fatal errors are commonly attributed * to dereferencing NULL pointers. @@ -45,7 +45,7 @@ * ERROR - 5 * FATAL - 6 * - * How the Log Level is calculated + * How the Log Level is calculated for tlevel and flevel * * - If the log level is 0 all logs are enabled. * - If the log level (X) is positive: diff --git a/src/utl/test.h b/src/utl/test.h index c56d05f..cdd7493 100644 --- a/src/utl/test.h +++ b/src/utl/test.h @@ -27,17 +27,8 @@ * Parameters: * - TNAME : Test name (const char *) * - BODY : Block of code containing a specific test - * Inside the BODY use the following macros: - * - CMC_TEST_PASS - * Pass current test. - * - CMC_TEST_FAIL - * Fail current test. - * - CMC_TEST_PASS_ELSE_FAIL - * If given expression is true, pass current test, else fail. - * - CMC_TEST_ABORT - * Abort current unit test and displays error message. All tests - * after the abort won't be called. - * All of these macros can only be called once per test. + * Inside the BODY use the macros in ./utl/assert.h. The unit test will keep + * track of cmc_assert_state and automatically pass or fail tests. * * CMC_TEST_COLOR * Define this macro to allow colored output. @@ -46,14 +37,13 @@ #ifndef CMC_TEST_H #define CMC_TEST_H -#include "assert.h" -#include "timer.h" #include #include -#include #include #include -#include + +#include "assert.h" +#include "timer.h" #ifdef CMC_TEST_COLOR static const char *cmc_test_color[] = { "\x1b[32m", "\x1b[31m", "\x1b[35m" }; @@ -84,7 +74,7 @@ static void cmc_test_log(const char *unit_name, const char *current_test, else { #ifdef CMC_TEST_COLOR - printf("Test from %s %s%7s\x1b[0m %s\n", unit_name, + printf("Test from \x1b[33m%s\x1b[0m %s%7s\x1b[0m %s\n", unit_name, passed ? cmc_test_color[0] : cmc_test_color[1], passed ? "PASSED" : "FAILED", current_test); #else diff --git a/src/utl/timer.h b/src/utl/timer.h index 95252f4..1cdb513 100644 --- a/src/utl/timer.h +++ b/src/utl/timer.h @@ -8,7 +8,9 @@ * */ -/* Simple timer macros utility */ +/** + * Simple timer macros utility for timing code execution. + */ #ifndef CMC_TIMER_H #define CMC_TIMER_H @@ -19,7 +21,7 @@ struct cmc_timer { clock_t start; clock_t stop; - double result; + double result; /* The result is given in milliseconds */ }; #define cmc_timer_start(timer) \