COPASI API  4.16.103
test000079.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000079.cpp,v $
3 // $Revision: 1.2 $
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 "test000079.h"
20 
21 #include "utilities.hpp"
25 
26 CCopasiDataModel* test000079::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 {
43  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
44 
45  try
46  {
47  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000079::MODEL_STRING1));
48  }
49  catch (...)
50  {
51  // there should not be an exception
52  CPPUNIT_ASSERT(false);
53  }
54 
55  CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
56  // there should only be one error message that the fast flag on "reaction3"
57  // was ignored.
58  CPPUNIT_ASSERT(CCopasiMessage::size() > 0);
59  CCopasiMessage message;
60  unsigned int i, iMax = CCopasiMessage::size();
61 
62  for (i = 0; i < iMax; ++i)
63  {
65 
66  if (message.getNumber() == MCSBML + 29)
67  {
68  break;
69  }
70  }
71 
72  // check if the message was found
73  CPPUNIT_ASSERT(i != iMax);
74  // check that only reaction 3 is listed in the message
75  std::string text = message.getText();
76  CPPUNIT_ASSERT(text.find("reaction1") == std::string::npos);
77  CPPUNIT_ASSERT(text.find("reaction2") == std::string::npos);
78  CPPUNIT_ASSERT(text.find("reaction3") != std::string::npos);
79 }
80 
81 const char* test000079::MODEL_STRING1 =
82  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
83  "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
84  " <model metaid=\"COPASI1\" id=\"Model_1\" name=\"test000079\">\n"
85  " <notes>\n"
86  " <html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
87  " <head>\n"
88  " <meta name=\"qrichtext\" content=\"1\"/>\n"
89  " </head>\n"
90  " <body style=\"font-size:13pt;font-family:Lucida Grande\">\n"
91  " <p>Model to test import the fast flag.</p>\n"
92  " </body>\n"
93  " </html>\n"
94  " </notes>\n"
95  " <listOfCompartments>\n"
96  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>\n"
97  " </listOfCompartments>\n"
98  " <listOfSpecies>\n"
99  " <species id=\"species_1\" name=\"S1\" compartment=\"compartment_1\" initialConcentration=\"1\"/>\n"
100  " <species id=\"species_2\" name=\"S2\" compartment=\"compartment_1\" initialConcentration=\"1\"/>\n"
101  " <species id=\"species_3\" name=\"S3\" compartment=\"compartment_1\" initialConcentration=\"1\"/>\n"
102  " </listOfSpecies>\n"
103  " <listOfParameters>\n"
104  " <parameter id=\"parameter_1\" name=\"k\" value=\"1\" units=\"time\"/>\n"
105  " </listOfParameters>\n"
106  " <listOfReactions>\n"
107  " <reaction id=\"reaction1\" fast=\"false\">\n"
108  " <listOfReactants>\n"
109  " <speciesReference species=\"species_1\"/>\n"
110  " </listOfReactants>\n"
111  " <kineticLaw>\n"
112  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
113  " <apply>\n"
114  " <divide/>\n"
115  " <apply>\n"
116  " <times/>\n"
117  " <ci> compartment_1 </ci>\n"
118  " <ci> species_1 </ci>\n"
119  " </apply>\n"
120  " <ci> parameter_1 </ci>\n"
121  " </apply>\n"
122  " </math>\n"
123  " </kineticLaw>\n"
124  " </reaction>\n"
125  " <reaction id=\"reaction2\">\n"
126  " <listOfReactants>\n"
127  " <speciesReference species=\"species_2\"/>\n"
128  " </listOfReactants>\n"
129  " <kineticLaw>\n"
130  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
131  " <apply>\n"
132  " <divide/>\n"
133  " <apply>\n"
134  " <times/>\n"
135  " <ci> compartment_1 </ci>\n"
136  " <ci> species_2 </ci>\n"
137  " </apply>\n"
138  " <ci> parameter_1 </ci>\n"
139  " </apply>\n"
140  " </math>\n"
141  " </kineticLaw>\n"
142  " </reaction>\n"
143  " <reaction id=\"reaction3\" fast=\"true\">\n"
144  " <listOfReactants>\n"
145  " <speciesReference species=\"species_3\"/>\n"
146  " </listOfReactants>\n"
147  " <kineticLaw>\n"
148  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
149  " <apply>\n"
150  " <divide/>\n"
151  " <apply>\n"
152  " <times/>\n"
153  " <ci> compartment_1 </ci>\n"
154  " <ci> species_3 </ci>\n"
155  " </apply>\n"
156  " <ci> parameter_1 </ci>\n"
157  " </apply>\n"
158  " </math>\n"
159  " </kineticLaw>\n"
160  " </reaction>\n"
161  " </listOfReactions>\n"
162  " </model>\n"
163  "</sbml>\n";
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000079.h:33
const std::string & getText() const
const size_t & getNumber() const
void tearDown()
Definition: test000079.cpp:36
#define MCSBML
void setUp()
Definition: test000079.cpp:28
static size_t size()
void test_import_fast()
Definition: test000079.cpp:41
static CCopasiDataModel * addDatamodel()
static const char * MODEL_STRING1
Definition: test000079.h:34
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)