]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add test case for locale_is_installed()
authorLennart Poettering <lennart@poettering.net>
Thu, 30 Apr 2020 16:32:55 +0000 (18:32 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 7 May 2020 15:24:19 +0000 (17:24 +0200)
src/test/test-locale-util.c

index e7a22797bb65fe87acdf8274a0dfc20b5bb0fefa..728196be0862b0e730f0005f032c77f6640a8ce9 100644 (file)
@@ -36,6 +36,28 @@ static void test_locale_is_valid(void) {
         assert_se(!locale_is_valid("\x01gar\x02 bage\x03"));
 }
 
+static void test_locale_is_installed(void) {
+        log_info("/* %s */", __func__);
+
+        /* Always available */
+        assert_se(locale_is_installed("POSIX") > 0);
+        assert_se(locale_is_installed("C") > 0);
+
+        /* Might, or might not be installed. */
+        assert_se(locale_is_installed("en_EN.utf8") >= 0);
+        assert_se(locale_is_installed("fr_FR.utf8") >= 0);
+        assert_se(locale_is_installed("fr_FR@euro") >= 0);
+        assert_se(locale_is_installed("fi_FI") >= 0);
+
+        /* Definitely not valid */
+        assert_se(locale_is_installed("") == 0);
+        assert_se(locale_is_installed("/usr/bin/foo") == 0);
+        assert_se(locale_is_installed("\x01gar\x02 bage\x03") == 0);
+
+        /* Definitely not installed */
+        assert_se(locale_is_installed("zz_ZZ") == 0);
+}
+
 static void test_keymaps(void) {
         _cleanup_strv_free_ char **kmaps = NULL;
         char **p;
@@ -98,6 +120,7 @@ static void dump_special_glyphs(void) {
 int main(int argc, char *argv[]) {
         test_get_locales();
         test_locale_is_valid();
+        test_locale_is_installed();
         test_keymaps();
 
         dump_special_glyphs();