Back to index

salome-kernel  6.5.0
Public Member Functions | Private Member Functions
UtilsTest Class Reference

#include <UtilsTest.hxx>

List of all members.

Public Member Functions

void setUp ()
 Set Trace mecanism.
void tearDown ()
void testSALOME_ExceptionThrow ()
 Check basic SALOME_exception mecanism.
void testSALOME_ExceptionMessage ()
 Check message on catch.

Private Member Functions

 CPPUNIT_TEST_SUITE (UtilsTest)
 CPPUNIT_TEST (testSALOME_ExceptionThrow)
 CPPUNIT_TEST (testSALOME_ExceptionMessage)
 CPPUNIT_TEST_SUITE_END ()

Detailed Description

Definition at line 28 of file UtilsTest.hxx.


Member Function Documentation

void UtilsTest::setUp ( )

Set Trace mecanism.

  • delete preexisting trace classes if any
  • set trace on file

Definition at line 44 of file UtilsTest.cxx.

{
  LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
  CPPUNIT_ASSERT(bp1);
  bp1->deleteInstance(bp1);

  // --- trace on file
  const char *theFileName = TRACEFILE;

  std::string s = "file:";
  s += theFileName;
  CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite

  std::ofstream traceFile;
  traceFile.open(theFileName, std::ios::out | std::ios::app);
  CPPUNIT_ASSERT(traceFile); // file created empty, then closed
  traceFile.close();

  bp1 = LocalTraceBufferPool::instance();
  CPPUNIT_ASSERT(bp1);
}
  • delete trace classes

Definition at line 73 of file UtilsTest.cxx.

{
  LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
  CPPUNIT_ASSERT(bp1);
  bp1->deleteInstance(bp1);
}

Check message on catch.

Definition at line 104 of file UtilsTest.cxx.

{
#define EXAMPLE_EXCEPTION_MESSAGE "something for the end user"
  try
    {
      throw SALOME_Exception(EXAMPLE_EXCEPTION_MESSAGE);
    }
  catch (const SALOME_Exception &ex)
    {
      std::string expectedMessage = EXAMPLE_EXCEPTION_MESSAGE;
      std::string actualMessage = ex.what();
      CPPUNIT_ASSERT(actualMessage.find(expectedMessage) != std::string::npos);
    }
}

Check basic SALOME_exception mecanism.

Definition at line 92 of file UtilsTest.cxx.

{
  CPPUNIT_ASSERT_THROW(genExcept(), SALOME_Exception);
}

Here is the call graph for this function:


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