summaryrefslogtreecommitdiff
path: root/src/test/regression.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2019-05-11 09:21:50 -0400
committerAllen Winter <allen.winter@kdab.com>2019-05-11 09:29:59 -0400
commitb504638ee06a5d638184b13507ec92898dacfe2b (patch)
tree02944e41803476cda00777559e367699fd5e850a /src/test/regression.c
parent9d6b43375a949d313c0abd99248c30d94d3b4016 (diff)
downloadlibical-git-b504638ee06a5d638184b13507ec92898dacfe2b.tar.gz
improve testing for icalproperty_get_datetime_with_compoment()
when using BUILTIN_TZDATA (and encountering the location fallback)
Diffstat (limited to 'src/test/regression.c')
-rw-r--r--src/test/regression.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/test/regression.c b/src/test/regression.c
index 13355053..4624f71c 100644
--- a/src/test/regression.c
+++ b/src/test/regression.c
@@ -34,6 +34,8 @@
#include <assert.h>
#include <stdlib.h>
+#define TESTS_TZID_PREFIX "/softwarestudio.org/tests/"
+
/* For GNU libc, strcmp appears to be a macro, so using strcmp in
assert results in incomprehansible assertion messages. This
eliminates the problem */
@@ -2536,10 +2538,10 @@ void test_convenience()
#if ADD_TESTS_BROKEN_BUILTIN_TZDATA
ok("Start is 1997-08-01 12:00:00 Europe/Rome",
- (0 == strcmp("1997-08-01 12:00:00 /softwarestudio.org/Europe/Rome",
+ (0 == strcmp("1997-08-01 12:00:00 " TESTS_TZID_PREFIX "Europe/Rome",
ictt_as_string(icalcomponent_get_dtstart(c)))));
ok("End is 1997-08-01 13:30:00 Europe/Rome",
- (0 == strcmp("1997-08-01 13:30:00 /softwarestudio.org/Europe/Rome",
+ (0 == strcmp("1997-08-01 13:30:00 " TESTS_TZID_PREFIX "Europe/Rome",
ictt_as_string(icalcomponent_get_dtend(c)))));
#endif
ok("Duration is 90 m", (duration == 90));
@@ -4276,7 +4278,7 @@ void test_set_date_datetime_value(void)
void test_timezone_from_builtin(void)
{
- const char *strcomp =
+ const char *strcomp_fmt =
"BEGIN:VCALENDAR\r\n"
"BEGIN:VTIMEZONE\r\n"
"TZID:my_zone\r\n"
@@ -4291,12 +4293,31 @@ void test_timezone_from_builtin(void)
"BEGIN:VEVENT\r\n"
"UID:0\r\n"
"DTSTART;TZID=my_zone:20180101T010000\r\n"
- "DTEND;TZID=/softwarestudio.org/America/New_York:20180101T030000\r\n"
+ "DTEND;TZID=%s:20180101T030000\r\n"
"DUE;TZID=Europe/Berlin:20180101T030000\r\n"
"END:VEVENT\r\n"
"END:VCALENDAR\r\n";
icalcomponent *comp, *subcomp;
+ icaltimezone *zone;
struct icaltimetype dtstart, dtend, due;
+ char *strcomp, *tzidprefix, *prevslash = NULL, *prevprevslash = NULL, *p;
+ int len;
+
+ zone = icaltimezone_get_builtin_timezone("America/New_York");
+ tzidprefix = strdup(icaltimezone_get_tzid (zone));
+ p = tzidprefix;
+ while(p = strchr(p + 1, '/'), p) {
+ prevprevslash = prevslash;
+ prevslash = p;
+ }
+ if(prevprevslash)
+ prevprevslash[1] = 0;
+
+ icaltimezone_set_tzid_prefix(tzidprefix);
+
+ len = strlen(strcomp_fmt) + strlen(icaltimezone_get_tzid(zone)) + 2;
+ strcomp = (char *) malloc(len + 1);
+ snprintf(strcomp, len, strcomp_fmt, icaltimezone_get_tzid(zone));
comp = icalcomponent_new_from_string(strcomp);
ok("icalcomponent_new_from_string()", (comp != NULL));
@@ -4311,7 +4332,11 @@ void test_timezone_from_builtin(void)
ok("DTEND is America/New_York", (strcmp(icaltimezone_get_location((icaltimezone *) dtend.zone), "America/New_York") == 0));
ok("DUE is Europe/Berlin", (strcmp(icaltimezone_get_location((icaltimezone *) due.zone), "Europe/Berlin") == 0));
+ icaltimezone_set_tzid_prefix(TESTS_TZID_PREFIX);
+
icalcomponent_free(comp);
+ free(tzidprefix);
+ free(strcomp);
}
int main(int argc, char *argv[])
@@ -4329,8 +4354,8 @@ int main(int argc, char *argv[])
int do_header = 0;
int failed_count = 0;
- set_zone_directory("../../zoneinfo");
- icaltimezone_set_tzid_prefix("/softwarestudio.org/");
+ set_zone_directory(TEST_ZONEDIR);
+ icaltimezone_set_tzid_prefix(TESTS_TZID_PREFIX);
test_start(0);
@@ -4446,9 +4471,7 @@ int main(int argc, char *argv[])
test_run("Test kind_to_string", test_kind_to_string, do_test, do_header);
test_run("Test string_to_kind", test_string_to_kind, do_test, do_header);
test_run("Test set DATE/DATE-TIME VALUE", test_set_date_datetime_value, do_test, do_header);
- if (!icaltimezone_get_builtin_tzdata()) {
- test_run("Test timezone from builtin", test_timezone_from_builtin, do_test, do_header);
- }
+ test_run("Test timezone from builtin", test_timezone_from_builtin, do_test, do_header);
/** OPTIONAL TESTS go here... **/