Menu

Is the CppUnit Thread safe?

Help
Anonymous
2002-07-25
2002-08-31
  • Anonymous

    Anonymous - 2002-07-25

    Is the CppUnit Thread safe?
    Can I open a thread from a class derived from TestFixture and in one of it's test cases open a thread and in this thread use the CPPUNIT_ASSERT(expression);?

    myClass :public TestFixture {
    public:
    void testXXX();

    CPPUNIT_TEST_SUITE( myClass );
    CPPUNIT_TEST( testXXX);
    CPPUNIT_TEST_SUITE_END();

    private:
    Thread _t;
    }

    void myClass::testXXX()
    {
    //Here I open a thread that will use expessions
    //like CPPUNIT_ASSERT(expression);?
    //is this OK?
       _t.start();
    }

     
    • Baptiste Lepilleur

      Assertion are thread-safe. They don't use any stati c variables and just throw an exception in case of failure.

      If you spawn a thread, be sure to catch the exception and propagate it in the main thread (you can clone it using clone() ).

      Baptiste.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.