From 04e3a2f9a8e422e0efa6ee8e1dad87d510bebe20 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Tue, 19 Sep 2023 23:43:30 +0300 Subject: [PATCH] mu-utils: improve tests --- lib/utils/tests/test-utils.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/utils/tests/test-utils.cc b/lib/utils/tests/test-utils.cc index 24642cf8..7b34aad1 100644 --- a/lib/utils/tests/test-utils.cc +++ b/lib/utils/tests/test-utils.cc @@ -62,9 +62,10 @@ test_date_basic() } g_setenv("TZ", hki, TRUE); - constexpr std::array, 13> cases = {{ + std::vector> cases = {{ {"2015-09-18T09:10:23", true, 1442556623}, {"1972-12-14T09:10:23", true, 93165023}, + {"1972-12-14T09:10", true, 93165000}, {"1854-11-18T17:10:23", true, 0}, {"2000-02-31T09:10:23", true, 951861599}, @@ -152,9 +153,11 @@ static void test_flatten() { CaseVec cases = { - {"Менделе́ев", true, "менделеев"}, - {"", false, ""}, - {"Ångström", true, "angstrom"}, + {"Менделе́ев", true, "менделеев"}, + {"", true, ""}, + {"Ångström", true, "angstrom"}, + {"đodø", true, "dodo"}, + // don't touch combining characters in CJK etc. {"スポンサーシップ募集",true, "スポンサーシップ募集"} }; @@ -180,9 +183,10 @@ static void test_clean() { CaseVec cases = { - {"\t a\t\nb ", true, "a b"}, - {"", false, ""}, - {"Ångström", true, "Ångström"}, + {"\t a\t\nb ", true, "a b"}, + {"", true, ""}, + {"Ångström", true, "Ångström"}, + {"\345\245", true, ".."}, }; test_cases(cases, [](auto s, auto f) { return utf8_clean(s); }); @@ -193,9 +197,10 @@ static void test_word_break() { CaseVec cases = { - {"aap+noot&mies", true, "aap noot mies"}, - {"hallo", true, "hallo"}, + {"aap+noot&mies", true, "aap noot mies"}, + {"hallo", true, "hallo"}, {" foo-bar###cuux,fnorb ", true, "foo bar cuux fnorb"}, + {"eyes\nof\tMedusa", true, "eyes of Medusa"}, }; test_cases(cases, [](auto s, auto f) { return utf8_wordbreak(s); });