COPASI API  4.16.103
test000062.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000062.cpp,v $
3 // $Revision: 1.6 $
4 // $Name: $
5 // $Author: bergmann $
6 // $Date: 2012/05/10 12:15:13 $
7 // End CVS Header
8 
9 // Copyright (C) 2012 - 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 "test000062.h"
20 
21 #include <sstream>
22 #include "utilities.hpp"
24 #include "copasi/model/CModel.h"
27 
28 #include "sbml/SBMLDocument.h"
29 #include "sbml/Model.h"
30 #include "sbml/Rule.h"
31 #include "sbml/Species.h"
32 #include "sbml/Parameter.h"
33 #include "sbml/math/ASTNode.h"
34 
36 
37 CCopasiDataModel* test000062::pCOPASIDATAMODEL = NULL;
38 
40 {
41  // Create the root container.
42  CCopasiRootContainer::init(0, NULL, false);
43  // Create the global data model.
45 }
46 
48 {
50 }
51 
53 {
54  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
55  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000062::MODEL_STRING1));
56  CModel* pModel = pDataModel->getModel();
57  CPPUNIT_ASSERT(pModel != NULL);
58  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
59  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
60  CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
61  CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
62  // check if the reactions function is set correctly
63  CReaction* pReaction = pModel->getReactions()[0];
64  CPPUNIT_ASSERT(pReaction->getFunction() == CCopasiRootContainer::getUndefinedFunction());
65  // check if the correct error message has been created
66 #if LIBSBML_VERSION >= 40200
67  // recent libsbml versions will complain about missing math element!
68  CPPUNIT_ASSERT(CCopasiMessage::size() == 2);
69 #else
70  CPPUNIT_ASSERT(CCopasiMessage::size() == 1);
71 #endif
73  CPPUNIT_ASSERT(message.getType() == CCopasiMessage::WARNING);
74  CPPUNIT_ASSERT(message.getNumber() == MCSBML + 56);
75 }
76 
77 /**
78  * The units given for the two parameters in the kinetic law are wrong and they
79  * are only there to stop libsbml from issuing warnings about best modeling practice.
80  */
81 const char* test000062::MODEL_STRING1 =
82  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
83  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">"
84  " <model id=\"Model_1\" name=\"Kinetic Law Without Math Element\">"
85  " <listOfUnitDefinitions>"
86  " <unitDefinition id=\"volume\">"
87  " <listOfUnits>"
88  " <unit kind=\"litre\" scale=\"-3\"/>"
89  " </listOfUnits>"
90  " </unitDefinition>"
91  " <unitDefinition id=\"substance\">"
92  " <listOfUnits>"
93  " <unit kind=\"mole\" scale=\"-3\"/>"
94  " </listOfUnits>"
95  " </unitDefinition>"
96  " </listOfUnitDefinitions>"
97  " <listOfCompartments>"
98  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>"
99  " </listOfCompartments>"
100  " <listOfSpecies>"
101  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"0.1\"/>"
102  " <species id=\"species_2\" name=\"B\" compartment=\"compartment_1\" initialConcentration=\"0.1\"/>"
103  " </listOfSpecies>"
104  " <listOfReactions>"
105  " <reaction id=\"reaction_1\" name=\"reaction\" reversible=\"false\">"
106  " <listOfReactants>"
107  " <speciesReference species=\"species_1\"/>"
108  " </listOfReactants>"
109  " <listOfProducts>"
110  " <speciesReference species=\"species_2\"/>"
111  " </listOfProducts>"
112  " <kineticLaw>"
113  " <listOfParameters>"
114  " <parameter id=\"Km\" value=\"0.1\" units=\"substance\"/>"
115  " <parameter id=\"V\" value=\"0.1\" units=\"substance\"/>"
116  " </listOfParameters>"
117  " </kineticLaw>"
118  " </reaction>"
119  " </listOfReactions>"
120  " </model>"
121  "</sbml>"
122  ;
void test_kineticlaw_without_math()
Definition: test000062.cpp:52
Header file of class CModelEntity and CModelValue.
static CFunction * getUndefinedFunction()
void setUp()
Definition: test000062.cpp:39
const size_t & getNumber() const
void tearDown()
Definition: test000062.cpp:47
#define MCSBML
const CCopasiMessage::Type & getType() const
static const char * MODEL_STRING1
Definition: test000062.h:37
static size_t size()
static CCopasiDataModel * addDatamodel()
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
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000062.h:38