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

#include <test000095.h>

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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_import_l3_event_1 ()
 
void test_import_l3_event_2 ()
 
void test_import_l3_event_3 ()
 
void test_import_l3_event_4 ()
 
void test_import_l3_event_5 ()
 

Static Protected Attributes

static const char * MODEL_STRING1
 
static const char * MODEL_STRING2
 
static const char * MODEL_STRING3
 
static const char * MODEL_STRING4
 
static const char * MODEL_STRING5
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_import_l3_event_1)
 
 CPPUNIT_TEST (test_import_l3_event_2)
 
 CPPUNIT_TEST (test_import_l3_event_3)
 
 CPPUNIT_TEST (test_import_l3_event_4)
 
 CPPUNIT_TEST (test_import_l3_event_5)
 
 CPPUNIT_TEST_SUITE (test000095)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 29 of file test000095.h.

Member Function Documentation

test000095::CPPUNIT_TEST ( test_import_l3_event_1  )
private
test000095::CPPUNIT_TEST ( test_import_l3_event_2  )
private
test000095::CPPUNIT_TEST ( test_import_l3_event_3  )
private
test000095::CPPUNIT_TEST ( test_import_l3_event_4  )
private
test000095::CPPUNIT_TEST ( test_import_l3_event_5  )
private
test000095::CPPUNIT_TEST_SUITE ( test000095  )
private
test000095::CPPUNIT_TEST_SUITE_END ( )
private
void test000095::setUp ( )

Definition at line 37 of file test000095.cpp.

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

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

Definition at line 45 of file test000095.cpp.

References CCopasiRootContainer::destroy().

void test000095::test_import_l3_event_1 ( )

Definition at line 50 of file test000095.cpp.

References CCopasiMessage::checkForMessage(), CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, MCSBML, MODEL_STRING1, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CEvaluationNode::subType(), and CEvaluationNode::type().

51 {
52  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
53  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING1));
54  CModel* pModel = pDataModel->getModel();
55  CPPUNIT_ASSERT(pModel != NULL);
56  CPPUNIT_ASSERT(pModel->getCompartments().size() == 0);
57  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 0);
58  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
59  const CModelValue* pModelValue = pModel->getModelValues()[0];
60  CPPUNIT_ASSERT(pModelValue != NULL);
61  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
62  const CEvent* pEvent = pModel->getEvents()[0];
63  CPPUNIT_ASSERT(pEvent != NULL);
64 
65  // check the trigger expression
66  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
67  CPPUNIT_ASSERT(pExpr != NULL);
68  const CEvaluationNode* pNode = pExpr->getRoot();
69  CPPUNIT_ASSERT(pNode != NULL);
70  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
72  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
73  CPPUNIT_ASSERT(pNode != NULL);
74  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
75  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
76  CPPUNIT_ASSERT(pObjectNode != NULL);
77  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
78  CPPUNIT_ASSERT(!objectCN.empty());
79  std::vector<CCopasiContainer*> listOfContainers;
80  listOfContainers.push_back(pModel);
81  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
82  CPPUNIT_ASSERT(pObject != NULL);
83  CPPUNIT_ASSERT(pObject->isReference() == true);
84  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
85  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
86  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
87  CPPUNIT_ASSERT(pNode != NULL);
88  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
89  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
90  CPPUNIT_ASSERT(pNumberNode != NULL);
91  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
92  // check that there is a delay
93 
94  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
95  // check the event assignment
96  std::string key = pEvent->getAssignments()[0]->getTargetKey();
97  CPPUNIT_ASSERT(key == pModelValue->getKey());
98  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
99  CPPUNIT_ASSERT(pExpr != NULL);
100  pNode = pExpr->getRoot();
101  CPPUNIT_ASSERT(pNode != NULL);
102  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
103  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
104  CPPUNIT_ASSERT(pNumberNode != NULL);
105  CPPUNIT_ASSERT((fabs(pNumberNode->getValue() - 8.0) / 8.0) < 1e-9);
106 
107  // check that the message stack contains a warning about event priorities
108  // MCSBML + 98
109  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 97) == false);
110  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 98) == true);
111  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 99) == false);
112 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
const Type & getType() const
static Type type(const Type &type)
#define MCSBML
bool isReference() const
static const char * MODEL_STRING1
Definition: test000095.h:43
static Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000095.h:57
static bool checkForMessage(const size_t &number)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000095::test_import_l3_event_2 ( )

