mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-28 10:07:13 +02:00
Add tests for g_utf8_strlen().
2006-02-24 Matthias Clasen <mclasen@redhat.com> * tests/utf8-pointer.c: Add tests for g_utf8_strlen(). * glib/gutf8.c: Fix boundary cases in g_utf8_strlen(). (#332435)
This commit is contained in:
committed by
Matthias Clasen
parent
a629b3f02d
commit
8b3b3adb6d
@@ -1,3 +1,10 @@
|
|||||||
|
2006-02-24 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/utf8-pointer.c: Add tests for g_utf8_strlen().
|
||||||
|
|
||||||
|
* glib/gutf8.c: Fix boundary cases in g_utf8_strlen().
|
||||||
|
(#332435)
|
||||||
|
|
||||||
2006-02-23 Kjartan Maraas <kmaraas@gnome.org>
|
2006-02-23 Kjartan Maraas <kmaraas@gnome.org>
|
||||||
|
|
||||||
* tests/completion-test.c: (main): Plug leaks reported by
|
* tests/completion-test.c: (main): Plug leaks reported by
|
||||||
|
@@ -1,3 +1,10 @@
|
|||||||
|
2006-02-24 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/utf8-pointer.c: Add tests for g_utf8_strlen().
|
||||||
|
|
||||||
|
* glib/gutf8.c: Fix boundary cases in g_utf8_strlen().
|
||||||
|
(#332435)
|
||||||
|
|
||||||
2006-02-23 Kjartan Maraas <kmaraas@gnome.org>
|
2006-02-23 Kjartan Maraas <kmaraas@gnome.org>
|
||||||
|
|
||||||
* tests/completion-test.c: (main): Plug leaks reported by
|
* tests/completion-test.c: (main): Plug leaks reported by
|
||||||
|
@@ -1,3 +1,10 @@
|
|||||||
|
2006-02-24 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/utf8-pointer.c: Add tests for g_utf8_strlen().
|
||||||
|
|
||||||
|
* glib/gutf8.c: Fix boundary cases in g_utf8_strlen().
|
||||||
|
(#332435)
|
||||||
|
|
||||||
2006-02-23 Kjartan Maraas <kmaraas@gnome.org>
|
2006-02-23 Kjartan Maraas <kmaraas@gnome.org>
|
||||||
|
|
||||||
* tests/completion-test.c: (main): Plug leaks reported by
|
* tests/completion-test.c: (main): Plug leaks reported by
|
||||||
|
@@ -242,7 +242,7 @@ g_utf8_strlen (const gchar *p,
|
|||||||
/* only do the last len increment if we got a complete
|
/* only do the last len increment if we got a complete
|
||||||
* char (don't count partial chars)
|
* char (don't count partial chars)
|
||||||
*/
|
*/
|
||||||
if (p - start == max)
|
if (p - start <= max)
|
||||||
++len;
|
++len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,9 +64,35 @@ gchar *longline = "asdasdas dsaf asfd as fdasdf asfd asdf as dfas dfasdf a"
|
|||||||
"asd fasdf asdf asdf asd fasfd as fdasfd asdf as fdas ffsd asfd as fdASASASAs D"
|
"asd fasdf asdf asdf asd fasfd as fdasfd asdf as fdas ffsd asfd as fdASASASAs D"
|
||||||
"Asfdsf sdfg sdfg dsfg dfg sdfgsdfgsdfgsdfg sdfgsdfg sdfg sdfg sdf gsdfg sdfg sd\n\nlalala\n";
|
"Asfdsf sdfg sdfg dsfg dfg sdfgsdfgsdfgsdfg sdfgsdfg sdfg sdfg sdf gsdfg sdfg sd\n\nlalala\n";
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_length (void)
|
||||||
|
{
|
||||||
|
g_assert (g_utf8_strlen ("1234", -1) == 4);
|
||||||
|
g_assert (g_utf8_strlen ("1234", 0) == 0);
|
||||||
|
g_assert (g_utf8_strlen ("1234", 1) == 1);
|
||||||
|
g_assert (g_utf8_strlen ("1234", 2) == 2);
|
||||||
|
g_assert (g_utf8_strlen ("1234", 3) == 3);
|
||||||
|
g_assert (g_utf8_strlen ("1234", 4) == 4);
|
||||||
|
g_assert (g_utf8_strlen ("1234", 5) == 4);
|
||||||
|
|
||||||
|
g_assert (g_utf8_strlen (longline, -1) == 762);
|
||||||
|
g_assert (g_utf8_strlen (longline, strlen (longline)) == 762);
|
||||||
|
g_assert (g_utf8_strlen (longline, 1024) == 762);
|
||||||
|
|
||||||
|
g_assert (g_utf8_strlen (NULL, 0) == 0);
|
||||||
|
|
||||||
|
g_assert (g_utf8_strlen ("a\340\250\201c", -1) == 3);
|
||||||
|
g_assert (g_utf8_strlen ("a\340\250\201c", 1) == 1);
|
||||||
|
g_assert (g_utf8_strlen ("a\340\250\201c", 2) == 1);
|
||||||
|
g_assert (g_utf8_strlen ("a\340\250\201c", 3) == 1);
|
||||||
|
g_assert (g_utf8_strlen ("a\340\250\201c", 4) == 2);
|
||||||
|
g_assert (g_utf8_strlen ("a\340\250\201c", 5) == 3);
|
||||||
|
}
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
test_utf8 (longline);
|
test_utf8 (longline);
|
||||||
|
test_length ();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user