From: spth Date: Mon, 29 Dec 2008 18:08:36 +0000 (+0000) Subject: Added simple test for memory functions X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=4e41b30943c02067da958752885fea1f4140b742;p=fw%2Fsdcc Added simple test for memory functions git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5307 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 76b0071a..24ee04a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-12-29 Philipp Klaus Krause + + * support/regression/tests/memory.c: + Added simple test for memset(), memcpy() and memmove() + 2008-12-29 Borut Razem * sdcc/support/scripts/sdcc.nsi: removed $INSTDIR\lib\src\z80\*.c diff --git a/support/regression/tests/memory.c b/support/regression/tests/memory.c new file mode 100644 index 00000000..6ad87559 --- /dev/null +++ b/support/regression/tests/memory.c @@ -0,0 +1,43 @@ +/** memory function test +*/ +#include + +#include + +unsigned char destination[4]; +const unsigned char source[4] = {0, 1, 2, 3}; + +void testmemory(void) +{ + /* Test memset() */ + destination[3] = 23; + memset(destination, 42, 3); + ASSERT(destination[0] == 42); + ASSERT(destination[2] == 42); + ASSERT(destination[3] == 23); + + /* Test memcpy() */ + memcpy(destination + 1, source + 1, 2); + ASSERT(destination[0] == 42); + ASSERT(destination[2] == source[2]); + ASSERT(destination[3] == 23); + + /* Test memmove() */ + memcpy(destination, source, 4); + memmove(destination, destination + 1, 3); + ASSERT(destination[0] == source[1]); + ASSERT(destination[2] == source[3]); + ASSERT(destination[3] == source[3]); + memcpy(destination, source, 4); + memmove(destination + 1, destination, 3); + ASSERT(destination[0] == source[0]); + ASSERT(destination[1] == source[0]); + ASSERT(destination[3] == source[2]); + + /* Test memchr() */ + /* memchr() is not yet supported by sdcc. + ASSERT(NULL == memchr(destination, 5, 4)); + ASSERT(destination == memchr(destination, 0, 4)); + ASSERT(destination + 3 == memchr(destination, 3, 4));*/ +} +