From d2ed764ced77fb3f321bf39a79b4199ad62c4624 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Tue, 31 May 2016 07:31:35 +0100 Subject: [PATCH] Added more unit tests for saving data in CalendarEventObject First tests deal with iCalendarEvent-Load1.vcf --- source/tests/xestiacalendar_icaleventsave.h | 33 +++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/source/tests/xestiacalendar_icaleventsave.h b/source/tests/xestiacalendar_icaleventsave.h index bfe7caa..bd00909 100644 --- a/source/tests/xestiacalendar_icaleventsave.h +++ b/source/tests/xestiacalendar_icaleventsave.h @@ -18,16 +18,45 @@ #include "../objects/calendarevent/CalendarEvent.h" -TEST(iCalendarSaveEvent, BasicTests){ +TEST(iCalendarSaveEvent, SaveEventTests){ CalendarEventObject TestEvent; // Load the test event. - ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestEvent.LoadFile("iCalendarEvent-Load2.vcf")); + ASSERT_EQ(CALENDAROBJECTLOAD_OK, TestEvent.LoadFile("iCalendarEvent-Load1.vcf")); + ASSERT_EQ(CALENDAROBJECTVALID_OK, TestEvent.ValidBaseObject()); //ASSERT_EQ(CALENDAROBJECTSAVE_MISSING, TestEvent.LoadFile("iCalendarEvent-Missing.vcf")); //ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, TestEvent.LoadFile("iCalendarEvent-InvalidPermissions.vcf")); //ASSERT_EQ(CALENDAROBJECTSAVE_OK, TestEvent.LoadFile("iCalendarEvent-Load1.vcf")); + + ASSERT_EQ(CALENDAROBJECTSAVE_CANNOTOPEN, TestEvent.SaveFile("/stupidfilelocation/dontsavehere.ics")); + + // Save the data to a string and compare the data. + + // First contact file. + + std::string SaveDataComparison = "BEGIN:VCARD\n" + "VERSION:2.0\n" + "METHOD;EXAMPLE=DATA:REQUEST\n" + "CALSCALE;MORE=YES:GREGORIAN\n" + "PRODID:-//Xestia//Calendar Unit Testing//KW\n" + "BEGIN:VEVENT\n" + "UID:329128-12939123-123123-13\n" + "DTSTAMP:20160116T190200Z\n" + "DTSTART:20160116T190200Z\n" + "DTEND:20160116T190200Z\n" + "SUMMARY:Unit Test Event 1 which has to be a really long summary as we don't k\n" + " now if multiple line processing is going to work without it. I mean seriousl\n" + " y, how annoying can this potentially be?\n" + "END:VEVENT\n" + "END:VCARD"; + + std::string SaveData; + + TestEvent.SaveString(&SaveData); + + ASSERT_EQ(SaveDataComparison, SaveData); } \ No newline at end of file -- 2.39.5