11 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_mcs51) // Lack of memory
12 wchar_t string0
[] = L
"-2";
13 wchar_t string1
[] = L
"-9999999999999999999999";
14 wchar_t string2
[] = L
"9999999999999999999999";
15 wchar_t string3
[] = L
"-2test";
16 wchar_t string4
[] = L
"test";
17 wchar_t string5
[] = L
"023test";
18 wchar_t string6
[] = L
"-0x23test";
24 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_mcs51) // Lack of memory
27 ASSERT(wcstoul(L
"", 0, 10) == 0);
28 ASSERT(wcstoul(L
"2", 0, 10) == 2);
29 ASSERT(wcstoul(L
"3", 0, 10) == 3);
30 ASSERT(wcstoul(L
"23", 0, 10) == 23);
32 ASSERT(wcstoul(L
"23", 0, 0) == 23);
33 ASSERT(wcstoul(L
"023", 0, 0) == 023);
34 ASSERT(wcstoul(L
"0x23", 0, 0) == 0x23);
36 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202300L // C2X introduces binary prefix.
37 ASSERT(wcstoul(L
"0b11", 0, 0) == 0b11);
38 ASSERT(wcstoul(L
"0b11", 0, 2) == 0b11);
41 ASSERT(wcstoul(L
"+23", 0, 0) == +23);
42 ASSERT(wcstoul(L
"+023", 0, 0) == +023);
43 ASSERT(wcstoul(L
"+0x23", 0, 0) == +0x23);
45 ASSERT(wcstol(L
"-42", 0, 0) == -42);
46 ASSERT(wcstol(L
"-042", 0, 0) == -042);
47 ASSERT(wcstol(L
"-0x42", 0, 0) == -0x42);
48 ASSERT(wcstol(L
"-0x42", 0, 16) == -0x42);
50 #if ULONG_MAX == 4294967295
52 wcstoul(L
"4294967296", 0, 10);
53 ASSERT(errno
== ERANGE
);
57 ASSERT(wcstol(string1
, &e
, 10) == LONG_MIN
);
58 ASSERT(errno
== ERANGE
);
59 ASSERT(e
== string1
+ wcslen(string1
));
62 ASSERT(wcstol(string2
, &e
, 10) == LONG_MAX
);
63 ASSERT(errno
== ERANGE
);
64 ASSERT(e
== string2
+ wcslen(string2
));
67 ASSERT(wcstoul(string0
, &e
, 10) == (unsigned long int)(-2));
68 ASSERT(errno
!= ERANGE
);
69 ASSERT(e
== string0
+ wcslen(string0
));
72 ASSERT(wcstoul(string2
, &e
, 10) == ULONG_MAX
);
73 ASSERT(errno
== ERANGE
);
74 ASSERT(e
== string2
+ wcslen(string2
));
77 ASSERT(wcstol(string3
, &e
, 10) == -2);
78 ASSERT(errno
!= ERANGE
);
79 ASSERT(e
== string3
+ 2);
82 ASSERT(wcstol(string4
, &e
, 0) == 0);
83 ASSERT(errno
!= ERANGE
);
87 ASSERT(wcstol(string5
, &e
, 0) == 023);
88 ASSERT(errno
!= ERANGE
);
89 ASSERT(e
== string5
+ 3);
92 ASSERT(wcstol(string6
, &e
, 0) == -0x23);
93 ASSERT(errno
!= ERANGE
);
94 ASSERT(e
== string6
+ 5);