-/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+/* We always want assert to be fully defined. */
+#undef NDEBUG
#include <assert.h>
#include <locale.h>
#include <stdio.h>
assert (mbrtowc (&wc, "", 1, &s) == 0); /* test final byte processing */
assert (wc == 0); /* test final byte decoding */
+ /* The following test is by Al Viro <aviro@redhat.com>. */
+ const char str[] = "\xe0\xa0\x80";
+
+ wc = 42; /* arbitrary number */
+ memset (&s, 0, sizeof (s)); /* get s into initial state */
+ assert (mbrtowc (&wc, str, 1, &s) == -2);
+ assert (mbrtowc (&wc, str + 1, 2, &s) == 2);
+ assert (wc == 0x800);
+
+ wc = 42; /* arbitrary number */
+ memset (&s, 0, sizeof (s)); /* get s into initial state */
+ assert (mbrtowc (&wc, str, 3, &s) == 3);
+ assert (wc == 0x800);
+
return 0;
}
}
-int
-main (void)
+static int
+do_test (void)
{
int result = 0;
char buf[MB_CUR_MAX];
wchar_t wc = 0xffffffff;
mbstate_t s;
- size_t n;
- int i;
+ size_t n, i;
for (i = 0; i < MB_CUR_MAX; ++i)
buf[i] = c + i;
return res != 0;
}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"