END_TEST


START_TEST ( test_Event_parent_create )
{
    Model *m = new Model(2, 4);
    Event *e = m->createEvent();

    ListOf *lo = m->getListOfEvents();

    fail_unless(lo == m->getEvent(0)->getParentSBMLObject());
    fail_unless(lo == e->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_UnitDefinition_parent_create )
{
    Model *m = new Model(2, 4);
    UnitDefinition *ud = m->createUnitDefinition();

    ListOf *lo = m->getListOfUnitDefinitions();

    fail_unless(lo == m->getUnitDefinition(0)->getParentSBMLObject());
    fail_unless(lo == ud->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_CompartmentType_parent_create )
{
    Model *m = new Model(2, 4);
    CompartmentType *ct = m->createCompartmentType();

    ListOf *lo = m->getListOfCompartmentTypes();

    fail_unless(lo == m->getCompartmentType(0)->getParentSBMLObject());
    fail_unless(lo == ct->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_InitialAssignment_parent_create )
{
    Model *m = new Model(2, 4);
    InitialAssignment *ia = m->createInitialAssignment();

    ListOf *lo = m->getListOfInitialAssignments();

    fail_unless(lo == m->getInitialAssignment(0)->getParentSBMLObject());
    fail_unless(lo == ia->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_FunctionDefinition_parent_create )
{
    Model *m = new Model(2, 4);
    FunctionDefinition *fd = m->createFunctionDefinition();

    ListOf *lo = m->getListOfFunctionDefinitions();

    fail_unless(lo == m->getFunctionDefinition(0)->getParentSBMLObject());
    fail_unless(lo == fd->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_Reaction_parent_create )
{
    Model *m = new Model(2, 4);
    Reaction *r = m->createReaction();

    ListOf *lo = m->getListOfReactions();

    fail_unless(lo == m->getReaction(0)->getParentSBMLObject());
    fail_unless(lo == r->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_Parameter_parent_create )
{
    Model *m = new Model(2, 4);
    Parameter *p = m->createParameter();

    ListOf *lo = m->getListOfParameters();

    fail_unless(lo == m->getParameter(0)->getParentSBMLObject());
    fail_unless(lo == p->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_SpeciesReference_Reactant_parent_create )
{
    Reaction *r = new Reaction(2, 4);
    SpeciesReference *sr = r->createReactant();

    ListOf *lo = r->getListOfReactants();

    fail_unless(lo == r->getReactant(0)->getParentSBMLObject());
    fail_unless(lo == sr->getParentSBMLObject());
    fail_unless(r == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_RateRule_parent_create )
{
    Model *m = new Model(2, 4);
    RateRule *r = m->createRateRule();

    ListOf *lo = m->getListOfRules();

    fail_unless(lo == m->getRule(0)->getParentSBMLObject());
    fail_unless(lo == r->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_SpeciesReference_Modifier_parent_create )
{
    Reaction *r = new Reaction(2, 4);
    ModifierSpeciesReference *sr = r->createModifier();

    ListOf *lo = r->getListOfModifiers();

    fail_unless(lo == sr->getParentSBMLObject());
    fail_unless(lo == r->getModifier(0)->getParentSBMLObject());
    fail_unless(r == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_SpeciesType_parent_create )
{
    Model *m = new Model(2, 4);
    SpeciesType *st = m->createSpeciesType();

    ListOf *lo = m->getListOfSpeciesTypes();

    fail_unless(lo == m->getSpeciesType(0)->getParentSBMLObject());
    fail_unless(lo == st->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_Constraint_parent_create )
{
    Model *m = new Model(2, 4);
    Constraint *ct = m->createConstraint();

    ListOf *lo = m->getListOfConstraints();

    fail_unless(lo == m->getConstraint(0)->getParentSBMLObject());
    fail_unless(lo == ct->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_SpeciesReference_Product_parent_create_model )
{
    Model *m = new Model(2, 4);
    Reaction *r = m->createReaction();
    SpeciesReference *sr = m->createProduct();

    ListOf *lo = r->getListOfProducts();

    fail_unless(lo == r->getProduct(0)->getParentSBMLObject());
    fail_unless(lo == sr->getParentSBMLObject());
    fail_unless(r == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_EventAssignment_parent_create )
{
    Event *e = new Event(2, 4);

    EventAssignment *ea = e->createEventAssignment();

    ListOf *lo = e->getListOfEventAssignments();

    fail_unless(lo == e->getEventAssignment(0)->getParentSBMLObject());
    fail_unless(lo == ea->getParentSBMLObject());
    fail_unless(e == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_Constraint_parent_add )
{
    Constraint *ct = new Constraint(2, 4);
    Model *m = new Model(2, 4);
    ct->setMath(SBML_parseFormula("a-k"));
    m->addConstraint(ct);

    delete ct;

    ListOf *lo = m->getListOfConstraints();

    fail_unless(lo == m->getConstraint(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_CompartmentType_parent_add )
{
    CompartmentType *ct = new CompartmentType(2, 4);
    Model *m = new Model(2, 4);
    ct->setId("ct");
    m->addCompartmentType(ct);

    delete ct;

    ListOf *lo = m->getListOfCompartmentTypes();

    fail_unless(lo == m->getCompartmentType(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_Unit_parent_create )
{
    UnitDefinition* ud = new UnitDefinition(2, 4);
    Unit * u = ud->createUnit();

    fail_unless(ud->getNumUnits() == 1);

    ListOf *lo = ud->getListOfUnits();

    fail_unless(lo == ud->getUnit(0)->getParentSBMLObject());
    fail_unless(lo == u->getParentSBMLObject());
    fail_unless(ud == lo->getParentSBMLObject());

    delete ud;
}
END_TEST


START_TEST ( test_Reaction_parent_add )
{
    Reaction *ia = new Reaction(2, 4);
    Model *m = new Model(2, 4);
    ia->setId("k");

    m->addReaction(ia);

    delete ia;

    ListOf *lo = m->getListOfReactions();

    fail_unless(lo == m->getReaction(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_Parameter_parent_add )
{
    Parameter *ia = new Parameter(2, 4);
    Model *m = new Model(2, 4);
    ia->setId("p");

    m->addParameter(ia);

    delete ia;

    ListOf *lo = m->getListOfParameters();

    fail_unless(lo == m->getParameter(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_SpeciesReference_Reactant_parent_add )
{
    SpeciesReference *sr = new SpeciesReference(2, 4);
    Reaction *r = new Reaction(2, 4);

    sr->setSpecies("s");
    r->addReactant(sr);

    delete sr;

    ListOf *lo = r->getListOfReactants();

    fail_unless(lo == r->getReactant(0)->getParentSBMLObject());
    fail_unless(r == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_SpeciesType_parent_add )
{
    SpeciesType *ia = new SpeciesType(2, 4);
    ia->setId("s");
    Model *m = new Model(2, 4);

    m->addSpeciesType(ia);

    delete ia;

    ListOf *lo = m->getListOfSpeciesTypes();

    fail_unless(lo == m->getSpeciesType(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_SpeciesReference_Modifier_parent_add )
{
    ModifierSpeciesReference *sr = new ModifierSpeciesReference(2, 4);
    sr->setSpecies("s");
    Reaction *r = new Reaction(2, 4);

    r->addModifier(sr);

    delete sr;

    ListOf *lo = r->getListOfModifiers();

    fail_unless(lo == r->getModifier(0)->getParentSBMLObject());
    fail_unless(r == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_EventAssignment_parent_add )
{
    Event *e = new Event(2, 4);
    EventAssignment *ea = new EventAssignment(2, 4);
    ea->setVariable("c");
    ea->setMath(SBML_parseFormula("K+L"));

    e->addEventAssignment(ea);

    delete ea;

    ListOf *lo = e->getListOfEventAssignments();

    fail_unless(lo == e->getEventAssignment(0)->getParentSBMLObject());
    fail_unless(e == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_InitialAssignment_parent_add )
{
    InitialAssignment *ia = new InitialAssignment(2, 4);
    Model *m = new Model(2, 4);
    ia->setSymbol("c");
    ia->setMath(SBML_parseFormula("9"));

    m->addInitialAssignment(ia);

    delete ia;

    ListOf *lo = m->getListOfInitialAssignments();

    fail_unless(lo == m->getInitialAssignment(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_UnitDefinition_parent_add )
{
    UnitDefinition *ia = new UnitDefinition(2, 4);
    Model *m = new Model(2, 4);
    ia->setId("u");
    ia->createUnit();

    m->addUnitDefinition(ia);

    delete ia;

    ListOf *lo = m->getListOfUnitDefinitions();

    fail_unless(lo == m->getUnitDefinition(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_FunctionDefinition_parent_add )
{
    FunctionDefinition *fd = new FunctionDefinition(2, 4);
    Model *m = new Model(2, 4);
    fd->setId("fd");
    fd->setMath(SBML_parseFormula("l"));

    m->addFunctionDefinition(fd);

    delete fd;

    ListOf *lo = m->getListOfFunctionDefinitions();

    fail_unless(lo == m->getFunctionDefinition(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST



START_TEST ( test_Rule_parent_add )
{
    Rule *ia = new RateRule(2, 4);
    ia->setVariable("a");
    ia->setMath(SBML_parseFormula("9"));
    Model *m = new Model(2, 4);

    m->addRule(ia);

    delete ia;

    ListOf *lo = m->getListOfRules();

    fail_unless(lo == m->getRule(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_Event_parent_add )
{
    Event *e = new Event(2, 4);
    Trigger *t = new Trigger(2, 4);
    e->setTrigger(t);
    e->createEventAssignment();
    Model *m = new Model(2, 4);

    m->addEvent(e);

    delete e;

    ListOf *lo = m->getListOfEvents();

    fail_unless(lo == m->getEvent(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}
END_TEST


START_TEST ( test_Unit_parent_add )
{
    UnitDefinition* ud=new UnitDefinition(2, 4);

    Unit * u = new Unit(2, 4);
    u->setKind(UNIT_KIND_MOLE);
    ud->addUnit(u);
    delete u;

    fail_unless(ud->getNumUnits() == 1);

    ListOf *lo = ud->getListOfUnits();

    fail_unless(lo == ud->getUnit(0)->getParentSBMLObject());
    fail_unless(ud == lo->getParentSBMLObject());

    delete ud;
}
LIBSBML_CPP_NAMESPACE_USE

/** @endcond */


BEGIN_C_DECLS

START_TEST ( test_Compartment_parent_add )
{
    Compartment *c = new Compartment(2, 4);
    c->setId("c");
    Model *m = new Model(2, 4);

    m->addCompartment(c);

    delete c;

    ListOf *lo = m->getListOfCompartments();

    fail_unless(lo == m->getCompartment(0)->getParentSBMLObject());
    fail_unless(m == lo->getParentSBMLObject());
}