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