1 #if LV_BUILD_TEST
2 #include "../lvgl.h"
3 #include "../../lvgl_private.h"
4 
5 #include "unity/unity.h"
6 #include "lv_test_helpers.h"
7 
setUp(void)8 void setUp(void)
9 {
10     /* Function run before every test */
11 }
12 
tearDown(void)13 void tearDown(void)
14 {
15     /* Function run after every test */
16 }
17 
test_memmove(void)18 void test_memmove(void)
19 {
20 #if LV_USE_STDLIB_STRING == LV_STDLIB_BUILTIN
21     char buf[6] = {0, 1, 2, 3, 4, 5};
22     char * dst;
23     char * src;
24 
25     dst = buf;
26     src = buf;
27 
28     /*Case of dst == src*/
29     lv_memmove(dst, src, 4);
30     for(int i = 0; i < 4; i++) {
31         TEST_ASSERT_EQUAL_INT(i, buf[i]);
32     }
33 
34     /* Case of dst < src */
35     dst = &buf[0];
36     src = &buf[1];
37     lv_memmove(dst, src, 4);
38     for(int i = 0; i < 4; i++) {
39         TEST_ASSERT_EQUAL_INT(i + 1, buf[i]);
40     }
41 
42     /* Case of dst > src */
43     for(int i = 0; i < 5; i++) buf[i] = i;
44     dst = &buf[1];
45     src = &buf[0];
46     lv_memmove(dst, src, 4);
47     TEST_ASSERT_EQUAL_INT(0, buf[0]);
48     for(int i = 1; i < 5; i++) {
49         TEST_ASSERT_EQUAL_INT(i - 1, buf[i]);
50     }
51 #endif
52 }
53 
54 #endif
55