COPASI API  4.16.103
test000099.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000099.cpp,v $
3 // $Revision: 1.2 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/08/02 20:44:07 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 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 "test000099.h"
15 
16 #include <vector>
17 #include "utilities.hpp"
18 
23 #include "copasi/model/CModel.h"
24 
26 {
27  // Create the root container.
28  CCopasiRootContainer::init(0, NULL, false);
30 }
31 
33 {
35 }
36 
37 
38 // tests whether we are importing notes on all elemnts
40 {
41  CPPUNIT_ASSERT(pDataModel != NULL);
42  CModel* pModel = NULL;
43  std::vector< CCopasiContainer * > listOfContainer;
44 
45  // try to import the file which should lead to an exception
46  try
47  {
49  // importing should lead to an exception, so we should never
50  // reach this point
51  assert(false);
52  }
53  catch (...)
54  {
55  CPPUNIT_ASSERT(pModel == NULL);
56  const CModel * pModel2 =
57  dynamic_cast< const CModel * >(pDataModel->ObjectFromName(listOfContainer, CCopasiObjectName("CN=Root,Model=my test model")));
58  CPPUNIT_ASSERT(pModel2 == NULL);
59  }
60 
61  // import the good model
62  try
63  {
64  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(SBML_MODEL_GOOD) == true);
65  }
66  catch (...)
67  {
68  // this should not lead to an exception
69  assert(false);
70  }
71 
72  // now check if we find the object for the model name
73  pModel = pDataModel->getModel();
74  CPPUNIT_ASSERT(pModel != NULL);
75  const CModel * pModel2 =
76  dynamic_cast< const CModel * >(pDataModel->ObjectFromName(listOfContainer, pDataModel->getModel()->getCN()));
77  CPPUNIT_ASSERT(pModel == pModel2);
78 }
79 
80 const char* test000099::SBML_MODEL_BAD =
81  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
82  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
83  " <model name=\"my test model\">\n"
84  " <listOfCompartments>\n"
85  " <compartment id=\"compartment_1\" size=\"1.0\"/>\n"
86  " </listOfCompartments>\n"
87  " <listOfSpecies>\n"
88  " <species id=\"species_1\" compartment=\"compartment_1\" initialConcentration=\"1.0\"/>\n"
89  " <species id=\"species_2\" compartment=\"compartment_1\" initialConcentration=\"1.0\"/>\n"
90  " </listOfSpecies>\n"
91  " <listOfReactions>\n"
92  " <reaction id=\"reaction_1\">\n"
93  " <listOfReactants>\n"
94  " <speciesReference species=\"species_1\"/>\n"
95  " </listOfReactants>\n"
96  " <kineticLaw>\n"
97  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
98  " <apply>\n"
99  " <times/>\n"
100  " <ci> species_1 </ci>\n"
101  " <ci> species_2 </ci>\n"
102  " </apply>\n"
103  " </math>\n"
104  " </kineticLaw>\n"
105  " </reaction>\n"
106  " </listOfReactions>\n"
107  " </model>\n"
108  "</sbml>\n"
109  ;
110 
111 
112 const char* test000099::SBML_MODEL_GOOD =
113  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
114  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
115  " <model name=\"my test model\">\n"
116  " <listOfCompartments>\n"
117  " <compartment id=\"compartment_1\" size=\"1.0\"/>\n"
118  " </listOfCompartments>\n"
119  " <listOfSpecies>\n"
120  " <species id=\"species_1\" compartment=\"compartment_1\" initialConcentration=\"1.0\"/>\n"
121  " <species id=\"species_2\" compartment=\"compartment_1\" initialConcentration=\"1.0\"/>\n"
122  " </listOfSpecies>\n"
123  " <listOfReactions>\n"
124  " <reaction id=\"reaction_1\">\n"
125  " <listOfReactants>\n"
126  " <speciesReference species=\"species_1\"/>\n"
127  " </listOfReactants>\n"
128  " <listOfModifiers>\n"
129  " <modifierSpeciesReference species=\"species_2\"/>\n"
130  " </listOfModifiers>\n"
131  " <kineticLaw>\n"
132  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
133  " <apply>\n"
134  " <times/>\n"
135  " <ci> species_1 </ci>\n"
136  " <ci> species_2 </ci>\n"
137  " </apply>\n"
138  " </math>\n"
139  " </kineticLaw>\n"
140  " </reaction>\n"
141  " </listOfReactions>\n"
142  " </model>\n"
143  "</sbml>\n"
144  ;
145 
146 
147 
static const char * SBML_MODEL_BAD
Definition: test000099.h:36
virtual CCopasiObjectName getCN() const
static const char * SBML_MODEL_GOOD
Definition: test000099.h:39
void test_bug1675()
Definition: test000099.cpp:39
CCopasiDataModel * pDataModel
Definition: test000099.h:41
Header file of class CCopasiContainer.
static CCopasiDataModel * addDatamodel()
void tearDown()
Definition: test000099.cpp:32
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
void setUp()
Definition: test000099.cpp:25
static void init(int argc, char *argv[], const bool &withGui=false)
Definition: CModel.h:50
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const