Check th ebelow code:
Code:
# include <cppunit/TestCase.h>
# include <cppunit/ui/text/TextTestRunner.h>
class mystringTest: public CppUnit:: TestCase (
public:
void runTest () (
mystring s;
CPPUNIT_ASSERT_MESSAGE ( "String Length Non-Zero", s.size ()! = 0);
)
);
int main ()
(
mystringTest test;
CppUnit:: TextTestRunner runner;
runner.addTest (& test);
runner.run ();
return 0;
)
To create a unit test for the string class, you need to create CppUnit:: TestCase Class, subclass, and override runTest Method. Defines the test itself, the instantiation TextTestRunner Class, this is a controller class, you must add the test (vide addTest Methods). Check and reply.
Bookmarks