summaryrefslogtreecommitdiff
path: root/src/journal/test-catalog.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-12-02 21:35:31 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-12-02 22:12:02 -0500
commitc7332b0844e28d9b70c3c763b929f105c1056fe8 (patch)
tree256ac480ebbe3a8a88b5a8b4fb8be8c57cfe7d22 /src/journal/test-catalog.c
parent6a371e23ee0e47827fb4e3aa469ed84da2599304 (diff)
catalog: determine language from the filename
Diffstat (limited to 'src/journal/test-catalog.c')
-rw-r--r--src/journal/test-catalog.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c
index 5db5bed8de..863b9f4b51 100644
--- a/src/journal/test-catalog.c
+++ b/src/journal/test-catalog.c
@@ -120,6 +120,28 @@ static void test_catalog_update(void) {
assert(r >= 0);
}
+static void test_catalog_file_lang(void) {
+ _cleanup_free_ char *lang = NULL, *lang2 = NULL, *lang3 = NULL;
+
+ assert_se(catalog_file_lang("systemd.de_DE.catalog", &lang) == 1);
+ assert_se(streq(lang, "de_DE"));
+
+ assert_se(catalog_file_lang("systemd..catalog", &lang2) == 0);
+ assert_se(lang2 == NULL);
+
+ assert_se(catalog_file_lang("systemd.fr.catalog", &lang2) == 1);
+ assert_se(streq(lang2, "fr"));
+
+ assert_se(catalog_file_lang("systemd.fr.catalog.gz", &lang3) == 0);
+ assert_se(lang3 == NULL);
+
+ assert_se(catalog_file_lang("systemd.01234567890123456789012345678901.catalog", &lang3) == 0);
+ assert_se(lang3 == NULL);
+
+ assert_se(catalog_file_lang("systemd.0123456789012345678901234567890.catalog", &lang3) == 1);
+ assert_se(streq(lang3, "0123456789012345678901234567890"));
+}
+
int main(int argc, char *argv[]) {
_cleanup_free_ char *text = NULL;
int r;
@@ -144,5 +166,7 @@ int main(int argc, char *argv[]) {
if (database)
unlink(database);
+ test_catalog_file_lang();
+
return 0;
}