59 CPPUNIT_ASSERT(pDataModel->
getModel() != NULL);
62 const Model* pSBMLModel = pDocument->getModel();
63 CPPUNIT_ASSERT(pSBMLModel != NULL);
64 CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 0);
65 CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 0);
66 CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
67 CPPUNIT_ASSERT(pSBMLModel->getNumInitialAssignments() == 0);
68 CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 5);
69 const Parameter* pParameter1 = pSBMLModel->getParameter(0);
70 CPPUNIT_ASSERT(pParameter1 != NULL);
71 CPPUNIT_ASSERT(pParameter1->getConstant() ==
false);
72 const Parameter* pParameter2 = pSBMLModel->getParameter(1);
73 CPPUNIT_ASSERT(pParameter2 != NULL);
74 CPPUNIT_ASSERT(pParameter2->getConstant() ==
false);
75 const Parameter* pParameter3 = pSBMLModel->getParameter(2);
76 CPPUNIT_ASSERT(pParameter3 != NULL);
77 CPPUNIT_ASSERT(pParameter3->getConstant() ==
false);
78 const Parameter* pParameter4 = pSBMLModel->getParameter(3);
79 CPPUNIT_ASSERT(pParameter4 != NULL);
80 CPPUNIT_ASSERT(pParameter4->getConstant() ==
false);
81 const Parameter* pParameter5 = pSBMLModel->getParameter(4);
82 CPPUNIT_ASSERT(pParameter5 != NULL);
83 CPPUNIT_ASSERT(pParameter5->getConstant() ==
false);
84 CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 5);
86 const Rule* pRule = pSBMLModel->getRule(0);
87 CPPUNIT_ASSERT(pRule != NULL);
88 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
89 const AssignmentRule* pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
90 CPPUNIT_ASSERT(pARule != NULL);
91 CPPUNIT_ASSERT(pARule->getVariable() == pParameter1->getId());
92 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
93 const ASTNode* pMath = pARule->getMath();
94 CPPUNIT_ASSERT(pMath != NULL);
95 CPPUNIT_ASSERT(pMath->getType() == AST_TIMES);
96 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
97 const ASTNode* pChild1 = pMath->getChild(0);
98 CPPUNIT_ASSERT(pChild1 != NULL);
99 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
100 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 3.0) / 3.0) < 1e-15);
101 const ASTNode* pChild2 = pMath->getChild(1);
102 CPPUNIT_ASSERT(pChild2 != NULL);
103 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
104 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 4.0) / 4.0) < 1e-15);
106 pRule = pSBMLModel->getRule(1);
107 CPPUNIT_ASSERT(pRule != NULL);
108 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
109 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
110 CPPUNIT_ASSERT(pARule != NULL);
111 CPPUNIT_ASSERT(pARule->getVariable() == pParameter2->getId());
112 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
113 pMath = pARule->getMath();
114 CPPUNIT_ASSERT(pMath != NULL);
115 CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
116 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
117 pChild1 = pMath->getChild(0);
118 CPPUNIT_ASSERT(pChild1 != NULL);
119 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
120 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 2.0) / 2.0) < 1e-15);
121 pChild2 = pMath->getChild(1);
122 CPPUNIT_ASSERT(pChild2 != NULL);
123 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
124 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 9.0) / 9.0) < 1e-15);
126 pRule = pSBMLModel->getRule(2);
127 CPPUNIT_ASSERT(pRule != NULL);
128 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
129 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
130 CPPUNIT_ASSERT(pARule != NULL);
131 CPPUNIT_ASSERT(pARule->getVariable() == pParameter3->getId());
132 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
133 pMath = pARule->getMath();
134 CPPUNIT_ASSERT(pMath != NULL);
135 CPPUNIT_ASSERT(pMath->getType() == AST_MINUS);
136 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
137 pChild1 = pMath->getChild(0);
138 CPPUNIT_ASSERT(pChild1 != NULL);
139 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
140 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 8.0) / 8.0) < 1e-15);
141 pChild2 = pMath->getChild(1);
142 CPPUNIT_ASSERT(pChild2 != NULL);
143 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
144 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 4.0) / 4.0) < 1e-15);
146 pRule = pSBMLModel->getRule(3);
147 CPPUNIT_ASSERT(pRule != NULL);
148 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
149 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
150 CPPUNIT_ASSERT(pARule != NULL);
151 CPPUNIT_ASSERT(pARule->getVariable() == pParameter4->getId());
152 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
153 pMath = pARule->getMath();
154 CPPUNIT_ASSERT(pMath != NULL);
155 CPPUNIT_ASSERT(pMath->getType() == AST_DIVIDE);
156 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
157 pChild1 = pMath->getChild(0);
158 CPPUNIT_ASSERT(pChild1 != NULL);
159 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
160 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 9.0) / 9.0) < 1e-15);
161 pChild2 = pMath->getChild(1);
162 CPPUNIT_ASSERT(pChild2 != NULL);
163 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
164 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 3.0) / 3.0) < 1e-15);
166 pRule = pSBMLModel->getRule(4);
167 CPPUNIT_ASSERT(pRule != NULL);
168 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
169 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
170 CPPUNIT_ASSERT(pARule != NULL);
171 CPPUNIT_ASSERT(pARule->getVariable() == pParameter5->getId());
172 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
173 pMath = pARule->getMath();
174 CPPUNIT_ASSERT(pMath != NULL);
175 CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
176 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
177 pChild1 = pMath->getChild(0);
178 CPPUNIT_ASSERT(pChild1 != NULL);
179 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
180 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 6.0) / 6.0) < 1e-15);
181 pChild2 = pMath->getChild(1);
182 CPPUNIT_ASSERT(pChild2 != NULL);
183 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
184 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 1.0) / 1.0) < 1e-15);
191 CPPUNIT_ASSERT(pModel != NULL);
192 CPPUNIT_ASSERT(pModel->getModelValues().size() == 5);
194 CModelValue *pMV1 = NULL, *pMV2 = NULL, *pMV3 = NULL, *pMV4 = NULL, *pMV5 = NULL;
195 unsigned int i, iMax = pModel->getModelValues().size();
197 for (i = 0; i < iMax; ++i)
201 if (pTmpMV->
getSBMLId() == pParameter1->getId())
205 else if (pTmpMV->
getSBMLId() == pParameter2->getId())
209 else if (pTmpMV->
getSBMLId() == pParameter3->getId())
213 else if (pTmpMV->
getSBMLId() == pParameter4->getId())
217 else if (pTmpMV->
getSBMLId() == pParameter5->getId())
223 CPPUNIT_ASSERT(pMV1 != NULL);
224 CPPUNIT_ASSERT(pMV2 != NULL);
225 CPPUNIT_ASSERT(pMV3 != NULL);
226 CPPUNIT_ASSERT(pMV4 != NULL);
227 CPPUNIT_ASSERT(pMV5 != NULL);
231 pMV1->setExpressionPtr(pExpr);
234 pExpr->setRoot(pObjectNode);
235 pMV3->setExpressionPtr(pExpr);
238 pExpr->setRoot(pObjectNode);
239 pMV4->setExpressionPtr(pExpr);
242 pExpr->setRoot(pObjectNode);
243 pMV2->setExpressionPtr(pExpr);
247 CPPUNIT_ASSERT(pDocument != NULL);
248 pSBMLModel = pDocument->getModel();
249 CPPUNIT_ASSERT(pSBMLModel != NULL);
250 CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 0);
251 CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 0);
252 CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
253 CPPUNIT_ASSERT(pSBMLModel->getNumInitialAssignments() == 0);
254 CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 5);
255 pParameter1 = pSBMLModel->getParameter(0);
256 CPPUNIT_ASSERT(pParameter1 != NULL);
257 CPPUNIT_ASSERT(pParameter1->getConstant() ==
false);
258 pParameter2 = pSBMLModel->getParameter(1);
259 CPPUNIT_ASSERT(pParameter2 != NULL);
260 CPPUNIT_ASSERT(pParameter2->getConstant() ==
false);
261 pParameter3 = pSBMLModel->getParameter(2);
262 CPPUNIT_ASSERT(pParameter3 != NULL);
263 CPPUNIT_ASSERT(pParameter3->getConstant() ==
false);
264 pParameter4 = pSBMLModel->getParameter(3);
265 CPPUNIT_ASSERT(pParameter4 != NULL);
266 CPPUNIT_ASSERT(pParameter4->getConstant() ==
false);
267 pParameter5 = pSBMLModel->getParameter(4);
268 CPPUNIT_ASSERT(pParameter5 != NULL);
269 CPPUNIT_ASSERT(pParameter5->getConstant() ==
false);
270 CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 5);
272 pRule = pSBMLModel->getRule(0);
273 CPPUNIT_ASSERT(pRule != NULL);
274 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
275 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
276 CPPUNIT_ASSERT(pARule != NULL);
277 CPPUNIT_ASSERT(pARule->getVariable() == pParameter5->getId());
278 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
279 pMath = pARule->getMath();
280 CPPUNIT_ASSERT(pMath != NULL);
281 CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
282 CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
283 pChild1 = pMath->getChild(0);
284 CPPUNIT_ASSERT(pChild1 != NULL);
285 CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
286 CPPUNIT_ASSERT(fabs((pChild1->getReal() - 6.0) / 6.0) < 1e-15);
287 pChild2 = pMath->getChild(1);
288 CPPUNIT_ASSERT(pChild2 != NULL);
289 CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
290 CPPUNIT_ASSERT(fabs((pChild2->getReal() - 1.0) / 1.0) < 1e-15);
292 pRule = pSBMLModel->getRule(1);
293 CPPUNIT_ASSERT(pRule != NULL);
294 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
295 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
296 CPPUNIT_ASSERT(pARule != NULL);
297 CPPUNIT_ASSERT(pARule->getVariable() == pParameter4->getId());
298 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
299 pMath = pARule->getMath();
300 CPPUNIT_ASSERT(pMath != NULL);
301 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
302 CPPUNIT_ASSERT(pMath->getName() == pParameter5->getId());
303 CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
305 pRule = pSBMLModel->getRule(2);
306 CPPUNIT_ASSERT(pRule != NULL);
307 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
308 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
309 CPPUNIT_ASSERT(pARule != NULL);
310 CPPUNIT_ASSERT(pARule->getVariable() == pParameter2->getId());
311 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
312 pMath = pARule->getMath();
313 CPPUNIT_ASSERT(pMath != NULL);
314 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
315 CPPUNIT_ASSERT(pMath->getName() == pParameter4->getId());
316 CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
318 pRule = pSBMLModel->getRule(3);
319 CPPUNIT_ASSERT(pRule != NULL);
320 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
321 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
322 CPPUNIT_ASSERT(pARule != NULL);
323 CPPUNIT_ASSERT(pARule->getVariable() == pParameter3->getId());
324 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
325 pMath = pARule->getMath();
326 CPPUNIT_ASSERT(pMath != NULL);
327 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
328 CPPUNIT_ASSERT(pMath->getName() == pParameter2->getId());
329 CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
331 pRule = pSBMLModel->getRule(4);
332 CPPUNIT_ASSERT(pRule != NULL);
333 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
334 pARule =
dynamic_cast<const AssignmentRule*
>(pRule);
335 CPPUNIT_ASSERT(pARule != NULL);
336 CPPUNIT_ASSERT(pARule->getVariable() == pParameter1->getId());
337 CPPUNIT_ASSERT(pARule->isSetMath() ==
true);
338 pMath = pARule->getMath();
339 CPPUNIT_ASSERT(pMath != NULL);
340 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
341 CPPUNIT_ASSERT(pMath->getName() == pParameter3->getId());
342 CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
virtual bool setRoot(CEvaluationNode *pRootNode)
SBMLDocument * getCurrentSBMLDocument()
const std::string & getSBMLId() const
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static CCopasiDataModel * pCOPASIDATAMODEL
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static const char * MODEL_STRING