I have been using CPPUnit (Version 1.11.4) for Borland C++ Builder 6.0.
Everything appears to work, except for the helper macro CPPUNIT_ASSERT_THROW(). I am not exactly sure what to put for the second parameter, ExceptionType. A sample given in the document:
to see if Division by 0 is verified, Compiler complains. I am not sure exactly what to put for this "division by 0" exception type for Borland C++ Builder, the second parameter of CPPUNIT_ASSERT_THROW macro.
Any help will be appreciated.
Cheers,
Yan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am putting the all the error messages (including warnings) just in case. Again, there are some warning messages but I am able to use CPPUNIT_ASSERT() helper macros without any problems so they don't seem to be causing any problems...
Thanks again,
- Yan
Build
[C++ Warning] TestAssert.h(84): W8075 Suspicious pointer conversion
Full parser context
Cookbook.cpp(2): #include C:\src\Hack cppUnitCookBook\Cookbook.h
Cookbook.h(1): #include C:\src\cppunit-1.11.4\include\cppunit/extensions/HelperMacros.h
HelperMacros.h(9): #include C:\src\cppunit-1.11.4\include\cppunit/TestCaller.h
TestCaller.h(5): #include C:\src\cppunit-1.11.4\include\cppunit/TestCase.h
TestCase.h(6): #include C:\src\cppunit-1.11.4\include\cppunit/TestAssert.h
TestAssert.h(12): namespace CppUnit
TestAssert.h(65): class assertion_traits<double>
TestAssert.h(87): decision to instantiate: _STL::string assertion_traits<double>::toString(double)
--- Resetting parser context for instantiation...
TestAssert.h(72): parsing: _STL::string assertion_traits<double>::toString(double)
[C++ Warning] TextTestRunner.h(88): W8022 'TextTestRunner::run(_STL::string,bool,bool,bool)' hides virtual function 'TestRunner::run(TestResult &,const _STL::string &)'
Full parser context
Cookbook.cpp(2): #include C:\src\Hack cppUnitCookBook\Cookbook.h
Cookbook.h(3): #include C:\src\cppunit-1.11.4\include\cppunit/ui/text/TestRunner.h
TestRunner.h(4): #include C:\src\cppunit-1.11.4\include\cppunit/ui/text/TextTestRunner.h
TextTestRunner.h(9): namespace CppUnit
TextTestRunner.h(63): class TextTestRunner
[C++ Warning] Asserter.h(104): W8058 Cannot create pre-compiled header: initialized data in header
[C++ Warning] Cookbook.cpp(46): W8082 Division by zero
Full parser context
Cookbook.cpp(9): class ComplexNumberTest
Cookbook.cpp(76): decision to instantiate: void ComplexNumberTest::testDivideByZeroThrows()
--- Resetting parser context for instantiation...
Cookbook.cpp(44): parsing: void ComplexNumberTest::testDivideByZeroThrows()
[C++ Error] Cookbook.cpp(46): E2377 Catch statement missing )
Full parser context
Cookbook.cpp(9): class ComplexNumberTest
Cookbook.cpp(76): decision to instantiate: void ComplexNumberTest::testDivideByZeroThrows()
--- Resetting parser context for instantiation...
Cookbook.cpp(44): parsing: void ComplexNumberTest::testDivideByZeroThrows()
[C++ Warning] Cookbook.cpp(47): W8082 Division by zero
Full parser context
Cookbook.cpp(9): class ComplexNumberTest
Cookbook.cpp(76): decision to instantiate: void ComplexNumberTest::testDivideByZeroThrows()
--- Resetting parser context for instantiation...
Cookbook.cpp(44): parsing: void ComplexNumberTest::testDivideByZeroThrows()
[C++ Error] Cookbook.cpp(47): E2377 Catch statement missing )
Full parser context
Cookbook.cpp(9): class ComplexNumberTest
Cookbook.cpp(76): decision to instantiate: void ComplexNumberTest::testDivideByZeroThrows()
--- Resetting parser context for instantiation...
Cookbook.cpp(44): parsing: void ComplexNumberTest::testDivideByZeroThrows()
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi.
(A Newbie quesion)
I have been using CPPUnit (Version 1.11.4) for Borland C++ Builder 6.0.
Everything appears to work, except for the helper macro CPPUNIT_ASSERT_THROW(). I am not exactly sure what to put for the second parameter, ExceptionType. A sample given in the document:
std::vector<int> v;
CPPUNIT_ASSERT_THROW( v.at( 50 ),std::out_of_range );
works fine. But if I try:
CPPUNIT_ASSERT_THROW(1/0, MathException);
to see if Division by 0 is verified, Compiler complains. I am not sure exactly what to put for this "division by 0" exception type for Borland C++ Builder, the second parameter of CPPUNIT_ASSERT_THROW macro.
Any help will be appreciated.
Cheers,
Yan
Can you please post the compiler error that you are getting?
Thanks.
Thank you for your willingness to help, Codeguru.
When I put the following:
CPPUNIT_ASSERT_THROW( 1/0,EDivByZero);
CPPUNIT_ASSERT_THROW( 1/0,MathException);
I get
[C++ Error] Cookbook.cpp(46): E2377 Catch statement missing )
[C++ Error] Cookbook.cpp(47): E2377 Catch statement missing )
for both statements.
I am putting the all the error messages (including warnings) just in case. Again, there are some warning messages but I am able to use CPPUNIT_ASSERT() helper macros without any problems so they don't seem to be causing any problems...
Thanks again,
- Yan
Build
[C++ Warning] TestAssert.h(84): W8075 Suspicious pointer conversion
Full parser context
Cookbook.cpp(2): #include C:\src\Hack cppUnitCookBook\Cookbook.h
Cookbook.h(1): #include C:\src\cppunit-1.11.4\include\cppunit/extensions/HelperMacros.h
HelperMacros.h(9): #include C:\src\cppunit-1.11.4\include\cppunit/TestCaller.h
TestCaller.h(5): #include C:\src\cppunit-1.11.4\include\cppunit/TestCase.h
TestCase.h(6): #include C:\src\cppunit-1.11.4\include\cppunit/TestAssert.h
TestAssert.h(12): namespace CppUnit
TestAssert.h(65): class assertion_traits<double>
TestAssert.h(87): decision to instantiate: _STL::string assertion_traits<double>::toString(double)
--- Resetting parser context for instantiation...
TestAssert.h(72): parsing: _STL::string assertion_traits<double>::toString(double)
[C++ Warning] TextTestRunner.h(88): W8022 'TextTestRunner::run(_STL::string,bool,bool,bool)' hides virtual function 'TestRunner::run(TestResult &,const _STL::string &)'
Full parser context
Cookbook.cpp(2): #include C:\src\Hack cppUnitCookBook\Cookbook.h
Cookbook.h(3): #include C:\src\cppunit-1.11.4\include\cppunit/ui/text/TestRunner.h
TestRunner.h(4): #include C:\src\cppunit-1.11.4\include\cppunit/ui/text/TextTestRunner.h
TextTestRunner.h(9): namespace CppUnit
TextTestRunner.h(63): class TextTestRunner
[C++ Warning] Asserter.h(104): W8058 Cannot create pre-compiled header: initialized data in header
[C++ Warning] Cookbook.cpp(46): W8082 Division by zero
Full parser context
Cookbook.cpp(9): class ComplexNumberTest
Cookbook.cpp(76): decision to instantiate: void ComplexNumberTest::testDivideByZeroThrows()
--- Resetting parser context for instantiation...
Cookbook.cpp(44): parsing: void ComplexNumberTest::testDivideByZeroThrows()
[C++ Error] Cookbook.cpp(46): E2377 Catch statement missing )
Full parser context
Cookbook.cpp(9): class ComplexNumberTest
Cookbook.cpp(76): decision to instantiate: void ComplexNumberTest::testDivideByZeroThrows()
--- Resetting parser context for instantiation...
Cookbook.cpp(44): parsing: void ComplexNumberTest::testDivideByZeroThrows()
[C++ Warning] Cookbook.cpp(47): W8082 Division by zero
Full parser context
Cookbook.cpp(9): class ComplexNumberTest
Cookbook.cpp(76): decision to instantiate: void ComplexNumberTest::testDivideByZeroThrows()
--- Resetting parser context for instantiation...
Cookbook.cpp(44): parsing: void ComplexNumberTest::testDivideByZeroThrows()
[C++ Error] Cookbook.cpp(47): E2377 Catch statement missing )
Full parser context
Cookbook.cpp(9): class ComplexNumberTest
Cookbook.cpp(76): decision to instantiate: void ComplexNumberTest::testDivideByZeroThrows()
--- Resetting parser context for instantiation...
Cookbook.cpp(44): parsing: void ComplexNumberTest::testDivideByZeroThrows()