52 CPPUNIT_ASSERT(content.empty() ==
false);
53 CPPUNIT_ASSERT(pDataModel->
getModel() != NULL);
55 CPPUNIT_ASSERT(pDocument != NULL);
56 Model* pModel = pDocument->getModel();
57 CPPUNIT_ASSERT(pModel != NULL);
60 CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
61 Compartment* pCompartment = pModel->getCompartment(0);
62 CPPUNIT_ASSERT(pCompartment->getConstant() ==
false);
63 CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
64 Species* pSpecies = pModel->getSpecies(1);
65 std::string idSpeciesS, idSpeciesA;
67 if (pSpecies->getName() ==
"S")
69 idSpeciesS = pSpecies->getId();
73 idSpeciesA = pSpecies->getId();
76 CPPUNIT_ASSERT(pSpecies->getHasOnlySubstanceUnits() ==
true);
77 pSpecies = pModel->getSpecies(0);
79 if (pSpecies->getName() ==
"S")
81 idSpeciesS = pSpecies->getId();
85 idSpeciesA = pSpecies->getId();
88 CPPUNIT_ASSERT(!idSpeciesS.empty());
89 CPPUNIT_ASSERT(!idSpeciesA.empty());
90 CPPUNIT_ASSERT(pSpecies->getHasOnlySubstanceUnits() ==
true);
91 CPPUNIT_ASSERT(pModel->getNumRules() == 2);
92 CPPUNIT_ASSERT(pModel->getNumInitialAssignments() == 2);
93 const InitialAssignment* pAssignment1 = pModel->getInitialAssignment(0);
94 CPPUNIT_ASSERT(pAssignment1 != NULL);
95 CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
96 Parameter* pParameter = pModel->getParameter(0);
97 CPPUNIT_ASSERT(pParameter != NULL);
103 const InitialAssignment* pAssignment2 = NULL;
105 if (pAssignment1->getSymbol() == pParameter->getId())
107 pAssignment2 = pModel->getInitialAssignment(1);
111 pAssignment2 = pAssignment1;
112 pAssignment1 = pModel->getInitialAssignment(1);
115 assert(pAssignment2 != NULL);
118 const ASTNode* pMath = pAssignment1->getMath();
119 CPPUNIT_ASSERT(pMath != NULL);
120 CPPUNIT_ASSERT(pMath->getType() == AST_DIVIDE);
121 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
122 const ASTNode* pChild1 = pMath->getChild(0);
123 CPPUNIT_ASSERT(pChild1 != NULL);
124 const ASTNode* pChild2 = NULL;
127 if (pChild1->getType() == AST_DIVIDE)
129 pChild2 = pMath->getChild(1);
134 pChild1 = pMath->getChild(1);
137 CPPUNIT_ASSERT(pChild2 != NULL);
138 CPPUNIT_ASSERT(pChild1->getType() == AST_DIVIDE);
139 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
140 CPPUNIT_ASSERT((fabs(pChild2->getReal() - 2.0) / 2.0) < 1e-9);
141 CPPUNIT_ASSERT(pChild1->getNumChildren() == 2);
142 pChild2 = pChild1->getChild(1);
143 CPPUNIT_ASSERT(pChild2 != NULL);
144 pChild1 = pChild1->getChild(0);
145 CPPUNIT_ASSERT(pChild1 != NULL);
146 CPPUNIT_ASSERT(pChild1->getType() == AST_NAME);
147 CPPUNIT_ASSERT(pChild2->getType() == AST_NAME);
148 CPPUNIT_ASSERT(pChild1->getName() == idSpeciesS);
149 CPPUNIT_ASSERT(pChild2->getName() == pCompartment->getId());
152 pMath = pAssignment2->getMath();
153 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
154 CPPUNIT_ASSERT(pMath->getType() == AST_TIMES);
155 pChild1 = pMath->getChild(0);
156 CPPUNIT_ASSERT(pChild1 != NULL);
158 if (pChild1->getType() == AST_PLUS)
160 pChild2 = pMath->getChild(1);
165 pChild1 = pMath->getChild(1);
168 CPPUNIT_ASSERT(pChild2 != NULL);
169 CPPUNIT_ASSERT(pChild1->getType() == AST_PLUS);
170 CPPUNIT_ASSERT(pChild2->getType() == AST_NAME);
171 CPPUNIT_ASSERT(pChild2->getName() == pCompartment->getId());
172 CPPUNIT_ASSERT(pChild1->getNumChildren() == 2);
173 pChild2 = pChild1->getChild(0);
174 pChild1 = pChild1->getChild(1);
175 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
177 if ((fabs(pChild2->getReal() - 12.0) / 12.0) < 1e-9)
179 CPPUNIT_ASSERT((fabs(pChild1->getReal() - 6.0) / 6.0) < 1e-9);
183 CPPUNIT_ASSERT((fabs(pChild2->getReal() - 6.0) / 6.0) < 1e-9);
184 CPPUNIT_ASSERT((fabs(pChild1->getReal() - 12.0) / 12.0) < 1e-9);
188 const Rule* pRule1 = pModel->getRule(0);
189 CPPUNIT_ASSERT(pRule1 != NULL);
190 const AssignmentRule* pARule1 =
dynamic_cast<const AssignmentRule*
>(pRule1);
191 CPPUNIT_ASSERT(pARule1 != NULL);
192 const Rule* pRule2 = NULL;
193 const AssignmentRule* pARule2 = NULL;
195 if (pARule1->getVariable() == pCompartment->getId())
197 pRule2 = pModel->getRule(1);
198 pARule2 =
dynamic_cast<const AssignmentRule*
>(pRule2);
204 pRule1 = pModel->getRule(1);
205 pARule1 =
dynamic_cast<const AssignmentRule*
>(pRule1);
208 CPPUNIT_ASSERT(pRule1 != NULL);
209 CPPUNIT_ASSERT(pARule1 != NULL);
210 CPPUNIT_ASSERT(pRule2 != NULL);
211 CPPUNIT_ASSERT(pARule2 != NULL);
214 pMath = pARule1->getMath();
215 CPPUNIT_ASSERT(pMath != 0);
216 CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
217 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
218 pChild2 = pMath->getChild(0);
219 pChild1 = pMath->getChild(1);
220 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
222 if ((fabs(pChild2->getReal() - 3.0) / 3.0) < 1e-9)
224 CPPUNIT_ASSERT((fabs(pChild1->getReal() - 4.0) / 4.0) < 1e-9);
228 CPPUNIT_ASSERT((fabs(pChild2->getReal() - 4.0) / 4.0) < 1e-9);
229 CPPUNIT_ASSERT((fabs(pChild1->getReal() - 3.0) / 3.0) < 1e-9);
235 pMath = pARule2->getMath();
236 CPPUNIT_ASSERT(pMath != NULL);
237 CPPUNIT_ASSERT(pMath->getType() == AST_TIMES);
238 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
239 pChild1 = pMath->getChild(0);
240 CPPUNIT_ASSERT(pChild1 != NULL);
242 if (pChild1->getType() == AST_NAME)
244 pChild2 = pMath->getChild(1);
249 pChild1 = pMath->getChild(1);
252 CPPUNIT_ASSERT(pChild1 != NULL);
253 CPPUNIT_ASSERT(pChild2 != NULL);
254 CPPUNIT_ASSERT(pChild1->getType() == AST_NAME);
255 CPPUNIT_ASSERT(pChild1->getName() == pCompartment->getId());
256 CPPUNIT_ASSERT(pChild2->getType() == AST_TIMES);
257 CPPUNIT_ASSERT(pChild2->getNumChildren() == 2);
258 pChild1 = pChild2->getChild(0);
260 if (pChild1->getType() == AST_REAL)
262 pChild2 = pChild2->getChild(1);
269 pChild1 = pMath->getChild(1);
272 CPPUNIT_ASSERT(pChild1 != NULL);
273 CPPUNIT_ASSERT(pChild2 != NULL);
274 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
275 CPPUNIT_ASSERT((fabs(pChild1->getReal() - 3.0) / 3.0) < 1e-9);
276 CPPUNIT_ASSERT(pChild2->getType() == AST_DIVIDE);
277 CPPUNIT_ASSERT(pChild2->getNumChildren() == 2);
278 pChild1 = pChild2->getChild(0);
279 pChild2 = pChild2->getChild(1);
280 CPPUNIT_ASSERT(pChild1 != NULL);
281 CPPUNIT_ASSERT(pChild1->getType() == AST_NAME);
282 CPPUNIT_ASSERT(pChild1->getName() == idSpeciesA);
283 CPPUNIT_ASSERT(pChild2 != NULL);
284 CPPUNIT_ASSERT(pChild2->getType() == AST_NAME);
285 CPPUNIT_ASSERT(pChild2->getName() == pCompartment->getId());
291 CPPUNIT_ASSERT(result ==
true);
300 CPPUNIT_ASSERT(pCCompartment != NULL);
302 const CExpression* pExpr = pCCompartment->getExpressionPtr();
303 CPPUNIT_ASSERT(pExpr != NULL);
305 CPPUNIT_ASSERT(pEvalNode != NULL);
309 CPPUNIT_ASSERT(pOperator != NULL);
310 CPPUNIT_ASSERT(pOperator->
getChild() != NULL);
312 CPPUNIT_ASSERT(pEvalNode != NULL);
316 if (fabs((pNumberNode->
getValue() - 3.0) / 3.0) < 1e-6)
318 CPPUNIT_ASSERT(pNumberNode->
getSibling() != NULL);
320 CPPUNIT_ASSERT(pEvalNode != NULL);
323 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 4.0) / 4.0) < 1e-6);
324 CPPUNIT_ASSERT(pNumberNode->
getSibling() == NULL);
328 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 4.0) / 4.0) < 1e-6);
329 CPPUNIT_ASSERT(pNumberNode->
getSibling() != NULL);
331 CPPUNIT_ASSERT(pEvalNode != NULL);
334 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 3.0) / 3.0) < 1e-6);
335 CPPUNIT_ASSERT(pNumberNode->
getSibling() == NULL);
340 CPPUNIT_ASSERT(pMetabA != NULL);
342 const CMetab* pMetabS = NULL;
352 CPPUNIT_ASSERT(pMetabA != NULL);
355 CPPUNIT_ASSERT(pMetabS != NULL);
363 for (
unsigned int i = 0; i < iMax; ++i)
372 CPPUNIT_ASSERT(pModelValue != NULL);
374 pExpr = pModelValue->getInitialExpressionPtr();
375 CPPUNIT_ASSERT(pExpr != NULL);
376 pEvalNode = pExpr->getRoot();
377 CPPUNIT_ASSERT(pEvalNode != NULL);
380 CPPUNIT_ASSERT(pOperator != NULL);
382 CPPUNIT_ASSERT(pOperator->
getChild() != NULL);
383 CPPUNIT_ASSERT(pOperator->
getChild()->getSibling() != NULL);
387 CPPUNIT_ASSERT(pNumberNode != NULL);
388 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 2.0) / 2.0) < 1e-6);
389 CPPUNIT_ASSERT(pNumberNode->
getSibling() == NULL);
391 CPPUNIT_ASSERT(pEvalNode != NULL);
394 CPPUNIT_ASSERT(pOperator != NULL);
396 CPPUNIT_ASSERT(pOperator->
getChild() != NULL);
397 CPPUNIT_ASSERT(pOperator->
getChild()->getSibling() != NULL);
401 CPPUNIT_ASSERT(pObjectNode != NULL);
402 CPPUNIT_ASSERT(pObjectNode->
getSibling() == NULL);
406 CPPUNIT_ASSERT(!objectCN.empty());
407 std::vector<CCopasiContainer*> listOfContainers;
408 listOfContainers.push_back(const_cast<CModel*>(pCModel));
410 CPPUNIT_ASSERT(pObject != NULL);
412 CPPUNIT_ASSERT(pObject->
getObjectName() == std::string(
"InitialVolume"));
416 CPPUNIT_ASSERT(pEvalNode != NULL);
421 CPPUNIT_ASSERT(pEvalNode != NULL);
424 CPPUNIT_ASSERT(pObjectNode != NULL);
428 CPPUNIT_ASSERT(!objectCN.empty());
430 CPPUNIT_ASSERT(pObject != NULL);
431 CPPUNIT_ASSERT(pObject->isReference() ==
true);
432 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"InitialParticleNumber"));
433 CPPUNIT_ASSERT(pObject->getObjectParent() == pMetabS);
435 CPPUNIT_ASSERT(pEvalNode != NULL);
438 CPPUNIT_ASSERT(pObjectNode != NULL);
442 CPPUNIT_ASSERT(!objectCN.empty());
444 CPPUNIT_ASSERT(pObject != NULL);
445 CPPUNIT_ASSERT(pObject->isReference() ==
true);
446 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"InitialValue"));
452 CPPUNIT_ASSERT(pExpr != NULL);
453 pEvalNode = pExpr->getRoot();
454 CPPUNIT_ASSERT(pEvalNode != NULL);
458 CPPUNIT_ASSERT(pOperator != NULL);
459 CPPUNIT_ASSERT(pOperator->
getChild() != NULL);
461 CPPUNIT_ASSERT(pEvalNode != NULL);
465 if (fabs((pNumberNode->
getValue() - 12.0) / 12.0) < 1e-6)
467 CPPUNIT_ASSERT(pNumberNode->
getSibling() != NULL);
469 CPPUNIT_ASSERT(pEvalNode != NULL);
472 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 6.0) / 6.0) < 1e-6);
473 CPPUNIT_ASSERT(pNumberNode->
getSibling() == NULL);
477 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 6.0) / 6.0) < 1e-6);
478 CPPUNIT_ASSERT(pNumberNode->
getSibling() != NULL);
480 CPPUNIT_ASSERT(pEvalNode != NULL);
483 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 12.0) / 12.0) < 1e-6);
484 CPPUNIT_ASSERT(pNumberNode->
getSibling() == NULL);
489 CPPUNIT_ASSERT(pExpr != NULL);
490 pEvalNode = pExpr->getRoot();
491 CPPUNIT_ASSERT(pEvalNode != NULL);
494 CPPUNIT_ASSERT(pOperator != NULL);
496 CPPUNIT_ASSERT(pOperator->
getChild() != NULL);
497 CPPUNIT_ASSERT(pOperator->
getChild()->getSibling() != NULL);
499 CPPUNIT_ASSERT(pEvalNode != NULL);
502 CPPUNIT_ASSERT(pNumberNode != NULL);
503 CPPUNIT_ASSERT(fabs((pNumberNode->
getValue() - 3.0) / 3.0) < 1e-6);
504 CPPUNIT_ASSERT(pNumberNode->
getSibling() == NULL);
507 CPPUNIT_ASSERT(pEvalNode != NULL);
510 CPPUNIT_ASSERT(pOperator != NULL);
512 CPPUNIT_ASSERT(pOperator->
getChild() != NULL);
513 CPPUNIT_ASSERT(pOperator->
getChild()->getSibling() != NULL);
515 CPPUNIT_ASSERT(pEvalNode != NULL);
518 CPPUNIT_ASSERT(pObjectNode != NULL);
522 CPPUNIT_ASSERT(!objectCN.empty());
524 CPPUNIT_ASSERT(pObject != NULL);
525 CPPUNIT_ASSERT(pObject->isReference() ==
true);
526 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"Volume"));
527 CPPUNIT_ASSERT(pObject->getObjectParent() == pCCompartment);
528 CPPUNIT_ASSERT(pObjectNode->
getSibling() == NULL);
531 CPPUNIT_ASSERT(pEvalNode != NULL);
534 CPPUNIT_ASSERT(pOperator != NULL);
536 CPPUNIT_ASSERT(pOperator->
getChild() != NULL);
538 CPPUNIT_ASSERT(pEvalNode != NULL);
541 CPPUNIT_ASSERT(pObjectNode != NULL);
545 CPPUNIT_ASSERT(!objectCN.empty());
547 CPPUNIT_ASSERT(pObject != NULL);
548 CPPUNIT_ASSERT(pObject->isReference() ==
true);
549 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"ParticleNumber"));
550 CPPUNIT_ASSERT(pObject->getObjectParent() == pMetabA);
552 CPPUNIT_ASSERT(pEvalNode != NULL);
555 CPPUNIT_ASSERT(pObjectNode != NULL);
559 CPPUNIT_ASSERT(!objectCN.empty());
561 CPPUNIT_ASSERT(pObject != NULL);
562 CPPUNIT_ASSERT(pObject->isReference() ==
true);
563 CPPUNIT_ASSERT(pObject->getObjectName() == std::string(
"Value"));
564 CPPUNIT_ASSERT(pObjectNode->
getSibling() == NULL);
const CExpression * getExpressionPtr() const
SBMLDocument * getCurrentSBMLDocument()
CCopasiNode< Data > * getSibling()
CCopasiVectorN< CEvent > & getEvents()
const CCopasiVector< CMetab > & getMetabolites() const
const std::string & getObjectName() const
const CCopasiVectorN< CModelValue > & getModelValues() const
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
virtual size_t size() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
bool newModel(CProcessReport *pProcessReport, const bool &deleteOldData)
static CCopasiDataModel * pCOPASIDATAMODEL
const Type & getType() const
static const char * MODEL_STRING_1
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
static Type type(const Type &type)
CCopasiVectorNS< CCompartment > & getCompartments()
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
CCopasiVectorNS< CReaction > & getReactions()
const CModelEntity::Status & getStatus() const
CCopasiNode< Data > * getChild()
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiContainer * getObjectParent() const
const CExpression * getInitialExpressionPtr() const