COPASI API  4.16.103
test000070.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000070.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 "test000070.h"
20 
21 #include <sstream>
22 #include <string>
24 
26 
27 /**
28  * These tests are supposed to make sure that assignments on a species with the
29  * hasOnlySubstanceUnits flag set are exported correctly.
30  * It tests rules and event assignments with and without the flag set.
31  */
32 CCopasiDataModel* test000070::pCOPASIDATAMODEL = NULL;
33 
35 {
36  // Create the root container.
37  CCopasiRootContainer::init(0, NULL, false);
38  // Create the global data model.
40 }
41 
43 {
45 }
46 
48 {
49  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
50  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING1));
51  // now try to export several times
52  unsigned int i, iMax = 5;
53 
54  for (i = 0; i < iMax; ++i)
55  {
56  std::string s = pDataModel->exportSBMLToString(NULL, 2, 3);
57  CPPUNIT_ASSERT(!s.empty());
58  }
59 }
60 
61 const char* test000070::MODEL_STRING1 =
62  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
63  "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">\n"
64  " <model id=\"Model_1\" name=\"New Model\">\n"
65  " <notes>\n"
66  " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n"
67  " </body>\n"
68  " </notes>\n"
69  " <listOfFunctionDefinitions>\n"
70  " <functionDefinition id=\"function_1\" name=\"function_1\">\n"
71  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
72  " <lambda>\n"
73  " <bvar>\n"
74  " <ci> k </ci>\n"
75  " </bvar>\n"
76  " <apply>\n"
77  " <times/>\n"
78  " <cn> 3.0 </cn>\n"
79  " <ci> k </ci>\n"
80  " </apply>\n"
81  " </lambda>\n"
82  " </math>\n"
83  " </functionDefinition>\n"
84  " <functionDefinition id=\"function_2\" name=\"function_2\">\n"
85  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
86  " <lambda>\n"
87  " <bvar>\n"
88  " <ci> A </ci>\n"
89  " </bvar>\n"
90  " <bvar>\n"
91  " <ci> B </ci>\n"
92  " </bvar>\n"
93  " <apply>\n"
94  " <plus/>\n"
95  " <ci> B </ci>\n"
96  " <ci> A </ci>\n"
97  " </apply>\n"
98  " </lambda>\n"
99  " </math>\n"
100  " </functionDefinition>\n"
101  " <functionDefinition id=\"function_3\" name=\"function_3\">\n"
102  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
103  " <lambda>\n"
104  " <bvar>\n"
105  " <ci> k </ci>\n"
106  " </bvar>\n"
107  " <bvar>\n"
108  " <ci> C </ci>\n"
109  " </bvar>\n"
110  " <apply>\n"
111  " <minus/>\n"
112  " <ci> C </ci>\n"
113  " <apply>\n"
114  " <times/>\n"
115  " <ci> k </ci>\n"
116  " <cn> 1.3 </cn>\n"
117  " </apply>\n"
118  " </apply>\n"
119  " </lambda>\n"
120  " </math>\n"
121  " </functionDefinition>\n"
122  " <functionDefinition id=\"function_4\" name=\"function_4\">\n"
123  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
124  " <lambda>\n"
125  " <bvar>\n"
126  " <ci> x </ci>\n"
127  " </bvar>\n"
128  " <bvar>\n"
129  " <ci> y </ci>\n"
130  " </bvar>\n"
131  " <apply>\n"
132  " <divide/>\n"
133  " <apply>\n"
134  " <ci> function_2 </ci>\n"
135  " <ci> x </ci>\n"
136  " <ci> y </ci>\n"
137  " </apply>\n"
138  " <cn> 2.0 </cn>\n"
139  " </apply>\n"
140  " </lambda>\n"
141  " </math>\n"
142  " </functionDefinition>\n"
143  " <functionDefinition id=\"function_5\" name=\"function_5\">\n"
144  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
145  " <lambda>\n"
146  " <bvar>\n"
147  " <ci> a </ci>\n"
148  " </bvar>\n"
149  " <bvar>\n"
150  " <ci> b </ci>\n"
151  " </bvar>\n"
152  " <bvar>\n"
153  " <ci> c </ci>\n"
154  " </bvar>\n"
155  " <apply>\n"
156  " <plus/>\n"
157  " <apply>\n"
158  " <ci> function_3 </ci>\n"
159  " <ci> c </ci>\n"
160  " <ci> a </ci>\n"
161  " </apply>\n"
162  " <apply>\n"
163  " <minus/>\n"
164  " <apply>\n"
165  " <ci> function_1 </ci>\n"
166  " <ci> b </ci>\n"
167  " </apply>\n"
168  " <cn> 5.23 </cn>\n"
169  " </apply>\n"
170  " </apply>\n"
171  " </lambda>\n"
172  " </math>\n"
173  " </functionDefinition>\n"
174  " <functionDefinition id=\"function_6\" name=\"function_6\">\n"
175  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
176  " <lambda>\n"
177  " <bvar>\n"
178  " <ci> k1 </ci>\n"
179  " </bvar>\n"
180  " <bvar>\n"
181  " <ci> k2 </ci>\n"
182  " </bvar>\n"
183  " <bvar>\n"
184  " <ci> k3 </ci>\n"
185  " </bvar>\n"
186  " <apply>\n"
187  " <ci> function_5 </ci>\n"
188  " <ci> k1 </ci>\n"
189  " <ci> k2 </ci>\n"
190  " <ci> k3 </ci>\n"
191  " </apply>\n"
192  " </lambda>\n"
193  " </math>\n"
194  " </functionDefinition>\n"
195  " </listOfFunctionDefinitions>\n"
196  " <listOfCompartments>\n"
197  " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>\n"
198  " </listOfCompartments>\n"
199  " <listOfSpecies>\n"
200  " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialConcentration=\"1\"/>\n"
201  " <species id=\"species_2\" name=\"B\" compartment=\"compartment_1\" initialConcentration=\"1\"/>\n"
202  " <species id=\"species_3\" name=\"C\" compartment=\"compartment_1\" initialConcentration=\"1\" constant=\"false\"/>\n"
203  " <species id=\"species_4\" name=\"D\" compartment=\"compartment_1\" initialConcentration=\"1\" constant=\"false\"/>\n"
204  " <species id=\"species_5\" name=\"E\" compartment=\"compartment_1\" initialConcentration=\"1\" constant=\"false\"/>\n"
205  " <species id=\"species_6\" name=\"F\" compartment=\"compartment_1\" initialConcentration=\"1\" constant=\"false\"/>\n"
206  " </listOfSpecies>\n"
207  " <listOfParameters>\n"
208  " <parameter id=\"parameter_1\" name=\"K1\" value=\"1.1\" constant=\"false\"/>\n"
209  " <parameter id=\"parameter_2\" name=\"K2\" value=\"1.2\"/>\n"
210  " <parameter id=\"parameter_3\" name=\"K3\" value=\"1.3\" constant=\"false\"/>\n"
211  " </listOfParameters>\n"
212  " <listOfRules>\n"
213  " <assignmentRule variable=\"parameter_1\">\n"
214  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
215  " <apply>\n"
216  " <ci> function_1 </ci>\n"
217  " <cn> 4.5 </cn>\n"
218  " </apply>\n"
219  " </math>\n"
220  " </assignmentRule>\n"
221  " <assignmentRule variable=\"parameter_3\">\n"
222  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
223  " <apply>\n"
224  " <ci> function_3 </ci>\n"
225  " <cn> 2.0 </cn>\n"
226  " <ci> parameter_1 </ci>\n"
227  " </apply>\n"
228  " </math>\n"
229  " </assignmentRule>\n"
230  " <assignmentRule variable=\"species_3\">\n"
231  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
232  " <apply>\n"
233  " <ci> function_5 </ci>\n"
234  " <ci> parameter_1 </ci>\n"
235  " <cn> 2.4 </cn>\n"
236  " <cn> 3.5 </cn>\n"
237  " </apply>\n"
238  " </math>\n"
239  " </assignmentRule>\n"
240  " <rateRule variable=\"species_4\">\n"
241  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
242  " <apply>\n"
243  " <ci> function_2 </ci>\n"
244  " <ci> parameter_1 </ci>\n"
245  " <cn> 3.4 </cn>\n"
246  " </apply>\n"
247  " </math>\n"
248  " </rateRule>\n"
249  " <rateRule variable=\"species_5\">\n"
250  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
251  " <apply>\n"
252  " <ci> function_4 </ci>\n"
253  " <cn> 1.4 </cn>\n"
254  " <ci> parameter_2 </ci>\n"
255  " </apply>\n"
256  " </math>\n"
257  " </rateRule>\n"
258  " <rateRule variable=\"species_6\">\n"
259  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
260  " <apply>\n"
261  " <ci> function_6 </ci>\n"
262  " <ci> parameter_3 </ci>\n"
263  " <ci> parameter_1 </ci>\n"
264  " <cn> 3.4 </cn>\n"
265  " </apply>\n"
266  " </math>\n"
267  " </rateRule>\n"
268  " </listOfRules>\n"
269  " <listOfReactions>\n"
270  " <reaction id=\"reaction1\" reversible=\"true\">\n"
271  " <listOfReactants>\n"
272  " <speciesReference species=\"species_1\"/>\n"
273  " </listOfReactants>\n"
274  " <listOfProducts>\n"
275  " <speciesReference species=\"species_2\"/>\n"
276  " </listOfProducts>\n"
277  " <kineticLaw>\n"
278  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
279  " <apply>\n"
280  " <times/>\n"
281  " <ci> compartment_1 </ci>\n"
282  " <apply>\n"
283  " <ci> function_1 </ci>\n"
284  " <ci> parameter_1 </ci>\n"
285  " </apply>\n"
286  " </apply>\n"
287  " </math>\n"
288  " </kineticLaw>\n"
289  " </reaction>\n"
290  " <reaction id=\"reaction2\" reversible=\"true\">\n"
291  " <listOfReactants>\n"
292  " <speciesReference species=\"species_1\"/>\n"
293  " </listOfReactants>\n"
294  " <listOfProducts>\n"
295  " <speciesReference species=\"species_2\"/>\n"
296  " </listOfProducts>\n"
297  " <kineticLaw>\n"
298  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
299  " <apply>\n"
300  " <times/>\n"
301  " <ci> compartment_1 </ci>\n"
302  " <apply>\n"
303  " <ci> function_2 </ci>\n"
304  " <ci> parameter_1 </ci>\n"
305  " <ci> parameter_2 </ci>\n"
306  " </apply>\n"
307  " </apply>\n"
308  " </math>\n"
309  " </kineticLaw>\n"
310  " </reaction>\n"
311  " <reaction id=\"reaction3\" reversible=\"true\">\n"
312  " <listOfReactants>\n"
313  " <speciesReference species=\"species_1\"/>\n"
314  " </listOfReactants>\n"
315  " <listOfProducts>\n"
316  " <speciesReference species=\"species_2\"/>\n"
317  " </listOfProducts>\n"
318  " <kineticLaw>\n"
319  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
320  " <apply>\n"
321  " <times/>\n"
322  " <ci> compartment_1 </ci>\n"
323  " <apply>\n"
324  " <ci> function_3 </ci>\n"
325  " <ci> parameter_1 </ci>\n"
326  " <ci> species_2 </ci>\n"
327  " </apply>\n"
328  " </apply>\n"
329  " </math>\n"
330  " </kineticLaw>\n"
331  " </reaction>\n"
332  " <reaction id=\"reaction4\" reversible=\"true\">\n"
333  " <listOfReactants>\n"
334  " <speciesReference species=\"species_1\"/>\n"
335  " </listOfReactants>\n"
336  " <listOfProducts>\n"
337  " <speciesReference species=\"species_2\"/>\n"
338  " </listOfProducts>\n"
339  " <kineticLaw>\n"
340  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
341  " <apply>\n"
342  " <times/>\n"
343  " <ci> compartment_1 </ci>\n"
344  " <apply>\n"
345  " <ci> function_4 </ci>\n"
346  " <ci> species_1 </ci>\n"
347  " <ci> species_2 </ci>\n"
348  " </apply>\n"
349  " </apply>\n"
350  " </math>\n"
351  " </kineticLaw>\n"
352  " </reaction>\n"
353  " <reaction id=\"reaction5\" reversible=\"true\">\n"
354  " <listOfReactants>\n"
355  " <speciesReference species=\"species_1\"/>\n"
356  " </listOfReactants>\n"
357  " <listOfProducts>\n"
358  " <speciesReference species=\"species_2\"/>\n"
359  " </listOfProducts>\n"
360  " <kineticLaw>\n"
361  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
362  " <apply>\n"
363  " <times/>\n"
364  " <ci> compartment_1 </ci>\n"
365  " <apply>\n"
366  " <ci> function_5 </ci>\n"
367  " <ci> parameter_1 </ci>\n"
368  " <ci> parameter_3 </ci>\n"
369  " <ci> species_2 </ci>\n"
370  " </apply>\n"
371  " </apply>\n"
372  " </math>\n"
373  " </kineticLaw>\n"
374  " </reaction>\n"
375  " <reaction id=\"reaction6\" reversible=\"true\">\n"
376  " <listOfReactants>\n"
377  " <speciesReference species=\"species_1\"/>\n"
378  " </listOfReactants>\n"
379  " <listOfProducts>\n"
380  " <speciesReference species=\"species_2\"/>\n"
381  " </listOfProducts>\n"
382  " <kineticLaw>\n"
383  " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
384  " <apply>\n"
385  " <times/>\n"
386  " <ci> compartment_1 </ci>\n"
387  " <apply>\n"
388  " <ci> function_6 </ci>\n"
389  " <ci> parameter_1 </ci>\n"
390  " <ci> parameter_2 </ci>\n"
391  " <ci> parameter_3 </ci>\n"
392  " </apply>\n"
393  " </apply>\n"
394  " </math>\n"
395  " </kineticLaw>\n"
396  " </reaction>\n"
397  " </listOfReactions>\n"
398  " </model>\n"
399  "</sbml>\n"
400  ;
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
void setUp()
Definition: test000070.cpp:34
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000070.h:34
void test_bug1084()
Definition: test000070.cpp:47
static CCopasiDataModel * addDatamodel()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
void tearDown()
Definition: test000070.cpp:42
static void init(int argc, char *argv[], const bool &withGui=false)
static const char * MODEL_STRING1
Definition: test000070.h:33