From: Steve Brokenshire Date: Tue, 16 Feb 2016 22:14:13 +0000 (+0000) Subject: Added unit tests for VALARM in iCalendarTask X-Git-Tag: release-0.02~353 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=0d5c6bf9eae44cd1adc90f85ebfbfffdc2c31043;p=xestiacalendar%2F.git Added unit tests for VALARM in iCalendarTask --- diff --git a/source/tests/xestiacalendar_icaltaskload.h b/source/tests/xestiacalendar_icaltaskload.h index 494e51f..9911197 100644 --- a/source/tests/xestiacalendar_icaltaskload.h +++ b/source/tests/xestiacalendar_icaltaskload.h @@ -1056,4 +1056,639 @@ TEST(iCalendarTask, ObjectDataTests){ ASSERT_EQ("None", XTokenData); ASSERT_EQ("X-PHANTOM-STATUS;HELP=NONE", XTokenName); -} \ No newline at end of file +} + +TEST(iCalendarTask, AlarmTests){ + + CalendarTaskObject TestTask; + ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestTask.LoadFile("iCalendarTask-Load2.vcf")); + ASSERT_EQ(CALENDAROBJECTVALID_OK, TestTask.ValidBaseObject()); + + // Tests for the first VALARM property. + + std::string ActionData; + std::string ActionDataTokens; + + std::string TriggerData; + std::string TriggerRelated; + std::string TriggerValue; + std::string TriggerTokens; + + std::string DurationData; + std::string DurationTokens; + + std::string RepeatData; + std::string RepeatTokens; + + std::string XTokenData; + std::string XTokenName; + + if (TestTask.CalendarAlarmData.size() > 0){ + + ActionData = TestTask.CalendarAlarmData[0].AlarmAction; + ActionDataTokens = TestTask.CalendarAlarmData[0].AlarmActionTokens; + + TriggerData = TestTask.CalendarAlarmData[0].TriggerData; + TriggerRelated = TestTask.CalendarAlarmData[0].TriggerRelated; + TriggerValue = TestTask.CalendarAlarmData[0].TriggerValue; + TriggerTokens = TestTask.CalendarAlarmData[0].TriggerTokens; + + DurationData = TestTask.CalendarAlarmData[0].DurationData; + DurationTokens = TestTask.CalendarAlarmData[0].DurationTokens; + + RepeatData = TestTask.CalendarAlarmData[0].RepeatData; + RepeatTokens = TestTask.CalendarAlarmData[0].RepeatTokens; + + } + + ASSERT_EQ("AUDIO", ActionData); + ASSERT_EQ("FUNKY=SOUNDS", ActionDataTokens); + + ASSERT_EQ("20160220T160000Z", TriggerData); + ASSERT_EQ("END", TriggerRelated); + ASSERT_EQ("DATE-TIME", TriggerValue); + ASSERT_EQ("PUSH=BUTTON", TriggerTokens); + + ASSERT_EQ("PT5H", DurationData); + ASSERT_EQ("FLYING=NO", DurationTokens); + + ASSERT_EQ("PT5M", RepeatData); + ASSERT_EQ("NEVER=SLEEP", RepeatTokens); + + // Tests for ATTACH. First ATTACH property. + + std::string AttachData; + std::string AttachDataFormatType; + std::string AttachDataValue; + std::string AttachDataEncoding; + std::string AttachDataTokens; + + if (TestTask.CalendarAlarmData[0].AttachList.begin() != TestTask.CalendarAlarmData[0].AttachList.end()){ + + AttachData = TestTask.AttachList[0]; + + } + + if (TestTask.CalendarAlarmData[0].AttachListFormatType.begin() != TestTask.CalendarAlarmData[0].AttachListFormatType.end()){ + + AttachDataFormatType = TestTask.AttachListFormatType[0]; + + } + + ASSERT_EQ("http://www.example.com/", AttachData); + ASSERT_EQ("application/internet-shortcut", AttachDataFormatType); + + // Second ATTACH property. + + AttachData.clear(); + AttachDataFormatType.clear(); + AttachDataValue.clear(); + AttachDataEncoding.clear(); + + if (TestTask.CalendarAlarmData[0].AttachList.size() > 1){ + + AttachData = TestTask.CalendarAlarmData[0].AttachList[1]; + + } + + if (TestTask.CalendarAlarmData[0].AttachListFormatType.size() > 1){ + + AttachDataFormatType = TestTask.CalendarAlarmData[0].AttachListFormatType[1]; + + } + + ASSERT_EQ("http://www.example.com/page2.html", AttachData); + ASSERT_EQ("application/internet-shortcut", AttachDataFormatType); + + // Third ATTACH property. + + AttachData.clear(); + AttachDataFormatType.clear(); + AttachDataValue.clear(); + AttachDataEncoding.clear(); + AttachDataTokens.clear(); + + if (TestTask.CalendarAlarmData[0].AttachList.size() > 2){ + + AttachData = TestTask.CalendarAlarmData[0].AttachList[2]; + + } + + if (TestTask.CalendarAlarmData[0].AttachListFormatType.size() > 2){ + + AttachDataFormatType = TestTask.CalendarAlarmData[0].AttachListFormatType[2]; + + } + + if (TestTask.CalendarAlarmData[0].AttachListValue.size() > 2){ + + AttachDataValue = TestTask.CalendarAlarmData[0].AttachListValue[2]; + + } + + if (TestTask.CalendarAlarmData[0].AttachListFormatType.size() > 2){ + + AttachDataEncoding = TestTask.CalendarAlarmData[0].AttachListEncoding[2]; + + } + + if (TestTask.CalendarAlarmData[0].AttachListTokens.size() > 2){ + + AttachDataTokens = TestTask.CalendarAlarmData[0].AttachListTokens[2]; + + } + + ASSERT_EQ("VGhpcyBpcyBhbiBleGFtcGxlIGZpbGU=", AttachData); + ASSERT_EQ("text/plain", AttachDataFormatType); + ASSERT_EQ("BASE64", AttachDataEncoding); + ASSERT_EQ("BINARY", AttachDataValue); + ASSERT_EQ("STUPID=EXAMPLE", AttachDataTokens); + + // Test the first X-Token. + + if (TestTask.CalendarAlarmData[0].XTokensData.size() > 0){ + + XTokenData = TestTask.CalendarAlarmData[0].XTokensData[0]; + XTokenName = TestTask.CalendarAlarmData[0].XTokensDataTokens[0]; + + } + + ASSERT_EQ("Example Data 1", XTokenData); + ASSERT_EQ("X-EXAMPLE1;YAY=YES", XTokenName); + + // Test the second X-Token. + + XTokenData.clear(); + XTokenName.clear(); + + if (TestTask.CalendarAlarmData[0].XTokensData.size() > 1){ + + XTokenData = TestTask.CalendarAlarmData[0].XTokensData[1]; + XTokenName = TestTask.CalendarAlarmData[0].XTokensDataTokens[1]; + + } + + ASSERT_EQ("Example Data 2", XTokenData); + ASSERT_EQ("X-EXAMPLE2;NOPE=YEP", XTokenName); + + // Test the third X-Token. + + XTokenData.clear(); + XTokenName.clear(); + + if (TestTask.CalendarAlarmData[0].XTokensData.size() > 2){ + + XTokenData = TestTask.CalendarAlarmData[0].XTokensData[2]; + XTokenName = TestTask.CalendarAlarmData[0].XTokensDataTokens[2]; + + } + + ASSERT_EQ("Example Data 3", XTokenData); + ASSERT_EQ("X-EXAMPLE3;WORLD=NO", XTokenName); + + // Tests for the second VALARM property. + + ActionData.clear(); + ActionDataTokens.clear(); + + TriggerData.clear(); + TriggerRelated.clear(); + TriggerValue.clear(); + TriggerTokens.clear(); + + DurationData.clear(); + DurationTokens.clear(); + + RepeatData.clear(); + RepeatTokens.clear(); + + XTokenData.clear(); + XTokenName.clear(); + + string DescriptionData; + string DescriptionAltRep; + string DescriptionLanguage; + string DescriptionTokens; + + if (TestTask.CalendarAlarmData.size() > 1){ + + ActionData = TestTask.CalendarAlarmData[1].AlarmAction; + ActionDataTokens = TestTask.CalendarAlarmData[1].AlarmActionTokens; + + TriggerData = TestTask.CalendarAlarmData[1].TriggerData; + TriggerRelated = TestTask.CalendarAlarmData[1].TriggerRelated; + TriggerValue = TestTask.CalendarAlarmData[1].TriggerValue; + TriggerTokens = TestTask.CalendarAlarmData[1].TriggerTokens; + + DurationData = TestTask.CalendarAlarmData[1].DurationData; + DurationTokens = TestTask.CalendarAlarmData[1].DurationTokens; + + RepeatData = TestTask.CalendarAlarmData[1].RepeatData; + RepeatTokens = TestTask.CalendarAlarmData[1].RepeatTokens; + + DescriptionData = TestTask.CalendarAlarmData[1].DescriptionData; + DescriptionAltRep = TestTask.CalendarAlarmData[1].DescriptionAltRep; + DescriptionLanguage = TestTask.CalendarAlarmData[1].DescriptionLanguage; + DescriptionTokens = TestTask.CalendarAlarmData[1].DescriptionTokens; + + } + + ASSERT_EQ("DISPLAY", ActionData); + ASSERT_EQ("FLASHING=LIGHTS", ActionDataTokens); + + ASSERT_EQ("20160230T110000Z", TriggerData); + ASSERT_EQ("END", TriggerRelated); + ASSERT_EQ("DATE-TIME", TriggerValue); + ASSERT_EQ("PUSH=BUTTON", TriggerTokens); + + ASSERT_EQ("PT7H", DurationData); + ASSERT_EQ("FLYING=YES", DurationTokens); + + ASSERT_EQ("PT3M", RepeatData); + ASSERT_EQ("SLEEP=ALWAYS", RepeatTokens); + + ASSERT_EQ("This is the second alarm.", DescriptionData); + ASSERT_EQ("null:nodata", DescriptionAltRep); + ASSERT_EQ("kw", DescriptionLanguage); + ASSERT_EQ("TERRIBLE=TOKEN", DescriptionTokens); + + // Test the first X-Token. + + if (TestTask.CalendarAlarmData[1].XTokensData.size() > 0){ + + XTokenData = TestTask.CalendarAlarmData[1].XTokensData[0]; + XTokenName = TestTask.CalendarAlarmData[1].XTokensDataTokens[0]; + + } + + ASSERT_EQ("Example Data 1", XTokenData); + ASSERT_EQ("X-EXAMPLE1;YAY=YES", XTokenName); + + // Test the second X-Token. + + XTokenData.clear(); + XTokenName.clear(); + + if (TestTask.CalendarAlarmData[1].XTokensData.size() > 1){ + + XTokenData = TestTask.CalendarAlarmData[1].XTokensData[1]; + XTokenName = TestTask.CalendarAlarmData[1].XTokensDataTokens[1]; + + } + + ASSERT_EQ("Example Data 2", XTokenData); + ASSERT_EQ("X-EXAMPLE2;NOPE=YEP", XTokenName); + + // Test the third X-Token. + + XTokenData.clear(); + XTokenName.clear(); + + if (TestTask.CalendarAlarmData[1].XTokensData.size() > 2){ + + XTokenData = TestTask.CalendarAlarmData[1].XTokensData[2]; + XTokenName = TestTask.CalendarAlarmData[1].XTokensDataTokens[2]; + + } + + ASSERT_EQ("Example Data 3", XTokenData); + ASSERT_EQ("X-EXAMPLE3;WORLD=NO", XTokenName); + + // Tests for the third VALARM property. + + ActionData.clear(); + ActionDataTokens.clear(); + + TriggerData.clear(); + TriggerRelated.clear(); + TriggerValue.clear(); + TriggerTokens.clear(); + + DurationData.clear(); + DurationTokens.clear(); + + RepeatData.clear(); + RepeatTokens.clear(); + + XTokenData.clear(); + XTokenName.clear(); + + DescriptionData.clear(); + DescriptionAltRep.clear(); + DescriptionLanguage.clear(); + DescriptionTokens.clear(); + + string SummaryData; + string SummaryAltRep; + string SummaryLanguage; + string SummaryTokens; + + string AttendeeDataMember; + string AttendeeDataDelegatedFrom; + string AttendeeDataDelegatedTo; + string AttendeeDataRole; + string AttendeeDataRSVP; + string AttendeeDataDirectoryEntry; + string AttendeeDataSentBy; + string AttendeeDataCommonName; + string AttendeeDataCalendarUserType; + string AttendeeDataParticipationStatus; + string AttendeeDataLanguage; + string AttendeeDataTokens; + string AttendeeData; + + AttachData.clear(); + AttachDataFormatType.clear(); + AttachDataValue.clear(); + AttachDataEncoding.clear(); + AttachDataTokens.clear(); + + if (TestTask.CalendarAlarmData.size() > 2){ + + ActionData = TestTask.CalendarAlarmData[2].AlarmAction; + ActionDataTokens = TestTask.CalendarAlarmData[2].AlarmActionTokens; + + TriggerData = TestTask.CalendarAlarmData[2].TriggerData; + TriggerRelated = TestTask.CalendarAlarmData[2].TriggerRelated; + TriggerValue = TestTask.CalendarAlarmData[2].TriggerValue; + TriggerTokens = TestTask.CalendarAlarmData[2].TriggerTokens; + + DurationData = TestTask.CalendarAlarmData[2].DurationData; + DurationTokens = TestTask.CalendarAlarmData[2].DurationTokens; + + RepeatData = TestTask.CalendarAlarmData[2].RepeatData; + RepeatTokens = TestTask.CalendarAlarmData[2].RepeatTokens; + + DescriptionData = TestTask.CalendarAlarmData[2].DescriptionData; + DescriptionAltRep = TestTask.CalendarAlarmData[2].DescriptionAltRep; + DescriptionLanguage = TestTask.CalendarAlarmData[2].DescriptionLanguage; + DescriptionTokens = TestTask.CalendarAlarmData[2].DescriptionTokens; + + SummaryData = TestTask.CalendarAlarmData[2].SummaryData; + SummaryAltRep = TestTask.CalendarAlarmData[2].SummaryAltRep; + SummaryLanguage = TestTask.CalendarAlarmData[2].SummaryLanguage; + SummaryTokens = TestTask.CalendarAlarmData[2].SummaryTokens; + + } + + ASSERT_EQ("EMAIL", ActionData); + ASSERT_EQ("FLASHING=LIGHTS", ActionDataTokens); + + ASSERT_EQ("20160230T120000Z", TriggerData); + ASSERT_EQ("END", TriggerRelated); + ASSERT_EQ("DATE-TIME", TriggerValue); + ASSERT_EQ("PUSH=BUTTON", TriggerTokens); + + ASSERT_EQ("PT7H", DurationData); + ASSERT_EQ("FLYING=YES", DurationTokens); + + ASSERT_EQ("PT3M", RepeatData); + ASSERT_EQ("SLEEP=ALWAYS", RepeatTokens); + + ASSERT_EQ("This is the third alarm.", DescriptionData); + ASSERT_EQ("null:nodata", DescriptionAltRep); + ASSERT_EQ("kw", DescriptionLanguage); + ASSERT_EQ("TERRIBLE=TOKEN", DescriptionTokens); + + ASSERT_EQ("This is the summary of the third alarm.", SummaryData); + ASSERT_EQ("null:nodata", SummaryAltRep); + ASSERT_EQ("en", SummaryLanguage); + ASSERT_EQ("MEEP=MOOP", SummaryTokens); + + // Tests for ATTENDEE. First ATTENDEE property. + + if (TestTask.CalendarAlarmData[2].AttendeeList.begin() != TestTask.CalendarAlarmData[2].AttendeeList.end()){ + + AttendeeData = TestTask.CalendarAlarmData[2].AttendeeList[0]; + + } + + ASSERT_EQ("Attendee One", AttendeeData); + + // Second ATTENDEE property. + + AttendeeData.clear(); + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 1){ + + AttendeeData = TestTask.CalendarAlarmData[2].AttendeeList[1]; + + } + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 1){ + + AttendeeDataDelegatedFrom = TestTask.CalendarAlarmData[2].AttendeeListDelegatedFrom[1]; + + } + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 1){ + + AttendeeDataDelegatedTo = TestTask.CalendarAlarmData[2].AttendeeListDelegatedTo[1]; + + } + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 1){ + + AttendeeDataRole = TestTask.CalendarAlarmData[2].AttendeeListRole[1]; + + } + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 1){ + + AttendeeDataRSVP = TestTask.CalendarAlarmData[2].AttendeeListRSVP[1]; + + } + + ASSERT_EQ("Attendee Two", AttendeeData); + ASSERT_EQ("mailto:delegated.from@example.com", AttendeeDataDelegatedFrom); + ASSERT_EQ("mailto:delegated.to@example.com", AttendeeDataDelegatedTo); + ASSERT_EQ("CHAIR", AttendeeDataRole); + ASSERT_EQ("TRUE", AttendeeDataRSVP); + + // Third ATTENDEE property. + + AttendeeData.clear(); + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 2){ + + AttendeeData = TestTask.CalendarAlarmData[2].AttendeeList[2]; + + } + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 2){ + + AttendeeDataDirectoryEntry = TestTask.CalendarAlarmData[2].AttendeeListDirectoryEntry[2]; + + } + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 2){ + + AttendeeDataSentBy = TestTask.CalendarAlarmData[2].AttendeeListSentBy[2]; + + } + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 2){ + + AttendeeDataCommonName = TestTask.CalendarAlarmData[2].AttendeeListCommonName[2]; + + } + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 2){ + + AttendeeDataCalendarUserType = TestTask.CalendarAlarmData[2].AttendeeListCalendarUserType[2]; + + } + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 2){ + + AttendeeDataParticipationStatus = TestTask.CalendarAlarmData[2].AttendeeListParticipationStatus[2]; + + } + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 2){ + + AttendeeDataLanguage = TestTask.CalendarAlarmData[2].AttendeeListLanguage[2]; + + } + + if (TestTask.CalendarAlarmData[2].AttendeeList.size() > 2){ + + AttendeeDataTokens = TestTask.CalendarAlarmData[2].AttendeeListTokens[2]; + + } + + ASSERT_EQ("Attendee Three", AttendeeData); + ASSERT_EQ("null:nodata", AttendeeDataDirectoryEntry); + ASSERT_EQ("mailto:sent.by@example.com", AttendeeDataSentBy); + ASSERT_EQ("Attendee The Third", AttendeeDataCommonName); + ASSERT_EQ("INDIVIDUAL", AttendeeDataCalendarUserType); + ASSERT_EQ("ACCEPTED", AttendeeDataParticipationStatus); + ASSERT_EQ("kw", AttendeeDataLanguage); + ASSERT_EQ("EXAMPLE=DATA", AttendeeDataTokens); + + // Tests for ATTACH. First ATTACH property. + + if (TestTask.CalendarAlarmData[2].AttachList.begin() != TestTask.CalendarAlarmData[2].AttachList.end()){ + + AttachData = TestTask.CalendarAlarmData[2].AttachList[0]; + + } + + if (TestTask.CalendarAlarmData[2].AttachListFormatType.begin() != TestTask.CalendarAlarmData[2].AttachListFormatType.end()){ + + AttachDataFormatType = TestTask.CalendarAlarmData[2].AttachListFormatType[0]; + + } + + ASSERT_EQ("http://www.example.com/", AttachData); + ASSERT_EQ("application/internet-shortcut", AttachDataFormatType); + + // Second ATTACH property. + + AttachData.clear(); + AttachDataFormatType.clear(); + AttachDataValue.clear(); + AttachDataEncoding.clear(); + + if (TestTask.CalendarAlarmData[2].AttachList.size() > 1){ + + AttachData = TestTask.CalendarAlarmData[2].AttachList[1]; + + } + + if (TestTask.CalendarAlarmData[2].AttachListFormatType.size() > 1){ + + AttachDataFormatType = TestTask.CalendarAlarmData[2].AttachListFormatType[1]; + + } + + ASSERT_EQ("http://www.example.com/page2.html", AttachData); + ASSERT_EQ("application/internet-shortcut", AttachDataFormatType); + + // Third ATTACH property. + + AttachData.clear(); + AttachDataFormatType.clear(); + AttachDataValue.clear(); + AttachDataEncoding.clear(); + AttachDataTokens.clear(); + + if (TestTask.CalendarAlarmData[2].AttachList.size() > 2){ + + AttachData = TestTask.CalendarAlarmData[2].AttachList[2]; + + } + + if (TestTask.CalendarAlarmData[2].AttachListFormatType.size() > 2){ + + AttachDataFormatType = TestTask.CalendarAlarmData[2].AttachListFormatType[2]; + + } + + if (TestTask.CalendarAlarmData[2].AttachListValue.size() > 2){ + + AttachDataValue = TestTask.CalendarAlarmData[2].AttachListValue[2]; + + } + + if (TestTask.CalendarAlarmData[2].AttachListFormatType.size() > 2){ + + AttachDataEncoding = TestTask.CalendarAlarmData[2].AttachListEncoding[2]; + + } + + if (TestTask.CalendarAlarmData[2].AttachListTokens.size() > 2){ + + AttachDataTokens = TestTask.CalendarAlarmData[2].AttachListTokens[2]; + + } + + ASSERT_EQ("VGhpcyBpcyBhbiBleGFtcGxlIGZpbGU=", AttachData); + ASSERT_EQ("text/plain", AttachDataFormatType); + ASSERT_EQ("BASE64", AttachDataEncoding); + ASSERT_EQ("BINARY", AttachDataValue); + ASSERT_EQ("STUPID=EXAMPLE", AttachDataTokens); + + // Test the first X-Token. + + if (TestTask.CalendarAlarmData[2].XTokensData.size() > 0){ + + XTokenData = TestTask.CalendarAlarmData[2].XTokensData[0]; + XTokenName = TestTask.CalendarAlarmData[2].XTokensDataTokens[0]; + + } + + ASSERT_EQ("Example Data 1", XTokenData); + ASSERT_EQ("X-EXAMPLE1;YAY=YES", XTokenName); + + // Test the second X-Token. + + XTokenData.clear(); + XTokenName.clear(); + + if (TestTask.CalendarAlarmData[2].XTokensData.size() > 1){ + + XTokenData = TestTask.CalendarAlarmData[2].XTokensData[1]; + XTokenName = TestTask.CalendarAlarmData[2].XTokensDataTokens[1]; + + } + + ASSERT_EQ("Example Data 2", XTokenData); + ASSERT_EQ("X-EXAMPLE2;NOPE=YEP", XTokenName); + + // Test the third X-Token. + + XTokenData.clear(); + XTokenName.clear(); + + if (TestTask.CalendarAlarmData[2].XTokensData.size() > 2){ + + XTokenData = TestTask.CalendarAlarmData[2].XTokensData[2]; + XTokenName = TestTask.CalendarAlarmData[2].XTokensDataTokens[2]; + + } + + ASSERT_EQ("Example Data 3", XTokenData); + ASSERT_EQ("X-EXAMPLE3;WORLD=NO", XTokenName); + +}