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

#include <test000077.h>

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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_export_dimensionless ()
 
void test_import_dimensionless_1 ()
 
void test_import_dimensionless_2 ()
 
void test_import_dimensionless_3 ()
 
void test_import_dimensionless_4 ()
 
void test_import_dimensionless_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 const char * MODEL_STRING6
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_import_dimensionless_1)
 
 CPPUNIT_TEST (test_import_dimensionless_2)
 
 CPPUNIT_TEST (test_import_dimensionless_3)
 
 CPPUNIT_TEST (test_import_dimensionless_4)
 
 CPPUNIT_TEST (test_import_dimensionless_5)
 
 CPPUNIT_TEST (test_export_dimensionless)
 
 CPPUNIT_TEST_SUITE (test000077)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 27 of file test000077.h.

Member Function Documentation

test000077::CPPUNIT_TEST ( test_import_dimensionless_1  )
private
test000077::CPPUNIT_TEST ( test_import_dimensionless_2  )
private
test000077::CPPUNIT_TEST ( test_import_dimensionless_3  )
private
test000077::CPPUNIT_TEST ( test_import_dimensionless_4  )
private
test000077::CPPUNIT_TEST ( test_import_dimensionless_5  )
private
test000077::CPPUNIT_TEST ( test_export_dimensionless  )
private
test000077::CPPUNIT_TEST_SUITE ( test000077  )
private
test000077::CPPUNIT_TEST_SUITE_END ( )
private
void test000077::setUp ( )

Test the export of models with references to local parameters in expressions.

Definition at line 37 of file test000077.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: test000077.h:50
static void init(int argc, char *argv[], const bool &withGui=false)
void test000077::tearDown ( )

Definition at line 45 of file test000077.cpp.

References CCopasiRootContainer::destroy().

void test000077::test_export_dimensionless ( )

Definition at line 189 of file test000077.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::getModel(), load_cps_model_from_stream(), MODEL_STRING6, and pCOPASIDATAMODEL.

190 {
191  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
192  std::istringstream iss(test000077::MODEL_STRING6);
193  CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
194  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
195  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
196  CPPUNIT_ASSERT(pDocument == NULL);
197  std::string sbmlString;
198 
199  try
200  {
201  sbmlString = pDataModel->exportSBMLToString(NULL, 2, 1);
202  }
203  catch (...)
204  {
205  // fail if an uncaught exception occurs during export
206  CPPUNIT_ASSERT(false);
207  }
208 
209  CPPUNIT_ASSERT(!sbmlString.empty());
210  // check if the exported SBML model has two parameters
211  pDocument = pDataModel->getCurrentSBMLDocument();
212  CPPUNIT_ASSERT(pDocument != NULL);
213  const Model* pModel = pDocument->getModel();
214  CPPUNIT_ASSERT(pModel != NULL);
215  CPPUNIT_ASSERT(pModel->getListOfCompartments()->size() == 1);
216  CPPUNIT_ASSERT(pModel->getListOfSpecies()->size() == 1);
217  const UnitDefinition* pUDef = pModel->getUnitDefinition("time");
218  CPPUNIT_ASSERT(pUDef != NULL);
219  CPPUNIT_ASSERT(pUDef->getListOfUnits()->size() == 1);
220  const Unit* pUnit = pUDef->getUnit(0);
221  CPPUNIT_ASSERT(pUnit != NULL);
222  CPPUNIT_ASSERT(pUnit->getScale() == 0);
223  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
224  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_DIMENSIONLESS);
225  pUDef = pModel->getUnitDefinition("volume");
226  CPPUNIT_ASSERT(pUDef != NULL);
227  CPPUNIT_ASSERT(pUDef->getListOfUnits()->size() == 1);
228  pUnit = pUDef->getUnit(0);
229  CPPUNIT_ASSERT(pUnit != NULL);
230  CPPUNIT_ASSERT(pUnit->getScale() == 0);
231  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
232  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_DIMENSIONLESS);
233  pUDef = pModel->getUnitDefinition("substance");
234  CPPUNIT_ASSERT(pUDef != NULL);
235  CPPUNIT_ASSERT(pUDef->getListOfUnits()->size() == 1);
236  pUnit = pUDef->getUnit(0);
237  CPPUNIT_ASSERT(pUnit != NULL);
238  CPPUNIT_ASSERT(pUnit->getScale() == 0);
239  CPPUNIT_ASSERT(fabs((pUnit->getMultiplier() - 1.0) / 1.0) < 1e-6);
240  CPPUNIT_ASSERT(pUnit->getKind() == UNIT_KIND_DIMENSIONLESS);
241 }
SBMLDocument * getCurrentSBMLDocument()
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * MODEL_STRING6
Definition: test000077.h:56
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
Definition: utilities.cpp:21
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000077.h:50
void test000077::test_import_dimensionless_1 ( )

