summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2015-02-19 17:37:01 +0100
committerPatrick Ohly <patrick.ohly@intel.com>2015-03-03 10:15:44 +0100
commita8e39070d6f3e8a49aa9d8cccd1d77c8d5ebc403 (patch)
tree4c998a705980d829fe82fa3d29f9107d36b75e37
parent4e60b67c272d780568e24e9e49db77f8c1c8af92 (diff)
testing: relax SyncEvo::IcalTest::testTimezone
The test started to fail in 2015 because the VTIMEZONE generated by the code copied from libical has a minor dependency on the current time: it finds the transitions for the current year, then pretends that the same rule applied since 1970. While doing that, it uses this years transition date and just replaces the year. Because the exact date varies between years, the result depends on the current year. The test now simply ignores the day of the month, while still checking year and month. Those should always be the same.
-rw-r--r--test/IcalTest.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/test/IcalTest.cpp b/test/IcalTest.cpp
index 035e11cb..1fd2690f 100644
--- a/test/IcalTest.cpp
+++ b/test/IcalTest.cpp
@@ -25,6 +25,7 @@
#include <syncevo/eds_abi_wrapper.h>
#include <syncevo/icalstrdup.h>
#include <syncevo/SmartPtr.h>
+#include <pcrecpp.h>
SE_BEGIN_CXX
@@ -35,6 +36,18 @@ class IcalTest : public CppUnit::TestFixture {
protected:
/**
+ * Ignore exact day in DTSTART because icaltz-util.c uses the
+ * transition day of the *current* year, instead of the one from
+ * the (arbitrary) 1970 year. The value is wrong either way,
+ * so fixing that bug is not important.
+ */
+ void patchDTSTART(std::string &vtimezone)
+ {
+ static const pcrecpp::RE re("(DTSTART:1970..)..");
+ re.GlobalReplace("\\1XX", &vtimezone);
+ }
+
+ /**
* Ensures that we get VTIMEZONE with RRULE from libical.
*
* This only works with libical 1.0 if we successfully
@@ -59,9 +72,8 @@ protected:
CPPUNIT_ASSERT(comp);
SyncEvo::eptr<char> str(ical_strdup(icalcomponent_as_ical_string(comp)));
CPPUNIT_ASSERT(str);
- // We are very specific here. This'll work until we change our
- // code or the zone data from Europe/Paris changes (not likely).
- CPPUNIT_ASSERT_EQUAL(std::string(str), std::string(
+ // 2014 version of the VTIMEZONE
+ std::string expected =
"BEGIN:VTIMEZONE\r\n"
"TZID:/freeassociation.sourceforge.net/Tzfile/Europe/Paris\r\n"
"X-LIC-LOCATION:Europe/Paris\r\n"
@@ -80,7 +92,13 @@ protected:
"TZOFFSETTO:+0200\r\n"
"END:DAYLIGHT\r\n"
"END:VTIMEZONE\r\n"
- ));
+ ;
+ patchDTSTART(expected);
+ std::string actual(str);
+ patchDTSTART(actual);
+ // We are very specific here. This'll work until we change our
+ // code or the zone data from Europe/Paris changes (not likely).
+ CPPUNIT_ASSERT_EQUAL(expected, actual);
}
};