END_TEST


START_TEST (test_ModelHistory_setModifiedDate1)
{
  ModelHistory_t * mh = ModelHistory_create();
  fail_unless(mh != NULL);

  Date_t *date = Date_createFromString("2005-12-30T12:15:32+02:00");

  int i = ModelHistory_setModifiedDate(mh, date);

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless(ModelHistory_isSetModifiedDate(mh) == 1);

  fail_unless(date != ModelHistory_getModifiedDate(mh));

  const char * dateChar
    = Date_getDateAsString(ModelHistory_getModifiedDate(mh));
  fail_unless(!strcmp(dateChar, "2005-12-30T12:15:32+02:00"));

  i = ModelHistory_setModifiedDate(mh, NULL);

  fail_unless( i == LIBSBML_OPERATION_FAILED );
  fail_unless(ModelHistory_isSetModifiedDate(mh) == 1);

  Date_free(date);
  ModelHistory_free(mh);
}
예제 #2
0
END_TEST


START_TEST (test_ModelHistory_setModifiedDate)
{
  ModelHistory_t * history = ModelHistory_create();

  fail_unless(history != NULL);
  fail_unless(ModelHistory_isSetModifiedDate(history) == 0);

  Date_t * date = Date_createFromValues(2005, 12, 30, 12, 15, 45, 1, 2, 0);
  
  ModelHistory_setModifiedDate(history, date);
  Date_free(date);
  fail_unless(ModelHistory_isSetModifiedDate(history) == 1);

  Date_t * newdate = ModelHistory_getModifiedDate(history);
  fail_unless(Date_getYear(newdate) == 2005);
  fail_unless(Date_getMonth(newdate) == 12);
  fail_unless(Date_getDay(newdate) == 30);
  fail_unless(Date_getHour(newdate) == 12);
  fail_unless(Date_getMinute(newdate) == 15);
  fail_unless(Date_getSecond(newdate) == 45);
  fail_unless(Date_getSignOffset(newdate) == 1);
  fail_unless(Date_getHoursOffset(newdate) == 2);
  fail_unless(Date_getMinutesOffset(newdate) == 0);

  ModelHistory_free(history);
}
예제 #3
0
END_TEST


START_TEST (test_ModelHistory_addModifiedDate)
{
  ModelHistory_t * history = ModelHistory_create();

  fail_unless(history != NULL);
  fail_unless(ModelHistory_isSetModifiedDate(history) == 0);
  fail_unless(ModelHistory_getNumModifiedDates(history) == 0);

  Date_t * date = Date_createFromValues(2005, 12, 30, 12, 15, 45, 1, 2, 0);
  
  ModelHistory_addModifiedDate(history, date);
  Date_free(date);

  fail_unless(ModelHistory_getNumModifiedDates(history) == 1);
  fail_unless(ModelHistory_isSetModifiedDate(history) == 1);

  Date_t * newdate = (Date_t *) List_get(ModelHistory_getListModifiedDates(history), 0);

  fail_unless(Date_getYear(newdate) == 2005);
  fail_unless(Date_getMonth(newdate) == 12);
  fail_unless(Date_getDay(newdate) == 30);
  fail_unless(Date_getHour(newdate) == 12);
  fail_unless(Date_getMinute(newdate) == 15);
  fail_unless(Date_getSecond(newdate) == 45);
  fail_unless(Date_getSignOffset(newdate) == 1);
  fail_unless(Date_getHoursOffset(newdate) == 2);
  fail_unless(Date_getMinutesOffset(newdate) == 0);

  Date_t * date1 = Date_createFromValues(2008, 11, 2, 16, 42, 40, 1, 2, 0);
  
  ModelHistory_addModifiedDate(history, date1);
  Date_free(date1);

  fail_unless(ModelHistory_getNumModifiedDates(history) == 2);
  fail_unless(ModelHistory_isSetModifiedDate(history) == 1);

  Date_t * newdate1 = ModelHistory_getModifiedDateFromList(history, 1);

  fail_unless(Date_getYear(newdate1) == 2008);
  fail_unless(Date_getMonth(newdate1) == 11);
  fail_unless(Date_getDay(newdate1) == 2);
  fail_unless(Date_getHour(newdate1) == 16);
  fail_unless(Date_getMinute(newdate1) == 42);
  fail_unless(Date_getSecond(newdate1) == 40);
  fail_unless(Date_getSignOffset(newdate1) == 1);
  fail_unless(Date_getHoursOffset(newdate1) == 2);
  fail_unless(Date_getMinutesOffset(newdate1) == 0);

  ModelHistory_free(history);
}
예제 #4
0
END_TEST

START_TEST (test_ModelHistory_accessWithNULL)
{
	fail_unless ( ModelHistory_addCreator(NULL, NULL) == LIBSBML_INVALID_OBJECT );
	fail_unless ( ModelHistory_addModifiedDate(NULL, NULL) == LIBSBML_INVALID_OBJECT );
	fail_unless ( ModelHistory_clone(NULL) == NULL );

	// ensure that we don't crash
    ModelHistory_free(NULL) ;

	fail_unless ( ModelHistory_getCreatedDate(NULL) == NULL );
	fail_unless ( ModelHistory_getCreator(NULL, 0) == NULL );
	fail_unless ( ModelHistory_getListCreators(NULL) == NULL );
	fail_unless ( ModelHistory_getListModifiedDates(NULL) == NULL );
	fail_unless ( ModelHistory_getModifiedDate(NULL) == NULL );
	fail_unless ( ModelHistory_getModifiedDateFromList(NULL, 0) == NULL );
	fail_unless ( ModelHistory_getNumCreators(NULL) == SBML_INT_MAX );
	fail_unless ( ModelHistory_getNumModifiedDates(NULL) == SBML_INT_MAX );
	fail_unless ( ModelHistory_hasRequiredAttributes(NULL) == 0 );
	fail_unless ( ModelHistory_isSetCreatedDate(NULL) == 0 );
	fail_unless ( ModelHistory_isSetModifiedDate(NULL) == 0 );
	fail_unless ( ModelHistory_setCreatedDate(NULL, NULL) == LIBSBML_INVALID_OBJECT );
	fail_unless ( ModelHistory_setModifiedDate(NULL, NULL) == LIBSBML_INVALID_OBJECT );

}
END_TEST


START_TEST (test_ModelHistory_setModifiedDate2)
{
  ModelHistory_t * mh = ModelHistory_create();
  fail_unless(mh != NULL);

  Date_t *date = Date_createFromValues(200, 13, 76, 56, 89, 90, 0, 0, 0);

  int i = ModelHistory_setModifiedDate(mh, date);

  fail_unless( i == LIBSBML_INVALID_OBJECT );
  fail_unless(ModelHistory_isSetModifiedDate(mh) == 0);

  Date_free(date);
  ModelHistory_free(mh);
}