Definition at line 50 of file test000077.cpp.

References CModel::dimensionlessQuantity, CModel::dimensionlessTime, CModel::dimensionlessVolume, CCopasiDataModel::getModel(), CModel::getQuantityUnitEnum(), CModel::getTimeUnitEnum(), CModel::getVolumeUnitEnum(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING1, and pCOPASIDATAMODEL.

51 {
52  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
53 
54  try
55  {
56  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000077::MODEL_STRING1));
57  }
58  catch (...)
59  {
60  // there should not be an exception
61  CPPUNIT_ASSERT(false);
62  }
63 
64  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
65  CPPUNIT_ASSERT(pDataModel->getModel()->getVolumeUnitEnum() == CModel::dimensionlessVolume);
66  CPPUNIT_ASSERT(pDataModel->getModel()->getTimeUnitEnum() == CModel::dimensionlessTime);
67  CPPUNIT_ASSERT(pDataModel->getModel()->getQuantityUnitEnum() == CModel::dimensionlessQuantity);
68 }
CModel::QuantityUnit getQuantityUnitEnum() const
Definition: CModel.cpp:2331
static const char * MODEL_STRING1
Definition: test000077.h:51
CModel::TimeUnit getTimeUnitEnum() const
Definition: CModel.cpp:2243
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000077.h:50
CModel::VolumeUnit getVolumeUnitEnum() const
Definition: CModel.cpp:2175
void test000077::test_import_dimensionless_2 ( )

Definition at line 70 of file test000077.cpp.

References CModel::dimensionlessQuantity, CModel::dimensionlessTime, CModel::dimensionlessVolume, CCopasiDataModel::getModel(), CModel::getQuantityUnitEnum(), CModel::getTimeUnitEnum(), CModel::getVolumeUnitEnum(), CCopasiDataModel::importSBMLFromString(), MODEL_STRING2, and pCOPASIDATAMODEL.

71 {
72  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
73 
74  try
75  {
76  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000077::MODEL_STRING2));
77  }
78  catch (...)
79  {
80  // there should not be an exception
81  CPPUNIT_ASSERT(false);
82  }
83 
84  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
85  CPPUNIT_ASSERT(pDataModel->getModel()->getVolumeUnitEnum() == CModel::dimensionlessVolume);
86  CPPUNIT_ASSERT(pDataModel->getModel()->getTimeUnitEnum() == CModel::dimensionlessTime);
87  CPPUNIT_ASSERT(pDataModel->getModel()->getQuantityUnitEnum() == CModel::dimensionlessQuantity);
88 }
CModel::QuantityUnit getQuantityUnitEnum() const
Definition: CModel.cpp:2331
CModel::TimeUnit getTimeUnitEnum() const
Definition: CModel.cpp:2243
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000077.h:50
CModel::VolumeUnit getVolumeUnitEnum() const
Definition: CModel.cpp:2175
static const char * MODEL_STRING2
Definition: test000077.h:52
void test000077::test_import_dimensionless_3 ( )

Definition at line 90 of file test000077.cpp.

References CCopasiMessage::getLastMessage(), CCopasiMessage::getNumber(), CCopasiMessage::getText(), CCopasiDataModel::importSBMLFromString(), MCSBML, MODEL_STRING3, pCOPASIDATAMODEL, and CCopasiMessage::size().

91 {
92  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
93 
94  try
95  {
96  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000077::MODEL_STRING3));
97  }
98  catch (...)
99  {
100  // there shouldn't be any reason for an exception
101  CPPUNIT_ASSERT(false);
102  }
103 
104  // check if a message MCSBML + 66 is on the message stack
105  bool found = false;
106  CCopasiMessage message;
107 
108  while (CCopasiMessage::size() > 0)
109  {
110  message = CCopasiMessage::getLastMessage();
111 
112  if (message.getNumber() == MCSBML + 66)
113  {
114  found = true;
115  break;
116  }
117  }
118 
119  CPPUNIT_ASSERT(found == true);
120  CPPUNIT_ASSERT(message.getText().find("volume") != std::string::npos);
121 }
static const char * MODEL_STRING3
Definition: test000077.h:53
const std::string & getText() const
const size_t & getNumber() const
#define MCSBML
static size_t size()
static CCopasiMessage getLastMessage()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000077.h:50
void test000077::test_import_dimensionless_4 ( )

Definition at line 123 of file test000077.cpp.

References CCopasiMessage::getLastMessage(), CCopasiMessage::getNumber(), CCopasiMessage::getText(), CCopasiDataModel::importSBMLFromString(), MCSBML, MODEL_STRING4, pCOPASIDATAMODEL, and CCopasiMessage::size().

