summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-01-30 20:54:37 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-01-30 21:44:03 +0100
commit69a635412d4787ccb96f6641f3b4d35b77d25072 (patch)
treedd3f6a701cf2ad780646570899c7cef99ed576bb /tests/unit
parent38ffac78f3bd635adf069e3c30fc62edc5e90f40 (diff)
downloadweechat-69a635412d4787ccb96f6641f3b4d35b77d25072.zip
core: add function string_get_common_bytes_count (issue #1877)
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/core/test-core-string.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/unit/core/test-core-string.cpp b/tests/unit/core/test-core-string.cpp
index 671a1327c..ce1468336 100644
--- a/tests/unit/core/test-core-string.cpp
+++ b/tests/unit/core/test-core-string.cpp
@@ -2542,7 +2542,29 @@ TEST(CoreString, InputForBuffer)
/*
* Tests functions:
- * string_levenshtein
+ * string_get_common_bytes_count
+ */
+
+TEST(CoreString, GetCommonBytesCount)
+{
+ LONGS_EQUAL(0, string_get_common_bytes_count (NULL, NULL));
+ LONGS_EQUAL(0, string_get_common_bytes_count ("", NULL));
+ LONGS_EQUAL(0, string_get_common_bytes_count (NULL, ""));
+ LONGS_EQUAL(0, string_get_common_bytes_count ("", ""));
+
+ LONGS_EQUAL(1, string_get_common_bytes_count ("a", "a"));
+ LONGS_EQUAL(0, string_get_common_bytes_count ("a", "b"));
+
+ LONGS_EQUAL(3, string_get_common_bytes_count ("abc", "abc"));
+
+ LONGS_EQUAL(3, string_get_common_bytes_count ("abcdef", "fac"));
+
+ LONGS_EQUAL(4, string_get_common_bytes_count ("noël", "noïl"));
+}
+
+/*
+ * Tests functions:
+ * string_levenshtein
*/
TEST(CoreString, Levenshtein)