xdrmem_setpos): Don't compare addresses as signed longs, check for
[glibc/history.git] / catgets / tst-catgets.c
blobfdaa8349496b54e70fe8b2ade1ef9801bdedbf91
1 #include <mcheck.h>
2 #include <nl_types.h>
3 #include <stdio.h>
4 #include <string.h>
7 static const char *msgs[] =
9 #define INPUT(str)
10 #define OUTPUT(str) str,
11 #include <intl/msgs.h>
13 #define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
15 #define ROUNDS 5
17 int
18 main (void)
20 int rnd;
21 int result = 0;
23 mtrace ();
25 /* We do this a few times to stress the memory handling. */
26 for (rnd = 0; rnd < ROUNDS; ++rnd)
28 nl_catd cd = catopen ("libc", 0);
29 size_t cnt;
31 if (cd == (nl_catd) -1)
33 printf ("cannot load catalog: %m\n");
34 result = 1;
35 break;
38 /* Go through all the messages and compare the result. */
39 for (cnt = 0; cnt < nmsgs; ++cnt)
41 char *trans;
43 trans = catgets (cd, 1, 1 + cnt,
44 "+#+# if this comes backs it's an error");
46 if (trans == NULL)
48 printf ("catgets return NULL for %zd\n", cnt);
49 result = 1;
51 else if (strcmp (trans, msgs[cnt]) != 0 && msgs[cnt][0] != '\0')
53 printf ("expected \"%s\", got \"%s\"\n", msgs[cnt], trans);
54 result = 1;
58 if (catclose (cd) != 0)
60 printf ("catclose failed: %m\n");
61 result = 1;
65 return result;