diff options
Diffstat (limited to 'test/source')
-rw-r--r-- | test/source/main.c | 21 | ||||
-rw-r--r-- | test/source/test/memcnt.i | 28 | ||||
-rw-r--r-- | test/source/test/memfnd.i (renamed from test/source/test/fndbyte.i) | 20 | ||||
-rw-r--r-- | test/source/test/memfor.i (renamed from test/source/test/foreach.i) | 6 | ||||
-rw-r--r-- | test/source/test/strfnd.i (renamed from test/source/test/fndchr.i) | 8 |
5 files changed, 57 insertions, 26 deletions
diff --git a/test/source/main.c b/test/source/main.c index ce73d3a..0d5ea85 100644 --- a/test/source/main.c +++ b/test/source/main.c @@ -19,19 +19,20 @@ typedef bool (* zaptest_testtyp)(void); #include "test/bool.i" #include "test/cmp.i" -#include "test/fndbyte.i" -#include "test/fndchr.i" -#include "test/foreach.i" #include "test/memcat.i" +#include "test/memcnt.i" #include "test/memcp.i" #include "test/memeq.i" #include "test/memfill.i" +#include "test/memfnd.i" +#include "test/memfor.i" #include "test/memgen.i" #include "test/nullptr.i" #include "test/strcat.i" #include "test/strcp.i" #include "test/streq.i" #include "test/strfill.i" +#include "test/strfnd.i" #include "test/strlen.i" #include "test/utf20len.i" #include "test/utf8dec.i" @@ -42,19 +43,20 @@ typedef bool (* zaptest_testtyp)(void); static zaptest_testtyp zaptest_tests[] = { zaptest_test_bool, zaptest_test_cmp, - zaptest_test_fndbyte, - zaptest_test_fndchr, - zaptest_test_foreach, zaptest_test_memcat, + zaptest_test_memcnt, zaptest_test_memcp, zaptest_test_memeq, zaptest_test_memfill, + zaptest_test_memfnd, + zaptest_test_memfor, zaptest_test_memgen, zaptest_test_nullptr, zaptest_test_strcat, zaptest_test_strcp, zaptest_test_streq, zaptest_test_strfill, + zaptest_test_strfnd, zaptest_test_strlen, zaptest_test_utf20len, zaptest_test_utf8dec, @@ -66,19 +68,20 @@ static zaptest_testtyp zaptest_tests[] = { static char const * zaptest_testnms[] = { "bool", "cmp", - "fndbyte", - "fndchr", - "foreach", "memcat", + "memcnt", "memcp", "memeq", "memfill", + "memfnd", + "memfor", "memgen", "nullptr", "strcat", "strcp", "streq", "strfill", + "strfnd", "strlen", "utf20len", "utf8dec", diff --git a/test/source/test/memcnt.i b/test/source/test/memcnt.i new file mode 100644 index 0000000..2e333f0 --- /dev/null +++ b/test/source/test/memcnt.i @@ -0,0 +1,28 @@ +#include <stdbool.h> + +static zap_bool memcntfn(void const * const _ptr) { + unsigned int const * ptr = _ptr; + if (*ptr & 0x1u) { + return zap_false; + } + return zap_true; +} + +static bool zaptest_test_memcnt(void) { + unsigned int arr[] = { + 0x0u, + 0x1u, + 0x2u, + 0x3u, + 0x4u, + 0x5u, + 0x6u, + 0x7u, + }; + zap_sz num = zap_memcnt(arr,sizeof (arr[0x0u]),sizeof (arr) / sizeof (arr[0x0u]),memcntfn); + zaptest_chk(num,0x4u,zap_sz,"%zX"); + arr[0x0u] = 0x1u; + num = zap_memcnt(arr,sizeof (arr[0x0u]),sizeof (arr) / sizeof (arr[0x0u]),memcntfn); + zaptest_chk(num,0x3u,zap_sz,"%zX"); + return false; +} diff --git a/test/source/test/fndbyte.i b/test/source/test/memfnd.i index 56231ac..50923c6 100644 --- a/test/source/test/fndbyte.i +++ b/test/source/test/memfnd.i @@ -1,6 +1,6 @@ #include <stdbool.h> -static bool zaptest_test_fndbyte(void) { +static bool zaptest_test_memfnd(void) { unsigned char const arr[] = { 0x1u, 0x3u, @@ -11,23 +11,23 @@ static bool zaptest_test_fndbyte(void) { 0x7Fu, 0xFFu, }; - zap_sz pos = zap_fndbyte(arr,sizeof (arr),0x1u); + zap_sz pos = zap_memfnd(arr,sizeof (arr),0x1u); zaptest_chk(pos,0x0u,zap_sz,"%zX"); - pos = zap_fndbyte(arr,sizeof (arr),0x3u); + pos = zap_memfnd(arr,sizeof (arr),0x3u); zaptest_chk(pos,0x1u,zap_sz,"%zX"); - pos = zap_fndbyte(arr,sizeof (arr),0x7u); + pos = zap_memfnd(arr,sizeof (arr),0x7u); zaptest_chk(pos,0x2u,zap_sz,"%zX"); - pos = zap_fndbyte(arr,sizeof (arr),0xFu); + pos = zap_memfnd(arr,sizeof (arr),0xFu); zaptest_chk(pos,0x3u,zap_sz,"%zX"); - pos = zap_fndbyte(arr,sizeof (arr),0x1Fu); + pos = zap_memfnd(arr,sizeof (arr),0x1Fu); zaptest_chk(pos,0x4u,zap_sz,"%zX"); - pos = zap_fndbyte(arr,sizeof (arr),0x3Fu); + pos = zap_memfnd(arr,sizeof (arr),0x3Fu); zaptest_chk(pos,0x5u,zap_sz,"%zX"); - pos = zap_fndbyte(arr,sizeof (arr),0x7Fu); + pos = zap_memfnd(arr,sizeof (arr),0x7Fu); zaptest_chk(pos,0x6u,zap_sz,"%zX"); - pos = zap_fndbyte(arr,sizeof (arr),0xFFu); + pos = zap_memfnd(arr,sizeof (arr),0xFFu); zaptest_chk(pos,0x7u,zap_sz,"%zX"); - pos = zap_fndbyte(arr,sizeof (arr),0xFEu); + pos = zap_memfnd(arr,sizeof (arr),0xFEu); zaptest_chk(pos,zap_nopos,zap_sz,"%zX"); return false; } diff --git a/test/source/test/foreach.i b/test/source/test/memfor.i index e7b933d..0d6768e 100644 --- a/test/source/test/foreach.i +++ b/test/source/test/memfor.i @@ -1,20 +1,20 @@ #include <stdbool.h> -static void foreachfn(void * const _ptr) { +static void memforfn(void * const _ptr) { unsigned int * ptr = _ptr; unsigned int val = *ptr; val %= 0x2; *ptr = val; } -static bool zaptest_test_foreach(void) { +static bool zaptest_test_memfor(void) { unsigned int arr[] = { 0x0u, 0x1u, 0x2u, 0x3u, }; - zap_foreach(arr,sizeof (arr[0x0u]),sizeof (arr) / sizeof (arr[0x0u]),foreachfn); + zap_memfor(arr,sizeof (arr[0x0u]),sizeof (arr) / sizeof (arr[0x0u]),memforfn); zaptest_chk(arr[0x0u],0x0u,unsigned int,"%X"); zaptest_chk(arr[0x1u],0x1u,unsigned int,"%X"); zaptest_chk(arr[0x2u],0x0u,unsigned int,"%X"); diff --git a/test/source/test/fndchr.i b/test/source/test/strfnd.i index 8fb670a..a85f227 100644 --- a/test/source/test/fndchr.i +++ b/test/source/test/strfnd.i @@ -1,12 +1,12 @@ #include <stdbool.h> -static bool zaptest_test_fndchr(void) { +static bool zaptest_test_strfnd(void) { char const str[] = "What the drake doing?"; - zap_sz pos = zap_fndchr(str,'?'); + zap_sz pos = zap_strfnd(str,'?'); zaptest_chk(pos,0x14u,zap_sz,"%zX"); - pos = zap_fndchr(str,'t'); + pos = zap_strfnd(str,'t'); zaptest_chk(pos,0x3u,zap_sz,"%zX"); - pos = zap_fndchr(str,'!'); + pos = zap_strfnd(str,'!'); zaptest_chk(pos,zap_nopos,zap_sz,"%zX"); return false; } |