END_TEST

START_TEST (test_Date_accessWithNULL)
{
	fail_unless( Date_clone(NULL) == NULL );
	fail_unless( Date_createFromString(NULL) == NULL );
	
	// ensure that we don't crash
    Date_free(NULL);
	
	fail_unless( Date_getDateAsString(NULL) == NULL );
	fail_unless( Date_getDay(NULL) == SBML_INT_MAX );
	fail_unless( Date_getHour(NULL) == SBML_INT_MAX );
	fail_unless( Date_getHoursOffset(NULL) == SBML_INT_MAX );
	fail_unless( Date_getMinute(NULL) == SBML_INT_MAX );
	fail_unless( Date_getMinutesOffset(NULL) == SBML_INT_MAX );
	fail_unless( Date_getMonth(NULL) == SBML_INT_MAX );
	fail_unless( Date_getSecond(NULL) == SBML_INT_MAX );
	fail_unless( Date_getSignOffset(NULL) == SBML_INT_MAX );
	fail_unless( Date_getYear(NULL) == SBML_INT_MAX );
	fail_unless( Date_representsValidDate(NULL) == 0 );
	fail_unless( Date_setDateAsString(NULL, NULL) == LIBSBML_INVALID_OBJECT );
	fail_unless( Date_setDay(NULL, 0) == LIBSBML_INVALID_OBJECT );
	fail_unless( Date_setHour(NULL, 0) == LIBSBML_INVALID_OBJECT );
	fail_unless( Date_setHoursOffset(NULL, 0) == LIBSBML_INVALID_OBJECT );
	fail_unless( Date_setMinute(NULL, 0) == LIBSBML_INVALID_OBJECT );
	fail_unless( Date_setMinutesOffset(NULL, 0) == LIBSBML_INVALID_OBJECT );
	fail_unless( Date_setMonth(NULL, 0) == LIBSBML_INVALID_OBJECT );
	fail_unless( Date_setSecond(NULL, 0) == LIBSBML_INVALID_OBJECT );
	fail_unless( Date_setSignOffset(NULL, 0) == LIBSBML_INVALID_OBJECT );
	fail_unless( Date_setYear(NULL, 0) == LIBSBML_INVALID_OBJECT );

}
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);
}
Пример #3
0
END_TEST

START_TEST (test_Date_getDateAsString)
{
  const char * dd = "2005-02-02T14:56:11Z";

  Date_t * date = Date_createFromString(dd);

  fail_unless(date != NULL);
  fail_unless(Date_getYear(date) == 2005);
  fail_unless(Date_getMonth(date) == 2);
  fail_unless(Date_getDay(date) == 2);
  fail_unless(Date_getHour(date) == 14);
  fail_unless(Date_getMinute(date) == 56);
  fail_unless(Date_getSecond(date) == 11);
  fail_unless(Date_getSignOffset(date) == 0);
  fail_unless(Date_getHoursOffset(date) == 0);
  fail_unless(Date_getMinutesOffset(date) == 0);

  Date_setYear(date, 2012);
  Date_setMonth(date, 3);
  Date_setDay(date, 28);
  Date_setHour(date, 23);
  Date_setMinute(date, 4);
  Date_setSecond(date, 32);
  Date_setSignOffset(date, 1);
  Date_setHoursOffset(date, 2);
  Date_setMinutesOffset(date, 32);

  fail_unless(!strcmp(Date_getDateAsString(date), "2012-03-28T23:04:32+02:32"));

  Date_free(date);
}
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);
}
Пример #5
0
int
main (int argc, char *argv[])
{

  SBMLDocument_t* d;
  Model_t* m;
  unsigned int  errors;

  if (argc != 3)
  {
    printf("\n"
      "  usage: addModelHistory <input-filename> <output-filename>\n"
      "\n");
    return 2;
  }


  d      = readSBML(argv[1]);
  errors = SBMLDocument_getNumErrors(d);

  if (errors > 0)
  {
    printf("Read Error(s):\n");
    SBMLDocument_printErrors(d, stdout);	 
    printf("Correct the above and re-run.\n");
  }
  else
  {
    int status;
    Date_t* date, *date2;
    ModelHistory_t* h = ModelHistory_create();
    ModelCreator_t* c = ModelCreator_create();

    ModelCreator_setFamilyName(c, "Keating");
    ModelCreator_setGivenName(c, "Sarah");
    ModelCreator_setEmail(c, "*****@*****.**");
    ModelCreator_setOrganisation(c, "University of Hertfordshire");


    status = ModelHistory_addCreator(h, c);
	  printStatus("Status for addCreator: ", status);

    
    date = Date_createFromString("1999-11-13T06:54:32");
    date2 = Date_createFromString("2007-11-30T06:54:00-02:00");
       
    status = ModelHistory_setCreatedDate(h, date);
	  printStatus("Set created date:      ", status);

    status = ModelHistory_setModifiedDate(h, date2);
	  printStatus("Set modified date:     ", status);

    m = SBMLDocument_getModel(d);
    status =  Model_setModelHistory(m, h);
	  printStatus("Set model history:     ", status);
  
    writeSBML(d, argv[2]);
  }

  SBMLDocument_free(d);
  return errors;
}