aboutsummaryrefslogtreecommitdiff
path: root/catgets/tst-catgets.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-09-07 03:49:56 +0000
committerUlrich Drepper <drepper@redhat.com>2000-09-07 03:49:56 +0000
commit04ba87901c8be7f38906147854e0fc1e4351f486 (patch)
tree3e4056e689d96b22364ea18fdf8a3f08dfa9358b /catgets/tst-catgets.c
parent82cd2e44f10f0f46bd515cc08e788bd6ad733de7 (diff)
downloadglibc-04ba87901c8be7f38906147854e0fc1e4351f486.zip
glibc-04ba87901c8be7f38906147854e0fc1e4351f486.tar.gz
glibc-04ba87901c8be7f38906147854e0fc1e4351f486.tar.bz2
Update.
* catgets/Depend: New file. Add intl. * catgets/Makefile (tests): Add tst-catgets. (generated): Remove de.msg. (generated-dirs): Add de. Add dependency if tst-catgets output on de/libc.cat. * catgets/tst-catgets.c: New file.
Diffstat (limited to 'catgets/tst-catgets.c')
-rw-r--r--catgets/tst-catgets.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/catgets/tst-catgets.c b/catgets/tst-catgets.c
new file mode 100644
index 0000000..20e2738
--- /dev/null
+++ b/catgets/tst-catgets.c
@@ -0,0 +1,66 @@
+#include <mcheck.h>
+#include <nl_types.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static const char *msgs[] =
+{
+#define INPUT(str)
+#define OUTPUT(str) str,
+#include <intl/msgs.h>
+};
+#define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
+
+#define ROUNDS 5
+
+int
+main (void)
+{
+ int rnd;
+ int result = 0;
+
+ mtrace ();
+
+ /* We do this a few times to stress the memory handling. */
+ for (rnd = 0; rnd < ROUNDS; ++rnd)
+ {
+ nl_catd cd = catopen ("libc", 0);
+ int cnt;
+
+ if (cd == (nl_catd) -1)
+ {
+ printf ("cannot load catalog: %m\n");
+ result = 1;
+ break;
+ }
+
+ /* Go through all the messages and compare the result. */
+ for (cnt = 0; cnt < nmsgs; ++cnt)
+ {
+ char *trans;
+
+ trans = catgets (cd, 1, 1 + cnt,
+ "+#+# is this comes backs it's an error");
+
+ if (trans == NULL)
+ {
+ printf ("catgets return NULL for %d\n", cnt);
+ result = 1;
+ }
+ else if (strcmp (trans, msgs[cnt]) != 0)
+ {
+ printf ("expected \"%s\", got \"%s\"\n", msgs[cnt], trans);
+ result = 1;
+ }
+ }
+
+ if (catclose (cd) != 0)
+ {
+ printf ("catclose failed: %m\n");
+ result = 1;
+ }
+ }
+
+ return result;
+}