diff options
author | Federico Mena Quintero <federico@src.gnome.org> | 2000-12-12 07:01:26 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2000-12-12 07:01:26 +0800 |
commit | 26eee7328031f78b063ab71265ef4fddc8619c72 (patch) | |
tree | 65334073d42b48a4c23f2d7d20a6813c2113f57c /libical/src/test | |
parent | 5ccacd6a5bbeb2d91aea706f37cc5f96ee3144fb (diff) | |
download | gsoc2013-evolution-26eee7328031f78b063ab71265ef4fddc8619c72.tar gsoc2013-evolution-26eee7328031f78b063ab71265ef4fddc8619c72.tar.gz gsoc2013-evolution-26eee7328031f78b063ab71265ef4fddc8619c72.tar.bz2 gsoc2013-evolution-26eee7328031f78b063ab71265ef4fddc8619c72.tar.lz gsoc2013-evolution-26eee7328031f78b063ab71265ef4fddc8619c72.tar.xz gsoc2013-evolution-26eee7328031f78b063ab71265ef4fddc8619c72.tar.zst gsoc2013-evolution-26eee7328031f78b063ab71265ef4fddc8619c72.zip |
Fix fucking CVS conflicts because fucking CVS is a fucking big doofus - Federico
svn path=/trunk/; revision=6920
Diffstat (limited to 'libical/src/test')
-rw-r--r-- | libical/src/test/Makefile.am | 26 | ||||
-rw-r--r-- | libical/src/test/copycluster.c | 11 | ||||
-rw-r--r-- | libical/src/test/regression.c | 707 | ||||
-rw-r--r-- | libical/src/test/storage.c | 31 | ||||
-rw-r--r-- | libical/src/test/stow.c | 39 |
5 files changed, 697 insertions, 117 deletions
diff --git a/libical/src/test/Makefile.am b/libical/src/test/Makefile.am index 7fc594ee84..a2ebea7610 100644 --- a/libical/src/test/Makefile.am +++ b/libical/src/test/Makefile.am @@ -1,18 +1,18 @@ -noinst_PROGRAMS = copycluster regression parser findobj storage stow recur testmime testvcal +noinst_PROGRAMS = copycluster regression parser storage stow recur testmime testvcal process testclassify + +LDADD = ../libicalss/libicalss.la ../libicalvcal/libicalvcal.la ../libical/libical.la -LDADD = ../libical/libical.a ../libicalss/libicalss.a ../libicalvcal/libicalvcal.a INCLUDES = \ - -I . \ - -I../libicalvcal \ - -I $(srcdir)/../libicalvcal \ - -I $(srcdir) \ - -I../libical \ - -I $(srcdir)/../libical \ - -I../libicalss \ - -I $(srcdir)/../libicalss + -I . \ + -I../libicalvcal \ + -I $(srcdir)/../libicalvcal \ + -I $(srcdir) \ + -I../libical \ + -I $(srcdir)/../libical \ + -I../libicalss \ + -I $(srcdir)/../libicalss -findobj_SOURCES = findobj.c copycluster_SOURCES = copycluster.c regression_SOURCES = regression.c parser_SOURCES = icaltestparser.c @@ -20,4 +20,6 @@ storage_SOURCES = storage.c stow_SOURCES = stow.c testvcal_SOURCES = testvcal.c recur_SOURCES = recur.c -test_mime = testmime.c +testmime_SOURCES = testmime.c +process_SOURCES = process.c +testclassify_SOURCES = testclassify.c diff --git a/libical/src/test/copycluster.c b/libical/src/test/copycluster.c index 11bd94c62d..0d6722fc94 100644 --- a/libical/src/test/copycluster.c +++ b/libical/src/test/copycluster.c @@ -4,7 +4,6 @@ CREATOR: eric 15 January 2000 $Id$ - $Locker$ (C) COPYRIGHT 2000 Eric Busboom http://www.softwarestudio.org @@ -27,6 +26,7 @@ #include <stdio.h> /* for printf */ #include "ical.h" +#include "icalss.h" #include "icalfileset.h" #include <errno.h> #include <string.h> /* For strerror */ @@ -72,11 +72,9 @@ int main(int c, char *argv[]){ } - for (itr = icalfileset_get_first_component(clusterin, - ICAL_ANY_COMPONENT); + for (itr = icalset_get_first_component(clusterin); itr != 0; - itr = icalfileset_get_next_component(clusterin, - ICAL_ANY_COMPONENT)){ + itr = icalset_get_next_component(clusterin)){ icalrestriction_check(itr); @@ -108,6 +106,7 @@ int main(int c, char *argv[]){ icalfileset_free(clusterout); } - return 0; + return 0; } + diff --git a/libical/src/test/regression.c b/libical/src/test/regression.c index dc6a5301f1..1d66ee4fc5 100644 --- a/libical/src/test/regression.c +++ b/libical/src/test/regression.c @@ -1,12 +1,11 @@ /* -*- Mode: C -*- ====================================================================== - FILE: usecases.c + FILE: regression.c CREATOR: eric 03 April 1999 DESCRIPTION: $Id$ - $Locker$ (C) COPYRIGHT 1999 Eric Busboom http://www.softwarestudio.org @@ -22,24 +21,20 @@ limitations under the License. The original author is Eric Busboom - The original code is usecases.c + The original code is regression.c ======================================================================*/ #include "ical.h" +#include "icalss.h" + #include <assert.h> #include <string.h> /* for strdup */ #include <stdlib.h> /* for malloc */ #include <stdio.h> /* for printf */ #include <time.h> /* for time() */ -#include "icalmemory.h" -#include "icalerror.h" -#include "icalrestriction.h" -#include "icalcalendar.h" -#include "icalgauge.h" -#include "icaldirset.h" -#include "icalfileset.h" + /* This example creates and minipulates the ical object that appears * in rfc 2445, page 137 */ @@ -829,11 +824,9 @@ int test_store() rtime.end = rtime.start; rtime.end.hour++; - for (itr = icalfileset_get_first_component(cluster, - ICAL_ANY_COMPONENT); + for (itr = icalfileset_get_first_component(cluster); itr != 0; - itr = icalfileset_get_next_component(cluster, - ICAL_ANY_COMPONENT)){ + itr = icalfileset_get_next_component(cluster)){ icalcomponent *clone; icalproperty *p; @@ -929,11 +922,11 @@ int test_store() #endif - for(c = icaldirset_get_first_component(s,ICAL_ANY_COMPONENT); + for(c = icaldirset_get_first_component(s); c != 0; c = next){ - next = icaldirset_get_next_component(s,ICAL_ANY_COMPONENT); + next = icaldirset_get_next_component(s); if (c != 0){ /*icaldirset_remove_component(s,c);*/ @@ -1023,34 +1016,6 @@ void test_restriction() rtime.end = icaltime_from_timet( time(0),0,0); rtime.end.hour++; - - - /* Property restrictions */ - assert(icalrestriction_get_property_restriction( - ICAL_METHOD_PUBLISH, - ICAL_VEVENT_COMPONENT, - ICAL_SEQUENCE_PROPERTY) == 5); /* ZEROORONE -> 5 */ - - assert(icalrestriction_get_property_restriction( - ICAL_METHOD_PUBLISH, - ICAL_VEVENT_COMPONENT, - ICAL_ATTACH_PROPERTY)==3); /* ZEROPLUS -> 3 */ - - assert(icalrestriction_get_property_restriction( - ICAL_METHOD_DECLINECOUNTER, - ICAL_VEVENT_COMPONENT, - ICAL_SEQUENCE_PROPERTY)==1); /* ZERO -> 1 */ - - /* Component restrictions */ - assert(icalrestriction_get_component_restriction( - ICAL_METHOD_PUBLISH, - ICAL_VJOURNAL_COMPONENT, - ICAL_X_COMPONENT) == 3); /* ZEROPLUS */ - - assert(icalrestriction_get_component_restriction( - ICAL_METHOD_CANCEL, - ICAL_VJOURNAL_COMPONENT, - ICAL_VEVENT_COMPONENT) == 1); /* ZERO */ comp = icalcomponent_vanew( @@ -1124,6 +1089,7 @@ void test_restriction() } +#if 0 void test_calendar() { icalcomponent *comp; @@ -1168,6 +1134,9 @@ void test_calendar() icalcalendar_free(calendar); } +#endif + +void test_increment(void); void test_recur() { @@ -1198,6 +1167,64 @@ void test_recur() printf("%s\n",icalvalue_as_ical_string(v)); + test_increment(); + +} + + +enum byrule { + NO_CONTRACTION = -1, + BY_SECOND = 0, + BY_MINUTE = 1, + BY_HOUR = 2, + BY_DAY = 3, + BY_MONTH_DAY = 4, + BY_YEAR_DAY = 5, + BY_WEEK_NO = 6, + BY_MONTH = 7, + BY_SET_POS +}; + +struct icalrecur_iterator_impl { + + struct icaltimetype dtstart; + struct icaltimetype last; /* last time return from _iterator_next*/ + int occurrence_no; /* number of step made on this iterator */ + struct icalrecurrencetype rule; + + short days[366]; + short days_index; + + enum byrule byrule; + short by_indices[9]; + + + short *by_ptrs[9]; /* Pointers into the by_* array elements of the rule */ +}; + +void icalrecurrencetype_test() +{ + icalvalue *v = icalvalue_new_from_string( + ICAL_RECUR_VALUE, + "FREQ=YEARLY;UNTIL=20060101T000000;INTERVAL=2;BYDAY=SU,WE;BYSECOND=15,30; BYMONTH=1,6,11"); + + struct icalrecurrencetype r = icalvalue_get_recur(v); + struct icaltimetype t = icaltime_from_timet( time(0), 0, 0); + struct icaltimetype next; + time_t tt; + + struct icalrecur_iterator_impl* itr + = (struct icalrecur_iterator_impl*) icalrecur_iterator_new(r,t); + + do { + + next = icalrecur_iterator_next(itr); + tt = icaltime_as_timet(next); + + printf("%s",ctime(&tt )); + + } while( ! icaltime_is_null_time(next)); + } void test_recur_expansion() @@ -1213,6 +1240,83 @@ void test_recur_expansion() icalrecurrencetype_test(); } +static const char test_icalcomp_str[] = +"BEGIN:VEVENT\r\n" +"UID\r\n" +" :20001121T203327-22955-2183-22933-0@guanabana.helixcode.com\r\n" +"DTSTAMP\r\n" +" :20001121T203327\r\n" +"DTSTART\r\n" +" :20001121T170000\r\n" +"DTEND\r\n" +" :20001121T180000\r\n" +"SUMMARY\r\n" +" :recur on the second Friday every month\\, forever\r\n" +"SEQUENCE\r\n" +" :3\r\n" +"CLASS\r\n" +" :PRIVATE\r\n" +"RRULE\r\n" +" :FREQ=MONTHLY;INTERVAL=1;BYDAY=-2WE,2FR,3SA,-2WE\n" +"END:VEVENT\r\n"; + +void test_recur_bug() +{ + icalcomponent *icalcomp; + char *str; + icalproperty *prop; + struct icalrecurrencetype r; + + /* Print the original stuff */ + + puts ("The original component is:\n\n"); + puts (test_icalcomp_str); + + /* Parse the component */ + + icalcomp = icalparser_parse_string ((char *) test_icalcomp_str); + + if (!icalcomp) { + fprintf (stderr, "main(): Could not parse the stuff\n"); + exit (EXIT_FAILURE); + } + + if (icalcomponent_isa (icalcomp) != ICAL_VEVENT_COMPONENT) { + fprintf (stderr, "main(): This is not the test data I want\n"); + exit (EXIT_FAILURE); + } + + /* Watch the property */ + + prop = icalcomponent_get_first_property (icalcomp, ICAL_RRULE_PROPERTY); + if (!prop) { + fprintf (stderr, "main(): This is not the test data I want\n"); + exit (EXIT_FAILURE); + } + + r = icalproperty_get_rrule (prop); + printf ("\nThe first BYDAY element is %d\n", r.by_day[0]); + + printf ("Position is %d, weekday is %d\n", + icalrecurrencetype_day_position (r.by_day[0]), + (int) icalrecurrencetype_day_day_of_week (r.by_day[0])); + + /* Re-stringify */ + + puts ("\nThe component looks like this after re-stringification:\n\n"); + + str = icalcomponent_as_ical_string (icalcomp); + if (!str) { + fprintf (stderr, "main(): Could not stringify the component\n"); + exit (EXIT_FAILURE); + } + + puts (str); + puts ("\n"); + +} + + void test_duration() { @@ -1223,6 +1327,12 @@ void test_duration() printf("%s\n",icalvalue_as_ical_string(v)); + + v = icalvalue_new_from_string(ICAL_DURATION_VALUE, + "-PT8H30M"); + + printf("%s\n",icalvalue_as_ical_string(v)); + icalvalue_free(v); v = icalvalue_new_from_string(ICAL_PERIOD_VALUE, "19971015T050000Z/PT8H30M"); @@ -1320,18 +1430,29 @@ void test_requeststat() } +char ictt_str[1024]; +char* ictt_as_string(struct icaltimetype t) +{ + + sprintf(ictt_str,"%02d-%02d-%02d %02d:%02d:%02d %c",t.year,t.month,t.day, + t.hour,t.minute,t.second,t.is_utc?'Z':' '); + + return ictt_str; +} void test_time() { - struct icaltimetype ictt; + struct icaltimetype ictt, icttutc, icttny,icttphoenix; time_t tt,tt2; icalvalue *v; short day_of_week,start_day_of_week, day_of_year; - tt = time(0); + tt = 973276230; /* Fri Nov 3 10:30:30 PST 2000 in UTC */ + + printf("\n Convert to and from lib c \n"); - printf("System time is: %s\n",ctime(&tt)); + printf("System time is: %s",ctime(&tt)); ictt = icaltime_from_timet(tt,0,0); @@ -1340,8 +1461,9 @@ void test_time() printf("System time from libical: %s\n",icalvalue_as_ical_string(v)); tt2 = icaltime_as_timet(ictt); - printf("Converted back to libc: %s\n",ctime(&tt2)); + printf("Converted back to libc: %s",ctime(&tt2)); + printf("\n Incrementing time \n"); ictt.year++; tt2 = icaltime_as_timet(ictt); @@ -1349,14 +1471,15 @@ void test_time() ictt.month+=13; tt2 = icaltime_as_timet(ictt); - printf("Add 13 months: %s\n",ctime(&tt2)); + printf("Add 13 months: %s",ctime(&tt2)); ictt.second+=90; tt2 = icaltime_as_timet(ictt); - printf("Add 90 seconds: %s\n",ctime(&tt2)); + printf("Add 90 seconds: %s",ctime(&tt2)); ictt = icaltime_from_timet(tt,0,0); + printf("\n Day Of week \n"); day_of_week = icaltime_day_of_week(ictt); start_day_of_week = icaltime_start_doy_of_week(ictt); @@ -1365,6 +1488,30 @@ void test_time() printf("Today is day of week %d, day of year %d\n",day_of_week,day_of_year); printf("Week started n doy of %d\n",start_day_of_week); + printf("\n To and From UTC\n"); + + ictt = icaltime_from_timet(tt,0,1); + printf("As utc : %s\n", ictt_as_string(ictt)); + ictt = icaltime_from_timet(tt,0,0); + printf("As local : %s\n", ictt_as_string(ictt)); + + + + printf("\n TimeZone Conversions \n"); + + ictt = icaltime_from_timet(tt,0,1); + + icttutc = icaltime_as_utc(ictt,"America/Los_Angeles"); + + icttny = icaltime_as_zone(icttutc,"America/New_York"); + + icttphoenix = icaltime_as_zone(icttutc,"America/Phoenix"); + + printf("Orig : %s", ctime(&tt) ); + printf("UTC : %s\n", ictt_as_string(icttutc)); + printf("Los Angeles: %s\n", ictt_as_string(ictt)); + printf("Phoenix : %s\n", ictt_as_string(icttphoenix)); + printf("New York : %s\n", ictt_as_string(icttny)); } @@ -1408,7 +1555,7 @@ void test_iterators() icalproperty *p = icalcomponent_get_first_property(this, ICAL_VERSION_PROPERTY); - char* s = icalproperty_get_version(p); + const char* s = icalproperty_get_version(p); printf("%s ",s); @@ -1452,7 +1599,7 @@ void test_iterators() icalproperty *p = icalcomponent_get_first_property(inner,ICAL_VERSION_PROPERTY); - char* s = icalproperty_get_version(p); + const char* s = icalproperty_get_version(p); printf("%s ",s); } @@ -1467,7 +1614,7 @@ void test_iterators() icalcomponent *this; icalproperty *p; - char* s; + const char* s; next = icalcomponent_get_next_component(c,ICAL_ANY_COMPONENT); p=icalcomponent_get_first_property(inner,ICAL_VERSION_PROPERTY); @@ -1498,7 +1645,7 @@ void test_iterators() icalproperty *p = icalcomponent_get_first_property(inner,ICAL_VERSION_PROPERTY); - char* s = icalproperty_get_version(p); + const char* s = icalproperty_get_version(p); printf("%s ",s); } @@ -1506,22 +1653,450 @@ void test_iterators() printf("\n"); } -int main(int argc, char *argv[]) + +void test_icalset() { + icalcomponent *c; - printf("\n------------Test Memory---------------\n"); - test_memory(); + icalset* f = icalset_new_file("2446.ics"); + icalset* d = icalset_new_dir("outdir"); -exit(0); + assert(f!=0); + assert(d!=0); + for(c = icalset_get_first_component(f); + c != 0; + c = icalset_get_next_component(f)){ - printf("\n------------Test Iterators-----------\n"); - test_iterators(); + icalcomponent *clone; + + clone = icalcomponent_new_clone(c); + + icalset_add_component(d,clone); + + printf(" class %d\n",icalclassify(c,0,"user")); + + } +} + +void test_classify() +{ + icalcomponent *c,*match; + + icalset* f = icalset_new_file("../../test-data/classify.ics"); + + assert(f!=0); + + c = icalset_get_first_component(f); + match = icalset_get_next_component(f); + + printf("Class %d\n",icalclassify(c,match,"A@example.com")); + + +} + +void print_span(int c, struct icaltime_span span ){ + + printf("#%02d start: %s",c,ctime(&span.start)); + printf(" end : %s",ctime(&span.end)); + +} + +void test_span() +{ + time_t tm1 = 973378800; /*Sat Nov 4 23:00:00 UTC 2000, + Sat Nov 4 15:00:00 PST 2000 */ + time_t tm2 = 973382400; /*Sat Nov 5 00:00:00 UTC 2000 + Sat Nov 4 16:00:00 PST 2000 */ + struct icaldurationtype dur; + struct icaltime_span span; + icalcomponent *c; + + memset(&dur,0,sizeof(dur)); + dur.minutes = 30; + + span.start = tm1; + span.end = tm2; + print_span(0,span); + + /* Specify save timezone as in commend above */ + c = + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_dtstart(icaltime_from_timet(tm1,0,0), + icalparameter_new_tzid("US/Pacific"),0), + icalproperty_vanew_dtend(icaltime_from_timet(tm2,0,0), + icalparameter_new_tzid("US/Pacific"),0), + 0 + ); + + printf("%s\n",icalcomponent_as_ical_string(c)); + + span = icalcomponent_get_span(c); + + print_span(1,span); + + /* Use machine's local timezone. Same as above if run in US/Pacific */ + c = + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_dtstart(icaltime_from_timet(tm1,0,0),0), + icalproperty_vanew_dtend(icaltime_from_timet(tm2,0,0),0), + 0 + ); + + span = icalcomponent_get_span(c); + + print_span(2,span); + + /* Specify different timezone */ + c = + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_dtstart(icaltime_from_timet(tm1,0,0), + icalparameter_new_tzid("US/Eastern"),0), + icalproperty_vanew_dtend(icaltime_from_timet(tm2,0,0), + icalparameter_new_tzid("US/Eastern"),0), + 0 + ); + span = icalcomponent_get_span(c); + print_span(3,span); + + /* Specify different timezone for start and end*/ + c = + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_dtstart(icaltime_from_timet(tm1,0,0), + icalparameter_new_tzid("US/Eastern"),0), + icalproperty_vanew_dtend(icaltime_from_timet(tm2,0,0), + icalparameter_new_tzid("US/Pacific"),0), + 0 + ); + span = icalcomponent_get_span(c); + print_span(4,span); + + + /* Use Duration */ + c = + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_dtstart(icaltime_from_timet(tm1,0,0), + icalparameter_new_tzid("US/Pacific"),0), + icalproperty_new_duration(dur), + + 0 + ); + span = icalcomponent_get_span(c); + print_span(5,span); + +#ifndef ICAL_ERRORS_ARE_FATAL + /* Both UTC and Timezone -- an error */ + icalerror_clear_errno(); + c = + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_dtstart(icaltime_from_timet(tm1,0,1), + icalparameter_new_tzid("US/Eastern"),0), + icalproperty_vanew_dtend(icaltime_from_timet(tm2,0,1), + icalparameter_new_tzid("US/Eastern"),0), + 0 + ); + + span = icalcomponent_get_span(c); + assert(icalerrno != ICAL_NO_ERROR); +#endif /*ICAL_ERRORS_ARE_FATAL*/ + +} + +icalcomponent* icalclassify_find_overlaps(icalset* set, icalcomponent* comp); + +void test_overlaps() +{ + icalcomponent *cset,*c; + icalset *set; + time_t tm1 = 973378800; /*Sat Nov 4 23:00:00 UTC 2000, + Sat Nov 4 15:00:00 PST 2000 */ + time_t tm2 = 973382400; /*Sat Nov 5 00:00:00 UTC 2000 + Sat Nov 4 16:00:00 PST 2000 */ + + time_t hh = 1800; /* one half hour */ + + set = icalset_new_file("../../test-data/overlaps.ics"); + + printf("-- 1 -- \n"); + c = icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_dtstart(icaltime_from_timet(tm1-hh,0,1),0), + icalproperty_vanew_dtend(icaltime_from_timet(tm2-hh,0,1),0), + 0 + ); + + cset = icalclassify_find_overlaps(set,c); + + printf("%s\n",icalcomponent_as_ical_string(cset)); + + printf("-- 2 -- \n"); + c = icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_dtstart(icaltime_from_timet(tm1-hh,0,1),0), + icalproperty_vanew_dtend(icaltime_from_timet(tm2,0,1),0), + 0 + ); + + cset = icalclassify_find_overlaps(set,c); + printf("%s\n",icalcomponent_as_ical_string(cset)); + + printf("-- 3 -- \n"); + c = icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_dtstart(icaltime_from_timet(tm1+5*hh,0,1),0), + icalproperty_vanew_dtend(icaltime_from_timet(tm2+5*hh,0,1),0), + 0 + ); + + cset = icalclassify_find_overlaps(set,c); + + printf("%s\n",icalcomponent_as_ical_string(cset)); + +} + +void test_fblist() +{ + icalspanlist *sl; + icalset* set = icalset_new_file("../../test-data/spanlist.ics"); + struct icalperiodtype period; + + sl = icalspanlist_new(set, + icaltime_from_string("19970324T1200Z"), + icaltime_from_string("19990424T020000Z")); + + printf("Restricted spanlist\n"); + icalspanlist_dump(sl); + + period= icalspanlist_next_free_time(sl, + icaltime_from_string("19970801T1200Z")); + + + printf("Next Free time: %s\n",icaltime_as_ctime(period.start)); + printf(" %s\n",icaltime_as_ctime(period.end)); + + + icalspanlist_free(sl); + + printf("Unrestricted spanlist\n"); + + sl = icalspanlist_new(set, + icaltime_from_string("19970324T1200Z"), + icaltime_null_time()); + + printf("Restricted spanlist\n"); + + icalspanlist_dump(sl); + + period= icalspanlist_next_free_time(sl, + icaltime_from_string("19970801T1200Z")); + + + printf("Next Free time: %s\n",icaltime_as_ctime(period.start)); + printf(" %s\n",icaltime_as_ctime(period.end)); + + + icalspanlist_free(sl); + + +} + +void test_convenience(){ + + icalcomponent *c; + int duration; + + c = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_new_dtstart(icaltime_from_string("19970801T1200")), + icalproperty_new_dtend(icaltime_from_string("19970801T1300")), + 0 + ), + 0); + + printf("** 1 DTSTART and DTEND **\n%s\n\n", + icalcomponent_as_ical_string(c)); + + duration = icaldurationtype_as_timet(icalcomponent_get_duration(c))/60; + + printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c))); + printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c))); + printf("Dur: %d m\n",duration); + + icalcomponent_free(c); + + c = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_new_dtstart(icaltime_from_string("19970801T1200Z")), + icalproperty_new_duration(icaldurationtype_from_string("PT1H30M")), + 0 + ), + 0); + + printf("\n** 2 DTSTART and DURATION **\n%s\n\n", + icalcomponent_as_ical_string(c)); + + duration = icaldurationtype_as_timet(icalcomponent_get_duration(c))/60; + + printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c))); + printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c))); + printf("Dur: %d m\n",duration); + + icalcomponent_free(c); + + c = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_new_dtstart(icaltime_from_string("19970801T1200")), + icalproperty_new_dtend(icaltime_from_string("19970801T1300")), + 0 + ), + 0); + + icalcomponent_set_duration(c,icaldurationtype_from_string("PT1H30M")); + + printf("** 3 DTSTART and DTEND, Set DURATION **\n%s\n\n", + icalcomponent_as_ical_string(c)); + + duration = icaldurationtype_as_timet(icalcomponent_get_duration(c))/60; + + printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c))); + printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c))); + printf("Dur: %d m\n",duration); + + icalcomponent_free(c); + + c = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_new_dtstart(icaltime_from_string("19970801T1200Z")), + icalproperty_new_duration(icaldurationtype_from_string("PT1H30M")), + 0 + ), + 0); + + icalcomponent_set_dtend(c,icaltime_from_string("19970801T1330Z")); + + printf("\n** 4 DTSTART and DURATION, set DTEND **\n%s\n\n", + icalcomponent_as_ical_string(c)); + + duration = icaldurationtype_as_timet(icalcomponent_get_duration(c))/60; + + printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c))); + printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c))); + printf("Dur: %d m\n",duration); + + icalcomponent_free(c); + + c = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + 0 + ), + 0); + + icalcomponent_set_dtstart(c,icaltime_from_string("19970801T1200Z")); + icalcomponent_set_dtend(c,icaltime_from_string("19970801T1330Z")); + + printf("\n** 5 Set DTSTART and DTEND **\n%s\n\n", + icalcomponent_as_ical_string(c)); + + + duration = icaldurationtype_as_timet(icalcomponent_get_duration(c))/60; + + printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c))); + printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c))); + printf("Dur: %d m\n",duration); + + icalcomponent_free(c); + + c = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + 0 + ), + 0); + + + icalcomponent_set_dtstart(c,icaltime_from_string("19970801T1200Z")); + icalcomponent_set_duration(c,icaldurationtype_from_string("PT1H30M")); + + printf("\n** 6 Set DTSTART and DURATION **\n%s\n\n", + icalcomponent_as_ical_string(c)); + + + duration = icaldurationtype_as_timet(icalcomponent_get_duration(c))/60; + + printf("Start: %s\n",ictt_as_string(icalcomponent_get_dtstart(c))); + printf("End: %s\n",ictt_as_string(icalcomponent_get_dtend(c))); + printf("Dur: %d m\n",duration); + + icalcomponent_free(c); + +} + +int main(int argc, char *argv[]) +{ + + printf("\n------------Test recur bug ----------\n"); + test_recur_bug(); + + exit(0); + + printf("\n------------Test recur---------------\n"); + test_recur(); + + printf("\n------------Test FBlist------------\n"); + test_fblist(); printf("\n------------Test time----------------\n"); test_time(); + + printf("\n------------Test Overlaps------------\n"); + test_overlaps(); + + + printf("\n------------Test Span----------------\n"); + test_span(); + + + printf("\n------------Test duration---------------\n"); + test_duration(); + + exit(0); + + + + printf("\n------------Test Convenience ------------\n"); + test_convenience(); + + + + printf("\n------------Test classify ---------------\n"); + test_classify(); + + printf("\n------------Test Memory---------------\n"); + test_memory(); + + + printf("\n------------Test Iterators-----------\n"); + test_iterators(); + printf("\n------------Test Restriction---------------\n"); test_restriction(); @@ -1531,12 +2106,6 @@ exit(0); printf("\n------------Test strings---------------\n"); test_strings(); - printf("\n------------Test recur---------------\n"); - test_recur(); - - printf("\n------------Test duration---------------\n"); - test_duration(); - printf("\n------------Test Compare---------------\n"); test_compare(); @@ -1559,9 +2128,13 @@ exit(0); create_new_component_with_va_args(); + return 0; + + printf("\n------------Test icalset ---------------\n"); + test_icalset(); + - return 0; } diff --git a/libical/src/test/storage.c b/libical/src/test/storage.c index d53001b574..b8eb48c30f 100644 --- a/libical/src/test/storage.c +++ b/libical/src/test/storage.c @@ -6,7 +6,6 @@ DESCRIPTION: $Id$ - $Locker$ (C) COPYRIGHT 1999 Eric Busboom http://www.softwarestudio.org @@ -162,11 +161,9 @@ void test_fileset() cout = icalfileset_new(OUTPUT_FILE); assert(cout != 0); - for (itr = icalfileset_get_first_component(cout, - ICAL_ANY_COMPONENT); + for (itr = icalfileset_get_first_component(cout); itr != 0; - itr = icalfileset_get_next_component(cout, - ICAL_ANY_COMPONENT)){ + itr = icalfileset_get_next_component(cout)){ icalcomponent *event; icalproperty *dtstart, *dtend; @@ -190,11 +187,9 @@ void test_fileset() cout = icalfileset_new(OUTPUT_FILE); assert(cout != 0); - for (itr = icalfileset_get_first_component(cout, - ICAL_ANY_COMPONENT); + for (itr = icalfileset_get_first_component(cout); itr != 0; - itr = icalfileset_get_next_component(cout, - ICAL_ANY_COMPONENT)){ + itr = icalfileset_get_next_component(cout)){ icalfileset_remove_component(cout, itr); @@ -209,11 +204,9 @@ void test_fileset() assert(cout != 0); count =0; - for (itr = icalfileset_get_first_component(cout, - ICAL_ANY_COMPONENT); + for (itr = icalfileset_get_first_component(cout); itr != 0; - itr = icalfileset_get_next_component(cout, - ICAL_ANY_COMPONENT)){ + itr = icalfileset_get_next_component(cout)){ icalcomponent *event; icalproperty *dtstart, *dtend; @@ -269,11 +262,9 @@ int test_dirset() rtime.end = rtime.start; rtime.end.hour++; - for (itr = icalfileset_get_first_component(cluster, - ICAL_ANY_COMPONENT); + for (itr = icalfileset_get_first_component(cluster); itr != 0; - itr = icalfileset_get_next_component(cluster, - ICAL_ANY_COMPONENT)){ + itr = icalfileset_get_next_component(cluster)){ icalcomponent *clone, *inner; icalproperty *p; @@ -370,9 +361,9 @@ int test_dirset() #endif - for(c = icaldirset_get_first_component(s,ICAL_ANY_COMPONENT); + for(c = icaldirset_get_first_component(s); c != 0; - c = icaldirset_get_next_component(s,ICAL_ANY_COMPONENT)){ + c = icaldirset_get_next_component(s)){ if (c != 0){ printf("%s", icalcomponent_as_ical_string(c));; @@ -395,6 +386,7 @@ int test_dirset() return 0; } +#if 0 void test_calendar() { icalcomponent *comp; @@ -439,6 +431,7 @@ void test_calendar() icalcalendar_free(calendar); } +#endif int main(int argc, char *argv[]) diff --git a/libical/src/test/stow.c b/libical/src/test/stow.c index f742b417a5..6c285afc77 100644 --- a/libical/src/test/stow.c +++ b/libical/src/test/stow.c @@ -4,7 +4,6 @@ CREATOR: eric 29 April 2000 $Id$ - $Locker$ (C) COPYRIGHT 2000 Eric Busboom http://www.softwarestudio.org @@ -47,6 +46,9 @@ char* program_name; #define TMPSIZE 2048 #define SENDMAIL "/usr/lib/sendmail -t" +void usage(char *message); + + enum options { STORE_IN_FILE, STORE_IN_DB, @@ -113,7 +115,7 @@ enum file_type test_file(char *path) return type; } -char* lowercase(char* str) +char* lowercase(const char* str) { char* p = 0; char* new = strdup(str); @@ -152,11 +154,6 @@ char* get_local_attendee(struct options_struct *opt) } #endif -void usage(char *message) -{ - fprintf(stderr,"Usage: %s [-emdcn] [-i inputfile] [-o outputfile] [-u calid]\n",program_name); - -} icalcomponent* get_first_real_component(icalcomponent *comp) { @@ -178,8 +175,9 @@ icalcomponent* get_first_real_component(icalcomponent *comp) -char* make_mime(char* to, char* from, char* subject, - char* text_message, char* method, char* ical_message) +char* make_mime(char* to, const char* from, const char* subject, + const char* text_message, const char* method, + const char* ical_message) { size_t size = strlen(to)+strlen(from)+strlen(subject)+ strlen(text_message)+ strlen(ical_message)+TMPSIZE; @@ -226,8 +224,8 @@ Content-Type: multipart/mixed; boundary=\"%s\"\n\ \n\ This is a multimedia message in MIME format\n\ \n\ ---%s -%s +--%s\n\ +%s\n\ ", to,from,subject,content_id,boundary,boundary, mime_part_1); @@ -251,7 +249,7 @@ void return_failure(icalcomponent* comp, char* message, icalcomponent *inner = get_first_real_component(comp); icalproperty *organizer_prop = icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY); - char *organizer = icalproperty_get_organizer(organizer_prop); + const char *organizer = icalproperty_get_organizer(organizer_prop); organizer += 7; @@ -347,7 +345,7 @@ icalcomponent* make_reply(icalcomponent *comp, icalproperty *return_status, } int check_attendee(icalproperty *p, struct options_struct *opt){ - char* s = icalproperty_get_attendee(p); + const char* s = icalproperty_get_attendee(p); char* lower_attendee = lowercase(s); char* local_attendee = opt->calid; @@ -481,6 +479,21 @@ char* check_component(icalcomponent* comp, icalproperty **return_status, } +void usage(char *message) +{ + fprintf(stderr,"Usage: %s [-emdcn] [-i inputfile] [-o outputfile] [-u calid]\n",program_name); + fprintf(stderr,"-e\tInput data is encapsulated in a MIME Message \n\ +-m\tInput is raw iCal \n\ +-i\tSpecify input file. Otherwise, input comed from stdin\n\ +-o\tSpecify file to save incoming message to\n\ +-d\tSpecify database to send data to\n\ +-u\tSet the calid to store the data to\n\ +-n\tSend errors to stdout instead of organizer\n\ +"); + +} + + void get_options(int argc, char* argv[], struct options_struct *opt) { int c; |