mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-21 08:28:53 +02:00
Handle the case where the to-be-inserted string is a substring of the
2003-11-05 Morten Welinder <terra@gnome.org> * glib/gstring.c (g_string_insert_len): Handle the case where the to-be-inserted string is a substring of the target string. (g_string_assign): Handle "s = s;". (#114260, self.)
This commit is contained in:
committed by
Morten Welinder
parent
76433d5365
commit
3b2f74d188
@@ -89,7 +89,7 @@ main (int argc,
|
||||
g_string_chunk_free (string_chunk);
|
||||
|
||||
string1 = g_string_new ("hi pete!");
|
||||
string2 = g_string_new ("");
|
||||
string2 = g_string_new (NULL);
|
||||
|
||||
g_assert (string1 != NULL);
|
||||
g_assert (string2 != NULL);
|
||||
@@ -182,6 +182,33 @@ main (int argc,
|
||||
g_assert (strcmp (string1->str, "firstlast") == 0);
|
||||
g_string_free (string1, TRUE);
|
||||
|
||||
/* insert_len with string overlap */
|
||||
string1 = g_string_new ("textbeforetextafter");
|
||||
g_string_insert_len (string1, 10, string1->str + 8, 5);
|
||||
g_assert (strcmp (string1->str, "textbeforeretextextafter") == 0);
|
||||
g_string_free (string1, TRUE);
|
||||
|
||||
string1 = g_string_new ("boring text");
|
||||
g_string_insert_len (string1, 7, string1->str + 2, 4);
|
||||
g_assert (strcmp (string1->str, "boring ringtext") == 0);
|
||||
g_string_free (string1, TRUE);
|
||||
|
||||
string1 = g_string_new ("boring text");
|
||||
g_string_insert_len (string1, 6, string1->str + 7, 4);
|
||||
g_assert (strcmp (string1->str, "boringtext text") == 0);
|
||||
g_string_free (string1, TRUE);
|
||||
|
||||
/* assign_len with string overlap */
|
||||
string1 = g_string_new ("textbeforetextafter");
|
||||
g_string_assign (string1, string1->str + 10);
|
||||
g_assert (strcmp (string1->str, "textafter") == 0);
|
||||
g_string_free (string1, TRUE);
|
||||
|
||||
string1 = g_string_new ("boring text");
|
||||
g_string_assign (string1, string1->str);
|
||||
g_assert (strcmp (string1->str, "boring text") == 0);
|
||||
g_string_free (string1, TRUE);
|
||||
|
||||
/* g_string_equal */
|
||||
string1 = g_string_new ("test");
|
||||
string2 = g_string_new ("te");
|
||||
|
Reference in New Issue
Block a user