COPASI API  4.16.103
test000103.cpp
Go to the documentation of this file.
1 // Copyright (C) 2011 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 #include "test000103.h"
7 
8 #include <string>
9 
12 #include <copasi/model/CModel.h>
13 
14 // in earlier version of COPASI, setting the SBML id on a model prior to exporting it
15 // had no effect (bug 1743)
16 
18 {
19  // Create the root container.
20  CCopasiRootContainer::init(0, NULL, false);
22 }
23 
25 {
27 }
28 
30 {
31  CModel* pModel = pDataModel->getModel();
32  CPPUNIT_ASSERT(pModel != NULL);
33  std::string id("MyTestModel");
34  pModel->setSBMLId(id);
35  CPPUNIT_ASSERT(pModel->getSBMLId() == id);
36  // export to l2v4
37  std::string model_string = pDataModel->exportSBMLToString(NULL, 2, 4);
38  pModel = pDataModel->getModel();
39  CPPUNIT_ASSERT(pModel != NULL);
40  CPPUNIT_ASSERT(pModel->getSBMLId() == id);
41  pDataModel->newModel(NULL, true);
42  pModel = pDataModel->getModel();
43  CPPUNIT_ASSERT(pModel != NULL);
44  CPPUNIT_ASSERT(pModel->getSBMLId() != id);
45 
46  try
47  {
48  bool result = pDataModel->importSBMLFromString(model_string);
49  CPPUNIT_ASSERT(result == true);
50  }
51  catch (...)
52  {
53  CPPUNIT_ASSERT_MESSAGE("Exception while importing the exported model string.", false);
54  }
55 
56  pModel = pDataModel->getModel();
57  CPPUNIT_ASSERT(pModel != NULL);
58  CPPUNIT_ASSERT(pModel->getSBMLId() == id);
59 }
60 
62 {
63  CModel* pModel = pDataModel->getModel();
64  CPPUNIT_ASSERT(pModel != NULL);
65  std::string id("MyTestModel");
66  pModel->setSBMLId(id);
67  CPPUNIT_ASSERT(pModel->getSBMLId() == id);
68  // export to l3v1
69  std::string model_string = pDataModel->exportSBMLToString(NULL, 3, 1);
70  pModel = pDataModel->getModel();
71  CPPUNIT_ASSERT(pModel != NULL);
72  CPPUNIT_ASSERT(pModel->getSBMLId() == id);
73  pDataModel->newModel(NULL, true);
74  pModel = pDataModel->getModel();
75  CPPUNIT_ASSERT(pModel != NULL);
76  CPPUNIT_ASSERT(pModel->getSBMLId() != id);
77 
78  try
79  {
80  bool result = pDataModel->importSBMLFromString(model_string);
81  CPPUNIT_ASSERT(result == true);
82  }
83  catch (...)
84  {
85  CPPUNIT_ASSERT_MESSAGE("Exception while importing the exported model string.", false);
86  }
87 
88  pModel = pDataModel->getModel();
89  CPPUNIT_ASSERT(pModel != NULL);
90  CPPUNIT_ASSERT(pModel->getSBMLId() == id);
91 }
void tearDown()
Definition: test000103.cpp:24
const std::string & getSBMLId() const
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool newModel(CProcessReport *pProcessReport, const bool &deleteOldData)
void test_bug1743_l2()
Definition: test000103.cpp:29
void test_bug1743_l3()
Definition: test000103.cpp:61
static CCopasiDataModel * addDatamodel()
CCopasiDataModel * pDataModel
Definition: test000103.h:39
void setUp()
Definition: test000103.cpp:17
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static void init(int argc, char *argv[], const bool &withGui=false)
Definition: CModel.h:50
void setSBMLId(const std::string &id)