summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRonny Chevalier <chevalier.ronny@gmail.com>2014-08-16 14:19:11 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-18 18:44:00 +0200
commit6accc7a24c76a2658129933ccda7ea1c6993f31e (patch)
treef15fcd596fcb88fe4f901f18a685a9bc7878738d /src/test
parentb08f2be60aceb0c260fb232b9e8b950f0c871cb9 (diff)
tests: add tests for time-util.c
add tests for: - timezone_is_valid - get_timezones
Diffstat (limited to 'src/test')
-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;
}