summaryrefslogtreecommitdiff
path: root/tests/test-iconv.c
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:15 +0200
committerAndreas Rottmann <a.rottmann@gmx.at>2010-05-27 18:23:15 +0200
commit3e0814cd9862b89c7a39672672937477bd87ddfb (patch)
tree159134a624e51509f40ed8823249f09a70d1dda3 /tests/test-iconv.c
parent3bebb94360f1c2333feb8d504a9fa4f96984d8b7 (diff)
Imported Upstream version 0.9.3upstream/0.9.3
Diffstat (limited to 'tests/test-iconv.c')
-rw-r--r--tests/test-iconv.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/tests/test-iconv.c b/tests/test-iconv.c
index 8bac1764..cf00ac89 100644
--- a/tests/test-iconv.c
+++ b/tests/test-iconv.c
@@ -1,5 +1,5 @@
/* Test of character set conversion.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,24 +20,23 @@
#if HAVE_ICONV
# include <iconv.h>
+
+# ifndef ICONV_CONST
+# define ICONV_CONST /* empty */
+# endif
+
+#include "signature.h"
+SIGNATURE_CHECK (iconv, size_t, (iconv_t, ICONV_CONST char **, size_t *,
+ char **, size_t *));
+SIGNATURE_CHECK (iconv_close, int, (iconv_t x));
+SIGNATURE_CHECK (iconv_open, iconv_t, (char const *, char const *));
+
#endif
#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
int
main ()
@@ -61,8 +60,8 @@ main ()
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_88591_to_utf8,
- (ICONV_CONST char **) &inptr, &inbytesleft,
- &outptr, &outbytesleft);
+ (ICONV_CONST char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
ASSERT (res == 0 && inbytesleft == 0);
ASSERT (outptr == buf + strlen (expected));
ASSERT (memcmp (buf, expected, strlen (expected)) == 0);
@@ -77,8 +76,8 @@ main ()
char *outptr = buf;
size_t outbytesleft = 1;
size_t res = iconv (cd_88591_to_utf8,
- (ICONV_CONST char **) &inptr, &inbytesleft,
- &outptr, &outbytesleft);
+ (ICONV_CONST char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
ASSERT (res == (size_t)(-1) && errno == E2BIG);
ASSERT (inbytesleft == 1);
ASSERT (outbytesleft == 1);
@@ -96,8 +95,8 @@ main ()
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_utf8_to_88591,
- (ICONV_CONST char **) &inptr, &inbytesleft,
- &outptr, &outbytesleft);
+ (ICONV_CONST char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
ASSERT (res == 0 && inbytesleft == 0);
ASSERT (outptr == buf + strlen (expected));
ASSERT (memcmp (buf, expected, strlen (expected)) == 0);
@@ -112,17 +111,17 @@ main ()
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_utf8_to_88591,
- (ICONV_CONST char **) &inptr, &inbytesleft,
- &outptr, &outbytesleft);
+ (ICONV_CONST char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
if (res == (size_t)(-1))
{
ASSERT (errno == EILSEQ);
- ASSERT (inbytesleft == strlen (input) && outptr == buf);
+ ASSERT (inbytesleft == strlen (input) && outptr == buf);
}
else
{
- ASSERT (res == 1);
- ASSERT (inbytesleft == 0);
+ ASSERT (res == 1);
+ ASSERT (inbytesleft == 0);
}
}
@@ -135,8 +134,8 @@ main ()
char *outptr = buf;
size_t outbytesleft = sizeof (buf);
size_t res = iconv (cd_utf8_to_88591,
- (ICONV_CONST char **) &inptr, &inbytesleft,
- &outptr, &outbytesleft);
+ (ICONV_CONST char **) &inptr, &inbytesleft,
+ &outptr, &outbytesleft);
ASSERT (res == (size_t)(-1) && errno == EINVAL);
ASSERT (inbytesleft == 1 && outptr == buf);
}