COPASI API  4.16.103
test000056.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000056.cpp,v $
3 // $Revision: 1.6 $
4 // $Name: $
5 // $Author: gauges $
6 // $Date: 2010/03/11 11:52:00 $
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 // 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 "test000056.h"
20 
21 #include <sstream>
22 #include "utilities.hpp"
24 
25 #include "sbml/SBMLDocument.h"
26 #include "sbml/Model.h"
27 #include "sbml/Rule.h"
28 #include "sbml/Species.h"
29 #include "sbml/Parameter.h"
30 #include "sbml/math/ASTNode.h"
31 
33 
34 CCopasiDataModel* test000056::pCOPASIDATAMODEL = NULL;
35 
37 {
38  // Create the root container.
39  CCopasiRootContainer::init(0, NULL, false);
40  // Create the global data model.
42 }
43 
45 {
47 }
48 
50 {
51  // make sure models without compartments don't lead to a crash
52  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
53 
54  try
55  {
56  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000056::MODEL_STRING));
57  }
58  catch (...)
59  {
60  CPPUNIT_ASSERT(false);
61  }
62 
63  const SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
64 
65  const Model* pSBMLModel = pDocument->getModel();
66 
67  CPPUNIT_ASSERT(pSBMLModel != NULL);
68 
69  CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 0);
70 
71  CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 0);
72 
73  CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
74 
75  CPPUNIT_ASSERT(pSBMLModel->getNumInitialAssignments() == 0);
76 
77  CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 1);
78 
79  const Parameter* pParameter1 = pSBMLModel->getParameter(0);
80 
81  CPPUNIT_ASSERT(pParameter1 != NULL);
82 
83  CPPUNIT_ASSERT(pParameter1->getConstant() == true);
84 
85  CPPUNIT_ASSERT(pParameter1->getId() == "parameter_1");
86 
87  CPPUNIT_ASSERT(pParameter1->getName() == "A");
88 
89  CPPUNIT_ASSERT(pParameter1->isSetValue() == true);
90 
91  CPPUNIT_ASSERT(fabs((pParameter1->getValue() - 12.0) / 12.0) < 1e-15);
92 }
93 
94 const char* test000056::MODEL_STRING =
95  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
96  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
97  " <model id=\"Model_1\" name=\"New Model\">\n"
98  " <listOfUnitDefinitions>\n"
99  " <unitDefinition id=\"volume\">\n"
100  " <listOfUnits>\n"
101  " <unit kind=\"litre\" scale=\"-3\"/>\n"
102  " </listOfUnits>\n"
103  " </unitDefinition>\n"
104  " <unitDefinition id=\"substance\">\n"
105  " <listOfUnits>\n"
106  " <unit kind=\"mole\" scale=\"-3\"/>\n"
107  " </listOfUnits>\n"
108  " </unitDefinition>\n"
109  " </listOfUnitDefinitions>\n"
110  " <listOfParameters>\n"
111  " <parameter id=\"parameter_1\" name=\"A\" value=\"12\" constant=\"true\"/>\n"
112  " </listOfParameters>\n"
113  " </model>\n"
114  "</sbml>\n"
115  ;
SBMLDocument * getCurrentSBMLDocument()
static const char * MODEL_STRING
Definition: test000056.h:31
void setUp()
Definition: test000056.cpp:36
static CCopasiDataModel * addDatamodel()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000056.h:32
static void init(int argc, char *argv[], const bool &withGui=false)
void test_bug1005()
Definition: test000056.cpp:49
void tearDown()
Definition: test000056.cpp:44