Added simple test for memory functions
authorspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 29 Dec 2008 18:08:36 +0000 (18:08 +0000)
committerspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 29 Dec 2008 18:08:36 +0000 (18:08 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5307 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
support/regression/tests/memory.c [new file with mode: 0644]

index 76b0071ab89b4e795254de671c66009d68965453..24ee04a0f4976b5761fa4cd10414bcc46f914c0a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-12-29 Philipp Klaus Krause <pkk AT spth.de>
+
+       * support/regression/tests/memory.c:
+         Added simple test for memset(), memcpy() and memmove()
+
 2008-12-29 Borut Razem <borut.razem AT siol.net>
 
        * 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 (file)
index 0000000..6ad8755
--- /dev/null
@@ -0,0 +1,43 @@
+/** memory function test
+*/
+#include <testfwk.h>
+
+#include <string.h>
+
+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));*/
+}
+