2 * Copyright (C) 2005-2009 Patrick Ohly <patrick.ohly@gmx.de>
3 * Copyright (C) 2009 Intel Corporation
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) version 3.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #include <syncevo/eds_abi_wrapper.h>
26 #include <syncevo/icalstrdup.h>
27 #include <syncevo/SmartPtr.h>
31 class IcalTest : public CppUnit::TestFixture {
32 CPPUNIT_TEST_SUITE(IcalTest);
33 CPPUNIT_TEST(testTimezone);
34 CPPUNIT_TEST_SUITE_END();
38 * Ensures that we get VTIMEZONE with RRULE from libical.
40 * This only works with libical 1.0 if we successfully
41 * pick up our icaltimezone_get_component() or
42 * libical uses our icaltzutil_fetch_timezone().
44 * This test uses the function lookup via eds_abi_wrapper.h if that
45 * was enabled, otherwise goes via the static or dynamic linker.
47 * It only passes if the given timezone has not been loaded by
48 * libical internally yet, because we cannot influence that. Only
49 * direct calls to icaltimezone_get_component() as done by
50 * libsynthesis are caught. This means that "Europe/Paris" must
51 * not be used by, for example, test data used in
52 * Client::Source::eds_event.
56 icaltimezone *zone = icaltimezone_get_builtin_timezone("Europe/Paris");
58 icalcomponent *comp = icaltimezone_get_component(zone);
60 SyncEvo::eptr<char> str(ical_strdup(icalcomponent_as_ical_string(comp)));
62 // We are very specific here. This'll work until we change our
63 // code or the zone data from Europe/Paris changes (not likely).
64 CPPUNIT_ASSERT_EQUAL(std::string(str), std::string(
66 "TZID:/freeassociation.sourceforge.net/Tzfile/Europe/Paris\r\n"
67 "X-LIC-LOCATION:Europe/Paris\r\n"
70 "DTSTART:19701026T030000\r\n"
71 "RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10\r\n"
72 "TZOFFSETFROM:+0200\r\n"
73 "TZOFFSETTO:+0100\r\n"
77 "DTSTART:19700330T020000\r\n"
78 "RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3\r\n"
79 "TZOFFSETFROM:+0100\r\n"
80 "TZOFFSETTO:+0200\r\n"
87 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(IcalTest, "SyncEvolution" );