struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3728.c
blob45293b666dd9a732a6decae637c16e672c6bded4
1 /** tests for string comparison functions, in particular for the handling of non-printable characters.
2 In bug #3728, the sign waas wrong on the strcmp result for some string with characters outside the ASCII range.
3 */
5 #include <testfwk.h>
6 #include <string.h>
8 const unsigned char s0[] = {0, 0};
9 const unsigned char s1[] = {1, 0};
10 const unsigned char s100[] = {100, 0};
11 const unsigned char s200[] = {200, 0};
13 static void
14 teststrcmp (void)
16 ASSERT (strcmp(s0, s1) < 0);
17 ASSERT (strncmp(s0, s1, 2) < 0);
18 ASSERT (memcmp(s0, s1, 2) < 0);
19 ASSERT (strcmp(s0, s100) < 0);
20 ASSERT (strncmp(s0, s100, 2) < 0);
21 ASSERT (memcmp(s0, s100, 2) < 0);
22 ASSERT (strcmp(s0, s200) < 0);
23 ASSERT (strncmp(s0, s200, 2) < 0);
24 ASSERT (memcmp(s0, s200, 2) < 0);
25 ASSERT (strcmp(s100, s200) < 0);
26 ASSERT (strncmp(s100, s200, 2) < 0);
27 ASSERT (memcmp(s100, s200, 2) < 0);
28 ASSERT (strcmp(s1, s0) > 0);
29 ASSERT (strncmp(s1, s0, 2) > 0);
30 ASSERT (memcmp(s1, s0, 2) > 0);
31 ASSERT (strcmp(s100, s0) > 0);
32 ASSERT (strncmp(s100, s0, 2) > 0);
33 ASSERT (memcmp(s100, s0, 2) > 0);
34 #if !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Lack of memory
35 ASSERT (strcmp(s200, s1) > 0);
36 ASSERT (strncmp(s200, s1, 2) > 0);
37 ASSERT (memcmp(s200, s1, 2) > 0);
38 ASSERT (strcmp(s200, s100) > 0);
39 ASSERT (strncmp(s200, s100, 2) > 0);
40 ASSERT (memcmp(s200, s100, 2) > 0);
41 #endif