summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMorten Welinder <terra@gnome.org>2003-11-05 16:24:44 +0000
committerMorten Welinder <mortenw@src.gnome.org>2003-11-05 16:24:44 +0000
commit3b2f74d188a54de236d14529e3ea656c47b3022a (patch)
tree36df9feca8c99b386913045acecc3937def58913 /tests
parent76433d5365b89f45c6ccd51e68c26ed3c59889bc (diff)
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.)
Diffstat (limited to 'tests')
-rw-r--r--tests/string-test.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/string-test.c b/tests/string-test.c
index b328e9cc8..d129b53f6 100644
--- a/tests/string-test.c
+++ b/tests/string-test.c
@@ -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");