From 7c788f2d02abbeb9aef03f3adb8e92b472a2086b Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 7 Feb 2016 12:29:19 +0000 Subject: [PATCH] Added unit tests for DAYLIGHT section in iCalendarTimezone/ObjectDataTests --- .../tests/xestiacalendar_icaltimezoneload.h | 303 ++++++++++++++++++ 1 file changed, 303 insertions(+) diff --git a/source/tests/xestiacalendar_icaltimezoneload.h b/source/tests/xestiacalendar_icaltimezoneload.h index 3581a9e..897f57c 100644 --- a/source/tests/xestiacalendar_icaltimezoneload.h +++ b/source/tests/xestiacalendar_icaltimezoneload.h @@ -352,4 +352,307 @@ TEST(iCalendarTimezone, ObjectDataTests){ ASSERT_EQ("3", XTokensData); ASSERT_EQ("X-NOPE;LONG=YES", XTokensDataTokens); + // Tests for the first DAYLIGHT data. + + DateTimeStartData.clear(); + TimeZoneOffsetToData.clear(); + TimeZoneOffsetFromData.clear(); + + if (TestTimezone.TimezoneDaylightCollection.size() > 0){ + + DateTimeStartData = TestTimezone.TimezoneDaylightCollection[0].DateTimeStartData; + + } + + if (TestTimezone.TimezoneDaylightCollection.size() > 0){ + + TimeZoneOffsetToData = TestTimezone.TimezoneDaylightCollection[0].TimeZoneOffsetToData; + + } + + if (TestTimezone.TimezoneDaylightCollection.size() > 0){ + + TimeZoneOffsetFromData = TestTimezone.TimezoneDaylightCollection[0].TimeZoneOffsetFromData; + + } + + ASSERT_EQ("20160204T020000", DateTimeStartData); + ASSERT_EQ("-0400", TimeZoneOffsetToData); + ASSERT_EQ("-0500", TimeZoneOffsetFromData); + + // Tests for the second DAYLIGHT data. + + DateTimeStartTokens.clear(); + TimeZoneOffsetToTokens.clear(); + TimeZoneOffsetFromTokens.clear(); + + RecurranceRuleData.clear(); + RecurranceRuleDataTokens.clear(); + + CommentList.clear(); + CommentListAltRep.clear(); + CommentListLanguage.clear(); + CommentListTokens.clear(); + + RecurranceDateData.clear(); + RecurranceDateValue.clear(); + RecurranceDateDataTimeZoneParam.clear(); + RecurranceDateDataTokens.clear(); + + TimeZoneNameData.clear(); + TimeZoneNameLanguage.clear(); + TimeZoneNameTokens.clear(); + + XTokensData.clear(); + XTokensDataTokens.clear(); + + DateTimeStartData.clear(); + TimeZoneOffsetToData.clear(); + TimeZoneOffsetFromData.clear(); + + if (TestTimezone.TimezoneDaylightCollection.size() > 1){ + + DateTimeStartData = TestTimezone.TimezoneDaylightCollection[1].DateTimeStartData; + DateTimeStartTokens = TestTimezone.TimezoneDaylightCollection[1].DateTimeStartTokens; + + } + + if (TestTimezone.TimezoneDaylightCollection.size() > 1){ + + TimeZoneOffsetToData = TestTimezone.TimezoneDaylightCollection[1].TimeZoneOffsetToData; + TimeZoneOffsetToTokens = TestTimezone.TimezoneDaylightCollection[1].TimeZoneOffsetToTokens; + + } + + if (TestTimezone.TimezoneDaylightCollection.size() > 1){ + + TimeZoneOffsetFromData = TestTimezone.TimezoneDaylightCollection[1].TimeZoneOffsetFromData; + TimeZoneOffsetFromTokens = TestTimezone.TimezoneDaylightCollection[1].TimeZoneOffsetFromTokens; + + } + + ASSERT_EQ("20160205T020000", DateTimeStartData); + ASSERT_EQ("MEEP=MOO", DateTimeStartTokens); + ASSERT_EQ("-0400", TimeZoneOffsetToData); + ASSERT_EQ("EXAMPLE=DATA", TimeZoneOffsetToTokens); + ASSERT_EQ("-0500", TimeZoneOffsetFromData); + ASSERT_EQ("LETS=GO", TimeZoneOffsetFromTokens); + + // Tests for third DAYLIGHT data. + + DateTimeStartData.clear(); + DateTimeStartTokens.clear(); + TimeZoneOffsetToData.clear(); + TimeZoneOffsetToTokens.clear(); + TimeZoneOffsetFromData.clear(); + TimeZoneOffsetFromTokens.clear(); + + if (TestTimezone.TimezoneDaylightCollection.size() > 2){ + + DateTimeStartData = TestTimezone.TimezoneDaylightCollection[2].DateTimeStartData; + DateTimeStartTokens = TestTimezone.TimezoneDaylightCollection[2].DateTimeStartTokens; + + } + + if (TestTimezone.TimezoneDaylightCollection.size() > 2){ + + TimeZoneOffsetToData = TestTimezone.TimezoneDaylightCollection[2].TimeZoneOffsetToData; + TimeZoneOffsetToTokens = TestTimezone.TimezoneDaylightCollection[2].TimeZoneOffsetToTokens; + + } + + if (TestTimezone.TimezoneDaylightCollection.size() > 2){ + + TimeZoneOffsetFromData = TestTimezone.TimezoneDaylightCollection[2].TimeZoneOffsetFromData; + TimeZoneOffsetFromTokens = TestTimezone.TimezoneDaylightCollection[2].TimeZoneOffsetFromTokens; + + } + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].CommentList.size() > 0){ + + CommentList = TestTimezone.TimezoneDaylightCollection[2].CommentList[0]; + CommentListAltRep = TestTimezone.TimezoneDaylightCollection[2].CommentListAltRep[0]; + CommentListLanguage = TestTimezone.TimezoneDaylightCollection[2].CommentListLanguage[0]; + CommentListTokens = TestTimezone.TimezoneDaylightCollection[2].CommentListTokens[0]; + + } + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].RecurranceRuleData.size() > 0){ + + RecurranceRuleData = TestTimezone.TimezoneDaylightCollection[2].RecurranceRuleData; + RecurranceRuleDataTokens = TestTimezone.TimezoneDaylightCollection[2].RecurranceRuleDataTokens; + + } + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].RecurranceDateData.size() > 0){ + + RecurranceDateData = TestTimezone.TimezoneDaylightCollection[2].RecurranceDateData[0]; + RecurranceDateValue = TestTimezone.TimezoneDaylightCollection[2].RecurranceDateDataValue[0]; + RecurranceDateDataTimeZoneParam = TestTimezone.TimezoneDaylightCollection[2].RecurranceDateDataTimeZoneParam[0]; + RecurranceDateDataTokens = TestTimezone.TimezoneDaylightCollection[2].RecurranceDateDataTokens[0]; + + } + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].TimeZoneNameData.size() > 0){ + + TimeZoneNameData = TestTimezone.TimezoneDaylightCollection[2].TimeZoneNameData[0]; + TimeZoneNameLanguage = TestTimezone.TimezoneDaylightCollection[2].TimeZoneNameLanguage[0]; + TimeZoneNameTokens = TestTimezone.TimezoneDaylightCollection[2].TimeZoneNameTokens[0]; + + } + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].XTokensData.size() > 0){ + + XTokensData = TestTimezone.TimezoneDaylightCollection[2].XTokensData[0]; + XTokensDataTokens = TestTimezone.TimezoneDaylightCollection[2].XTokensDataTokens[0]; + + } + + ASSERT_EQ("20160206T020000", DateTimeStartData); + ASSERT_EQ("MEEP=MOO", DateTimeStartTokens); + ASSERT_EQ("-0400", TimeZoneOffsetToData); + ASSERT_EQ("EXAMPLE=DATA", TimeZoneOffsetToTokens); + ASSERT_EQ("-0500", TimeZoneOffsetFromData); + ASSERT_EQ("LETS=GO", TimeZoneOffsetFromTokens); + + ASSERT_EQ("Example timezone comment.", CommentList); + ASSERT_EQ("null:nodata", CommentListAltRep); + ASSERT_EQ("kw", CommentListLanguage); + ASSERT_EQ("YO=YOYOS", CommentListTokens); + + ASSERT_EQ("FREQ=DAILY;COUNT=10", RecurranceRuleData); + ASSERT_EQ("YAK=YES", RecurranceRuleDataTokens); + + ASSERT_EQ("20160205,20160207,20160216,20160305", RecurranceDateData); + ASSERT_EQ("DATE", RecurranceDateValue); + ASSERT_EQ("Europe/Truro", RecurranceDateDataTimeZoneParam); + ASSERT_EQ("BEEP=BOOP", RecurranceDateDataTokens); + + ASSERT_EQ("Example Timezone Name 1", TimeZoneNameData); + ASSERT_EQ("en", TimeZoneNameLanguage); + ASSERT_EQ("NOPE=YES", TimeZoneNameTokens); + + ASSERT_EQ("Example Timezone Name 1", TimeZoneNameData); + ASSERT_EQ("en", TimeZoneNameLanguage); + + ASSERT_EQ("Meep", XTokensData); + ASSERT_EQ("X-MOO", XTokensDataTokens); + + XTokensData.clear(); + XTokensDataTokens.clear(); + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].XTokensData.size() > 1){ + + XTokensData = TestTimezone.TimezoneDaylightCollection[2].XTokensData[1]; + XTokensDataTokens = TestTimezone.TimezoneDaylightCollection[2].XTokensDataTokens[1]; + + } + + ASSERT_EQ("Moop", XTokensData); + ASSERT_EQ("X-MOO", XTokensDataTokens); + + XTokensData.clear(); + XTokensDataTokens.clear(); + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].XTokensData.size() > 2){ + + XTokensData = TestTimezone.TimezoneDaylightCollection[2].XTokensData[2]; + XTokensDataTokens = TestTimezone.TimezoneDaylightCollection[2].XTokensDataTokens[2]; + + } + + ASSERT_EQ("Zaap", XTokensData); + ASSERT_EQ("X-MOO;MEEP=YIKES", XTokensDataTokens); + + XTokensData.clear(); + XTokensDataTokens.clear(); + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].XTokensData.size() > 3){ + + XTokensData = TestTimezone.TimezoneDaylightCollection[2].XTokensData[3]; + XTokensDataTokens = TestTimezone.TimezoneDaylightCollection[2].XTokensDataTokens[3]; + + } + + ASSERT_EQ("Fork", XTokensData); + ASSERT_EQ("X-ITEM", XTokensDataTokens); + + XTokensData.clear(); + XTokensDataTokens.clear(); + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].XTokensData.size() > 4){ + + XTokensData = TestTimezone.TimezoneDaylightCollection[2].XTokensData[4]; + XTokensDataTokens = TestTimezone.TimezoneDaylightCollection[2].XTokensDataTokens[4]; + + } + + ASSERT_EQ("Spoon", XTokensData); + ASSERT_EQ("X-ITEM", XTokensDataTokens); + + XTokensData.clear(); + XTokensDataTokens.clear(); + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].XTokensData.size() > 5){ + + XTokensData = TestTimezone.TimezoneDaylightCollection[2].XTokensData[5]; + XTokensDataTokens = TestTimezone.TimezoneDaylightCollection[2].XTokensDataTokens[5]; + + } + + ASSERT_EQ("Knife", XTokensData); + ASSERT_EQ("X-ITEM;DIRTY=NO", XTokensDataTokens); + + XTokensData.clear(); + XTokensDataTokens.clear(); + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].XTokensData.size() > 6){ + + XTokensData = TestTimezone.TimezoneDaylightCollection[2].XTokensData[6]; + XTokensDataTokens = TestTimezone.TimezoneDaylightCollection[2].XTokensDataTokens[6]; + + } + + ASSERT_EQ("1", XTokensData); + ASSERT_EQ("X-NOPE", XTokensDataTokens); + + XTokensData.clear(); + XTokensDataTokens.clear(); + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].XTokensData.size() > 7){ + + XTokensData = TestTimezone.TimezoneDaylightCollection[2].XTokensData[7]; + XTokensDataTokens = TestTimezone.TimezoneDaylightCollection[2].XTokensDataTokens[7]; + + } + + ASSERT_EQ("2", XTokensData); + ASSERT_EQ("X-NOPE", XTokensDataTokens); + + XTokensData.clear(); + XTokensDataTokens.clear(); + + if (TestTimezone.TimezoneDaylightCollection.size() > 2 && + TestTimezone.TimezoneDaylightCollection[2].XTokensData.size() > 8){ + + XTokensData = TestTimezone.TimezoneDaylightCollection[2].XTokensData[8]; + XTokensDataTokens = TestTimezone.TimezoneDaylightCollection[2].XTokensDataTokens[8]; + + } + + ASSERT_EQ("3", XTokensData); + ASSERT_EQ("X-NOPE;LONG=YES", XTokensDataTokens); + } \ No newline at end of file -- 2.39.5