Definition at line 114 of file test000095.cpp.

References CCopasiMessage::checkForMessage(), CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, MCSBML, MODEL_STRING2, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CEvaluationNode::subType(), and CEvaluationNode::type().

115 {
116  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
117  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING2));
118  CModel* pModel = pDataModel->getModel();
119  CPPUNIT_ASSERT(pModel != NULL);
120  CPPUNIT_ASSERT(pModel->getCompartments().size() == 0);
121  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 0);
122  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
123  const CModelValue* pModelValue = pModel->getModelValues()[0];
124  CPPUNIT_ASSERT(pModelValue != NULL);
125  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
126  const CEvent* pEvent = pModel->getEvents()[0];
127  CPPUNIT_ASSERT(pEvent != NULL);
128 
129  // check the trigger expression
130  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
131  CPPUNIT_ASSERT(pExpr != NULL);
132  const CEvaluationNode* pNode = pExpr->getRoot();
133  CPPUNIT_ASSERT(pNode != NULL);
134  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
136  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
137  CPPUNIT_ASSERT(pNode != NULL);
138  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
139  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
140  CPPUNIT_ASSERT(pObjectNode != NULL);
141  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
142  CPPUNIT_ASSERT(!objectCN.empty());
143  std::vector<CCopasiContainer*> listOfContainers;
144  listOfContainers.push_back(pModel);
145  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
146  CPPUNIT_ASSERT(pObject != NULL);
147  CPPUNIT_ASSERT(pObject->isReference() == true);
148  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
149  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
150  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
151  CPPUNIT_ASSERT(pNode != NULL);
152  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
153  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
154  CPPUNIT_ASSERT(pNumberNode != NULL);
155  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
156  // check that there is a delay
157 
158  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
159  // check the event assignment
160  std::string key = pEvent->getAssignments()[0]->getTargetKey();
161  CPPUNIT_ASSERT(key == pModelValue->getKey());
162  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
163  CPPUNIT_ASSERT(pExpr != NULL);
164  pNode = pExpr->getRoot();
165  CPPUNIT_ASSERT(pNode != NULL);
166  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
167  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
168  CPPUNIT_ASSERT(pNumberNode != NULL);
169  CPPUNIT_ASSERT((fabs(pNumberNode->getValue() - 8.0) / 8.0) < 1e-9);
170 
171 
172  // check that the message stack contains a warning about initial values for triggers
173  // MCSBML + 97
174  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 97) == true);
175  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 98) == false);
176  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 99) == false);
177 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
const Type & getType() const
static Type type(const Type &type)
#define MCSBML
static const char * MODEL_STRING2
Definition: test000095.h:46
bool isReference() const
static Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000095.h:57
static bool checkForMessage(const size_t &number)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000095::test_import_l3_event_3 ( )

Definition at line 179 of file test000095.cpp.

References CCopasiMessage::checkForMessage(), CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, MCSBML, MODEL_STRING3, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CEvaluationNode::subType(), and CEvaluationNode::type().

180 {
181  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
182  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING3));
183  CModel* pModel = pDataModel->getModel();
184  CPPUNIT_ASSERT(pModel != NULL);
185  CPPUNIT_ASSERT(pModel->getCompartments().size() == 0);
186  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 0);
187  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
188  const CModelValue* pModelValue = pModel->getModelValues()[0];
189  CPPUNIT_ASSERT(pModelValue != NULL);
190  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
191  const CEvent* pEvent = pModel->getEvents()[0];
192  CPPUNIT_ASSERT(pEvent != NULL);
193 
194  // check the trigger expression
195  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
196  CPPUNIT_ASSERT(pExpr != NULL);
197  const CEvaluationNode* pNode = pExpr->getRoot();
198  CPPUNIT_ASSERT(pNode != NULL);
199  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
201  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
202  CPPUNIT_ASSERT(pNode != NULL);
203  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
204  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
205  CPPUNIT_ASSERT(pObjectNode != NULL);
206  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
207  CPPUNIT_ASSERT(!objectCN.empty());
208  std::vector<CCopasiContainer*> listOfContainers;
209  listOfContainers.push_back(pModel);
210  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
211  CPPUNIT_ASSERT(pObject != NULL);
212  CPPUNIT_ASSERT(pObject->isReference() == true);
213  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
214  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
215  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
216  CPPUNIT_ASSERT(pNode != NULL);
217  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
218  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
219  CPPUNIT_ASSERT(pNumberNode != NULL);
220  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
221  // check that there is a delay
222 
223  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
224  // check the event assignment
225  std::string key = pEvent->getAssignments()[0]->getTargetKey();
226  CPPUNIT_ASSERT(key == pModelValue->getKey());
227  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
228  CPPUNIT_ASSERT(pExpr != NULL);
229  pNode = pExpr->getRoot();
230  CPPUNIT_ASSERT(pNode != NULL);
231  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
232  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
233  CPPUNIT_ASSERT(pNumberNode != NULL);
234  CPPUNIT_ASSERT((fabs(pNumberNode->getValue() - 8.0) / 8.0) < 1e-9);
235 
236  // check that the message stack contains a warning about event priorities
237  // MCSBML + 98
238  // check that the message stack contains a warning about initial values for triggers
239  // MCSBML + 97
240  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 97) == true);
241  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 98) == true);
242  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 99) == false);
243 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
static const char * MODEL_STRING3
Definition: test000095.h:49
const Type & getType() const
static Type type(const Type &type)
#define MCSBML
bool isReference() const
static Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000095.h:57
static bool checkForMessage(const size_t &number)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000095::test_import_l3_event_4 ( )

Definition at line 245 of file test000095.cpp.

References CCopasiMessage::checkForMessage(), CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, MCSBML, MODEL_STRING4, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CEvaluationNode::subType(), and CEvaluationNode::type().

246 {
247  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
248  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING4));
249  CModel* pModel = pDataModel->getModel();
250  CPPUNIT_ASSERT(pModel != NULL);
251  CPPUNIT_ASSERT(pModel->getCompartments().size() == 0);
252  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 0);
253  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
254  const CModelValue* pModelValue = pModel->getModelValues()[0];
255  CPPUNIT_ASSERT(pModelValue != NULL);
256  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
257  const CEvent* pEvent = pModel->getEvents()[0];
258  CPPUNIT_ASSERT(pEvent != NULL);
259 
260  // check the trigger expression
261  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
262  CPPUNIT_ASSERT(pExpr != NULL);
263  const CEvaluationNode* pNode = pExpr->getRoot();
264  CPPUNIT_ASSERT(pNode != NULL);
265  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
267  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
268  CPPUNIT_ASSERT(pNode != NULL);
269  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
270  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
271  CPPUNIT_ASSERT(pObjectNode != NULL);
272  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
273  CPPUNIT_ASSERT(!objectCN.empty());
274  std::vector<CCopasiContainer*> listOfContainers;
275  listOfContainers.push_back(pModel);
276  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
277  CPPUNIT_ASSERT(pObject != NULL);
278  CPPUNIT_ASSERT(pObject->isReference() == true);
279  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
280  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
281  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
282  CPPUNIT_ASSERT(pNode != NULL);
283  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
284  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
285  CPPUNIT_ASSERT(pNumberNode != NULL);
286  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
287  // check that there is a delay
288 
289  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
290  // check the event assignment
291  std::string key = pEvent->getAssignments()[0]->getTargetKey();
292  CPPUNIT_ASSERT(key == pModelValue->getKey());
293  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
294  CPPUNIT_ASSERT(pExpr != NULL);
295  pNode = pExpr->getRoot();
296  CPPUNIT_ASSERT(pNode != NULL);
297  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
298  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
299  CPPUNIT_ASSERT(pNumberNode != NULL);
300  CPPUNIT_ASSERT((fabs(pNumberNode->getValue() - 8.0) / 8.0) < 1e-9);
301 
302  // check that the message stack contains a warning about non-persistent triggers
303  // MCSBML + 99
304  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 97) == false);
305  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 98) == false);
306  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 99) == true);
307 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
const Type & getType() const
static Type type(const Type &type)
#define MCSBML
bool isReference() const
static const char * MODEL_STRING4
Definition: test000095.h:52
static Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000095.h:57
static bool checkForMessage(const size_t &number)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
void test000095::test_import_l3_event_5 ( )

Definition at line 309 of file test000095.cpp.

References CCopasiMessage::checkForMessage(), CCopasiNode< _Data >::getChild(), CCopasiDataModel::getModel(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CEvaluationTree::getRoot(), CEvaluationNode::getType(), CEvaluationNode::getValue(), CEvaluationNodeLogical::GT, CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CEvaluationNode::LOGICAL, MCSBML, MODEL_STRING5, CEvaluationNode::NUMBER, CEvaluationNode::OBJECT, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CEvaluationNode::subType(), and CEvaluationNode::type().

310 {
311  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
312  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING5));
313  CModel* pModel = pDataModel->getModel();
314  CPPUNIT_ASSERT(pModel != NULL);
315  CPPUNIT_ASSERT(pModel->getCompartments().size() == 0);
316  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 0);
317  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
318  const CModelValue* pModelValue = pModel->getModelValues()[0];
319  CPPUNIT_ASSERT(pModelValue != NULL);
320  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
321  const CEvent* pEvent = pModel->getEvents()[0];
322  CPPUNIT_ASSERT(pEvent != NULL);
323 
324  // check the trigger expression
325  const CExpression* pExpr = pEvent->getTriggerExpressionPtr();
326  CPPUNIT_ASSERT(pExpr != NULL);
327  const CEvaluationNode* pNode = pExpr->getRoot();
328  CPPUNIT_ASSERT(pNode != NULL);
329  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::LOGICAL);
331  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getChild());
332  CPPUNIT_ASSERT(pNode != NULL);
333  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::OBJECT);
334  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
335  CPPUNIT_ASSERT(pObjectNode != NULL);
336  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
337  CPPUNIT_ASSERT(!objectCN.empty());
338  std::vector<CCopasiContainer*> listOfContainers;
339  listOfContainers.push_back(pModel);
340  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
341  CPPUNIT_ASSERT(pObject != NULL);
342  CPPUNIT_ASSERT(pObject->isReference() == true);
343  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
344  CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
345  pNode = dynamic_cast<const CEvaluationNode*>(pNode->getSibling());
346  CPPUNIT_ASSERT(pNode != NULL);
347  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
348  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
349  CPPUNIT_ASSERT(pNumberNode != NULL);
350  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 2.0) / 2.0) < 1e-6);
351  // check that there is a delay
352 
353  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 1);
354  // check the event assignment
355  std::string key = pEvent->getAssignments()[0]->getTargetKey();
356  CPPUNIT_ASSERT(key == pModelValue->getKey());
357  pExpr = pEvent->getAssignments()[0]->getExpressionPtr();
358  CPPUNIT_ASSERT(pExpr != NULL);
359  pNode = pExpr->getRoot();
360  CPPUNIT_ASSERT(pNode != NULL);
361  CPPUNIT_ASSERT(CEvaluationNode::type(pNode->getType()) == CEvaluationNode::NUMBER);
362  pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode);
363  CPPUNIT_ASSERT(pNumberNode != NULL);
364  CPPUNIT_ASSERT((fabs(pNumberNode->getValue() - 8.0) / 8.0) < 1e-9);
365 
366  // check that there is no MCSBML + 97, MCSBML + 98 or MCSBML + 99 error message
367  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 97) == false);
368  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 98) == false);
369  CPPUNIT_ASSERT(CCopasiMessage::checkForMessage(MCSBML + 99) == false);
370 }
Definition: CEvent.h:152
const std::string & getObjectName() const
const CRegisteredObjectName & getObjectCN() const
const C_FLOAT64 & getValue() const
const Type & getType() const
static Type type(const Type &type)
#define MCSBML
bool isReference() const
static Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000095.h:57
static bool checkForMessage(const size_t &number)
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
static const char * MODEL_STRING5
Definition: test000095.h:55

Member Data Documentation

const char * test000095::MODEL_STRING1
staticprotected

Definition at line 43 of file test000095.h.

Referenced by test_import_l3_event_1().

const char * test000095::MODEL_STRING2
staticprotected

Definition at line 46 of file test000095.h.

Referenced by test_import_l3_event_2().

const char * test000095::MODEL_STRING3
staticprotected

Definition at line 49 of file test000095.h.

Referenced by test_import_l3_event_3().

const char * test000095::MODEL_STRING4
staticprotected

Definition at line 52 of file test000095.h.

Referenced by test_import_l3_event_4().

const char * test000095::MODEL_STRING5
staticprotected

Definition at line 55 of file test000095.h.

Referenced by test_import_l3_event_5().

CCopasiDataModel * test000095::pCOPASIDATAMODEL = NULL
staticprotected

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