summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandra Pratap <chandrapratap3519@gmail.com>2024-03-08 15:37:29 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2024-03-08 22:29:08 +0100
commit793732d32b1ead6cd93bf493636a39ba2037d5cc (patch)
tree831a6fdc5a3f8b6901aa2b1700586bca0738bfed
parentadd unittest cases for argv_looks_like_help (diff)
downloadsystemd-793732d32b1ead6cd93bf493636a39ba2037d5cc.tar.xz
systemd-793732d32b1ead6cd93bf493636a39ba2037d5cc.zip
extract-word: increase test-extract-word coverage for unicode inputs
In the current testing scheme in test-extract-word, we only have two test cases covering unicode strings. Improve upon this by adding more cases for the same. Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Diffstat (limited to '')
-rw-r--r--src/test/test-extract-word.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/test-extract-word.c b/src/test/test-extract-word.c
index 32c01b99fd..0f10fe7e6f 100644
--- a/src/test/test-extract-word.c
+++ b/src/test/test-extract-word.c
@@ -533,6 +533,20 @@ TEST(extract_first_word) {
assert_se(streq(t, "a:a"));
assert_se(streq(p, ":b"));
free(t);
+
+ p = original = "zaΕΌΓ³Ε‚ciΔ‡ πŸ‘ŠπŸ”ͺπŸ’ κ°€λ„ˆλ„λ£¨";
+ assert_se(extract_first_word(&p, &t, NULL, 0) > 0);
+ assert_se(streq(t, "zażółcić"));
+ free(t);
+ assert_se(p == original + 13);
+
+ assert_se(extract_first_word(&p, &t, NULL, 0) > 0);
+ assert_se(streq(t, "πŸ‘ŠπŸ”ͺπŸ’"));
+ free(t);
+ assert_se(extract_first_word(&p, &t, NULL, 0) > 0);
+ assert_se(streq(t, "κ°€λ„ˆλ„λ£¨"));
+ free(t);
+ assert_se(isempty(p));
}
TEST(extract_first_word_and_warn) {
@@ -758,6 +772,16 @@ TEST(extract_many_words) {
assert_se(isempty(p));
assert_se(streq_ptr(a, "foobar"));
free(a);
+
+ p = original = "gΔ™Ε›lΔ…:πŸ‘ŠπŸ”ͺπŸ’ κ°€λ„ˆλ„λ£¨";
+ assert_se(extract_many_words(&p, ":" WHITESPACE, 0, &a, &b, &c) == 3);
+ assert_se(isempty(p));
+ assert_se(streq(a, "gΔ™Ε›lΔ…"));
+ assert_se(streq(b, "πŸ‘ŠπŸ”ͺπŸ’"));
+ assert_se(streq(c, "κ°€λ„ˆλ„λ£¨"));
+ free(a);
+ free(b);
+ free(c);
}
DEFINE_TEST_MAIN(LOG_INFO);