Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
regression.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ok(TEST, EX)   (_ok(TEST, EX, __FILE__, __LINE__, #EX))
#define is(S1, S2, EX)   (_is(S1, S2, EX, __FILE__, __LINE__))
#define int_is(I1, I2, EX)   (_int_is(I1, I2, EX, __FILE__, __LINE__))

Functions

void create_new_component (void)
void create_new_component_with_va_args (void)
void create_simple_component (void)
void test_icalcomponent_get_span (void)
 Test icalcomponent_get_span()
void test_classify (void)
void test_recur_file (void)
void test_cxx (void)
void test_fileset_extended (void)
void test_dirset_extended (void)
void test_bdbset (void)
const char * ical_timet_string (const time_t t)
const char * ictt_as_string (struct icaltimetype t)
char * icaltime_as_ctime (struct icaltimetype t)
void _ok (char *name, int result, char *file, int linenum, char *test)
void _is (char *test_name, const char *str1, const char *str2, char *file, int linenum)
void _int_is (char *test_name, int i1, int i2, char *file, int linenum)
void test_header (char *title, int test_set)
void test_start (int)
void test_end (void)
void test_run (char *test_name, void(*test_fcn)(void), int do_test, int headeronly)

Variables

int VERBOSE
int QUIET

Define Documentation

#define int_is (   I1,
  I2,
  EX 
)    (_int_is(I1, I2, EX, __FILE__, __LINE__))

Definition at line 40 of file regression.h.

#define is (   S1,
  S2,
  EX 
)    (_is(S1, S2, EX, __FILE__, __LINE__))

Definition at line 39 of file regression.h.

