X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-mbrtowc.c;h=727016a2cacf7dfdd3a0a8293207f12dd924394c;hb=ae0b8a21cc48db0d06413df85be4184f17de8d5f;hp=178e2106cc919a631ce6960ff957c121324819ea;hpb=441aa3044f43e5572f58c354f01e6bc070acd5c7;p=gnulib.git diff --git a/tests/test-mbrtowc.c b/tests/test-mbrtowc.c index 178e2106c..727016a2c 100644 --- a/tests/test-mbrtowc.c +++ b/tests/test-mbrtowc.c @@ -1,5 +1,5 @@ /* Test of conversion of multibyte character to wide character. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2011 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,22 +20,15 @@ #include +#include "signature.h" +SIGNATURE_CHECK (mbrtowc, size_t, (wchar_t *, char const *, size_t, + mbstate_t *)); + #include #include -#include #include -#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 (int argc, char *argv[]) @@ -150,6 +143,11 @@ main (int argc, char *argv[]) ASSERT (mbsinit (&state)); input[1] = '\0'; + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 2, 3, &state); + ASSERT (ret == 1); + ASSERT (mbsinit (&state)); + wc = (wchar_t) 0xBADFACE; ret = mbrtowc (&wc, input + 2, 3, &state); ASSERT (ret == 1); @@ -199,6 +197,11 @@ main (int argc, char *argv[]) ASSERT (mbsinit (&state)); input[2] = '\0'; + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 3, 4, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + wc = (wchar_t) 0xBADFACE; ret = mbrtowc (&wc, input + 3, 4, &state); ASSERT (ret == 2); @@ -257,6 +260,11 @@ main (int argc, char *argv[]) ASSERT (mbsinit (&state)); input[4] = '\0'; + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 5, 3, &state); + ASSERT (ret == 2); + ASSERT (mbsinit (&state)); + wc = (wchar_t) 0xBADFACE; ret = mbrtowc (&wc, input + 5, 3, &state); ASSERT (ret == 2); @@ -300,6 +308,11 @@ main (int argc, char *argv[]) ASSERT (mbsinit (&state)); input[2] = '\0'; + /* Test support of NULL first argument. */ + ret = mbrtowc (NULL, input + 3, 6, &state); + ASSERT (ret == 4); + ASSERT (mbsinit (&state)); + wc = (wchar_t) 0xBADFACE; ret = mbrtowc (&wc, input + 3, 6, &state); ASSERT (ret == 4);