struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / wcsnlen.c
blobdb01e7c69b9fe55a4d3845145cd9d05ffc60e679
1 /** tests for wcsnlen
2 */
4 #include <testfwk.h>
6 #include <string.h>
7 #include <wchar.h>
9 const wchar_t* hello1 = L"hello1";
10 const wchar_t hello2[] = L"hello2";
11 wchar_t hello3[] = L"hello3";
13 void
14 testStr(void)
16 #ifndef __SDCC_pdk14 // lack of RAM
17 const wchar_t hello4[] = L"hello4";
18 const wchar_t hello5[7];
20 memcpy (hello5, hello4, 7 * sizeof(wchar_t));
22 ASSERT(wcsnlen(L"hello0", 23) == wcslen(L"hello0"));
23 ASSERT(wcsnlen(hello1, 23) == wcslen(hello1));
24 ASSERT(wcsnlen(hello2, 23) == wcslen(hello2));
25 ASSERT(wcsnlen(hello3, 23) == wcslen(hello3));
26 ASSERT(wcsnlen(hello4, 23) == wcslen(hello4));
27 ASSERT(wcsnlen(hello5, 23) == wcslen(hello5));
29 ASSERT(wcsnlen(L"hello0", 3) == 3);
30 ASSERT(wcsnlen(hello1, 3) == 3);
31 ASSERT(wcsnlen(hello2, 3) == 3);
32 ASSERT(wcsnlen(hello3, 3) == 3);
33 ASSERT(wcsnlen(hello4, 3) == 3);
34 ASSERT(wcsnlen(hello5, 3) == 3);
36 #if !(defined(__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // lack of code memory
37 ASSERT(wcsnlen(L"hello0", 6) == 6);
38 ASSERT(wcsnlen(hello1, 6) == 6);
39 ASSERT(wcsnlen(hello2, 6) == 6);
40 ASSERT(wcsnlen(hello3, 6) == 6);
41 ASSERT(wcsnlen(hello4, 6) == 6);
42 ASSERT(wcsnlen(hello5, 6) == 6);
44 ASSERT(wcsnlen(L"hello0", 7) == 6);
45 ASSERT(wcsnlen(hello1, 7) == 6);
46 ASSERT(wcsnlen(hello2, 7) == 6);
47 ASSERT(wcsnlen(hello3, 7) == 6);
48 ASSERT(wcsnlen(hello4, 7) == 6);
49 ASSERT(wcsnlen(hello5, 7) == 6);
50 #endif
51 #endif