diff options
Diffstat (limited to 'test/source/test/foreach.i')
-rw-r--r-- | test/source/test/foreach.i | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/source/test/foreach.i b/test/source/test/foreach.i new file mode 100644 index 0000000..e7b933d --- /dev/null +++ b/test/source/test/foreach.i @@ -0,0 +1,23 @@ +#include <stdbool.h> + +static void foreachfn(void * const _ptr) { + unsigned int * ptr = _ptr; + unsigned int val = *ptr; + val %= 0x2; + *ptr = val; +} + +static bool zaptest_test_foreach(void) { + unsigned int arr[] = { + 0x0u, + 0x1u, + 0x2u, + 0x3u, + }; + zap_foreach(arr,sizeof (arr[0x0u]),sizeof (arr) / sizeof (arr[0x0u]),foreachfn); + zaptest_chk(arr[0x0u],0x0u,unsigned int,"%X"); + zaptest_chk(arr[0x1u],0x1u,unsigned int,"%X"); + zaptest_chk(arr[0x2u],0x0u,unsigned int,"%X"); + zaptest_chk(arr[0x3u],0x1u,unsigned int,"%X"); + return false; +} |