124 {
125  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
126 
127  try
128  {
129  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000077::MODEL_STRING4));
130  }
131  catch (...)
132  {
133  // there shouldn't be any reason for an exception
134  CPPUNIT_ASSERT(false);
135  }
136 
137  // check if a message MCSBML + 66 is on the message stack
138  bool found = false;
139  CCopasiMessage message;
140 
141  while (CCopasiMessage::size() > 0)
142  {
143  message = CCopasiMessage::getLastMessage();
144 
145  if (message.getNumber() == MCSBML + 66)
146  {
147  found = true;
148  break;
149  }
150  }
151 
152  CPPUNIT_ASSERT(found == true);
153  CPPUNIT_ASSERT(message.getText().find("time") != std::string::npos);
154 }
const std::string & getText() const
const size_t & getNumber() const
#define MCSBML
static size_t size()
static const char * MODEL_STRING4
Definition: test000077.h:54
static CCopasiMessage getLastMessage()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000077.h:50
void test000077::test_import_dimensionless_5 ( )

Definition at line 156 of file test000077.cpp.

References CCopasiMessage::getLastMessage(), CCopasiMessage::getNumber(), CCopasiMessage::getText(), CCopasiDataModel::importSBMLFromString(), MCSBML, MODEL_STRING5, pCOPASIDATAMODEL, and CCopasiMessage::size().

157 {
158  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
159 
160  try
161  {
162  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000077::MODEL_STRING5));
163  }
164  catch (...)
165  {
166  // there shouldn't be any reason for an exception
167  CPPUNIT_ASSERT(false);
168  }
169 
170  // check if a message MCSBML + 66 is on the message stack
171  bool found = false;
172  CCopasiMessage message;
173 
174  while (CCopasiMessage::size() > 0)
175  {
176  message = CCopasiMessage::getLastMessage();
177 
178  if (message.getNumber() == MCSBML + 66)
179  {
180  found = true;
181  break;
182  }
183  }
184 
185  CPPUNIT_ASSERT(found == true);
186  CPPUNIT_ASSERT(message.getText().find("substance") != std::string::npos);
187 }
const std::string & getText() const
const size_t & getNumber() const
#define MCSBML
static size_t size()
static const char * MODEL_STRING5
Definition: test000077.h:55
static CCopasiMessage getLastMessage()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000077.h:50

Member Data Documentation

const char * test000077::MODEL_STRING1
staticprotected

Definition at line 51 of file test000077.h.

Referenced by test_import_dimensionless_1().

const char * test000077::MODEL_STRING2
staticprotected

Definition at line 52 of file test000077.h.

Referenced by test_import_dimensionless_2().

const char * test000077::MODEL_STRING3
staticprotected

Definition at line 53 of file test000077.h.

Referenced by test_import_dimensionless_3().

const char * test000077::MODEL_STRING4
staticprotected

Definition at line 54 of file test000077.h.

Referenced by test_import_dimensionless_4().

const char * test000077::MODEL_STRING5
staticprotected

Definition at line 55 of file test000077.h.

Referenced by test_import_dimensionless_5().

const char * test000077::MODEL_STRING6
staticprotected
Initial value:
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<!-- generated with COPASI 4.5.30 (Debug) (http://www.copasi.org) at 2009-01-27 14:56:07 UTC -->\n"
"<COPASI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.copasi.org/static/schema.xsd\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"30\">\n"
" <Model key=\"Model_0\" name=\"test000077\" timeUnit=\"dimensionless\" volumeUnit=\"dimensionless\" quantityUnit=\"dimensionless\" type=\"deterministic\">\n"
" <Comment>\n"
" <html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\"font-size:13pt;font-family:Lucida Grande\">\n"
"<p>Model to test export of dimensionless units.</p>\n"
"</body></html>\n"
" </Comment>\n"
" <ListOfCompartments>\n"
" <Compartment key=\"Compartment_0\" name=\"compartment\" simulationType=\"fixed\">\n"
" </Compartment>\n"
" </ListOfCompartments>\n"
" <ListOfMetabolites>\n"
" <Metabolite key=\"Metabolite_0\" name=\"S\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
" </Metabolite>\n"
" </ListOfMetabolites>\n"
" <StateTemplate>\n"
" <StateTemplateVariable objectReference=\"Model_0\"/>\n"
" <StateTemplateVariable objectReference=\"Metabolite_0\"/>\n"
" <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
" </StateTemplate>\n"
" <InitialState type=\"initialState\">\n"
" 0 1 1\n"
" </InitialState>\n"
" </Model>\n"
"</COPASI>\n"

Definition at line 56 of file test000077.h.

Referenced by test_export_dimensionless().

CCopasiDataModel * test000077::pCOPASIDATAMODEL = NULL
staticprotected

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