[tepl] Utils: improve docs and unit test of str_replace()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] Utils: improve docs and unit test of str_replace()
- Date: Tue, 19 Nov 2019 04:54:40 +0000 (UTC)
commit 43ca74b0453427142f7b622113bc94553bcf08a3
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Nov 19 05:51:00 2019 +0100
Utils: improve docs and unit test of str_replace()
tepl/tepl-utils.c | 6 ++++++
testsuite/test-utils.c | 5 +++++
2 files changed, 11 insertions(+)
---
diff --git a/tepl/tepl-utils.c b/tepl/tepl-utils.c
index 019163e..7e310a1 100644
--- a/tepl/tepl-utils.c
+++ b/tepl/tepl-utils.c
@@ -139,6 +139,12 @@ tepl_utils_str_end_truncate (const gchar *str,
*
* Replaces all occurences of @search by @replacement.
*
+ * The function does only one pass, for example:
+ * |[
+ * tepl_utils_str_replace ("aaaa", "aa", "a");
+ * ]|
+ * returns "aa", not "a".
+ *
* Returns: A newly allocated string with the replacements. Free with g_free().
* Since: 4.4
*/
diff --git a/testsuite/test-utils.c b/testsuite/test-utils.c
index 7a7f2d4..5d12509 100644
--- a/testsuite/test-utils.c
+++ b/testsuite/test-utils.c
@@ -59,6 +59,11 @@ test_str_replace (void)
result = tepl_utils_str_replace ("abcd", "ef", "r");
g_assert_cmpstr (result, ==, "abcd");
g_free (result);
+
+ /* Only one pass. */
+ result = tepl_utils_str_replace ("aaaa", "aa", "a");
+ g_assert_cmpstr (result, ==, "aa"); /* Not: "a" */
+ g_free (result);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]