1 /** memory function test
7 unsigned char destination[4];
8 const unsigned char source[4] = {0, 1, 2, 3};
14 memset(destination, 42, 3);
15 ASSERT(destination[0] == 42);
16 ASSERT(destination[2] == 42);
17 ASSERT(destination[3] == 23);
20 memcpy(destination + 1, source + 1, 2);
21 ASSERT(destination[0] == 42);
22 ASSERT(destination[2] == source[2]);
23 ASSERT(destination[3] == 23);
26 memcpy(destination, source, 4);
27 memmove(destination, destination + 1, 3);
28 ASSERT(destination[0] == source[1]);
29 ASSERT(destination[2] == source[3]);
30 ASSERT(destination[3] == source[3]);
31 memcpy(destination, source, 4);
32 memmove(destination + 1, destination, 3);
33 ASSERT(destination[0] == source[0]);
34 ASSERT(destination[1] == source[0]);
35 ASSERT(destination[3] == source[2]);
38 /* memchr() is not yet supported by sdcc.
39 ASSERT(NULL == memchr(destination, 5, 4));
40 ASSERT(destination == memchr(destination, 0, 4));
41 ASSERT(destination + 3 == memchr(destination, 3, 4));*/
43 ASSERT(strlen("test") == 4);
44 ASSERT(strlen("t") == 1);
45 ASSERT(strlen("") == 0);