HelloWorldTest.cpp 850 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <cppunit/extensions/HelperMacros.h>
  2. #include "HelloWorld.h"
  3. #include <string>
  4. using namespace std;
  5. class HelloWorldTest : public CPPUNIT_NS::TestFixture
  6. {
  7. private:
  8. CPPUNIT_TEST_SUITE( HelloWorldTest );
  9. CPPUNIT_TEST( test0 );
  10. CPPUNIT_TEST( test1 );
  11. CPPUNIT_TEST_SUITE_END();
  12. public:
  13. void test0();
  14. void test1();
  15. };
  16. // Registers the fixture into the 'registry'
  17. CPPUNIT_TEST_SUITE_REGISTRATION( HelloWorldTest );
  18. void HelloWorldTest::test0()
  19. {
  20. HelloWorld hello;
  21. string expected("Hello World");
  22. CPPUNIT_ASSERT_EQUAL(expected, hello.message());
  23. }
  24. void HelloWorldTest::test1()
  25. {
  26. string expected("Hola Mundo");
  27. HelloWorld hello(expected);
  28. CPPUNIT_ASSERT_EQUAL(expected, hello.message());
  29. expected = "Hello, world!";
  30. hello.setMessage(expected);
  31. CPPUNIT_ASSERT_EQUAL(expected, hello.message());
  32. }