END_TEST


START_TEST (test_Species_setSubstanceUnits)
{
  const char *units = "item";


  Species_setSubstanceUnits(S, units);

  fail_unless( !strcmp(Species_getSubstanceUnits(S), units) );
  fail_unless( Species_isSetSubstanceUnits(S) );

  if (Species_getSubstanceUnits(S) == units)
  {
    fail("Species_setSubstanceUnits(...) did not make a copy of string.");
  }

  /* Reflexive case (pathological) */
  Species_setSubstanceUnits(S, Species_getSubstanceUnits(S));
  fail_unless( !strcmp(Species_getSubstanceUnits(S), units) );

  Species_setSubstanceUnits(S, NULL);
  fail_unless( !Species_isSetSubstanceUnits(S) );

  if (Species_getSubstanceUnits(S) != NULL)
  {
    fail("Species_setSubstanceUnits(S, NULL) did not clear string.");
  }
}
END_TEST


START_TEST (test_L3_Species_substanceUnits)
{
  const char *units = "volume";


  fail_unless( !Species_isSetSubstanceUnits(S) );
  
  Species_setSubstanceUnits(S, units);

  fail_unless( !strcmp(Species_getSubstanceUnits(S), units) );
  fail_unless( Species_isSetSubstanceUnits(S) );

  if (Species_getSubstanceUnits(S) == units)
  {
    fail("Species_setSubstanceUnits(...) did not make a copy of string.");
  }

  Species_unsetSubstanceUnits(S);
  
  fail_unless( !Species_isSetSubstanceUnits(S) );

  if (Species_getSubstanceUnits(S) != NULL)
  {
    fail("Species_unsetSubstanceUnits(S, NULL) did not clear string.");
  }
}
END_TEST


START_TEST (test_Species_setSubstanceUnits1)
{
  int i = Species_setSubstanceUnits(C, "mm");

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( Species_isSetSubstanceUnits(C) );

}
END_TEST


START_TEST (test_Species_setSubstanceUnits4)
{
  Species_t *c = 
    Species_create(2, 2);

  int i = Species_setSubstanceUnits(c, "mole");

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( !strcmp(Species_getSubstanceUnits(c), "mole") );
  fail_unless( Species_isSetSubstanceUnits(c) );

  i = Species_setSubstanceUnits(c, NULL);

  fail_unless( i == LIBSBML_OPERATION_SUCCESS );
  fail_unless( !Species_isSetSubstanceUnits(c) );

  Species_free(c);
}
END_TEST


START_TEST (test_Species_setSubstanceUnits2)
{
  Species_t *c = 
    Species_create(2, 2);

  int i = Species_setSubstanceUnits(c, "1cell");

  fail_unless( i == LIBSBML_INVALID_ATTRIBUTE_VALUE );
  fail_unless( !Species_isSetSubstanceUnits(c) );

  Species_free(c);
}