]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Extend string.replace() test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 18 Jan 2023 13:13:13 +0000 (14:13 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 18 Jan 2023 13:13:13 +0000 (14:13 +0100)
tests/basic-types/strings.c-expected
tests/basic-types/strings.vala

index f060dd0fe8b6413abf0095751850d0e00b2b4707..4bf10a9895a449fd1e1ba35d5be82170d00d1f86 100644 (file)
@@ -581,6 +581,10 @@ test_string_replace (void)
        const gchar* _tmp1_;
        gchar* _tmp2_;
        const gchar* _tmp3_;
+       gchar* _tmp4_;
+       const gchar* _tmp5_;
+       gchar* _tmp6_;
+       const gchar* _tmp7_;
        _tmp0_ = g_strdup ("hellomyworld");
        s = _tmp0_;
        _tmp1_ = s;
@@ -589,6 +593,16 @@ test_string_replace (void)
        s = _tmp2_;
        _tmp3_ = s;
        _vala_assert (g_strcmp0 (_tmp3_, "hellowholeworld") == 0, "s == \"hellowholeworld\"");
+       _tmp4_ = string_replace ("Γειά σου Κόσμε", "Γειά σου ", "");
+       _g_free0 (s);
+       s = _tmp4_;
+       _tmp5_ = s;
+       _vala_assert (g_strcmp0 (_tmp5_, "Κόσμε") == 0, "s == \"\316\232\317\214\317\203\316\274\316\265\"");
+       _tmp6_ = string_replace ("こんにちは世界", "世界", "");
+       _g_free0 (s);
+       s = _tmp6_;
+       _tmp7_ = s;
+       _vala_assert (g_strcmp0 (_tmp7_, "こんにちは") == 0, "s == \"\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257\"");
        _g_free0 (s);
 }
 
index 31eab55ddc56753d48390a458e58d3829f1ec79f..59db047d6b520989283349608e9f589be5d891b6 100644 (file)
@@ -83,6 +83,12 @@ void test_string_replace () {
 
        s = s.replace ("my", "whole");
        assert (s == "hellowholeworld");
+
+       s = "Γειά σου Κόσμε".replace ("Γειά σου ", "");
+       assert (s == "Κόσμε");
+
+       s = "こんにちは世界".replace ("世界", "");
+       assert (s == "こんにちは");
 }
 
 void test_string_slice () {