X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Ftest-iconv.c;h=566ddee62fa93e490d70bda342c3f5ecc657fe89;hb=89ae4589dd58d12e7cbcf0e92c1d828c1e430f97;hp=0a0c2aab14c21b431efe3655e3f21c68706b8c54;hpb=c0fea97ccf33a4e6b6f9116216b1634663f29474;p=gnulib.git
diff --git a/tests/test-iconv.c b/tests/test-iconv.c
index 0a0c2aab1..566ddee62 100644
--- a/tests/test-iconv.c
+++ b/tests/test-iconv.c
@@ -1,10 +1,10 @@
/* Test of character set conversion.
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify
+ 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
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -12,8 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
/* Written by Bruno Haible , 2007. */
@@ -21,6 +20,17 @@
#if HAVE_ICONV
# include
+
+# 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
@@ -29,14 +39,15 @@
#include
#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
+ do \
+ { \
+ if (!(expr)) \
+ { \
fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- abort (); \
- } \
- } \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
while (0)
int
@@ -61,8 +72,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 +88,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 +107,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 +123,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 +146,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);
}