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);
}
Exemplo n.º 2
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 );

}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
END_TEST

START_TEST (test_ModelHistory_addCreator)
{
  ModelCreator_t * newMC;
  ModelHistory_t * history = ModelHistory_create();

  fail_unless(ModelHistory_getNumCreators(history) == 0);

  fail_unless(history != NULL);

  ModelCreator_t * mc = ModelCreator_create();
  fail_unless(mc != NULL);

  ModelCreator_setFamilyName(mc, "Keating");
  ModelCreator_setGivenName(mc, "Sarah");
  ModelCreator_setEmail(mc, "*****@*****.**");
  ModelCreator_setOrganisation(mc, "UH");

  ModelHistory_addCreator(history, mc);

  fail_unless(ModelHistory_getNumCreators(history) == 1);
  ModelCreator_free(mc);

  newMC = (ModelCreator_t*) List_get(ModelHistory_getListCreators(history), 0);
  fail_unless(newMC != NULL);

  fail_unless(!strcmp(ModelCreator_getFamilyName(newMC), "Keating"));
  fail_unless(!strcmp(ModelCreator_getGivenName(newMC), "Sarah"));
  fail_unless(!strcmp(ModelCreator_getEmail(newMC), "*****@*****.**"));
  fail_unless(!strcmp(ModelCreator_getOrganisation(newMC), "UH"));

  ModelHistory_free(history);
}
Exemplo n.º 5
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);
}
Exemplo n.º 6
0
END_TEST

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

  fail_unless(history != NULL);
  fail_unless(ModelHistory_getListCreators(history) != NULL);
  fail_unless(ModelHistory_getCreatedDate(history) == NULL);
  fail_unless(ModelHistory_getModifiedDate(history) == NULL);

  ModelHistory_free(history);
}
END_TEST


START_TEST (test_ModelHistory_addCreator3)
{
  ModelHistory_t * mh = ModelHistory_create();
  ModelCreator_t * mc = NULL;

  int i = ModelHistory_addCreator(mh, mc);

  fail_unless( i == LIBSBML_OPERATION_FAILED );
  fail_unless(ModelHistory_getNumCreators(mh) == 0);

  ModelHistory_free(mh);
}
END_TEST


START_TEST (test_ModelHistory_addCreator2)
{
  ModelHistory_t * mh = ModelHistory_create();
  ModelCreator_t * mc = ModelCreator_create();
  ModelCreator_setGivenName(mc, "Sarah");

  int i = ModelHistory_addCreator(mh, mc);

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

  ModelCreator_free(mc);
  ModelHistory_free(mh);
}
END_TEST


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

  Date_t *date = Date_createFromString("Jan 12");

  int i = ModelHistory_setCreatedDate(mh, date);

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

  Date_free(date);
  ModelHistory_free(mh);
}
END_TEST


START_TEST (test_ModelHistory_addCreator1)
{
  ModelHistory_t * mh = ModelHistory_create();
  ModelCreator_t * mc = ModelCreator_create();
  ModelCreator_setFamilyName(mc, "Keating");
  ModelCreator_setGivenName(mc, "Sarah");

  int i = ModelHistory_addCreator(mh, mc);

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

  ModelCreator_free(mc);
  ModelHistory_free(mh);
}
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);
}
Exemplo n.º 12
0
END_TEST


START_TEST (test_L3_Species_ModelHistory)
{
  ModelHistory_t * history = ModelHistory_create();
  SBase_setMetaId((SBase_t *)(S), "_3");
  int i = SBase_setModelHistory((SBase_t *)(S), history);

  fail_unless( i == LIBSBML_INVALID_OBJECT );
  fail_unless( !SBase_isSetModelHistory((SBase_t *)(S)) );

  ModelCreator_t * mc = ModelCreator_create();
  Date_t * date = 
    Date_createFromValues(2005, 12, 30, 12, 15, 45, 1, 2, 0);

  ModelCreator_setFamilyName(mc, "Keating");
  ModelCreator_setGivenName(mc, "Sarah");
  ModelCreator_setEmail(mc, "*****@*****.**");
  ModelCreator_setOrganisation(mc, "UH");

  ModelHistory_addCreator(history, mc);
  ModelHistory_setCreatedDate(history, date);
  ModelHistory_setModifiedDate(history, date);

  i = SBase_setModelHistory((SBase_t *)(S), history);

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( SBase_isSetModelHistory((SBase_t *)(S)) );
  
  i = SBase_unsetModelHistory((SBase_t *)(S));

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( !SBase_isSetModelHistory((SBase_t *)(S)) );
  fail_unless( SBase_getModelHistory((SBase_t *)(S)) == NULL );

  ModelHistory_free(history);
  ModelCreator_free(mc);
  Date_free(date);
}