diff options
Diffstat (limited to 'test/source/test/memgen.i')
-rw-r--r-- | test/source/test/memgen.i | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/source/test/memgen.i b/test/source/test/memgen.i new file mode 100644 index 0000000..dcc7c69 --- /dev/null +++ b/test/source/test/memgen.i @@ -0,0 +1,29 @@ +#include <stdbool.h> +#include <stddef.h> + +static unsigned long zaptest_fib(zap_sz const _num) { + if (_num <= 0x1u) { + if (_num == 0x0u) {return 0x0u;} + return 0x1u; + } + return zaptest_fib(_num - 0x1u) + zaptest_fib(_num - 0x2u); +} + +static void zatest_memgenfn(zap_sz const _num,void * const _ptr) { + unsigned long * ptr = _ptr; + *ptr = zaptest_fib(_num); +} + +static bool zaptest_test_memgen(void) { + unsigned long arr[0x8u]; + zap_memgen(arr,sizeof (arr[0x0u]),sizeof (arr) / sizeof (arr[0x0u]),zatest_memgenfn); + zaptest_chk(arr[0x0u],0x0u,unsigned long,"%lX"); + zaptest_chk(arr[0x1u],0x1u,unsigned long,"%lX"); + zaptest_chk(arr[0x2u],0x1u,unsigned long,"%lX"); + zaptest_chk(arr[0x3u],0x2u,unsigned long,"%lX"); + zaptest_chk(arr[0x4u],0x3u,unsigned long,"%lX"); + zaptest_chk(arr[0x5u],0x5u,unsigned long,"%lX"); + zaptest_chk(arr[0x6u],0x8u,unsigned long,"%lX"); + zaptest_chk(arr[0x7u],0xDu,unsigned long,"%lX"); + return false; +} |