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



commit 67c5bbaf03c95df198b2828d5dbf51b010721f11
Author: Mikhail Zabaluev <mikhail zabaluev gmail com>
Date:   Sat Sep 12 12:13:10 2015 +0300

    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

 glib/tests/utf8-validate.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/utf8-validate.c b/glib/tests/utf8-validate.c
index c8eb735..8c97b40 100644
--- a/glib/tests/utf8-validate.c
+++ b/glib/tests/utf8-validate.c
@@ -16,6 +16,7 @@
  */
 
 #include "glib.h"
+#include <string.h>
 
 #define UNICODE_VALID(Char)                   \
     ((Char) < 0x110000 &&                     \
@@ -281,6 +282,14 @@ do_test (gconstpointer d)
 
   g_assert (result == test->valid);
   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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]