#define ok (   TEST,
  EX 
)    (_ok(TEST, EX, __FILE__, __LINE__, #EX))

Definition at line 38 of file regression.h.


Function Documentation

void _int_is ( char *  test_name,
int  i1,
int  i2,
char *  file,
int  linenum 
)

Definition at line 97 of file regression-utils.c.

                                                                       {
  _ok(test_name, (i1==i2), file, linenum, "");
  
  if (i1!=i2) {
    printf("#      got: %d\n", i1);
    printf("# expected: %d\n", i2);
  }
}

Here is the call graph for this function:

void _is ( char *  test_name,
const char *  str1,
const char *  str2,
char *  file,
int  linenum 
)

Definition at line 78 of file regression-utils.c.

                                                                                       {
  int diff;
  
  if (str1 == NULL || str2 == NULL) {
    diff = 1;
  } else {
    diff = strcmp(str1, str2);
  }

  if (!test_name) test_name = "()";

  _ok(test_name, (diff==0), file, linenum, "");
  
  if (diff) {
    printf("#      got: %s\n", str1 ? str1 : "(null)");
    printf("# expected: %s\n", str2 ? str2 : "(null)");
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void _ok ( char *  name,
int  result,
char *  file,
int  linenum,
char *  test 
)

Definition at line 59 of file regression-utils.c.

                                                                            {
  testnumber++;

  if (!QUIET || (QUIET && !success))
  printf("%sok %d - %s\n", (success)?"" : "not ", testnumber, test_name);
  if (!success) {
    failed_tests[failed].set  = current_set;
    failed_tests[failed].test = testnumber;
    failed++;

    printf("# test failed: \"%s\"\n", test);
    printf("#          at: %s:%-d\n", file, linenum);
  }

  if (die_on_errors == 1 && !success) {
    abort();
  }
}

Here is the caller graph for this function:

Definition at line 75 of file regression-component.c.

{
    icalcomponent* calendar;
    icalcomponent* timezone;
    icalcomponent* tzc;
    icalcomponent* event;
    struct icaltimetype atime = icaltime_from_timet( 1023398689, 0);
    struct icaldatetimeperiodtype rtime;
    icalproperty* property;
    char *calendar_as_string;

    rtime.period.start = icaltime_from_timet( 1023398689,0);
    rtime.period.end = icaltime_from_timet( 1023409689,0);
    rtime.period.end.hour++;
    rtime.time = icaltime_null_time();

    /* Create calendar and add properties */
    calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);

    
    icalcomponent_add_property(
       calendar,
       icalproperty_new_version("2.0")
       );
    
    icalcomponent_add_property(
       calendar,
       icalproperty_new_prodid("-//RDU Software//NONSGML HandCal//EN")
       );
    
    /* Create a timezone object and add it to the calendar */

    timezone = icalcomponent_new(ICAL_VTIMEZONE_COMPONENT);

    icalcomponent_add_property(
       timezone,
       icalproperty_new_tzid("America/New_York")
       );

    /* Add a sub-component of the timezone */
    tzc = icalcomponent_new(ICAL_XDAYLIGHT_COMPONENT);

    icalcomponent_add_property(
       tzc, 
       icalproperty_new_dtstart(atime)
       );

    icalcomponent_add_property(
       tzc, 
       icalproperty_new_rdate(rtime)
       );
           
    icalcomponent_add_property(
       tzc, 
       icalproperty_new_tzoffsetfrom(-5*3600)
       );

    icalcomponent_add_property(
       tzc, 
       icalproperty_new_tzoffsetto(-4*3600)
       );

    icalcomponent_add_property(
       tzc, 
       icalproperty_new_tzname("EST")
       );

    icalcomponent_add_component(timezone,tzc);

    icalcomponent_add_component(calendar,timezone);

    /* Add a second subcomponent */
    tzc = icalcomponent_new(ICAL_XSTANDARD_COMPONENT);

    icalcomponent_add_property(
       tzc, 
       icalproperty_new_dtstart(atime)
       );

    icalcomponent_add_property(
       tzc, 
       icalproperty_new_rdate(rtime)
       );
           
    icalcomponent_add_property(
       tzc, 
       icalproperty_new_tzoffsetfrom(-4*3600)
       );

    icalcomponent_add_property(
       tzc, 
       icalproperty_new_tzoffsetto(-5*3600)
       );

    icalcomponent_add_property(
       tzc, 
       icalproperty_new_tzname("EST")
       );

    icalcomponent_add_component(timezone,tzc);

    /* Add an event */

    event = icalcomponent_new(ICAL_VEVENT_COMPONENT);

    icalcomponent_add_property(
       event,
       icalproperty_new_dtstamp(atime)
       );

    icalcomponent_add_property(
       event,
       icalproperty_new_uid("guid-1.host1.com")
       );

    /* add a property that has parameters */
    property = icalproperty_new_organizer("mrbig@host.com");
    
    icalproperty_add_parameter(
       property,
       icalparameter_new_role(ICAL_ROLE_CHAIR)
       );

    icalcomponent_add_property(event,property);

    /* add another property that has parameters */
    property = icalproperty_new_attendee("employee-A@host.com");
    
    icalproperty_add_parameter(
       property,
       icalparameter_new_role(ICAL_ROLE_REQPARTICIPANT)
       );

    icalproperty_add_parameter(
       property,
       icalparameter_new_rsvp(ICAL_RSVP_TRUE)
       );

    icalproperty_add_parameter(
       property,
       icalparameter_new_cutype(ICAL_CUTYPE_GROUP)
       );

    icalcomponent_add_property(event,property);


    /* more properties */

    icalcomponent_add_property(
       event,
       icalproperty_new_description("Project XYZ Review Meeting")
       );

    icalcomponent_add_property(
       event,
       icalproperty_new_categories("MEETING")
       );

    icalcomponent_add_property(
       event,
       icalproperty_new_class(ICAL_CLASS_PRIVATE)
       );
    
    icalcomponent_add_property(
       event,
       icalproperty_new_created(atime)
       );

    icalcomponent_add_property(
       event,
       icalproperty_new_summary("XYZ Project Review")
       );


    property = icalproperty_new_dtstart(atime);
    
    icalproperty_add_parameter(
       property,
       icalparameter_new_tzid("America/New_York")
       );

    icalcomponent_add_property(event,property);


    property = icalproperty_new_dtend(atime);
    
    icalproperty_add_parameter(
       property,
       icalparameter_new_tzid("America/New_York")
       );

    icalcomponent_add_property(event,property);

    icalcomponent_add_property(
       event,
       icalproperty_new_location("1CP Conference Room 4350")
       );

    icalcomponent_add_component(calendar,event);
    
    calendar_as_string = icalcomponent_as_ical_string(calendar);

    is("build large, complex component", 
       calendar_as_string,
       create_new_component_str);

    if (VERBOSE && calendar)
      printf("%s\n",icalcomponent_as_ical_string(calendar));


    if (calendar)
      icalcomponent_free(calendar);

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 292 of file regression-component.c.

{

    icalcomponent* calendar;
    struct icaltimetype atime = icaltime_from_timet( time(0),0);
    struct icaldatetimeperiodtype rtime;
    
    rtime.period.start = icaltime_from_timet( time(0),0);
    rtime.period.end = icaltime_from_timet( time(0),0);
    rtime.period.end.hour++;
    rtime.time = icaltime_null_time();

    calendar = 
       icalcomponent_vanew(
           ICAL_VCALENDAR_COMPONENT,
           icalproperty_new_version("2.0"),
           icalproperty_new_prodid("-//RDU Software//NONSGML HandCal//EN"),
           icalcomponent_vanew(
              ICAL_VTIMEZONE_COMPONENT,
              icalproperty_new_tzid("America/New_York"),
              icalcomponent_vanew(
                  ICAL_XDAYLIGHT_COMPONENT,
                  icalproperty_new_dtstart(atime),
                  icalproperty_new_rdate(rtime),
                  icalproperty_new_tzoffsetfrom(-4.0),
                  icalproperty_new_tzoffsetto(-5.0),
                  icalproperty_new_tzname("EST"),
                  0
                  ),
              icalcomponent_vanew(
                  ICAL_XSTANDARD_COMPONENT,
                  icalproperty_new_dtstart(atime),
                  icalproperty_new_rdate(rtime),
                  icalproperty_new_tzoffsetfrom(-5.0),
                  icalproperty_new_tzoffsetto(-4.0),
                  icalproperty_new_tzname("EST"),
                  0
                  ),
              0
              ),
           icalcomponent_vanew(
              ICAL_VEVENT_COMPONENT,
              icalproperty_new_dtstamp(atime),
              icalproperty_new_uid("guid-1.host1.com"),
              icalproperty_vanew_organizer(
                  "mrbig@host.com",
                  icalparameter_new_role(ICAL_ROLE_CHAIR),
                  0
                  ),
              icalproperty_vanew_attendee(
                  "employee-A@host.com",
                  icalparameter_new_role(ICAL_ROLE_REQPARTICIPANT),
                  icalparameter_new_rsvp(ICAL_RSVP_TRUE),
                  icalparameter_new_cutype(ICAL_CUTYPE_GROUP),
                  0
                  ),
              icalproperty_new_description("Project XYZ Review Meeting"),
              icalproperty_new_categories("MEETING"),
              icalproperty_new_class(ICAL_CLASS_PUBLIC),
              icalproperty_new_created(atime),
              icalproperty_new_summary("XYZ Project Review"),
              icalproperty_vanew_dtstart(
                  atime,
                  icalparameter_new_tzid("America/New_York"),
                  0
                  ),
              icalproperty_vanew_dtend(
                  atime,
                  icalparameter_new_tzid("America/New_York"),
                  0
                  ),
              icalproperty_new_location("1CP Conference Room 4350"),
              0
              ),
           0
           );

    ok("creating a complex vcalendar", (calendar != NULL));
    if (VERBOSE && calendar)
      printf("%s\n",icalcomponent_as_ical_string(calendar));

    icalcomponent_free(calendar);

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 7 of file regression-component.c.

{

    icalcomponent* calendar;
    icalproperty *version, *bogus;
      
    /* Create calendar and add properties */
    calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);

    ok("create vcalendar component", (calendar!=NULL));

    icalcomponent_add_property(
       calendar,
       icalproperty_new_version("2.0")
       );
    
    version = icalcomponent_get_first_property(calendar,ICAL_VERSION_PROPERTY);
    ok("version property added", (version!=NULL));

    bogus = icalcomponent_get_first_property(calendar,ICAL_DTSTART_PROPERTY);
    ok("bogus dtstart not found", (bogus == NULL));

    if (VERBOSE && calendar)
      printf("%s\n",icalcomponent_as_ical_string(calendar));

    icalcomponent_free(calendar);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* ical_timet_string ( const time_t  t)

Definition at line 10 of file regression-utils.c.

{
    struct tm stm = *(gmtime(&t));    

    sprintf(ictt_str,"%02d-%02d-%02d %02d:%02d:%02d Z",stm.tm_year+1900,
           stm.tm_mon+1,stm.tm_mday,stm.tm_hour,stm.tm_min,stm.tm_sec);

    return ictt_str;
    
}

Here is the caller graph for this function:

char* icaltime_as_ctime ( struct icaltimetype  t)

Definition at line 36 of file regression-utils.c.

{
    time_t tt;
 
    tt = icaltime_as_timet(t);
    sprintf(ictt_str,"%s",ctime(&tt));

    return ictt_str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* ictt_as_string ( struct icaltimetype  t)

Definition at line 21 of file regression-utils.c.

{
    const char *zone = icaltimezone_get_tzid((icaltimezone *)t.zone);

    if (icaltime_is_utc(t))
       sprintf(ictt_str,"%02d-%02d-%02d %02d:%02d:%02d Z UTC",
       t.year,t.month,t.day, t.hour,t.minute,t.second);
    else
       sprintf(ictt_str,"%02d-%02d-%02d %02d:%02d:%02d %s",
       t.year,t.month,t.day, t.hour,t.minute,t.second,
       zone == NULL? "(floating)": zone);

    return ictt_str;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

eventually test this too..

Definition at line 84 of file regression-classify.c.

{
    icalcomponent *c,*match; 
    int i=0;
    int error_count = 0;
    /* Open up the two storage files, one for the incomming components, 
       one for the calendar */
    icalset* incoming = icalset_new_file("../../test-data/incoming.ics");
    icalset* cal = icalset_new_file("../../test-data/calendar.ics");
    icalset* f = icalset_new_file("../../test-data/classify.ics");

    ok("opening file classify.ics", (f!=0));
    ok("opening file calendar.ics", (cal!=0));
    ok("opening file incoming.ics", (incoming!=0));

    /* some basic tests.. */
    if (f) {
      c = icalset_get_first_component(f);
      match = icalset_get_next_component(f);
    
      ok("test two vcalendars for SEQUENCE with icalclassify()",
        (icalclassify(c,match,"A@example.com") == ICAL_XLICCLASS_REQUESTRESCHEDULE));
      
      icalset_free(f);
    }

    assert(incoming!= 0);
    assert(cal!=0);

    /* Iterate through all of the incoming components */
    for(c=icalset_get_first_component(incoming);c!=0;
       c=icalset_get_next_component(incoming)){
       
       icalproperty_xlicclass class;
       icalcomponent *match = 0;
        const char* this_uid;
       const char* this_note = get_note(c);
       const char* expected_result = get_expect(c);
       const char* actual_result;
       const char* match_note;
       char msg[128];

       i++;

        /* Check this component against the restrictions imposed by
           iTIP. An errors will be inserted as X-LIC-ERROR properties
           in the component. The Parser will also insert errors if it
           cannot parse the component */
        icalcomponent_check_restrictions(c);

        /* If there are any errors, print out the component */
       
       error_count = icalcomponent_count_errors(c);
       sprintf(msg, "%s - parsing", this_note);
       int_is(msg, error_count, 0);

       if (error_count !=0) {
         if (VERBOSE) printf("----- Component has errors ------- \n%s-----------------\n",
                           icalcomponent_as_ical_string(c));
        }

        /* Use one of the icalcomponent convenience routines to get
           the UID. This routine will save you from having to use
           icalcomponent_get_inner(),
           icalcomponent_get_first_property(), checking the return
           value, and then calling icalproperty_get_uid. There are
           several other convenience routines for DTSTART, DTEND,
           DURATION, SUMMARY, METHOD, and COMMENT */
       this_uid = icalcomponent_get_uid(c);

        if(this_uid != 0){
            /* Look in the calendar for a component with the same UID
               as the incomming component. We should reall also be
               checking the RECURRENCE-ID. Another way to do this
               operation is to us icalset_find_match(), which does use
               the RECURRENCE-ID. */
            match = icalset_fetch(cal,this_uid);
        }

       
        /* Classify the incoming component. The third argument is the
           calid of the user who owns the calendar. In a real program,
           you would probably switch() on the class.*/
       class = icalclassify(c,match,"A@example.com");
        match_note = get_note(match);
       actual_result = icalproperty_enum_to_string(class);
       sprintf(msg, "expecting %s", expected_result);
       is(msg, expected_result, actual_result);

       if (VERBOSE) printf("Test %d\n\
Incoming:      %s\n\
Matched:       %s\n\
Classification: %s\n\n",
               i,this_note,get_note(match),
               icalproperty_enum_to_string(class));     
    }

       icalset_free(incoming);
       icalset_free(cal);

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 19 of file regression-cxx.cpp.

{
    ICalProperty            *summProp  = new ICalProperty(ICAL_SUMMARY_PROPERTY);
    ICalProperty            *startProp = new ICalProperty(ICAL_DTSTART_PROPERTY);
    ICalProperty            *endProp   = new ICalProperty(ICAL_DTEND_PROPERTY);
    ICalProperty         *locationProp = new ICalProperty(ICAL_LOCATION_PROPERTY);
    ICalProperty            *descProp = new ICalProperty(ICAL_DESCRIPTION_PROPERTY);

    ok("Valid SUMMARY     Property", (summProp != 0));
    ok("Valid DTSTART     Property", (startProp != 0));
    ok("Valid DTEND       Property", (endProp != 0));
    ok("Valid LOCATION    Property", (locationProp != 0));
    ok("Valid DESCRIPTION Property", (descProp != 0));

    struct icaltimetype     starttime  = icaltime_from_string("20011221T180000Z");   // UTC time ends in Z
    struct icaltimetype     endtime    = icaltime_from_string("20020101T080000Z");   // UTC time ends in Z

    summProp->set_summary("jon said: change dir to c:\\rest\\test\\nest to get the file called <foo.dat>\nthis should be in the next line.");
    startProp->set_dtstart(starttime);
    endProp->set_dtend(endtime);
    locationProp->set_location("SF, California; Seattle, Washington");
    descProp->set_description("The best cities on the west coast, hit 'NO' if you don't agree!\n");

    VEvent *vEvent = new VEvent();

    ok("Create a new VEvent", (vEvent!=0));

    vEvent->add_property(summProp);
    vEvent->add_property(startProp);
    vEvent->add_property(endProp);
    vEvent->add_property(locationProp);
    vEvent->add_property(descProp);
 
    // 
    is ("vEvent->get_summary()", 
       vEvent->get_summary(), 
       "jon said: change dir to c:\\rest\\test\\nest to get the file called <foo.dat>\nthis should be in the next line.");

    is ("vEvent->get_dtstart()",
       icaltime_as_ical_string(vEvent->get_dtstart()),
       "20011221T180000Z");

    is ("vEvent->get_dtend()",
       icaltime_as_ical_string(vEvent->get_dtend()),
       "20020101T080000Z");

    ok ("vEvent->as_ical_string()",
       (vEvent->as_ical_string() != 0));

    if (VERBOSE) {
      printf("Summary: %s\n", vEvent->get_summary());
      printf("DTSTART: %s\n",  icaltime_as_ical_string(vEvent->get_dtstart()));
      printf("DTEND: %s\n",   icaltime_as_ical_string(vEvent->get_dtend()));
      printf("LOCATION: %s\n", vEvent->get_location());
      printf("DESCRIPTION: %s\n", vEvent->get_description());
      
      printf("vcomponent: %s", vEvent->as_ical_string());
    }

    VComponent ic(icalparser_parse_string((const char*)content));
    ok("Parsing component", (ic.is_valid()));

    if (VERBOSE)
      printf("%s\n", ic.as_ical_string());

    // component is wrapped within BEGIN:VCALENDAR END:VCALENDAR
    // we need to unwrap it.

    VEvent* sub_ic = dynamic_cast<VEvent*>(ic.get_first_component(ICAL_VEVENT_COMPONENT));

    int_is("Getting VEvent subcomponent", 
       sub_ic->isa(),
       ICAL_VEVENT_COMPONENT);

    while (sub_ic != NULL) {
      if (VERBOSE)
       printf("subcomponent: %s\n", sub_ic->as_ical_string());
      
      sub_ic = dynamic_cast<VEvent*>(ic.get_next_component(ICAL_VEVENT_COMPONENT));
    }

    VCalendar* cal = new VCalendar();
    VAgenda* vAgenda = new VAgenda();

    ok("Create a new VCalendar object", (cal != 0));
    ok("Create a new VAgenda object", (vAgenda != 0));

    ICalProperty* prop = new ICalProperty(ICAL_OWNER_PROPERTY);
    prop->set_owner("fred@flintstone.net");
    vAgenda->add_property(prop);

    prop = new ICalProperty(ICAL_SUMMARY_PROPERTY);
    prop->set_summary("CPMain");
    vAgenda->add_property(prop);

    prop = new ICalProperty(ICAL_TZID_PROPERTY);
    prop->set_tzid("America/Los_Angeles");
    vAgenda->add_property(prop);

    cal->add_component(vAgenda);

    ok("Complex VCALENDAR/VAGENDA", (cal->as_ical_string() != 0));

    if (VERBOSE)
      printf("vAgenda: %s\n", cal->as_ical_string());

    int caughtException = 0;
    try {
      string foo = "HFHFHFHF";
      VComponent v = VComponent(foo);
    } catch (icalerrorenum err) {
           if (err == ICAL_BADARG_ERROR) {
                  caughtException = 1;
            }
    }
    int_is("Testing exception handling", caughtException, 1);

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 656 of file regression-storage.c.

{

    icalcomponent *c;
    icalgauge *gauge;
    icalerrorenum error;
    icalcomponent *itr;
    icalset* cluster;
    struct icalperiodtype rtime;
    icalset *s = icaldirset_new("store");
    icalset *s2 = icaldirset_new("store-new");
    int i, count = 0;

    ok("Open dirset 'store'", (s!=0));
    assert(s != 0);

    rtime.start = icaltime_from_timet( time(0),0);

    cluster = icalfileset_new(OUTPUT_FILE);

    ok("Open fileset to duplicate 4 times", (cluster != 0));
    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 = icalfileset_get_first_component(cluster);
            itr != 0;
            itr = icalfileset_get_next_component(cluster)){
           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);

           ok("Duplicating component...", 
              (icalerrno == ICAL_NO_ERROR)&&(inner!=0));

           assert(icalerrno == ICAL_NO_ERROR);
           assert(inner !=0);

           /* DTSTART*/
           p = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY);
           ok("Fetching DTSTART", (icalerrno == ICAL_NO_ERROR));
           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);
           }

           ok("Adding DTSTART property", (icalerrno == ICAL_NO_ERROR));
           assert(icalerrno  == ICAL_NO_ERROR);

           /* DTEND*/
           p = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY);
           ok("Fetching DTEND property", (icalerrno == ICAL_NO_ERROR));
           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);
           }
           ok("Setting DTEND property", (icalerrno == ICAL_NO_ERROR));
           assert(icalerrno  == ICAL_NO_ERROR);
           
           if (VERBOSE)
             printf("\n----------\n%s\n---------\n",icalcomponent_as_ical_string(inner));

           error = icaldirset_add_component(s,
                                        icalcomponent_new_clone(itr));
           
           ok("Adding component to dirset", (icalerrno == ICAL_NO_ERROR));
           assert(icalerrno  == ICAL_NO_ERROR);
       }

    }
    
    gauge = icalgauge_new_from_sql("SELECT * FROM VEVENT WHERE VEVENT.SUMMARY = 'Submit Income Taxes' OR VEVENT.SUMMARY = 'Bastille Day Party'", 0);

    ok("Creating complex Gauge", (gauge!=0));

    icaldirset_select(s,gauge);

    for(c = icaldirset_get_first_component(s); c != 0; 
       c = icaldirset_get_next_component(s)){
       
       printf("Got one! (%d)\n", count++);
       
       if (c != 0){
           printf("%s", icalcomponent_as_ical_string(c));;
           if (icaldirset_add_component(s2,c) == 0){
              printf("Failed to write!\n");
           }
           icalcomponent_free(c);
       } else {
           printf("Failed to get component\n");
       }
    }

    icalset_free(s2);

    for(c = icaldirset_get_first_component(s); 
       c != 0; 
       c = icaldirset_get_next_component(s)){

       if (c != 0){
           printf("%s", icalcomponent_as_ical_string(c));;
       } else {
           printf("Failed to get component\n");
       }

    }

    /* Remove all of the components */
    i=0;
    while((c=icaldirset_get_current_component(s)) != 0 ){
       i++;

       icaldirset_remove_component(s,c);
    }
       

    icalset_free(s);
    icalset_free(cluster);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 127 of file regression-utils.c.

                    {
  int pct;

  if (failed) {
    int i, oldset = 0;
    
    pct = ((testnumber - failed)*100)/testnumber;
    printf("\n        Failed %d/%d tests, %2d%% okay\n", failed, testnumber, pct);
    printf("\n        Failed tests:\n          ");
    for (i = 0; i < failed; i++) {
      int this_set = failed_tests[i].set;
      char *prefix = "";
      if (this_set != oldset) {
       prefix = "\n          ";
       oldset = this_set;
      }
      
      printf("%s%d/%d ", prefix, this_set, failed_tests[i].test);
    }
    printf("\n");
      
  } else {
    printf("\n        All Tests Successful.\n");
  }
}

Here is the caller graph for this function:

Definition at line 137 of file regression-storage.c.

{
    icalset *cout;
    int month = 0;
    int count=0;
    struct icaltimetype start, end;
    icalcomponent *c,*clone, *itr;
    icalsetiter iter;

    start = icaltime_from_timet( time(0),0);
    end = start;
    end.hour++;

    cout = icalfileset_new(OUTPUT_FILE);
    ok("Opening output file", (cout != 0));
    assert(cout!=0);

    c = icalparser_parse_string(str2);
    ok("Parsing str2", (c!=0));
    assert(c != 0);

    icalset_free(cout);

    /* Add data to the file */

    for(month = 1; month < 10; month++){
       icalcomponent *event;
       icalproperty *dtstart, *dtend;

        cout = icalfileset_new(OUTPUT_FILE);
       ok("Opening output file", (cout != 0));
        assert(cout != 0);

       start.month = month; 
       end.month = month;
       
       clone = icalcomponent_new_clone(c);
       ok("Making clone of output file", (clone!=0));
       assert(clone !=0);

       event = icalcomponent_get_first_component(clone,ICAL_VEVENT_COMPONENT);
       ok("Getting first event from clone", (event!=0));
       assert(event != 0);

       dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
       ok("find DTSTART", (dtstart !=0));
       assert(dtstart!=0);

       icalproperty_set_dtstart(dtstart,start);
        
       dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
       ok("find DTEND", (dtend !=0));

       assert(dtend!=0);

       icalproperty_set_dtend(dtend,end);
       
       icalfileset_add_component(cout,clone);
       icalfileset_commit(cout);

        icalset_free(cout);
    }

    /* Print them out */

    cout = icalfileset_new(OUTPUT_FILE);

    ok("Opening output file", (cout != 0));
    assert(cout != 0);
    
    for (iter = icalfileset_begin_component(cout, ICAL_ANY_COMPONENT, 0);
         icalsetiter_deref(&iter) != 0; icalsetiter_next(&iter)) {
      icalcomponent *event;
      icalproperty *dtstart, *dtend;

      itr = icalsetiter_deref(&iter);
      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);
      
      if (VERBOSE)
       printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart),
              icalproperty_as_ical_string(dtend));

    }

    /* Remove all of them */

    icalset_free(cout);

    cout = icalfileset_new(OUTPUT_FILE);
    ok("Opening output file", (cout!=0));
    assert(cout != 0);

    /* need to advance the iterator first before calling remove_componenet() */
    /* otherwise, iter will contain a "removed" component and icalsetiter_next(&iter) */
    /* will fail. */

    iter = icalfileset_begin_component(cout, ICAL_ANY_COMPONENT, 0);
    itr = icalsetiter_deref(&iter);
    while (itr != 0) {
        icalsetiter_next(&iter);
        icalfileset_remove_component(cout, itr);
       icalcomponent_free(itr);
        itr = icalsetiter_deref(&iter);
    }
    
    icalset_free(cout);

    /* Print them out again */

    cout = icalfileset_new(OUTPUT_FILE);
    ok("Opening output file", (cout != 0));
    assert(cout != 0);
    count =0;
    
    for (itr = icalfileset_get_first_component(cout);
         itr != 0;
         itr = icalfileset_get_next_component(cout)){

      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));

    }

    icalset_free(cout);
    icalcomponent_free(c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void test_header ( char *  title,
int  test_set 
)

Definition at line 121 of file regression-utils.c.

                                        {
  if (!QUIET)
  printf("########## %-40s (%d) ##########\n", header, set);
  current_set = set;
}

Here is the caller graph for this function:

Test icalcomponent_get_span()

test 0 Direct assigning time_t means they will be interpreted as UTC

test 1 We specify times in a timezone, the returned span is in UTC

test 2 We specify times as floating, the returned span is in UTC with no conversion applied - so result should be as test 0

test 3 We specify times in a timezone, the returned span is in UTC

test 4 We specify times in two different timezones, the returned span is in UTC

test 5 We specify start time in a timezone and a duration, the returned span is in UTC

test 6 We specify only start time, should return a null span with no error

test 7 We specify start and end date

test 8 We specify start and end date

test 9 We specify start date

Definition at line 394 of file regression-component.c.

{
    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;
    icaltimezone *azone, *bzone; 
    int       tnum = 0;

    span.start = tm1;
    span.end = tm2;
    if (VERBOSE) print_span(tnum++,span);

    azone = icaltimezone_get_builtin_timezone("America/Los_Angeles");
    c = icalcomponent_vanew(
           ICAL_VEVENT_COMPONENT,
              icalproperty_vanew_dtstart(
                  icaltime_from_timet_with_zone(tm1,0,azone),
                  icalparameter_new_tzid("America/Los_Angeles"),0),
              icalproperty_vanew_dtend(
                  icaltime_from_timet_with_zone(tm2,0,azone),
                  icalparameter_new_tzid("America/Los_Angeles"),0),
           0
           );

    span = icalcomponent_get_span(c);
    if (VERBOSE) print_span(tnum++,span);
    int_is("America/Los_Angeles", span.start, 973407600);
    icalcomponent_free(c);

    c = icalcomponent_vanew(
           ICAL_VEVENT_COMPONENT,
           icalproperty_vanew_dtstart(icaltime_from_timet(tm1,0),0),
           icalproperty_vanew_dtend(icaltime_from_timet(tm2,0),0),
           0
           );

    span = icalcomponent_get_span(c);
    if (VERBOSE) print_span(tnum++,span);
    int_is("floating time", span.start, tm1);

    icalcomponent_free(c);

    azone = icaltimezone_get_builtin_timezone("America/New_York");
    c = icalcomponent_vanew(
           ICAL_VEVENT_COMPONENT,
              icalproperty_vanew_dtstart(
                  icaltime_from_timet_with_zone(tm1,0,azone),
                  icalparameter_new_tzid("America/New_York"),0),
              icalproperty_vanew_dtend(
                  icaltime_from_timet_with_zone(tm2,0,azone),
                  icalparameter_new_tzid("America/New_York"),0),
           0
           );

    span = icalcomponent_get_span(c);
    if (VERBOSE) print_span(tnum++,span);
    int_is("America/New_York", span.start, 973396800);

    icalcomponent_free(c);

    azone = icaltimezone_get_builtin_timezone("America/New_York");
    bzone = icaltimezone_get_builtin_timezone("America/Los_Angeles");
    c = icalcomponent_vanew(
           ICAL_VEVENT_COMPONENT,
              icalproperty_vanew_dtstart(
                  icaltime_from_timet_with_zone(tm1,0,azone),
                  icalparameter_new_tzid("America/New_York"),0),
              icalproperty_vanew_dtend(
                  icaltime_from_timet_with_zone(tm2,0,bzone),
                  icalparameter_new_tzid("America/Los_Angeles"),0),
           0
           );

    span = icalcomponent_get_span(c);
    if (VERBOSE) print_span(tnum++,span);
    int_is("America/New_York", span.start, 973396800);
    
    icalcomponent_free(c);

    azone = icaltimezone_get_builtin_timezone("America/Los_Angeles");
    memset(&dur,0,sizeof(dur));
    dur.minutes = 30;
    c = icalcomponent_vanew(
           ICAL_VEVENT_COMPONENT,
              icalproperty_vanew_dtstart(
                  icaltime_from_timet_with_zone(tm1,0,azone),
                  icalparameter_new_tzid("America/Los_Angeles"),0),
           icalproperty_new_duration(dur),

           0
           );

    span = icalcomponent_get_span(c);
    if (VERBOSE) print_span(tnum++,span);
    int_is("America/Los_Angeles w/ duration", span.end, 973409400);

    icalcomponent_free(c);

    icalerror_errors_are_fatal = 0;
    c = icalcomponent_vanew(
           ICAL_VEVENT_COMPONENT,
              icalproperty_new_dtstart(icaltime_from_timet(tm1,0)),
           0
           );

    span = icalcomponent_get_span(c);
    if (VERBOSE) print_span(tnum++,span);
    int_is("null span", span.start, 0);
    icalcomponent_free(c);

    c = icalcomponent_vanew(
           ICAL_VEVENT_COMPONENT,
              icalproperty_new_dtstart(icaltime_from_timet(tm1,1)),
              icalproperty_new_dtend(icaltime_from_timet(tm1,1)),
           0
           );

    span = icalcomponent_get_span(c);
    if (VERBOSE) print_span(tnum++,span);
    int_is("UTC", span.start, 973296000);
    icalcomponent_free(c);

    c = icalcomponent_vanew(
           ICAL_VEVENT_COMPONENT,
              icalproperty_new_dtstart(icaltime_from_timet(tm1,1)),
              icalproperty_new_dtend(icaltime_from_timet(tm2,1)),
           0
           );

    span = icalcomponent_get_span(c);
    int_is("UTC #2", span.start, 973296000);
    if (VERBOSE) print_span(tnum++,span);

    icalcomponent_free(c);

    c = icalcomponent_vanew(
           ICAL_VEVENT_COMPONENT,
              icalproperty_new_dtstart(icaltime_from_timet(tm1,1)),
           0
           );

    span = icalcomponent_get_span(c);
    if (VERBOSE) print_span(tnum++,span);
    int_is("start date only", span.end, 973382399);

    icalcomponent_free(c);

    /* assert(icalerrno == ICAL_MALFORMEDDATA_ERROR); */
    icalerror_errors_are_fatal = 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 91 of file regression-recur.c.

{
    icalset *cin = 0;
    struct icaltimetype next;
    icalcomponent *itr;
    icalproperty *desc, *dtstart, *rrule;
    struct icalrecurrencetype recur;
    icalrecur_iterator* ritr;
    time_t tt;
    char* file; 
    int num_recurs_found = 0;
       
    icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL);
       
#ifndef WIN32
    signal(SIGALRM,sig_alrm);
#endif
    file = getenv("ICAL_RECUR_FILE");
    if (!file)
      file = "../../test-data/recur.txt";
       
#ifndef WIN32
    alarm(15); /* to get file lock */
#endif
    cin = icalfileset_new(file);
#ifndef WIN32
    alarm(0);
#endif
       
    ok("opening file with recurring events", (cin!=NULL));
    assert(cin!=NULL);
       
    for (itr = icalfileset_get_first_component(cin);
       itr != 0;
       itr = icalfileset_get_next_component(cin)){
      int badcomp = 0;
      int expected_events = 0;
      char msg[128];


      struct icaltimetype start = icaltime_null_time();
      struct icaltimetype startmin = icaltime_from_timet(1,0);
      struct icaltimetype endmax = icaltime_null_time();
      const char *desc_str = "malformed component";

      desc = icalcomponent_get_first_property(itr,ICAL_DESCRIPTION_PROPERTY);
      dtstart = icalcomponent_get_first_property(itr,ICAL_DTSTART_PROPERTY);
      rrule = icalcomponent_get_first_property(itr,ICAL_RRULE_PROPERTY);
      if (desc) {
       desc_str = icalproperty_get_description(desc);
      }
      
      ok((char*)desc_str, !(desc == 0 || dtstart == 0 || rrule == 0));

      if (desc == 0 || dtstart == 0 || rrule == 0) {
       badcomp = 1;
       if (VERBOSE) {
         printf("\n******** Error in input component ********\n");
         printf("The following component is malformed:\n %s\n", desc_str);
       }
       continue;
      }
      if (VERBOSE) {
       printf("\n\n#### %s\n",desc_str);
       printf("#### %s\n",icalvalue_as_ical_string(icalproperty_get_value(rrule)));
      }
      
      recur = icalproperty_get_rrule(rrule);
      start = icalproperty_get_dtstart(dtstart);
      
      ritr = icalrecur_iterator_new(recur,start);
      
      tt = icaltime_as_timet(start);
      
      if (VERBOSE)
       printf("#### %s\n",ctime(&tt ));
      
      icalrecur_iterator_free(ritr);
      
      for(ritr = icalrecur_iterator_new(recur,start),
           next = icalrecur_iterator_next(ritr); 
         !icaltime_is_null_time(next);
         next = icalrecur_iterator_next(ritr)){
       
       tt = icaltime_as_timet(next);
       
       if (VERBOSE)
         printf("  %s",ctime(&tt ));             
       
      }

      icalrecur_iterator_free(ritr);
      num_recurs_found = 0;
      expected_events = get_expected_numevents(itr);

      icalcomponent_foreach_recurrence(itr, startmin, endmax, 
                                   recur_callback, &num_recurs_found);
      
      sprintf(msg,"   expecting total of %d events", expected_events);
      int_is(msg, num_recurs_found, expected_events);
    }
    
    icalset_free(cin);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void test_run ( char *  test_name,
void(*)(void test_fcn,
int  do_test,
int  headeronly 
)

Definition at line 154 of file regression-utils.c.

{
  static int test_set = 1;

  if (headeronly || do_test == 0 || do_test == test_set)
    test_header(test_name, test_set);
  
  if (!headeronly && (do_test==0 || do_test == test_set)) {
    (*test_fcn)();
    if (!QUIET)
    printf("\n");
  }
  test_set++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 111 of file regression-utils.c.

                              {
  if (numtests) {
    if (!QUIET)
    printf("1..%-d\n", numtests);
  } else {
    if (!QUIET)
    printf("1..\n");
  }
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 8 of file regression-utils.c.

Definition at line 7 of file regression-utils.c.