glib/tests/utf8-validate: test known-length case along with null-terminated

For all test cases where the text length is given as -1, also
call g_utf8_validate() with the actual string length to exercise
the known-length case. Unknown-length and known-length validation
use different code paths, but most of the tests only exercised with
unknown-length parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=754924
This commit is contained in:
Mikhail Zabaluev 2015-09-12 12:13:10 +03:00 committed by Matthias Clasen
parent 8ab28b448b
commit 67c5bbaf03

View File

@ -16,6 +16,7 @@
*/ */
#include "glib.h" #include "glib.h"
#include <string.h>
#define UNICODE_VALID(Char) \ #define UNICODE_VALID(Char) \
((Char) < 0x110000 && \ ((Char) < 0x110000 && \
@ -281,6 +282,14 @@ do_test (gconstpointer d)
g_assert (result == test->valid); g_assert (result == test->valid);
g_assert (end - test->text == test->offset); g_assert (end - test->text == test->offset);
if (test->max_len < 0)
{
result = g_utf8_validate (test->text, strlen (test->text), &end);
g_assert (result == test->valid);
g_assert (end - test->text == test->offset);
}
} }
int int