COPASI API  4.16.103
test000096.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sbml/unittests/test000096.cpp,v $
3 // $Revision: 1.3 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/05/24 16:32:32 $
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 "test000096.h"
15 
16 #include "sbml/SBMLDocument.h"
17 #include "sbml/Model.h"
18 #include "sbml/xml/XMLNode.h"
19 
22 
23 #include <string>
24 
26 {
27  // Create the root container.
28  CCopasiRootContainer::init(0, NULL, false);
29 }
30 
32 {
34 }
35 
37 {
38  XMLNode* pNotes = CSBMLExporter::createSBMLNotes(NOTES_STRING_1);
39  CPPUNIT_ASSERT(pNotes != NULL);
40  CPPUNIT_ASSERT(pNotes->getName() == "body");
41  CPPUNIT_ASSERT(pNotes->getURI() == "http://www.w3.org/1999/xhtml");
42  CPPUNIT_ASSERT(pNotes->hasNamespaceURI("http://www.w3.org/1999/xhtml") == true);
43  CPPUNIT_ASSERT(pNotes->getNumChildren() == 1);
44  XMLNode* pChild = &pNotes->getChild(0);
45  CPPUNIT_ASSERT(pChild != NULL);
46  CPPUNIT_ASSERT(pChild->getName() == "pre");
47  CPPUNIT_ASSERT(pChild->getNumChildren() == 1);
48  pChild = &pChild->getChild(0);
49  CPPUNIT_ASSERT(pChild->isText());
50  CPPUNIT_ASSERT(pChild->getCharacters().find("This") != std::string::npos);
51  SBMLDocument *pDocument = new SBMLDocument(2, 4);
52  CPPUNIT_ASSERT(pDocument != NULL);
53  Model* pModel = pDocument->createModel("test_model");
54  CPPUNIT_ASSERT(pModel != NULL);
55  int set_result = pModel->setNotes(pNotes);
56  CPPUNIT_ASSERT(set_result == LIBSBML_OPERATION_SUCCESS);
57  delete pDocument;
58  delete pNotes;
59 }
60 
62 {
63  XMLNode* pNotes = CSBMLExporter::createSBMLNotes(NOTES_STRING_2);
64  CPPUNIT_ASSERT(pNotes != NULL);
65  CPPUNIT_ASSERT(pNotes->getName() == "p");
66  CPPUNIT_ASSERT(pNotes->getURI() == "http://www.w3.org/1999/xhtml");
67  CPPUNIT_ASSERT(pNotes->hasNamespaceURI("http://www.w3.org/1999/xhtml") == true);
68  CPPUNIT_ASSERT(pNotes->getNumChildren() == 1);
69  XMLNode* pChild = &pNotes->getChild(0);
70  CPPUNIT_ASSERT(pChild != NULL);
71  CPPUNIT_ASSERT(pChild->isText());
72  CPPUNIT_ASSERT(pChild->getCharacters().find("This") != std::string::npos);
73  SBMLDocument *pDocument = new SBMLDocument(2, 4);
74  CPPUNIT_ASSERT(pDocument != NULL);
75  Model* pModel = pDocument->createModel("test_model");
76  CPPUNIT_ASSERT(pModel != NULL);
77  int set_result = pModel->setNotes(pNotes);
78  CPPUNIT_ASSERT(set_result == LIBSBML_OPERATION_SUCCESS);
79  delete pDocument;
80  delete pNotes;
81 }
82 
84 {
85  XMLNode* pNotes = CSBMLExporter::createSBMLNotes(NOTES_STRING_3);
86  CPPUNIT_ASSERT(pNotes != NULL);
87  CPPUNIT_ASSERT(pNotes->getName() == "body");
88  CPPUNIT_ASSERT(pNotes->getURI() == "http://www.w3.org/1999/xhtml");
89  CPPUNIT_ASSERT(pNotes->hasNamespaceURI("http://www.w3.org/1999/xhtml") == true);
90  CPPUNIT_ASSERT(pNotes->getNumChildren() == 3);
91  XMLNode* pChild = &pNotes->getChild(0);
92  CPPUNIT_ASSERT(pChild != NULL);
93  CPPUNIT_ASSERT(pChild->isElement());
94  CPPUNIT_ASSERT(pChild->getName() == "p");
95  CPPUNIT_ASSERT(pChild->getNumChildren() == 1);
96  pChild = &pChild->getChild(0);
97  CPPUNIT_ASSERT(pChild != NULL);
98  CPPUNIT_ASSERT(pChild->isText());
99  CPPUNIT_ASSERT(pChild->getCharacters().find("This") != std::string::npos);
100  pChild = &pNotes->getChild(1);
101  CPPUNIT_ASSERT(pChild != NULL);
102  CPPUNIT_ASSERT(pChild->isElement());
103  CPPUNIT_ASSERT(pChild->getName() == "p");
104  CPPUNIT_ASSERT(pChild->getNumChildren() == 1);
105  pChild = &pChild->getChild(0);
106  CPPUNIT_ASSERT(pChild != NULL);
107  CPPUNIT_ASSERT(pChild->isText());
108  CPPUNIT_ASSERT(pChild->getCharacters().find("several") != std::string::npos);
109  pChild = &pNotes->getChild(2);
110  CPPUNIT_ASSERT(pChild != NULL);
111  CPPUNIT_ASSERT(pChild->isElement());
112  CPPUNIT_ASSERT(pChild->getName() == "p");
113  CPPUNIT_ASSERT(pChild->getNumChildren() == 1);
114  pChild = &pChild->getChild(0);
115  CPPUNIT_ASSERT(pChild != NULL);
116  CPPUNIT_ASSERT(pChild->isText());
117  CPPUNIT_ASSERT(pChild->getCharacters().find("correctly") != std::string::npos);
118 
119  SBMLDocument *pDocument = new SBMLDocument(2, 4);
120  CPPUNIT_ASSERT(pDocument != NULL);
121  Model* pModel = pDocument->createModel("test_model");
122  CPPUNIT_ASSERT(pModel != NULL);
123  int set_result = pModel->setNotes(pNotes);
124  CPPUNIT_ASSERT(set_result == LIBSBML_OPERATION_SUCCESS);
125  delete pDocument;
126  delete pNotes;
127 }
128 
130 {
131  XMLNode* pNotes = CSBMLExporter::createSBMLNotes(NOTES_STRING_4);
132  CPPUNIT_ASSERT(pNotes != NULL);
133  CPPUNIT_ASSERT(pNotes->getName() == "body");
134  CPPUNIT_ASSERT(pNotes->getURI() == "http://www.w3.org/1999/xhtml");
135  CPPUNIT_ASSERT(pNotes->hasNamespaceURI("http://www.w3.org/1999/xhtml") == true);
136 
137  CPPUNIT_ASSERT(pNotes->getNumChildren() == 4);
138  XMLNode* pChild = &pNotes->getChild(0);
139  CPPUNIT_ASSERT(pChild != NULL);
140  CPPUNIT_ASSERT(pChild->isText());
141  CPPUNIT_ASSERT(pChild->getCharacters().find("This") != std::string::npos);
142  pChild = &pNotes->getChild(1);
143  CPPUNIT_ASSERT(pChild != NULL);
144  CPPUNIT_ASSERT(pChild->isElement());
145  CPPUNIT_ASSERT(pChild->getName() == "p");
146  CPPUNIT_ASSERT(pChild->getNumChildren() == 1);
147  pChild = &pChild->getChild(0);
148  CPPUNIT_ASSERT(pChild != NULL);
149  CPPUNIT_ASSERT(pChild->isText());
150  CPPUNIT_ASSERT(pChild->getCharacters().find("mixed") != std::string::npos);
151  pChild = &pNotes->getChild(2);
152  CPPUNIT_ASSERT(pChild != NULL);
153  CPPUNIT_ASSERT(pChild->isText());
154  CPPUNIT_ASSERT(pChild->getCharacters().find("paragraphs") != std::string::npos);
155  pChild = &pNotes->getChild(3);
156  CPPUNIT_ASSERT(pChild != NULL);
157  CPPUNIT_ASSERT(pChild->isElement());
158  CPPUNIT_ASSERT(pChild->getName() == "p");
159  CPPUNIT_ASSERT(pChild->getNumChildren() == 1);
160  pChild = &pChild->getChild(0);
161  CPPUNIT_ASSERT(pChild != NULL);
162  CPPUNIT_ASSERT(pChild->isText());
163  CPPUNIT_ASSERT(pChild->getCharacters().find("set ") != std::string::npos);
164 
165  SBMLDocument *pDocument = new SBMLDocument(2, 4);
166  CPPUNIT_ASSERT(pDocument != NULL);
167  Model* pModel = pDocument->createModel("test_model");
168  CPPUNIT_ASSERT(pModel != NULL);
169  int set_result = pModel->setNotes(pNotes);
170  CPPUNIT_ASSERT(set_result == LIBSBML_OPERATION_SUCCESS);
171  delete pDocument;
172  delete pNotes;
173 }
174 
176 {
177  XMLNode* pNotes = CSBMLExporter::createSBMLNotes(NOTES_STRING_5);
178  CPPUNIT_ASSERT(pNotes != NULL);
179  CPPUNIT_ASSERT(pNotes->getName() == "body");
180  CPPUNIT_ASSERT(pNotes->getURI() == "http://www.w3.org/1999/xhtml");
181  CPPUNIT_ASSERT(pNotes->hasNamespaceURI("http://www.w3.org/1999/xhtml") == true);
182 
183  CPPUNIT_ASSERT(pNotes->getNumChildren() == 4);
184  XMLNode* pChild = &pNotes->getChild(0);
185  CPPUNIT_ASSERT(pChild != NULL);
186  CPPUNIT_ASSERT(pChild->isText());
187  CPPUNIT_ASSERT(pChild->getCharacters().find("This") != std::string::npos);
188  pChild = &pNotes->getChild(1);
189  CPPUNIT_ASSERT(pChild != NULL);
190  CPPUNIT_ASSERT(pChild->isElement());
191  CPPUNIT_ASSERT(pChild->getName() == "p");
192  CPPUNIT_ASSERT(pChild->getNumChildren() == 1);
193  pChild = &pChild->getChild(0);
194  CPPUNIT_ASSERT(pChild != NULL);
195  CPPUNIT_ASSERT(pChild->isText());
196  CPPUNIT_ASSERT(pChild->getCharacters().find("mixed") != std::string::npos);
197  pChild = &pNotes->getChild(2);
198  CPPUNIT_ASSERT(pChild != NULL);
199  CPPUNIT_ASSERT(pChild->isText());
200  CPPUNIT_ASSERT(pChild->getCharacters().find("paragraphs") != std::string::npos);
201  pChild = &pNotes->getChild(3);
202  CPPUNIT_ASSERT(pChild != NULL);
203  CPPUNIT_ASSERT(pChild->isElement());
204  CPPUNIT_ASSERT(pChild->getName() == "p");
205  CPPUNIT_ASSERT(pChild->getNumChildren() == 1);
206  pChild = &pChild->getChild(0);
207  CPPUNIT_ASSERT(pChild != NULL);
208  CPPUNIT_ASSERT(pChild->isText());
209  CPPUNIT_ASSERT(pChild->getCharacters().find("set ") != std::string::npos);
210 
211 
212  SBMLDocument *pDocument = new SBMLDocument(2, 4);
213  CPPUNIT_ASSERT(pDocument != NULL);
214  Model* pModel = pDocument->createModel("test_model");
215  CPPUNIT_ASSERT(pModel != NULL);
216  int set_result = pModel->setNotes(pNotes);
217  CPPUNIT_ASSERT(set_result == LIBSBML_OPERATION_SUCCESS);
218  delete pDocument;
219  delete pNotes;
220 }
221 
223 {
224  XMLNode* pNotes = CSBMLExporter::createSBMLNotes(NOTES_STRING_6);
225  CPPUNIT_ASSERT(pNotes != NULL);
226  CPPUNIT_ASSERT(pNotes->getName() == "body");
227  CPPUNIT_ASSERT(pNotes->getURI() == "http://www.w3.org/1999/xhtml");
228  CPPUNIT_ASSERT(pNotes->hasNamespaceURI("http://www.w3.org/1999/xhtml") == true);
229 
230  CPPUNIT_ASSERT(pNotes->getNumChildren() == 4);
231  XMLNode* pChild = &pNotes->getChild(0);
232  CPPUNIT_ASSERT(pChild != NULL);
233  CPPUNIT_ASSERT(pChild->isText());
234  CPPUNIT_ASSERT(pChild->getCharacters().find("This") != std::string::npos);
235  pChild = &pNotes->getChild(1);
236  CPPUNIT_ASSERT(pChild != NULL);
237  CPPUNIT_ASSERT(pChild->isElement());
238  CPPUNIT_ASSERT(pChild->getName() == "p");
239  CPPUNIT_ASSERT(pChild->getNumChildren() == 1);
240  pChild = &pChild->getChild(0);
241  CPPUNIT_ASSERT(pChild != NULL);
242  CPPUNIT_ASSERT(pChild->isText());
243  CPPUNIT_ASSERT(pChild->getCharacters().find("mixed") != std::string::npos);
244  pChild = &pNotes->getChild(2);
245  CPPUNIT_ASSERT(pChild != NULL);
246  CPPUNIT_ASSERT(pChild->isText());
247  CPPUNIT_ASSERT(pChild->getCharacters().find("paragraphs") != std::string::npos);
248  pChild = &pNotes->getChild(3);
249  CPPUNIT_ASSERT(pChild != NULL);
250  CPPUNIT_ASSERT(pChild->isElement());
251  CPPUNIT_ASSERT(pChild->getName() == "p");
252  CPPUNIT_ASSERT(pChild->getNumChildren() == 1);
253  pChild = &pChild->getChild(0);
254  CPPUNIT_ASSERT(pChild != NULL);
255  CPPUNIT_ASSERT(pChild->isText());
256  CPPUNIT_ASSERT(pChild->getCharacters().find("set ") != std::string::npos);
257 
258 
259  SBMLDocument *pDocument = new SBMLDocument(2, 4);
260  CPPUNIT_ASSERT(pDocument != NULL);
261  Model* pModel = pDocument->createModel("test_model");
262  CPPUNIT_ASSERT(pModel != NULL);
263  int set_result = pModel->setNotes(pNotes);
264  CPPUNIT_ASSERT(set_result == LIBSBML_OPERATION_SUCCESS);
265  delete pDocument;
266  delete pNotes;
267 }
268 
269 const char* test000096::NOTES_STRING_1 =
270  "This is a test\n"
271  "to see if simple text is\n"
272  "set correctly.\n"
273  ;
274 
275 const char* test000096::NOTES_STRING_2 =
276  "<p>This is a test\n"
277  "to see if a single paragraph is\n"
278  "set correctly.</p>\n"
279  ;
280 
281 const char* test000096::NOTES_STRING_3 =
282  "<p>This is a test</p>\n"
283  "<p>to see if a several paragraphs are</p>\n"
284  "<p>set correctly.</p>\n"
285  ;
286 
287 const char* test000096::NOTES_STRING_4 =
288  "This is a test\n"
289  "<p>to see if text mixed with</p>\n"
290  "several paragraphs is\n"
291  "<p>set correctly.</p>\n"
292  ;
293 
294 const char* test000096::NOTES_STRING_5 =
295  "<body>\n"
296  "This is a test\n"
297  "<p>to see if body element plus text mixed with</p>\n"
298  "several paragraphs is\n"
299  "<p>set correctly.</p>\n"
300  "</body>\n"
301  ;
302 
303 const char* test000096::NOTES_STRING_6 =
304  "<body xmlns=\"http://www.w3.org/1999/xhtml\"> \n"
305  "This is a test\n"
306  "<p>to see if body element plus text mixed with</p>\n"
307  "several paragraphs is\n"
308  "<p>set correctly.</p>\n"
309  "</body>\n"
310  ;
311 
312 
void test_export_model_notes_5()
Definition: test000096.cpp:175
static const char * NOTES_STRING_3
Definition: test000096.h:41
void test_export_model_notes_3()
Definition: test000096.cpp:83
static const char * NOTES_STRING_4
Definition: test000096.h:42
static const char * NOTES_STRING_5
Definition: test000096.h:43
void test_export_model_notes_4()
Definition: test000096.cpp:129
void setUp()
Definition: test000096.cpp:25
void test_export_model_notes_2()
Definition: test000096.cpp:61
static const char * NOTES_STRING_1
Definition: test000096.h:39
void test_export_model_notes_1()
Definition: test000096.cpp:36
static const char * NOTES_STRING_6
Definition: test000096.h:44
static void init(int argc, char *argv[], const bool &withGui=false)
void tearDown()
Definition: test000096.cpp:31
void test_export_model_notes_6()
Definition: test000096.cpp:222
static const char * NOTES_STRING_2
Definition: test000096.h:40