COPASI API  4.16.103
test000053.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000053.cpp,v $
3 // $Revision: 1.8 $
4 // $Name: $
5 // $Author: bergmann $
6 // $Date: 2012/05/16 06:24:49 $
7 // End CVS Header
8 
9 // Copyright (C) 2012 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 #include "test000053.h"
20 
21 #include <sstream>
22 #include "utilities.hpp"
24 #include "copasi/model/CModel.h"
26 #include "copasi/model/CMetab.h"
33 
34 #include "sbml/SBMLDocument.h"
35 #include "sbml/Model.h"
36 #include "sbml/Rule.h"
37 #include "sbml/Species.h"
38 #include "sbml/Parameter.h"
39 #include "sbml/math/ASTNode.h"
40 
42 
43 CCopasiDataModel* test000053::pCOPASIDATAMODEL = NULL;
44 
46 {
47  // Create the root container.
48  CCopasiRootContainer::init(0, NULL, false);
49  // Create the global data model.
51 }
52 
54 {
56 }
57 
59 {
60  // load the CPS file
61  // export to SBML
62  // check the resulting SBML model
63  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
64  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000053::MODEL_STRING_1));
65  const CModel* pModel = pDataModel->getModel();
66  CPPUNIT_ASSERT(pModel != NULL);
67  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
68  CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
69  CPPUNIT_ASSERT(pModel->getReactions().size() == 0);
70  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
71  const CMetab* pMetab = pModel->getMetabolites()[0];
72  CPPUNIT_ASSERT(pMetab != NULL);
73  CPPUNIT_ASSERT(pMetab->getObjectName() == "A");
74  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ASSIGNMENT);
75  const CExpression* pExpr = pMetab->getExpressionPtr();
76  CPPUNIT_ASSERT(pExpr != NULL);
77  const CEvaluationNode* pRoot = pExpr->getRoot();
78  CPPUNIT_ASSERT(pRoot != NULL);
79  CPPUNIT_ASSERT(CEvaluationNode::type(pRoot->getType()) == CEvaluationNode::CHOICE);
80  const CEvaluationNodeChoice* pChoiceNode = dynamic_cast<const CEvaluationNodeChoice*>(pRoot);
81  CPPUNIT_ASSERT(pChoiceNode != NULL);
82  const CEvaluationNode* pChild1 = dynamic_cast<const CEvaluationNode*>(pChoiceNode->getChild());
83  CPPUNIT_ASSERT(pChild1 != NULL);
84  const CEvaluationNode* pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
85  CPPUNIT_ASSERT(pChild2 != NULL);
86  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
88  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
89  CPPUNIT_ASSERT(pNumberNode != NULL);
90  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 0.5) / 0.5) < 1e-6);
91  const CEvaluationNode* pChild3 = dynamic_cast<const CEvaluationNode*>(pChild2->getSibling());
92  CPPUNIT_ASSERT(pChild3 != NULL);
93  CPPUNIT_ASSERT(CEvaluationNode::type(pChild3->getType()) == CEvaluationNode::NUMBER);
95  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild3);
96  CPPUNIT_ASSERT(pNumberNode != NULL);
97  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 1.5) / 1.5) < 1e-6);
98  CPPUNIT_ASSERT(pChild3->getSibling() == NULL);
99  CPPUNIT_ASSERT(CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::LOGICAL);
101  pChild1 = dynamic_cast<const CEvaluationNode*>(pChild1->getChild());
102  CPPUNIT_ASSERT(pChild1 != NULL);
103  CPPUNIT_ASSERT(CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::NUMBER);
105  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild1);
106  CPPUNIT_ASSERT(pNumberNode != NULL);
107  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 3.0) / 3.0) < 1e-6);
108  pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
109  CPPUNIT_ASSERT(pChild2 != NULL);
110  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
112  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
113  CPPUNIT_ASSERT(pNumberNode != NULL);
114  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 4.0) / 4.0) < 1e-6);
115 }
116 
117 const char* test000053::MODEL_STRING_1 =
118  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
119  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
120  " <model id=\"Model_1\" name=\"New Model\">\n"
121  " <listOfUnitDefinitions>\n"
122  " <unitDefinition id=\"volume\">\n"
123  " <listOfUnits>\n"
124  " <unit kind=\"litre\" scale=\"-3\"/>\n"
125  " </listOfUnits>\n"
126  " </unitDefinition>\n"
127  " <unitDefinition id=\"substance\">\n"
128  " <listOfUnits>\n"
129  " <unit kind=\"mole\" scale=\"-3\"/>\n"
130  " </listOfUnits>\n"
131  " </unitDefinition>\n"
132  " </listOfUnitDefinitions>\n"
133  " <listOfCompartments>\n"
134  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>\n"
135  " </listOfCompartments>\n"
136  " <listOfSpecies>\n"
137  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" boundaryCondition=\"true\"/>\n"
138  " </listOfSpecies>\n"
139  " <listOfRules>\n"
140  " <assignmentRule variable=\"species_1\">\n"
141  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
142  " <piecewise>\n"
143  " <piece>\n"
144  " <cn> 0.5 </cn>\n"
145  " <apply>\n"
146  " <gt/>\n"
147  " <cn> 3 </cn>\n"
148  " <cn> 4 </cn>\n"
149  " </apply>\n"
150  " </piece>\n"
151  " <otherwise>\n"
152  " <cn> 1.5 </cn>\n"
153  " </otherwise>\n"
154  " </piecewise>\n"
155  " </math>\n"
156  " </assignmentRule>\n"
157  " </listOfRules>\n"
158  " </model>\n"
159  "</sbml>\n"
160  ;
161 
163 {
164  // load the CPS file
165  // export to SBML
166  // check the resulting SBML model
167  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
168  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000053::MODEL_STRING_2));
169  const CModel* pModel = pDataModel->getModel();
170  CPPUNIT_ASSERT(pModel != NULL);
171  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
172  CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
173  CPPUNIT_ASSERT(pModel->getReactions().size() == 0);
174  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
175  const CMetab* pMetab = pModel->getMetabolites()[0];
176  CPPUNIT_ASSERT(pMetab != NULL);
177  CPPUNIT_ASSERT(pMetab->getObjectName() == "A");
178  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ASSIGNMENT);
179  const CExpression* pExpr = pMetab->getExpressionPtr();
180  CPPUNIT_ASSERT(pExpr != NULL);
181  const CEvaluationNode* pRoot = pExpr->getRoot();
182  CPPUNIT_ASSERT(pRoot != NULL);
183  CPPUNIT_ASSERT(CEvaluationNode::type(pRoot->getType()) == CEvaluationNode::CONSTANT);
184  const CEvaluationNodeConstant* pConstantNode = dynamic_cast<const CEvaluationNodeConstant*>(pRoot);
185  CPPUNIT_ASSERT(pConstantNode != NULL);
187 }
188 
189 const char* test000053::MODEL_STRING_2 =
190  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
191  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
192  " <model id=\"Model_1\" name=\"New Model\">\n"
193  " <listOfUnitDefinitions>\n"
194  " <unitDefinition id=\"volume\">\n"
195  " <listOfUnits>\n"
196  " <unit kind=\"litre\" scale=\"-3\"/>\n"
197  " </listOfUnits>\n"
198  " </unitDefinition>\n"
199  " <unitDefinition id=\"substance\">\n"
200  " <listOfUnits>\n"
201  " <unit kind=\"mole\" scale=\"-3\"/>\n"
202  " </listOfUnits>\n"
203  " </unitDefinition>\n"
204  " </listOfUnitDefinitions>\n"
205  " <listOfCompartments>\n"
206  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>\n"
207  " </listOfCompartments>\n"
208  " <listOfSpecies>\n"
209  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" boundaryCondition=\"true\"/>\n"
210  " </listOfSpecies>\n"
211  " <listOfRules>\n"
212  " <assignmentRule variable=\"species_1\">\n"
213  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
214  " <piecewise>\n"
215  " </piecewise>\n"
216  " </math>\n"
217  " </assignmentRule>\n"
218  " </listOfRules>\n"
219  " </model>\n"
220  "</sbml>\n"
221  ;
222 
224 {
225  // load the CPS file
226  // export to SBML
227  // check the resulting SBML model
228  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
229  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000053::MODEL_STRING_3));
230  const CModel* pModel = pDataModel->getModel();
231  CPPUNIT_ASSERT(pModel != NULL);
232  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
233  CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
234  CPPUNIT_ASSERT(pModel->getReactions().size() == 0);
235  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
236  const CMetab* pMetab = pModel->getMetabolites()[0];
237  CPPUNIT_ASSERT(pMetab != NULL);
238  CPPUNIT_ASSERT(pMetab->getObjectName() == "A");
239  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ASSIGNMENT);
240  const CExpression* pExpr = pMetab->getExpressionPtr();
241  CPPUNIT_ASSERT(pExpr != NULL);
242  const CEvaluationNode* pRoot = pExpr->getRoot();
243  CPPUNIT_ASSERT(pRoot != NULL);
244  CPPUNIT_ASSERT(CEvaluationNode::type(pRoot->getType()) == CEvaluationNode::CHOICE);
245  const CEvaluationNodeChoice* pChoiceNode = dynamic_cast<const CEvaluationNodeChoice*>(pRoot);
246  CPPUNIT_ASSERT(pChoiceNode != NULL);
247  const CEvaluationNode* pChild1 = dynamic_cast<const CEvaluationNode*>(pChoiceNode->getChild());
248  CPPUNIT_ASSERT(pChild1 != NULL);
249  const CEvaluationNode* pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
250  CPPUNIT_ASSERT(pChild2 != NULL);
251  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
253  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
254  CPPUNIT_ASSERT(pNumberNode != NULL);
255  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 0.5) / 0.5) < 1e-6);
256  const CEvaluationNode* pChild3 = dynamic_cast<const CEvaluationNode*>(pChild2->getSibling());
257  CPPUNIT_ASSERT(pChild3 != NULL);
258  CPPUNIT_ASSERT(CEvaluationNode::type(pChild3->getType()) == CEvaluationNode::CONSTANT);
260  pChild1 = dynamic_cast<const CEvaluationNode*>(pChild1->getChild());
261  CPPUNIT_ASSERT(pChild1 != NULL);
262  CPPUNIT_ASSERT(CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::NUMBER);
264  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild1);
265  CPPUNIT_ASSERT(pNumberNode != NULL);
266  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 3.0) / 3.0) < 1e-6);
267  pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
268  CPPUNIT_ASSERT(pChild2 != NULL);
269  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
271  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
272  CPPUNIT_ASSERT(pNumberNode != NULL);
273  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 4.0) / 4.0) < 1e-6);
274 }
275 
276 const char* test000053::MODEL_STRING_3 =
277  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
278  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
279  " <model id=\"Model_1\" name=\"New Model\">\n"
280  " <listOfUnitDefinitions>\n"
281  " <unitDefinition id=\"volume\">\n"
282  " <listOfUnits>\n"
283  " <unit kind=\"litre\" scale=\"-3\"/>\n"
284  " </listOfUnits>\n"
285  " </unitDefinition>\n"
286  " <unitDefinition id=\"substance\">\n"
287  " <listOfUnits>\n"
288  " <unit kind=\"mole\" scale=\"-3\"/>\n"
289  " </listOfUnits>\n"
290  " </unitDefinition>\n"
291  " </listOfUnitDefinitions>\n"
292  " <listOfCompartments>\n"
293  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>\n"
294  " </listOfCompartments>\n"
295  " <listOfSpecies>\n"
296  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" boundaryCondition=\"true\"/>\n"
297  " </listOfSpecies>\n"
298  " <listOfRules>\n"
299  " <assignmentRule variable=\"species_1\">\n"
300  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
301  " <piecewise>\n"
302  " <piece>\n"
303  " <cn> 0.5 </cn>\n"
304  " <apply>\n"
305  " <gt/>\n"
306  " <cn> 3 </cn>\n"
307  " <cn> 4 </cn>\n"
308  " </apply>\n"
309  " </piece>\n"
310  " </piecewise>\n"
311  " </math>\n"
312  " </assignmentRule>\n"
313  " </listOfRules>\n"
314  " </model>\n"
315  "</sbml>\n"
316  ;
317 
319 {
320  // load the CPS file
321  // export to SBML
322  // check the resulting SBML model
323  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
324  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000053::MODEL_STRING_4));
325  const CModel* pModel = pDataModel->getModel();
326  CPPUNIT_ASSERT(pModel != NULL);
327  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
328  CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
329  CPPUNIT_ASSERT(pModel->getReactions().size() == 0);
330  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
331  const CMetab* pMetab = pModel->getMetabolites()[0];
332  CPPUNIT_ASSERT(pMetab != NULL);
333  CPPUNIT_ASSERT(pMetab->getObjectName() == "A");
334  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ASSIGNMENT);
335  const CExpression* pExpr = pMetab->getExpressionPtr();
336  CPPUNIT_ASSERT(pExpr != NULL);
337  const CEvaluationNode* pRoot = pExpr->getRoot();
338  CPPUNIT_ASSERT(pRoot != NULL);
339  CPPUNIT_ASSERT(CEvaluationNode::type(pRoot->getType()) == CEvaluationNode::NUMBER);
341  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pRoot);
342  CPPUNIT_ASSERT(pNumberNode != NULL);
343  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 1.5) / 1.5) < 1e-6);
344 }
345 
346 const char* test000053::MODEL_STRING_4 =
347  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
348  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
349  " <model id=\"Model_1\" name=\"New Model\">\n"
350  " <listOfUnitDefinitions>\n"
351  " <unitDefinition id=\"volume\">\n"
352  " <listOfUnits>\n"
353  " <unit kind=\"litre\" scale=\"-3\"/>\n"
354  " </listOfUnits>\n"
355  " </unitDefinition>\n"
356  " <unitDefinition id=\"substance\">\n"
357  " <listOfUnits>\n"
358  " <unit kind=\"mole\" scale=\"-3\"/>\n"
359  " </listOfUnits>\n"
360  " </unitDefinition>\n"
361  " </listOfUnitDefinitions>\n"
362  " <listOfCompartments>\n"
363  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>\n"
364  " </listOfCompartments>\n"
365  " <listOfSpecies>\n"
366  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" boundaryCondition=\"true\"/>\n"
367  " </listOfSpecies>\n"
368  " <listOfRules>\n"
369  " <assignmentRule variable=\"species_1\">\n"
370  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
371  " <piecewise>\n"
372  " <otherwise>\n"
373  " <cn> 1.5 </cn>\n"
374  " </otherwise>\n"
375  " </piecewise>\n"
376  " </math>\n"
377  " </assignmentRule>\n"
378  " </listOfRules>\n"
379  " </model>\n"
380  "</sbml>\n"
381  ;
382 
384 {
385  // load the CPS file
386  // export to SBML
387  // check the resulting SBML model
388  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
389  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000053::MODEL_STRING_5));
390  const CModel* pModel = pDataModel->getModel();
391  CPPUNIT_ASSERT(pModel != NULL);
392  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
393  CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
394  CPPUNIT_ASSERT(pModel->getReactions().size() == 0);
395  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
396  const CMetab* pMetab = pModel->getMetabolites()[0];
397  CPPUNIT_ASSERT(pMetab != NULL);
398  CPPUNIT_ASSERT(pMetab->getObjectName() == "A");
399  CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ASSIGNMENT);
400  const CExpression* pExpr = pMetab->getExpressionPtr();
401  CPPUNIT_ASSERT(pExpr != NULL);
402  const CEvaluationNode* pRoot = pExpr->getRoot();
403  CPPUNIT_ASSERT(pRoot != NULL);
404  CPPUNIT_ASSERT(CEvaluationNode::type(pRoot->getType()) == CEvaluationNode::CHOICE);
405  const CEvaluationNodeChoice* pChoiceNode = dynamic_cast<const CEvaluationNodeChoice*>(pRoot);
406  CPPUNIT_ASSERT(pChoiceNode != NULL);
407  const CEvaluationNode* pChild1 = dynamic_cast<const CEvaluationNode*>(pChoiceNode->getChild());
408  CPPUNIT_ASSERT(pChild1 != NULL);
409  const CEvaluationNode* pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
410  CPPUNIT_ASSERT(pChild2 != NULL);
411  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
413  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
414  CPPUNIT_ASSERT(pNumberNode != NULL);
415  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 0.1) / 0.1) < 1e-6);
416  const CEvaluationNode* pChild3 = dynamic_cast<const CEvaluationNode*>(pChild2->getSibling());
417  CPPUNIT_ASSERT(pChild3 != NULL);
418  CPPUNIT_ASSERT(CEvaluationNode::type(pChild3->getType()) == CEvaluationNode::CHOICE);
419  pChoiceNode = dynamic_cast<const CEvaluationNodeChoice*>(pChild3);
420  CPPUNIT_ASSERT(pChoiceNode);
421  CPPUNIT_ASSERT(CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::LOGICAL);
423  pChild1 = dynamic_cast<const CEvaluationNode*>(pChild1->getChild());
424  CPPUNIT_ASSERT(pChild1 != NULL);
425  CPPUNIT_ASSERT(CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::NUMBER);
427  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild1);
428  CPPUNIT_ASSERT(pNumberNode != NULL);
429  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 3.0) / 3.0) < 1e-6);
430  pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
431  CPPUNIT_ASSERT(pChild2 != NULL);
432  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
434  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
435  CPPUNIT_ASSERT(pNumberNode != NULL);
436  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 4.0) / 4.0) < 1e-6);
437 
438  // second choice level (child3 of first choice level)
439  pChild1 = dynamic_cast<const CEvaluationNode*>(pChoiceNode->getChild());
440  CPPUNIT_ASSERT(pChild1 != NULL);
441  pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
442  CPPUNIT_ASSERT(pChild2 != NULL);
443  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
445  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
446  CPPUNIT_ASSERT(pNumberNode != NULL);
447  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 0.2) / 0.2) < 1e-6);
448  pChild3 = dynamic_cast<const CEvaluationNode*>(pChild2->getSibling());
449  CPPUNIT_ASSERT(pChild3 != NULL);
450  CPPUNIT_ASSERT(CEvaluationNode::type(pChild3->getType()) == CEvaluationNode::CHOICE);
451  pChoiceNode = dynamic_cast<const CEvaluationNodeChoice*>(pChild3);
452  CPPUNIT_ASSERT(pChoiceNode);
453  CPPUNIT_ASSERT(CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::LOGICAL);
455  pChild1 = dynamic_cast<const CEvaluationNode*>(pChild1->getChild());
456  CPPUNIT_ASSERT(pChild1 != NULL);
457  CPPUNIT_ASSERT(CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::NUMBER);
459  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild1);
460  CPPUNIT_ASSERT(pNumberNode != NULL);
461  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 3.0) / 3.0) < 1e-6);
462  pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
463  CPPUNIT_ASSERT(pChild2 != NULL);
464  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
466  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
467  CPPUNIT_ASSERT(pNumberNode != NULL);
468  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 4.0) / 4.0) < 1e-6);
469 
470  // third choice level (child3 of second choice level)
471  pChild1 = dynamic_cast<const CEvaluationNode*>(pChoiceNode->getChild());
472  CPPUNIT_ASSERT(pChild1 != NULL);
473  pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
474  CPPUNIT_ASSERT(pChild2 != NULL);
475  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
477  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
478  CPPUNIT_ASSERT(pNumberNode != NULL);
479  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 0.3) / 0.3) < 1e-6);
480  pChild3 = dynamic_cast<const CEvaluationNode*>(pChild2->getSibling());
481  CPPUNIT_ASSERT(pChild3 != NULL);
482  CPPUNIT_ASSERT(CEvaluationNode::type(pChild3->getType()) == CEvaluationNode::CHOICE);
483  pChoiceNode = dynamic_cast<const CEvaluationNodeChoice*>(pChild3);
484  CPPUNIT_ASSERT(pChoiceNode);
485  CPPUNIT_ASSERT(CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::LOGICAL);
487  pChild1 = dynamic_cast<const CEvaluationNode*>(pChild1->getChild());
488  CPPUNIT_ASSERT(pChild1 != NULL);
489  CPPUNIT_ASSERT(CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::NUMBER);
491  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild1);
492  CPPUNIT_ASSERT(pNumberNode != NULL);
493  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 3.0) / 3.0) < 1e-6);
494  pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
495  CPPUNIT_ASSERT(pChild2 != NULL);
496  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
498  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
499  CPPUNIT_ASSERT(pNumberNode != NULL);
500  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 4.0) / 4.0) < 1e-6);
501 
502  // fourth choice level (child3 of third choice level)
503  pChild1 = dynamic_cast<const CEvaluationNode*>(pChoiceNode->getChild());
504  CPPUNIT_ASSERT(pChild1 != NULL);
505  pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
506  CPPUNIT_ASSERT(pChild2 != NULL);
507  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
509  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
510  CPPUNIT_ASSERT(pNumberNode != NULL);
511  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 0.4) / 0.4) < 1e-6);
512  pChild3 = dynamic_cast<const CEvaluationNode*>(pChild2->getSibling());
513  CPPUNIT_ASSERT(pChild3 != NULL);
514  // the third child of the fourth choice level must be the otherwise element
515  CPPUNIT_ASSERT(CEvaluationNode::type(pChild3->getType()) == CEvaluationNode::NUMBER);
517  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild3);
518  CPPUNIT_ASSERT(pNumberNode != NULL);
519  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 1.5) / 1.5) < 1e-6);
520  CPPUNIT_ASSERT(pChild3->getSibling() == NULL);
521  CPPUNIT_ASSERT(CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::LOGICAL);
523  pChild1 = dynamic_cast<const CEvaluationNode*>(pChild1->getChild());
524  CPPUNIT_ASSERT(pChild1 != NULL);
525  CPPUNIT_ASSERT(CEvaluationNode::type(pChild1->getType()) == CEvaluationNode::NUMBER);
527  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild1);
528  CPPUNIT_ASSERT(pNumberNode != NULL);
529  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 3.0) / 3.0) < 1e-6);
530  pChild2 = dynamic_cast<const CEvaluationNode*>(pChild1->getSibling());
531  CPPUNIT_ASSERT(pChild2 != NULL);
532  CPPUNIT_ASSERT(CEvaluationNode::type(pChild2->getType()) == CEvaluationNode::NUMBER);
534  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pChild2);
535  CPPUNIT_ASSERT(pNumberNode != NULL);
536  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 4.0) / 4.0) < 1e-6);
537 }
538 
539 const char* test000053::MODEL_STRING_5 =
540  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
541  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
542  " <model id=\"Model_1\" name=\"New Model\">\n"
543  " <listOfUnitDefinitions>\n"
544  " <unitDefinition id=\"volume\">\n"
545  " <listOfUnits>\n"
546  " <unit kind=\"litre\" scale=\"-3\"/>\n"
547  " </listOfUnits>\n"
548  " </unitDefinition>\n"
549  " <unitDefinition id=\"substance\">\n"
550  " <listOfUnits>\n"
551  " <unit kind=\"mole\" scale=\"-3\"/>\n"
552  " </listOfUnits>\n"
553  " </unitDefinition>\n"
554  " </listOfUnitDefinitions>\n"
555  " <listOfCompartments>\n"
556  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>\n"
557  " </listOfCompartments>\n"
558  " <listOfSpecies>\n"
559  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\" boundaryCondition=\"true\"/>\n"
560  " </listOfSpecies>\n"
561  " <listOfRules>\n"
562  " <assignmentRule variable=\"species_1\">\n"
563  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
564  " <piecewise>\n"
565  " <piece>\n"
566  " <cn> 0.1 </cn>\n"
567  " <apply>\n"
568  " <lt/>\n"
569  " <cn> 3 </cn>\n"
570  " <cn> 4 </cn>\n"
571  " </apply>\n"
572  " </piece>\n"
573  " <piece>\n"
574  " <cn> 0.2 </cn>\n"
575  " <apply>\n"
576  " <gt/>\n"
577  " <cn> 3 </cn>\n"
578  " <cn> 4 </cn>\n"
579  " </apply>\n"
580  " </piece>\n"
581  " <piece>\n"
582  " <cn> 0.3 </cn>\n"
583  " <apply>\n"
584  " <leq/>\n"
585  " <cn> 3 </cn>\n"
586  " <cn> 4 </cn>\n"
587  " </apply>\n"
588  " </piece>\n"
589  " <piece>\n"
590  " <cn> 0.4 </cn>\n"
591  " <apply>\n"
592  " <eq/>\n"
593  " <cn> 3 </cn>\n"
594  " <cn> 4 </cn>\n"
595  " </apply>\n"
596  " </piece>\n"
597  " <otherwise>\n"
598  " <cn> 1.5 </cn>\n"
599  " </otherwise>\n"
600  " </piecewise>\n"
601  " </math>\n"
602  " </assignmentRule>\n"
603  " </listOfRules>\n"
604  " </model>\n"
605  "</sbml>\n"
606  ;
Header file of class CExpression.
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000053.h:40
void test1_bug1000()
Definition: test000053.cpp:58
Header file of class CModelEntity and CModelValue.
CCopasiNode< Data > * getSibling()
Definition: CCopasiNode.h:353
static const char * MODEL_STRING_4
Definition: test000053.h:38
static const char * MODEL_STRING_1
Definition: test000053.h:35
void test5_bug1000()
Definition: test000053.cpp:383
void test2_bug1000()
Definition: test000053.cpp:162
static const char * MODEL_STRING_2
Definition: test000053.h:36
const Type & getType() const
void test3_bug1000()
Definition: test000053.cpp:223
static const char * MODEL_STRING_5
Definition: test000053.h:39
Definition: CMetab.h:178
static Type type(const Type &type)
static CCopasiDataModel * addDatamodel()
static Type subType(const Type &type)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static void init(int argc, char *argv[], const bool &withGui=false)
void test4_bug1000()
Definition: test000053.cpp:318
Definition: CModel.h:50
void tearDown()
Definition: test000053.cpp:53
void setUp()
Definition: test000053.cpp:45
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
static const char * MODEL_STRING_3
Definition: test000053.h:37