COPASI API  4.16.103
Public Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
test000101 Class Reference

#include <test000101.h>

Inheritance diagram for test000101:
Inheritance graph
[legend]
Collaboration diagram for test000101:
Collaboration graph
[legend]

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_bug1740 ()
 

Static Protected Member Functions

static void abort_handler (int)
 

Protected Attributes

CCopasiDataModelpDataModel
 

Static Protected Attributes

static struct sigaction * pNewAct = new struct sigaction()
 
static struct sigaction * pOldAct = new struct sigaction()
 
static const char * SBML_STRING
 

Private Member Functions

 CPPUNIT_TEST (test_bug1740)
 
 CPPUNIT_TEST_SUITE (test000101)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 31 of file test000101.h.

Member Function Documentation

void test000101::abort_handler ( int  )
staticprotected

Definition at line 30 of file test000101.cpp.

Referenced by setUp().

31 {
32  throw std::runtime_error("Received SIGSEGV signal.");
33 }
test000101::CPPUNIT_TEST ( test_bug1740  )
private
test000101::CPPUNIT_TEST_SUITE ( test000101  )
private
test000101::CPPUNIT_TEST_SUITE_END ( )
private
void test000101::setUp ( )

Definition at line 39 of file test000101.cpp.

References abort_handler(), CCopasiRootContainer::addDatamodel(), CCopasiRootContainer::init(), pDataModel, pNewAct, and pOldAct.

40 {
41 #ifndef WIN32
42  // set a new action handler for SIGABRT that throws an exception
43  // instead of terminating the program. This is needed to handle failed assertions
44  // in debug versions.
45  pNewAct->sa_handler = &test000101::abort_handler;
46  int x = sigaction(SIGSEGV, test000101::pNewAct, test000101::pOldAct);
47 
48  if (x != 0)
49  {
50  std::cerr << "Setting the signal handler failed." << std::endl;
51  }
52 
53 #endif
54  // Create the root container.
55  CCopasiRootContainer::init(0, NULL, false);
57 }
static struct sigaction * pOldAct
Definition: test000101.h:44
static struct sigaction * pNewAct
Definition: test000101.h:43
static void abort_handler(int)
Definition: test000101.cpp:30
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
CCopasiDataModel * pDataModel
Definition: test000101.h:41
void test000101::tearDown ( )

Definition at line 59 of file test000101.cpp.

References CCopasiRootContainer::destroy(), and pOldAct.

60 {
61 #ifndef WIN32
63  // restore the old action handler
64  int x = sigaction(SIGSEGV, test000101::pOldAct, NULL);
65 
66  if (x != 0)
67  {
68  std::cerr << "Resetting the signal handler failed." << std::endl;
69  }
70 
71 #endif
72 }
static struct sigaction * pOldAct
Definition: test000101.h:44
void test000101::test_bug1740 ( )

Definition at line 76 of file test000101.cpp.

References CCopasiDataModel::exportSBMLToString(), CCopasiDataModel::importSBMLFromString(), pDataModel, and SBML_STRING.

77 {
79  pDataModel->exportSBMLToString(NULL, 3, 1);
80 
81  try
82  {
83  // the second export crashes without a bug fix
84  pDataModel->exportSBMLToString(NULL, 3, 1);
85  }
86  catch (const std::runtime_error& e)
87  {
88  CPPUNIT_ASSERT_MESSAGE("The second export to Level 3 Version 1 failed.", false);
89  }
90 }
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static const char * SBML_STRING
Definition: test000101.h:39
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
CCopasiDataModel * pDataModel
Definition: test000101.h:41

Member Data Documentation

CCopasiDataModel* test000101::pDataModel
protected

Definition at line 41 of file test000101.h.

Referenced by setUp(), and test_bug1740().

struct sigaction * test000101::pNewAct = new struct sigaction()
staticprotected

Definition at line 43 of file test000101.h.

Referenced by setUp().

struct sigaction * test000101::pOldAct = new struct sigaction()
staticprotected

Definition at line 44 of file test000101.h.

Referenced by setUp(), and tearDown().

const char * test000101::SBML_STRING
staticprotected
Initial value:
= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<sbml xmlns=\"http://www.sbml.org/sbml/level3/version1/core\" level=\"3\" version=\"1\">\n"
" <model id=\"Module_1_RL2_1\" name=\"Module_1_RL2\">\n"
" <listOfReactions>\n"
" <reaction fast=\"false\" id=\"reaction_0\" name=\"reaction_0\" reversible=\"false\">\n"
" </reaction>\n"
" </listOfReactions>\n"
" </model>\n"
"</sbml>\n"

Definition at line 39 of file test000101.h.

Referenced by test_bug1740().


The documentation for this class was generated from the following files: