COPASI API  4.16.103
test000088.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000088.cpp,v $
3 // $Revision: 1.2 $
4 // $Name: $
5 // $Author: gauges $
6 // $Date: 2010/03/11 11:55:16 $
7 // End CVS Header
8 
9 // Copyright (C) 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 #include "test000088.h"
15 
16 #include "utilities.hpp"
20 #include "copasi/model/CModel.h"
22 #include "copasi/model/CEvent.h"
23 
24 // test for Bug 1411
25 
26 CCopasiDataModel* test000088::pCOPASIDATAMODEL = NULL;
27 
29 {
30  // Create the root container.
31  CCopasiRootContainer::init(0, NULL, false);
32  // Create the global data model.
34 }
35 
37 {
39 }
40 
42 {
44  // check if we have the correct warning message on the stack
45  // there should be a warning (MCSBML + 58)
46  unsigned int i, iMax = CCopasiMessage::size();
47  CCopasiMessage message;
48  bool found58 = false;
49 
50  for (i = 0; i < iMax; ++i)
51  {
53 
54  if (message.getNumber() == MCSBML + 58)
55  {
56  found58 = true;
57  break;
58  }
59  }
60 
61  CPPUNIT_ASSERT(found58 == true);
62  // check if the model contains one parameter and that this parameter does not
63  // have an expression
64  const CModel* pModel = pCOPASIDATAMODEL->getModel();
65  CPPUNIT_ASSERT(pModel != NULL);
66  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
67  const CModelValue* pMV = pModel->getModelValues()[0];
68  CPPUNIT_ASSERT(pMV != NULL);
69  CPPUNIT_ASSERT(pMV->getExpression().empty());
70 }
71 
73 {
75  CPPUNIT_ASSERT(result == true);
76  // check if we have the correct warning message on the stack
77  // there should be a warning (MCSBML + 58)
78  unsigned int i, iMax = CCopasiMessage::size();
79  CCopasiMessage message;
80  bool found58 = false;
81 
82  for (i = 0; i < iMax; ++i)
83  {
85 
86  if (message.getNumber() == MCSBML + 58)
87  {
88  found58 = true;
89  break;
90  }
91  }
92 
93  CPPUNIT_ASSERT(found58 == true);
94  // check if the model contains one parameter and that this parameter does not
95  // have an expression
96  const CModel* pModel = pCOPASIDATAMODEL->getModel();
97  CPPUNIT_ASSERT(pModel != NULL);
98  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
99  const CModelValue* pMV = pModel->getModelValues()[0];
100  CPPUNIT_ASSERT(pMV != NULL);
101  CPPUNIT_ASSERT(pMV->getInitialExpression().empty());
102  // since the parameter does not set an initial value, it's value should be 1.0
103  CPPUNIT_ASSERT(fabs(pMV->getInitialValue() - 1.0) < 1e-6);
104 }
105 
107 {
109  // check if we have the correct warning message on the stack
110  // there should be a warning (MCSBML + 58)
111  unsigned int i, iMax = CCopasiMessage::size();
112  CCopasiMessage message;
113  bool found58 = false;
114 
115  for (i = 0; i < iMax; ++i)
116  {
117  message = CCopasiMessage::getLastMessage();
118 
119  if (message.getNumber() == MCSBML + 58)
120  {
121  found58 = true;
122  break;
123  }
124  }
125 
126  CPPUNIT_ASSERT(found58 == true);
127  // check if the model contains one parameter and that this parameter does not
128  // have an expression
129  const CModel* pModel = pCOPASIDATAMODEL->getModel();
130  CPPUNIT_ASSERT(pModel != NULL);
131  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
132  const CModelValue* pMV = pModel->getModelValues()[0];
133  CPPUNIT_ASSERT(pMV != NULL);
134  // since the parameter does not set an initial value, it's value should be 1
135  CPPUNIT_ASSERT(fabs(pMV->getInitialValue() - 1.0) < 1e-6);
136 
137  // check if there is one event and that this event does not have an event
138  // assignment
139  CPPUNIT_ASSERT(pModel->getEvents().size() == 1);
140  const CEvent* pEvent = pModel->getEvents()[0];
141  CPPUNIT_ASSERT(pEvent != NULL);
142  CPPUNIT_ASSERT(pEvent->getAssignments().size() == 0);
143 }
144 
145 const char* test000088::MODEL_STRING1 =
146  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
147  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
148  " <model id=\"model_1\" name=\"model\">\n"
149  " <listOfParameters>\n"
150  " <parameter constant=\"false\" id=\"parameter_1\"/>\n"
151  " </listOfParameters>\n"
152  " <listOfRules>\n"
153  " <assignmentRule variable=\"parameter_1\" />\n"
154  " </listOfRules>\n"
155  " </model>\n"
156  "</sbml>\n";
157 
158 const char* test000088::MODEL_STRING2 =
159  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
160  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" level=\"2\" version=\"4\">\n"
161  " <model id=\"model_1\" name=\"model\">\n"
162  " <listOfParameters>\n"
163  " <parameter constant=\"false\" id=\"parameter_1\"/>\n"
164  " </listOfParameters>\n"
165  " <listOfInitialAssignments>\n"
166  " <initialAssignment symbol=\"parameter_1\" />\n"
167  " </listOfInitialAssignments>\n"
168  " </model>\n"
169  "</sbml>\n";
170 
171 const char* test000088::MODEL_STRING3 =
172  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
173  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
174  " <model id=\"model_1\" name=\"model\">\n"
175  " <listOfParameters>\n"
176  " <parameter constant=\"false\" id=\"parameter_1\"/>\n"
177  " </listOfParameters>\n"
178  " <listOfEvents>\n"
179  " <event>\n"
180  " <trigger>\n"
181  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
182  " <apply>\n"
183  " <geq/>\n"
184  " <ci> parameter_1 </ci>\n"
185  " <cn> 3.0 </cn>\n"
186  " </apply>\n"
187  " </math>\n"
188  " </trigger>\n"
189  " <listOfEventAssignments>\n"
190  " <eventAssignment variable=\"parameter_1\" />\n"
191  " </listOfEventAssignments>\n"
192  " </event>\n"
193  " </listOfEvents>\n"
194  " </model>\n"
195  "</sbml>\n";
Definition: CEvent.h:152
static const char * MODEL_STRING2
Definition: test000088.h:37
Header file of class CModelEntity and CModelValue.
CCopasiVectorN< CEvent > & getEvents()
Definition: CModel.cpp:1110
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
virtual size_t size() const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000088.h:35
static const char * MODEL_STRING1
Definition: test000088.h:36
const size_t & getNumber() const
void test_import_eventassignment_without_expression()
Definition: test000088.cpp:106
#define MCSBML
void tearDown()
Definition: test000088.cpp:36
static size_t size()
static CCopasiDataModel * addDatamodel()
void test_import_initialassignment_without_expression()
Definition: test000088.cpp:72
static CCopasiMessage getLastMessage()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static void init(int argc, char *argv[], const bool &withGui=false)
Definition: CModel.h:50
Header file of class CEvent.
void test_import_assignment_without_expression()
Definition: test000088.cpp:41
static const char * MODEL_STRING3
Definition: test000088.h:38
void setUp()
Definition: test000088.cpp:28