COPASI API  4.16.103
Public Member Functions | Static Protected Attributes | Private Member Functions | List of all members
test000057 Class Reference

#include <test000057.h>

Inheritance diagram for test000057:
Inheritance graph
[legend]
Collaboration diagram for test000057:
Collaboration graph
[legend]

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_bug1006 ()
 

Static Protected Attributes

static const char * MODEL_STRING
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_bug1006)
 
 CPPUNIT_TEST_SUITE (test000057)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 24 of file test000057.h.

Member Function Documentation

test000057::CPPUNIT_TEST ( test_bug1006  )
private
test000057::CPPUNIT_TEST_SUITE ( test000057  )
private
test000057::CPPUNIT_TEST_SUITE_END ( )
private
void test000057::setUp ( )

Definition at line 38 of file test000057.cpp.

References CCopasiRootContainer::addDatamodel(), CCopasiRootContainer::init(), and pCOPASIDATAMODEL.

39 {
40  // Create the root container.
41  CCopasiRootContainer::init(0, NULL, false);
42  // Create the global data model.
44 }
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000057.h:32
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
void test000057::tearDown ( )

Definition at line 46 of file test000057.cpp.

References CCopasiRootContainer::destroy().

void test000057::test_bug1006 ( )

Definition at line 51 of file test000057.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), CModelEntity::getSBMLId(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING, and pCOPASIDATAMODEL.

52 {
53  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
54  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000057::MODEL_STRING));
55  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
56  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
57  const Model* pSBMLModel = pDocument->getModel();
58  CPPUNIT_ASSERT(pSBMLModel != NULL);
59  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 0);
60  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 0);
61  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
62  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
63  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 5);
64  const Parameter* pParameter1 = pSBMLModel->getParameter(0);
65  CPPUNIT_ASSERT(pParameter1 != NULL);
66  CPPUNIT_ASSERT(pParameter1->getConstant() == true);
67  const Parameter* pParameter2 = pSBMLModel->getParameter(1);
68  CPPUNIT_ASSERT(pParameter2 != NULL);
69  CPPUNIT_ASSERT(pParameter2->getConstant() == true);
70  const Parameter* pParameter3 = pSBMLModel->getParameter(2);
71  CPPUNIT_ASSERT(pParameter3 != NULL);
72  CPPUNIT_ASSERT(pParameter3->getConstant() == true);
73  const Parameter* pParameter4 = pSBMLModel->getParameter(3);
74  CPPUNIT_ASSERT(pParameter4 != NULL);
75  CPPUNIT_ASSERT(pParameter4->getConstant() == true);
76  const Parameter* pParameter5 = pSBMLModel->getParameter(4);
77  CPPUNIT_ASSERT(pParameter5 != NULL);
78  CPPUNIT_ASSERT(pParameter5->getConstant() == true);
79  CPPUNIT_ASSERT(pSBMLModel->getNumInitialAssignments() == 5);
80  const InitialAssignment* pIA = pSBMLModel->getInitialAssignment(0);
81  CPPUNIT_ASSERT(pIA != NULL);
82  CPPUNIT_ASSERT(pIA->getSymbol() == pParameter1->getId());
83  CPPUNIT_ASSERT(pIA->isSetMath() == true);
84  const ASTNode* pMath = pIA->getMath();
85  CPPUNIT_ASSERT(pMath != NULL);
86  CPPUNIT_ASSERT(pMath->getType() == AST_TIMES);
87  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
88  const ASTNode* pChild1 = pMath->getChild(0);
89  CPPUNIT_ASSERT(pChild1 != NULL);
90  CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
91  CPPUNIT_ASSERT(fabs((pChild1->getReal() - 3.0) / 3.0) < 1e-15);
92  const ASTNode* pChild2 = pMath->getChild(1);
93  CPPUNIT_ASSERT(pChild2 != NULL);
94  CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
95  CPPUNIT_ASSERT(fabs((pChild2->getReal() - 4.0) / 4.0) < 1e-15);
96 
97  pIA = pSBMLModel->getInitialAssignment(1);
98  CPPUNIT_ASSERT(pIA != NULL);
99  CPPUNIT_ASSERT(pIA->getSymbol() == pParameter2->getId());
100  CPPUNIT_ASSERT(pIA->isSetMath() == true);
101  pMath = pIA->getMath();
102  CPPUNIT_ASSERT(pMath != NULL);
103  CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
104  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
105  pChild1 = pMath->getChild(0);
106  CPPUNIT_ASSERT(pChild1 != NULL);
107  CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
108  CPPUNIT_ASSERT(fabs((pChild1->getReal() - 9.0) / 9.0) < 1e-15);
109  pChild2 = pMath->getChild(1);
110  CPPUNIT_ASSERT(pChild2 != NULL);
111  CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
112  CPPUNIT_ASSERT(fabs((pChild2->getReal() - 2.0) / 2.0) < 1e-15);
113 
114  pIA = pSBMLModel->getInitialAssignment(2);
115  CPPUNIT_ASSERT(pIA != NULL);
116  CPPUNIT_ASSERT(pIA->getSymbol() == pParameter3->getId());
117  CPPUNIT_ASSERT(pIA->isSetMath() == true);
118  pMath = pIA->getMath();
119  CPPUNIT_ASSERT(pMath != NULL);
120  CPPUNIT_ASSERT(pMath->getType() == AST_MINUS);
121  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
122  pChild1 = pMath->getChild(0);
123  CPPUNIT_ASSERT(pChild1 != NULL);
124  CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
125  CPPUNIT_ASSERT(fabs((pChild1->getReal() - 8.0) / 8.0) < 1e-15);
126  pChild2 = pMath->getChild(1);
127  CPPUNIT_ASSERT(pChild2 != NULL);
128  CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
129  CPPUNIT_ASSERT(fabs((pChild2->getReal() - 4.0) / 4.0) < 1e-15);
130 
131  pIA = pSBMLModel->getInitialAssignment(3);
132  CPPUNIT_ASSERT(pIA != NULL);
133  CPPUNIT_ASSERT(pIA->getSymbol() == pParameter4->getId());
134  CPPUNIT_ASSERT(pIA->isSetMath() == true);
135  pMath = pIA->getMath();
136  CPPUNIT_ASSERT(pMath != NULL);
137  CPPUNIT_ASSERT(pMath->getType() == AST_DIVIDE);
138  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
139  pChild1 = pMath->getChild(0);
140  CPPUNIT_ASSERT(pChild1 != NULL);
141  CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
142  CPPUNIT_ASSERT(fabs((pChild1->getReal() - 9.0) / 9.0) < 1e-15);
143  pChild2 = pMath->getChild(1);
144  CPPUNIT_ASSERT(pChild2 != NULL);
145  CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
146  CPPUNIT_ASSERT(fabs((pChild2->getReal() - 3.0) / 3.0) < 1e-15);
147 
148  pIA = pSBMLModel->getInitialAssignment(4);
149  CPPUNIT_ASSERT(pIA != NULL);
150  CPPUNIT_ASSERT(pIA->getSymbol() == pParameter5->getId());
151  CPPUNIT_ASSERT(pIA->isSetMath() == true);
152  pMath = pIA->getMath();
153  CPPUNIT_ASSERT(pMath != NULL);
154  CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
155  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
156  pChild1 = pMath->getChild(0);
157  CPPUNIT_ASSERT(pChild1 != NULL);
158  CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
159  CPPUNIT_ASSERT(fabs((pChild1->getReal() - 6.0) / 6.0) < 1e-15);
160  pChild2 = pMath->getChild(1);
161  CPPUNIT_ASSERT(pChild2 != NULL);
162  CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
163  CPPUNIT_ASSERT(fabs((pChild2->getReal() - 1.0) / 1.0) < 1e-15);
164  // delete some initial assignments
165  // delete iniaitl assignments for model value1,model value4 and model value5
166  CModel* pModel = pDataModel->getModel();
167  CPPUNIT_ASSERT(pModel != NULL);
168  CPPUNIT_ASSERT(pModel->getModelValues().size() == 5);
169  CModelValue *pMV1 = NULL, *pMV2 = NULL, *pMV3 = NULL, *pMV4 = NULL, *pMV5 = NULL;
170  unsigned int i, iMax = pModel->getModelValues().size();
171 
172  for (i = 0; i < iMax; ++i)
173  {
174  CModelValue* pTmpMV = pModel->getModelValues()[i];
175 
176  if (pTmpMV->getSBMLId() == pParameter1->getId())
177  {
178  pMV1 = pTmpMV;
179  }
180  else if (pTmpMV->getSBMLId() == pParameter2->getId())
181  {
182  pMV2 = pTmpMV;
183  }
184  else if (pTmpMV->getSBMLId() == pParameter3->getId())
185  {
186  pMV3 = pTmpMV;
187  }
188  else if (pTmpMV->getSBMLId() == pParameter4->getId())
189  {
190  pMV4 = pTmpMV;
191  }
192  else if (pTmpMV->getSBMLId() == pParameter5->getId())
193  {
194  pMV5 = pTmpMV;
195  }
196  }
197 
198  CPPUNIT_ASSERT(pMV1 != NULL);
199  CPPUNIT_ASSERT(pMV2 != NULL);
200  CPPUNIT_ASSERT(pMV3 != NULL);
201  CPPUNIT_ASSERT(pMV4 != NULL);
202  CPPUNIT_ASSERT(pMV5 != NULL);
203  pMV1->setInitialExpression("");
204  pMV4->setInitialExpression("");
205  pMV5->setInitialExpression("");
206 
207  // reexport the model to L2V3
208  CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
209  pDocument = pDataModel->getCurrentSBMLDocument();
210  CPPUNIT_ASSERT(pDocument != NULL);
211  pSBMLModel = pDocument->getModel();
212  CPPUNIT_ASSERT(pSBMLModel != NULL);
213  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 0);
214  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 0);
215  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
216  CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 0);
217  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 5);
218  pParameter1 = pSBMLModel->getParameter(0);
219  CPPUNIT_ASSERT(pParameter1 != NULL);
220  CPPUNIT_ASSERT(pParameter1->getConstant() == true);
221  pParameter2 = pSBMLModel->getParameter(1);
222  CPPUNIT_ASSERT(pParameter2 != NULL);
223  CPPUNIT_ASSERT(pParameter2->getConstant() == true);
224  pParameter3 = pSBMLModel->getParameter(2);
225  CPPUNIT_ASSERT(pParameter3 != NULL);
226  CPPUNIT_ASSERT(pParameter3->getConstant() == true);
227  pParameter4 = pSBMLModel->getParameter(3);
228  CPPUNIT_ASSERT(pParameter4 != NULL);
229  CPPUNIT_ASSERT(pParameter4->getConstant() == true);
230  pParameter5 = pSBMLModel->getParameter(4);
231  CPPUNIT_ASSERT(pParameter5 != NULL);
232  CPPUNIT_ASSERT(pParameter5->getConstant() == true);
233  CPPUNIT_ASSERT(pSBMLModel->getNumInitialAssignments() == 2);
234  pIA = pSBMLModel->getInitialAssignment(0);
235  CPPUNIT_ASSERT(pIA != NULL);
236  CPPUNIT_ASSERT(pIA->getSymbol() == pParameter2->getId());
237  CPPUNIT_ASSERT(pIA->isSetMath() == true);
238  pMath = pIA->getMath();
239  CPPUNIT_ASSERT(pMath != NULL);
240  CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
241  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
242  pChild1 = pMath->getChild(0);
243  CPPUNIT_ASSERT(pChild1 != NULL);
244  CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
245  CPPUNIT_ASSERT(fabs((pChild1->getReal() - 9.0) / 9.0) < 1e-15);
246  pChild2 = pMath->getChild(1);
247  CPPUNIT_ASSERT(pChild2 != NULL);
248  CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
249  CPPUNIT_ASSERT(fabs((pChild2->getReal() - 2.0) / 2.0) < 1e-15);
250 
251  pIA = pSBMLModel->getInitialAssignment(1);
252  CPPUNIT_ASSERT(pIA != NULL);
253  CPPUNIT_ASSERT(pIA->getSymbol() == pParameter3->getId());
254  CPPUNIT_ASSERT(pIA->isSetMath() == true);
255  pMath = pIA->getMath();
256  CPPUNIT_ASSERT(pMath != NULL);
257  CPPUNIT_ASSERT(pMath->getType() == AST_MINUS);
258  CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
259  pChild1 = pMath->getChild(0);
260  CPPUNIT_ASSERT(pChild1 != NULL);
261  CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
262  CPPUNIT_ASSERT(fabs((pChild1->getReal() - 8.0) / 8.0) < 1e-15);
263  pChild2 = pMath->getChild(1);
264  CPPUNIT_ASSERT(pChild2 != NULL);
265  CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
266  CPPUNIT_ASSERT(fabs((pChild2->getReal() - 4.0) / 4.0) < 1e-15);
267 }
SBMLDocument * getCurrentSBMLDocument()
const std::string & getSBMLId() const
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000057.h:32
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static const char * MODEL_STRING
Definition: test000057.h:31
Definition: CModel.h:50

Member Data Documentation

const char * test000057::MODEL_STRING
staticprotected

Definition at line 31 of file test000057.h.

Referenced by test_bug1006().

CCopasiDataModel * test000057::pCOPASIDATAMODEL = NULL
staticprotected

Definition at line 32 of file test000057.h.

Referenced by setUp(), and test_bug1006().


The documentation for this class was generated from the following files: