summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/test/test-time.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/test-time.c b/src/test/test-time.c
index 7c29f96a34..87e7ae742a 100644
--- a/src/test/test-time.c
+++ b/src/test/test-time.c
@@ -20,6 +20,7 @@
***/
#include "time-util.h"
+#include "strv.h"
static void test_parse_sec(void) {
usec_t u;
@@ -126,11 +127,33 @@ static void test_format_timespan(usec_t accuracy) {
test_format_timespan_one(9*USEC_PER_YEAR/5 - 23, accuracy);
}
+static void test_timezone_is_valid(void) {
+ assert_se(timezone_is_valid("Europe/Berlin"));
+ assert_se(timezone_is_valid("Australia/Sydney"));
+ assert_se(!timezone_is_valid("Europe/Do not exist"));
+}
+
+static void test_get_timezones(void) {
+ _cleanup_strv_free_ char **zones = NULL;
+ int r;
+ char **zone;
+
+ r = get_timezones(&zones);
+ assert_se(r == 0);
+
+ STRV_FOREACH(zone, zones) {
+ assert_se(timezone_is_valid(*zone));
+ }
+}
+
int main(int argc, char *argv[]) {
test_parse_sec();
test_parse_nsec();
test_format_timespan(1);
test_format_timespan(USEC_PER_MSEC);
test_format_timespan(USEC_PER_SEC);
+ test_timezone_is_valid();
+ test_get_timezones();
+
return 0;
}