diff options
author | Seth Alves <alves@src.gnome.org> | 2000-04-19 02:17:07 +0800 |
---|---|---|
committer | Seth Alves <alves@src.gnome.org> | 2000-04-19 02:17:07 +0800 |
commit | 25e1b34aafe43ba6cf1040340a38dd38a90aad33 (patch) | |
tree | 0b4e666e45bf457edcc0095634f0ae6f429b8b5a /libical/src/test | |
parent | bc17057ec598cd5f755fd66244c429ecc51cff01 (diff) | |
download | gsoc2013-evolution-25e1b34aafe43ba6cf1040340a38dd38a90aad33.tar gsoc2013-evolution-25e1b34aafe43ba6cf1040340a38dd38a90aad33.tar.gz gsoc2013-evolution-25e1b34aafe43ba6cf1040340a38dd38a90aad33.tar.bz2 gsoc2013-evolution-25e1b34aafe43ba6cf1040340a38dd38a90aad33.tar.lz gsoc2013-evolution-25e1b34aafe43ba6cf1040340a38dd38a90aad33.tar.xz gsoc2013-evolution-25e1b34aafe43ba6cf1040340a38dd38a90aad33.tar.zst gsoc2013-evolution-25e1b34aafe43ba6cf1040340a38dd38a90aad33.zip |
import of libical-0.16
svn path=/trunk/; revision=2484
Diffstat (limited to 'libical/src/test')
-rw-r--r-- | libical/src/test/Makefile.am | 12 | ||||
-rw-r--r-- | libical/src/test/Makefile.in | 324 | ||||
-rw-r--r-- | libical/src/test/icaltestparser.c | 123 | ||||
-rw-r--r-- | libical/src/test/regression.c | 232 | ||||
-rw-r--r-- | libical/src/test/storage.c | 460 | ||||
-rw-r--r-- | libical/src/test/usecases.c | 46 |
6 files changed, 971 insertions, 226 deletions
diff --git a/libical/src/test/Makefile.am b/libical/src/test/Makefile.am new file mode 100644 index 0000000000..0ebb00ac9a --- /dev/null +++ b/libical/src/test/Makefile.am @@ -0,0 +1,12 @@ + +noinst_PROGRAMS = usecases copycluster regression parser findobj storage + +LDADD = ../libical/libical.a ../libicalss/libicalss.a +INCLUDES = -I . -I../libical -I../libicalss + +findobj_SOURCES = findobj.c +usecases_SOURCES = usecases.c +copycluster_SOURCES = copycluster.c +regression_SOURCES = regression.c +parser_SOURCES = icaltestparser.c +storage_SOURCES = storage.c
\ No newline at end of file diff --git a/libical/src/test/Makefile.in b/libical/src/test/Makefile.in index 5d3d5f709f..a8af11a146 100644 --- a/libical/src/test/Makefile.in +++ b/libical/src/test/Makefile.in @@ -1,36 +1,310 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +AR = @AR@ +CC = @CC@ +LEX = @LEX@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ + +noinst_PROGRAMS = usecases copycluster regression parser findobj storage + +LDADD = ../libical/libical.a ../libicalss/libicalss.a INCLUDES = -I . -I../libical -I../libicalss -CFLAGS = -Wall -g $(INCLUDES) -LIBS = -L../libical -L../libicalss -licalss -lical -CC = gcc -LD = ld -all: usecases copycluster regression parser findobj +findobj_SOURCES = findobj.c +usecases_SOURCES = usecases.c +copycluster_SOURCES = copycluster.c +regression_SOURCES = regression.c +parser_SOURCES = icaltestparser.c +storage_SOURCES = storage.c +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(noinst_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +usecases_OBJECTS = usecases.o +usecases_LDADD = $(LDADD) +usecases_DEPENDENCIES = ../libical/libical.a ../libicalss/libicalss.a +usecases_LDFLAGS = +copycluster_OBJECTS = copycluster.o +copycluster_LDADD = $(LDADD) +copycluster_DEPENDENCIES = ../libical/libical.a \ +../libicalss/libicalss.a +copycluster_LDFLAGS = +regression_OBJECTS = regression.o +regression_LDADD = $(LDADD) +regression_DEPENDENCIES = ../libical/libical.a ../libicalss/libicalss.a +regression_LDFLAGS = +parser_OBJECTS = icaltestparser.o +parser_LDADD = $(LDADD) +parser_DEPENDENCIES = ../libical/libical.a ../libicalss/libicalss.a +parser_LDFLAGS = +findobj_OBJECTS = findobj.o +findobj_LDADD = $(LDADD) +findobj_DEPENDENCIES = ../libical/libical.a ../libicalss/libicalss.a +findobj_LDFLAGS = +storage_OBJECTS = storage.o +storage_LDADD = $(LDADD) +storage_DEPENDENCIES = ../libical/libical.a ../libicalss/libicalss.a +storage_LDFLAGS = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +SOURCES = $(usecases_SOURCES) $(copycluster_SOURCES) $(regression_SOURCES) $(parser_SOURCES) $(findobj_SOURCES) $(storage_SOURCES) +OBJECTS = $(usecases_OBJECTS) $(copycluster_OBJECTS) $(regression_OBJECTS) $(parser_OBJECTS) $(findobj_OBJECTS) $(storage_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/test/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-noinstPROGRAMS: + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) + +distclean-noinstPROGRAMS: + +maintainer-clean-noinstPROGRAMS: + +.c.o: + $(COMPILE) -c $< + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +usecases: $(usecases_OBJECTS) $(usecases_DEPENDENCIES) + @rm -f usecases + $(LINK) $(usecases_LDFLAGS) $(usecases_OBJECTS) $(usecases_LDADD) $(LIBS) + +copycluster: $(copycluster_OBJECTS) $(copycluster_DEPENDENCIES) + @rm -f copycluster + $(LINK) $(copycluster_LDFLAGS) $(copycluster_OBJECTS) $(copycluster_LDADD) $(LIBS) + +regression: $(regression_OBJECTS) $(regression_DEPENDENCIES) + @rm -f regression + $(LINK) $(regression_LDFLAGS) $(regression_OBJECTS) $(regression_LDADD) $(LIBS) + +parser: $(parser_OBJECTS) $(parser_DEPENDENCIES) + @rm -f parser + $(LINK) $(parser_LDFLAGS) $(parser_OBJECTS) $(parser_LDADD) $(LIBS) + +findobj: $(findobj_OBJECTS) $(findobj_DEPENDENCIES) + @rm -f findobj + $(LINK) $(findobj_LDFLAGS) $(findobj_OBJECTS) $(findobj_LDADD) $(LIBS) + +storage: $(storage_OBJECTS) $(storage_DEPENDENCIES) + @rm -f storage + $(LINK) $(storage_LDFLAGS) $(storage_OBJECTS) $(storage_LDADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = src/test + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-noinstPROGRAMS mostlyclean-compile \ + mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am -parser: icaltestparser.o ../libical/libical.a ../libicalss/libicalss.a - $(CC) -o icalparser icaltestparser.o $(LIBS) +clean-am: clean-noinstPROGRAMS clean-compile clean-tags clean-generic \ + mostlyclean-am -copycluster: copycluster.o ../libical/libical.a ../libicalss/libicalss.a - $(CC) -o copycluster copycluster.o $(INCLUDES) $(LIBS) +clean: clean-am -findobj: findobj.o ../libical/libical.a ../libicalss/libicalss.a - $(CC) -o findobj findobj.o $(INCLUDES) $(LIBS) +distclean-am: distclean-noinstPROGRAMS distclean-compile distclean-tags \ + distclean-generic clean-am -regression: regression.o ../libical/libical.a ../libicalss/libicalss.a - $(CC) -o regression regression.o $(INCLUDES) $(LIBS) +distclean: distclean-am -usecases: usecases.o ../libical/libical.a ../libicalss/libicalss.a - $(CC) -o usecases usecases.o $(INCLUDES) $(LIBS) +maintainer-clean-am: maintainer-clean-noinstPROGRAMS \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." -clean: - -/bin/rm -f *.o - -/bin/rm -f \#* - -/bin/rm -f *~ Makefile.bak icalitip.tab.h icalitip.tab.c lex.yy.c - -/bin/rm -rf icalparser core regression usecases copycluster findobj +maintainer-clean: maintainer-clean-am -ci: clean - ci -u *.c *.h +.PHONY: mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \ +clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ +check-am installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean -depend: - @makedepend -Y $(INCLUDES) $(SOURCES) -install:
\ No newline at end of file +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libical/src/test/icaltestparser.c b/libical/src/test/icaltestparser.c index d56af49258..3f07fcd044 100644 --- a/libical/src/test/icaltestparser.c +++ b/libical/src/test/icaltestparser.c @@ -33,78 +33,91 @@ #include <stdlib.h> -char str[] = "BEGIN:VCALENDAR -PRODID:\"-//RDU Software//NONSGML HandCal//EN\" -VERSION:2.0 -BEGIN:VTIMEZONE -TZID:US-Eastern -BEGIN:STANDARD -DTSTART:19990404T020000 -RDATE:19990u404xT020000 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19990404T020000 -RDATE:19990404T020000 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -Dkjhgri:derhvnv; -BEGIN:dfkjh -END:dfdfkjh -END:DAYLIGHT -END:VTIMEZONE -BEGIN:VEVENT -GEO:Bongo -DTSTAMP:19980309T231000Z -UID:guid-1.host1.com -ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com -ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP - :MAILTO:employee-A@host.com -DESCRIPTION:Project XYZ Review Meeting -CATEGORIES:MEETING -CLASS:PUBLIC -CREATED:19980309T130000Z -SUMMARY:XYZ Project Review -DTSTART;TZID=US-Eastern:19980312T083000 -DTEND;TZID=US-Eastern:19980312T093000 -LOCATION:1CP Conference Room 4350 -END:VEVENT -END:VCALENDAR +char str[] = "BEGIN:VCALENDAR\ +PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\ +VERSION:2.0\ +BEGIN:VTIMEZONE\ +TZID:US-Eastern\ +BEGIN:STANDARD\ +DTSTART:19990404T020000\ +RDATE:19990u404xT020000\ +TZOFFSETFROM:-0500\ +TZOFFSETTO:-0400\ +END:STANDARD\ +BEGIN:DAYLIGHT\ +DTSTART:19990404T020000\ +RDATE:19990404T020000\ +TZOFFSETFROM:-0500\ +TZOFFSETTO:-0400\ +TZNAME:EDT\ +Dkjhgri:derhvnv;\ +BEGIN:dfkjh\ +END:dfdfkjh\ +END:DAYLIGHT\ +END:VTIMEZONE\ +BEGIN:VEVENT\ +GEO:Bongo\ +DTSTAMP:19980309T231000Z\ +UID:guid-1.host1.com\ +ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\ +ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP\ + :MAILTO:employee-A@host.com\ +DESCRIPTION:Project XYZ Review Meeting\ +CATEGORIES:MEETING\ +CLASS:PUBLIC\ +CREATED:19980309T130000Z\ +SUMMARY:XYZ Project Review\ +DTSTART;TZID=US-Eastern:19980312T083000\ +DTEND;TZID=US-Eastern:19980312T093000\ +LOCATION:1CP Conference Room 4350\ +END:VEVENT\ +END:VCALENDAR\ "; extern int yydebug; /* Have the parser fetch data from stdin */ -char* read_stdin(char *s, size_t size, void *d) +char* read_stream(char *s, size_t size, void *d) { - char *c = fgets(s,size, stdin); + char *c = fgets(s,size, (FILE*)d); return c; } -int main() + + +int main(int argc, char* argv[]) { - /* This is how we would have the parser parse a string */ - /* icalcomponent *c = icalparser_parse_string(str);*/ + int lineno = 0; + char* line; + FILE* stream; + icalcomponent *c; + icalparser *parser = icalparser_new(); - icalcomponent *c = icalparser_parse(read_stdin); + stream = fopen(argv[1],"r"); - printf("%s\n",icalcomponent_as_ical_string(c)); + assert(stream != 0); - /* Strip errors and spit it out again - printf("\n%d Errors in Component\n",icalcomponent_count_errors(c)); - icalcomponent_strip_errors(c); - printf("%s\n",icalcomponent_as_ical_string(c)); - */ + icalparser_set_gen_data(parser,stream); - icalmemory_free_ring(); - icalcomponent_free(c); + do{ + + line = icalparser_get_line(parser,read_stream); - return 1; -} + c = icalparser_add_line(parser,line); + if (c != 0){ + icalcomponent_convert_errors(c); + printf("%s",icalcomponent_as_ical_string(c)); + icalparser_claim(parser); + printf("\n---------------\n"); + icalcomponent_free(c); + } + + } while ( line != 0); + + +} diff --git a/libical/src/test/regression.c b/libical/src/test/regression.c index a969022d98..7b1606d432 100644 --- a/libical/src/test/regression.c +++ b/libical/src/test/regression.c @@ -43,94 +43,48 @@ /* This example creates and minipulates the ical object that appears * in rfc 2445, page 137 */ -/* - BEGIN:VCALENDAR - PRODID:-//RDU Software//NONSGML HandCal//EN - VERSION:2.0 - BEGIN:VTIMEZONE - TZID:US-Eastern - BEGIN:STANDARD - DTSTART:19981025T020000 - RDATE:19981025T020000 - TZOFFSETFROM:-0400 - TZOFFSETTO:-0500 - TZNAME:EST - END:STANDARD - BEGIN:DAYLIGHT - DTSTART:19990404T020000 - RDATE:19990404T020000 - TZOFFSETFROM:-0500 - TZOFFSETTO:-0400 - TZNAME:EDT - END:DAYLIGHT - END:VTIMEZONE - BEGIN:VEVENT - DTSTAMP:19980309T231000Z - UID:guid-1.host1.com - ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com - ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP: - MAILTO:employee-A@host.com - DESCRIPTION:Project XYZ Review Meeting - CATEGORIES:MEETING - CLASS:PUBLIC - CREATED:19980309T130000Z - SUMMARY:XYZ Project Review - DTSTART;TZID=US-Eastern:19980312T083000 - DTEND;TZID=US-Eastern:19980312T093000 - LOCATION:1CP Conference Room 4350 - END:VEVENT - END:VCALENDAR - -*/ -char str[] = "BEGIN:VCALENDAR -PRODID:\"-//RDU Software//NONSGML HandCal//EN\" -VERSION:2.0 -BEGIN:VTIMEZONE -TZID:US-Eastern -BEGIN:STANDARD -DTSTART:19981025T020000 -RDATE:19981025T020000 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:EST -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19990404T020000 -RDATE:19990404T020000 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:EDT -END:DAYLIGHT -END:VTIMEZONE -BEGIN:VEVENT -DTSTAMP:19980309T231000Z -UID:guid-1.host1.com -ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com -ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com -DESCRIPTION:Project XYZ Review Meeting -CATEGORIES:MEETING -CLASS:PUBLIC -CREATED:19980309T130000Z -SUMMARY:XYZ Project Review -DTSTART;TZID=US-Eastern:19980312T083000 -DTEND;TZID=US-Eastern:19980312T093000 -LOCATION:1CP Conference Room 4350 -END:VEVENT -BEGIN:BOOGA -DTSTAMP:19980309T231000Z -X-LIC-FOO:Booga -DTSTOMP:19980309T231000Z -UID:guid-1.host1.com -END:BOOGA +char str[] = "BEGIN:VCALENDAR\ +PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\ +VERSION:2.0\ +BEGIN:VTIMEZONE\ +TZID:US-Eastern\ +BEGIN:STANDARD\ +DTSTART:19981025T020000\ +RDATE:19981025T020000\ +TZOFFSETFROM:-0400\ +TZOFFSETTO:-0500\ +TZNAME:EST\ +END:STANDARD\ +BEGIN:DAYLIGHT\ +DTSTART:19990404T020000\ +RDATE:19990404T020000\ +TZOFFSETFROM:-0500\ +TZOFFSETTO:-0400\ +TZNAME:EDT\ +END:DAYLIGHT\ +END:VTIMEZONE\ +BEGIN:VEVENT\ +DTSTAMP:19980309T231000Z\ +UID:guid-1.host1.com\ +ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\ +ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com\ +DESCRIPTION:Project XYZ Review Meeting\ +CATEGORIES:MEETING\ +CLASS:PUBLIC\ +CREATED:19980309T130000Z\ +SUMMARY:XYZ Project Review\ +DTSTART;TZID=US-Eastern:19980312T083000\ +DTEND;TZID=US-Eastern:19980312T093000\ +LOCATION:1CP Conference Room 4350\ +END:VEVENT\ +BEGIN:BOOGA\ +DTSTAMP:19980309T231000Z\ +X-LIC-FOO:Booga\ +DTSTOMP:19980309T231000Z\ +UID:guid-1.host1.com\ +END:BOOGA\ END:VCALENDAR"; -void _test_string_line_generator(char* str); - -void test_string_line_generator() { - - _test_string_line_generator(str); - -} icalcomponent* create_simple_component() { @@ -611,9 +565,9 @@ void test_properties() icalparameter_new_cn("A Common Name 4"), 0); - for(param = icalproperty_get_first_parameter(prop,ICAL_ANY_PROPERTY); + for(param = icalproperty_get_first_parameter(prop,ICAL_ANY_PARAMETER); param != 0; - param = icalproperty_get_next_parameter(prop,ICAL_ANY_PROPERTY)) { + param = icalproperty_get_next_parameter(prop,ICAL_ANY_PARAMETER)) { printf("Prop parameter: %s\n",icalparameter_get_cn(param)); } @@ -811,17 +765,6 @@ void test_memory() } -int test_parser() -{ - - - icalcomponent *c = icalparser_parse_string(str); - printf("%s\n",icalcomponent_as_ical_string(c)); - icalcomponent_free(c); - icalmemory_free_ring(); - return 1; -} - int test_store() { @@ -1084,7 +1027,7 @@ void test_restriction() ICAL_VCALENDAR_COMPONENT, icalproperty_new_version("2.0"), icalproperty_new_prodid("-//RDU Software//NONSGML HandCal//EN"), - icalproperty_new_method(ICAL_METHOD_CANCEL), + icalproperty_new_method(ICAL_METHOD_REQUEST), icalcomponent_vanew( ICAL_VTIMEZONE_COMPONENT, icalproperty_new_tzid("US_Eastern"), @@ -1129,11 +1072,11 @@ void test_restriction() icalproperty_new_class("PUBLIC"), icalproperty_new_created(atime), icalproperty_new_summary("XYZ Project Review"), - icalproperty_vanew_dtstart( +/* icalproperty_vanew_dtstart( atime, icalparameter_new_tzid("US-Eastern"), 0 - ), + ),*/ icalproperty_vanew_dtend( atime, icalparameter_new_tzid("US-Eastern"), @@ -1273,35 +1216,89 @@ void test_strings(){ } -int main(int argc, char *argv[]) +void test_requeststat() { + icalrequeststatus s; + struct icalreqstattype st, st2; + char temp[1024]; + s = icalenum_num_to_reqstat(2,1); - printf("\n------------Test strings---------------\n"); - test_strings(); + assert(s == ICAL_2_1_FALLBACK_STATUS); -exit(0); + assert(icalenum_reqstat_major(s) == 2); + assert(icalenum_reqstat_minor(s) == 1); - printf("\n------------Test recur---------------\n"); - test_recur(); + printf("2.1: %s\n",icalenum_reqstat_desc(s)); -#if 0 - printf("\n------------Test Calendar---------------\n"); - test_calendar(); + st.code = s; + st.debug = "booga"; + st.desc = 0; - printf("\n------------Test Store---------------\n"); - test_store(); -#endif + printf("%s\n",icalreqstattype_as_string(st)); - printf("\n------------Test duration---------------\n"); - test_duration(); + st.desc = " A non-standard description"; + + printf("%s\n",icalreqstattype_as_string(st)); + st.desc = 0; + + sprintf(temp,"%s\n",icalreqstattype_as_string(st)); + + + st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values.;booga"); + + printf("%d -- %d -- %s -- %s\n",icalenum_reqstat_major(st2.code), + icalenum_reqstat_minor(st2.code), + icalenum_reqstat_desc(st2.code), + st2.debug); + + st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values.;booga"); + printf("%s\n",icalreqstattype_as_string(st2)); + + st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values.;"); + printf("%s\n",icalreqstattype_as_string(st2)); + + st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values."); + printf("%s\n",icalreqstattype_as_string(st2)); + + st2 = icalreqstattype_from_string("2.1;"); + printf("%s\n",icalreqstattype_as_string(st2)); + + st2 = icalreqstattype_from_string("2.1"); + printf("%s\n",icalreqstattype_as_string(st2)); + + st2 = icalreqstattype_from_string("16.4"); + assert(st2.code == ICAL_UNKNOWN_STATUS); + + st2 = icalreqstattype_from_string("1."); + assert(st2.code == ICAL_UNKNOWN_STATUS); + +} + + +int main(int argc, char *argv[]) +{ + printf("\n------------Test Restriction---------------\n"); test_restriction(); + exit(0); + printf("\n------------Test request status-------\n"); + test_requeststat(); + + + 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(); @@ -1324,9 +1321,6 @@ exit(0); printf("\n------------Create Components --------\n"); create_new_component(); - printf("\n------------Test Parser---------------\n"); - test_parser(); - printf("\n----- Create Components with vaargs ---\n"); create_new_component_with_va_args(); diff --git a/libical/src/test/storage.c b/libical/src/test/storage.c new file mode 100644 index 0000000000..f6d0dd69e5 --- /dev/null +++ b/libical/src/test/storage.c @@ -0,0 +1,460 @@ +/* -*- Mode: C -*- + ====================================================================== + FILE: usecases.c + CREATOR: eric 03 April 1999 + + DESCRIPTION: + + $Id$ + $Locker$ + + (C) COPYRIGHT 1999 Eric Busboom + http://www.softwarestudio.org + + The contents of this file are subject to the Mozilla Public License + Version 1.0 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + the License for the specific language governing rights and + limitations under the License. + + The original author is Eric Busboom + The original code is usecases.c + + + ======================================================================*/ + +#include "ical.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 "icalstore.h" +#include "icalcluster.h" +#include "icalerror.h" +#include "icalrestriction.h" +#include "icalcalendar.h" + +/* This example creates and minipulates the ical object that appears + * in rfc 2445, page 137 */ + +char str[] = "BEGIN:VCALENDAR\n\ +PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\n\ +VERSION:2.0\n\ +BEGIN:VTIMEZONE\n\ +TZID:US-Eastern\n\ +BEGIN:STANDARD\n\ +DTSTART:19981025T020000\n\ +RDATE:19981025T020000\n\ +TZOFFSETFROM:-0400\n\ +TZOFFSETTO:-0500\n\ +TZNAME:EST\n\ +END:STANDARD\n\ +BEGIN:DAYLIGHT\n\ +DTSTART:19990404T020000\n\ +RDATE:19990404T020000\n\ +TZOFFSETFROM:-0500\n\ +TZOFFSETTO:-0400\n\ +TZNAME:EDT\n\ +END:DAYLIGHT\n\ +END:VTIMEZONE\n\ +BEGIN:VEVENT\n\ +DTSTAMP:19980309T231000Z\n\ +UID:guid-1.host1.com\n\ +ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\n\ +ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com\n\ +DESCRIPTION:Project XYZ Review Meeting\n\ +CATEGORIES:MEETING\n\ +CLASS:PUBLIC\n\ +CREATED:19980309T130000Z\n\ +SUMMARY:XYZ Project Review\n\ +DTSTART;TZID=US-Eastern:19980312T083000\n\ +DTEND;TZID=US-Eastern:19980312T093000\n\ +LOCATION:1CP Conference Room 4350\n\ +END:VEVENT\n\ +BEGIN:BOOGA\n\ +DTSTAMP:19980309T231000Z\n\ +X-LIC-FOO:Booga\n\ +DTSTOMP:19980309T231000Z\n\ +UID:guid-1.host1.com\n\ +END:BOOGA\n\ +END:VCALENDAR"; + +char str2[] = "BEGIN:VCALENDAR\n\ +PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\n\ +VERSION:2.0\n\ +BEGIN:VEVENT\n\ +DTSTAMP:19980309T231000Z\n\ +UID:guid-1.host1.com\n\ +ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\n\ +ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com\n\ +DESCRIPTION:Project XYZ Review Meeting\n\ +CATEGORIES:MEETING\n\ +CLASS:PUBLIC\n\ +CREATED:19980309T130000Z\n\ +SUMMARY:XYZ Project Review\n\ +DTSTART;TZID=US-Eastern:19980312T083000\n\ +DTEND;TZID=US-Eastern:19980312T093000\n\ +LOCATION:1CP Conference Room 4350\n\ +END:VEVENT\n\ +END:VCALENDAR\n\ +"; + + +void test_cluster() +{ + icalcluster *cin, *cout; + int month = 0; + int count=0; + struct icaltimetype start, end; + icalcomponent *c,*clone, *itr; + + start = icaltimetype_from_timet( time(0),0); + end = start; + end.hour++; + + cout = icalcluster_new("clusterout.ics"); + assert(cout != 0); + + c = icalparser_parse_string(str2); + assert(c != 0); + + for(month = 1; month < 2; month++){ + icalcomponent *event; + icalproperty *dtstart, *dtend; + + cout = icalcluster_new("clusterout.ics"); + assert(cout != 0); + + start.month = month; + end.month = month; + + clone = icalcomponent_new_clone(c); + assert(clone !=0); + event = icalcomponent_get_first_component(clone,ICAL_VEVENT_COMPONENT); + assert(event != 0); + + dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY); + assert(dtstart!=0); + icalproperty_set_dtstart(dtstart,start); + + dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY); + assert(dtend!=0); + icalproperty_set_dtend(dtend,end); + + icalcluster_add_component(cout,clone); + icalcluster_commit(cout); + + icalcluster_free(cout); + + } + + + /* Print them out */ + + + cout = icalcluster_new("clusterout.ics"); + assert(cout != 0); + + for (itr = icalcluster_get_first_component(cout, + ICAL_ANY_COMPONENT); + itr != 0; + itr = icalcluster_get_next_component(cout, + ICAL_ANY_COMPONENT)){ + + icalcomponent *event; + icalproperty *dtstart, *dtend; + + count++; + + event = icalcomponent_get_first_component(itr,ICAL_VEVENT_COMPONENT); + + dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY); + dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY); + + printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart), + icalproperty_as_ical_string(dtend)); + + } + + /* Remove all of them */ + + icalcluster_free(cout); + + cout = icalcluster_new("clusterout.ics"); + assert(cout != 0); + + for (itr = icalcluster_get_first_component(cout, + ICAL_ANY_COMPONENT); + itr != 0; + itr = icalcluster_get_next_component(cout, + ICAL_ANY_COMPONENT)){ + + + icalcluster_remove_component(cout, itr); + } + + icalcluster_free(cout); + + + /* Print them out again */ + + cout = icalcluster_new("clusterout.ics"); + assert(cout != 0); + count =0; + + for (itr = icalcluster_get_first_component(cout, + ICAL_ANY_COMPONENT); + itr != 0; + itr = icalcluster_get_next_component(cout, + ICAL_ANY_COMPONENT)){ + + icalcomponent *event; + icalproperty *dtstart, *dtend; + + count++; + + event = icalcomponent_get_first_component(itr,ICAL_VEVENT_COMPONENT); + + dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY); + dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY); + + printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart), + icalproperty_as_ical_string(dtend)); + + } + + icalcluster_free(cout); + + +} + + + +int test_store() +{ + + icalcomponent *c, *gauge; + icalerrorenum error; + icalcomponent *next, *itr; + icalcluster* cluster; + struct icalperiodtype rtime; + icalstore *s = icalstore_new("store"); + int i; + + assert(s != 0); + + rtime.start = icaltimetype_from_timet( time(0),0); + + cluster = icalcluster_new("clusterout.ics"); + + assert(cluster != 0); + +#define NUMCOMP 4 + + /* Duplicate every component in the cluster NUMCOMP times */ + + icalerror_clear_errno(); + + for (i = 1; i<NUMCOMP+1; i++){ + + /*rtime.start.month = i%12;*/ + rtime.start.month = i; + rtime.end = rtime.start; + rtime.end.hour++; + + for (itr = icalcluster_get_first_component(cluster, + ICAL_ANY_COMPONENT); + itr != 0; + itr = icalcluster_get_next_component(cluster, + ICAL_ANY_COMPONENT)){ + icalcomponent *clone, *inner; + icalproperty *p; + + inner = icalcomponent_get_first_component(itr,ICAL_VEVENT_COMPONENT); + if (inner == 0){ + continue; + } + + /* Change the dtstart and dtend times in the component + pointed to by Itr*/ + + clone = icalcomponent_new_clone(itr); + inner = icalcomponent_get_first_component(itr,ICAL_VEVENT_COMPONENT); + + assert(icalerrno == ICAL_NO_ERROR); + assert(inner !=0); + + /* DTSTART*/ + p = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY); + assert(icalerrno == ICAL_NO_ERROR); + + if (p == 0){ + p = icalproperty_new_dtstart(rtime.start); + icalcomponent_add_property(inner,p); + } else { + icalproperty_set_dtstart(p,rtime.start); + } + assert(icalerrno == ICAL_NO_ERROR); + + /* DTEND*/ + p = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY); + assert(icalerrno == ICAL_NO_ERROR); + + if (p == 0){ + p = icalproperty_new_dtstart(rtime.end); + icalcomponent_add_property(inner,p); + } else { + icalproperty_set_dtstart(p,rtime.end); + } + assert(icalerrno == ICAL_NO_ERROR); + + printf("\n----------\n%s\n---------\n",icalcomponent_as_ical_string(inner)); + + error = icalstore_add_component(s,inner); + + assert(icalerrno == ICAL_NO_ERROR); + + } + + } + + gauge = + icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_summary( + "Submit Income Taxes", + icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_EQUAL), + 0), + 0), + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_summary( + "Bastille Day Party", + icalparameter_new_xliccomparetype(ICAL_XLICCOMPARETYPE_EQUAL), + 0), + 0), + 0); + +#if 0 + + + icalstore_select(s,gauge); + + for(c = icalstore_first(s); c != 0; c = icalstore_next(s)){ + + printf("Got one! (%d)\n", count++); + + if (c != 0){ + printf("%s", icalcomponent_as_ical_string(c));; + if (icalstore_store(s2,c) == 0){ + printf("Failed to write!\n"); + } + icalcomponent_free(c); + } else { + printf("Failed to get component\n"); + } + } + + + icalstore_free(s2); +#endif + + + for(c = icalstore_get_first_component(s); + c != 0; + c = next){ + + next = icalstore_get_next_component(s); + + if (c != 0){ + /*icalstore_remove_component(s,c);*/ + printf("%s", icalcomponent_as_ical_string(c));; + } else { + printf("Failed to get component\n"); + } + + + } + + icalstore_free(s); + return 0; +} + +void test_calendar() +{ + icalcomponent *comp; + icalcluster *c; + icalstore *s; + icalcalendar* calendar = icalcalendar_new("calendar"); + icalerrorenum error; + struct icaltimetype atime = icaltimetype_from_timet( time(0),0); + + comp = icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_new_version("2.0"), + icalproperty_new_description("This is an event"), + icalproperty_new_dtstart(atime), + icalproperty_vanew_comment( + "Another Comment", + icalparameter_new_cn("A Common Name 1"), + icalparameter_new_cn("A Common Name 2"), + icalparameter_new_cn("A Common Name 3"), + icalparameter_new_cn("A Common Name 4"), + 0), + icalproperty_vanew_xlicerror( + "This is only a test", + icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_COMPONENTPARSEERROR), + 0), + + 0); + + + s = icalcalendar_get_booked(calendar); + + error = icalstore_add_component(s,comp); + + assert(error == ICAL_NO_ERROR); + + c = icalcalendar_get_properties(calendar); + + error = icalcluster_add_component(c,icalcomponent_new_clone(comp)); + + assert(error == ICAL_NO_ERROR); + + icalcalendar_free(calendar); + +} + + +int main(int argc, char *argv[]) +{ + + + printf("\n------------Test Cluster---------------\n"); + test_cluster(); + +#if 0 + + printf("\n------------Test Store---------------\n"); + test_store(); + + + + printf("\n------------Test Calendar---------------\n"); + test_calendar(); + +#endif + + return 0; +} + + + diff --git a/libical/src/test/usecases.c b/libical/src/test/usecases.c index d07b5edac5..05c295197f 100644 --- a/libical/src/test/usecases.c +++ b/libical/src/test/usecases.c @@ -59,21 +59,22 @@ END:VCALENDAR */ -char str[] = "BEGIN:VCALENDAR -PRODID:\"-//RDU Software//NONSGML HandCal//EN\" -VERSION:2.0 -BEGIN:VEVENT -DTSTAMP:19980309T231000Z -UID:guid-1.host1.com -ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com -ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com -DESCRIPTION:Project XYZ Review Meeting -CATEGORIES:MEETING -CREATED:19980309T130000Z -SUMMARY:XYZ Project Review -DTSTART;TZID=US-Eastern:19980312T083000 -DTEND;TZID=US-Eastern:19980312T093000 -END:VEVENT + +char str[] = "BEGIN:VCALENDAR\ +PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\ +VERSION:2.0\ +BEGIN:VEVENT\ +DTSTAMP:19980309T231000Z\ +UID:guid-1.host1.com\ +ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\ +ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com\ +DESCRIPTION:Project XYZ Review Meeting\ +CATEGORIES:MEETING\ +CREATED:19980309T130000Z\ +SUMMARY:XYZ Project Review\ +DTSTART;TZID=US-Eastern:19980312T083000\ +DTEND;TZID=US-Eastern:19980312T093000\ +END:VEVENT\ END:VCALENDAR"; /* Creating iCal Components @@ -148,6 +149,9 @@ icalcomponent* create_new_component() If the routine returns a string ( "get" and "as_ical_string" ) The library owns the returned memory. + There are more rules, so refer to the documentation for more + details. + */ icalcomponent_add_property( @@ -515,18 +519,6 @@ void test_parameters() } -int test_parser() -{ - - - icalcomponent *c = icalparser_parse_string(str); - printf("%s\n",icalcomponent_as_ical_string(c)); - icalcomponent_free(c); - icalmemory_free_ring(); - return 1; -} - - int main(int argc, char *argv[]) { icalcomponent *c1; |