Updating documentation
This commit is contained in:
1 parent
4c16cae56d
commit
e37cf42c12
37 files changed
+2291
-21
No files matched your search
@@ -0,0 +1,2 @@
|
||||
# Array Assertion
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# assert.h
|
||||
|
||||
Definition of many typed non-abortive assertions. Every assertion that fails will print a message to `stderr` but will not abort the program execution. The macro parameters are first assigned to a temporary variable of the specified `dtype` in order to generate warnings from the compiler in case of type mismatch.
|
||||
|
||||
The advantage of these typed macros is that when an assertion fails, it is possible to print to `stderr` the actual value that was passed to the function and check the expected result(s) all in one message.
|
||||
|
||||
There are assertions that work with a single value to be tested and others that work with arrays. Single value assertions work with a selected list of `dtype`, while the assertion with arrays work with any `dtype` that is a valid data type.
|
||||
|
||||
The macro parameters can be an lvalue or an rvalue.
|
||||
@@ -0,0 +1,45 @@
|
||||
# Overview
|
||||
|
||||
## Single Value Assertion Macros
|
||||
|
||||
* cmc_assert
|
||||
* cmc_assert_equals
|
||||
* cmc_assert_not_equals
|
||||
* cmc_assert_greater
|
||||
* cmc_assert_greater_equals
|
||||
* cmc_assert_lesser
|
||||
* cmc_assert_lesser_equals
|
||||
* cmc_assert_in_range
|
||||
* cmc_assert_not_in_range
|
||||
|
||||
## Array Assertion Macros
|
||||
|
||||
* cmc_assert_array_equals_any
|
||||
* cmc_assert_array_within_any
|
||||
* cmc_assert_array_outside_any
|
||||
* cmc_assert_array_sorted_any
|
||||
|
||||
## dtype
|
||||
|
||||
These are the data types supported by the single value assertion macros:
|
||||
|
||||
* int8_t
|
||||
* int16_t
|
||||
* int32_t
|
||||
* int64_t
|
||||
* uint8_t
|
||||
* uint16_t
|
||||
* uint32_t
|
||||
* uint64_t
|
||||
* intmax_t
|
||||
* uintmax_t
|
||||
* size_t
|
||||
* float
|
||||
* double
|
||||
|
||||
The following two are only accepted by `cmc_assert_equals` and `cmc_assert_not_equals`:
|
||||
|
||||
* ptr
|
||||
* bool
|
||||
|
||||
Note that `ptr` is used for any pointers. They are first casted to `void *` and then their address is compared.
|
||||
@@ -0,0 +1,29 @@
|
||||
# Single Value Assertion Macros
|
||||
|
||||
|
||||
|
||||
## cmc_assert_state
|
||||
|
||||
This is a global variable that can be used to test if all assertions passed. If a single assertion fails, this variable will be set to `false`. If an assertion passes this variable will not be set back to `true`.
|
||||
|
||||
```c
|
||||
static bool cmc_assert_state = true;
|
||||
```
|
||||
|
||||
This variable is used in [test.h](./test.html) utility to automatically pass or fail a unit test. Once the unit test finishes, this variable is set back to `true` so that another unit test may follow.
|
||||
|
||||
## cmc_assert
|
||||
|
||||
Asserts that an expression evaluates to `true`.
|
||||
|
||||
```c
|
||||
#define cmc_assert(expression)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
* `expression` - An expression that needs to be evaluated to true.
|
||||
|
||||
## cmc_assert_equals
|
||||
|
||||
Asserts that a
|
||||
@@ -0,0 +1,7 @@
|
||||
# assert.h
|
||||
|
||||
Definition of many typed non-abortive assertions. Every assertion that fails will print a message to `stderr` but will not abort the program execution. The macro parameters are first assigned to a temporary variable of the specified `dtype` in order to generate warnings from the compiler in case of type mismatch.
|
||||
|
||||
The advantage of these typed macros is that when an assertion fails, it is possible to print to `stderr` the actual value that was passed to the function and check the expected result(s) all in one message.
|
||||
|
||||
There are assertions that work with a single value to be tested and others that work with arrays. Single value assertions work with a selected list of `dtype`, while the assertion with arrays work with any `dtype` that is a valid data type.
|
||||
@@ -0,0 +1,13 @@
|
||||
# foreach.md
|
||||
|
||||
For-Each macros. Since doing a for loop with iterators can be a lot to write, these macros solve that problem. There are two of them:
|
||||
|
||||
* `CMC_FOREACH` - Goes from the beginning of a Collection to the end
|
||||
* `CMC_FOREAC_REV` - Goes from the end of a Collection to the beginning
|
||||
|
||||
## Parameters
|
||||
|
||||
* `PFX` - Functions prefix
|
||||
* `SNAME` - Struct name
|
||||
* `ITERNAME` - Iterator variable name
|
||||
* `TARGET` - Target variable
|
||||
@@ -0,0 +1,3 @@
|
||||
# log.h
|
||||
|
||||
Logging utility.
|
||||
@@ -0,0 +1,4 @@
|
||||
# test.h
|
||||
|
||||
Simple unit test utility.
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# timer.h
|
||||
|
||||
Simple code execution utility.
|
||||
@@ -0,0 +1,3 @@
|
||||
# UTL
|
||||
|
||||
Inside the `./utl/` folder there are many utility functions and macros that can be extensively used with the C Macro Collections library. Most of these utilities can be used without the main library.
|
||||
Reference in new issue
Block a user