diff options
author | Chandra Pratap <chandrapratap3519@gmail.com> | 2024-03-08 15:37:29 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2024-03-08 22:29:08 +0100 |
commit | 793732d32b1ead6cd93bf493636a39ba2037d5cc (patch) | |
tree | 831a6fdc5a3f8b6901aa2b1700586bca0738bfed | |
parent | add unittest cases for argv_looks_like_help (diff) | |
download | systemd-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.c | 24 |
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); |