Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 22nd, 2012  |  syntax: None  |  size: 4.95 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Error with compile source file, which used cppunit classes
  2. libcppunit-1.12-1 - Unit Testing Library for C++
  3. libcppunit-dev - Unit Testing Library for C++
  4. libcppunit-doc - Unit Testing Library for C++
  5. libcppunit-subunit-dev - SubunitTestProgressListener for CPPUnit - Development headers
  6. libcppunit-subunit0 - SubunitTestProgressListener for CPPUnit - C++ shared library
  7. libcunit1 - Unit Testing Library for C
  8. libcunit1-dev - Unit Testing Library for C -- development files
  9. libcunit1-doc - Unit Testing Library for C -- documentation
  10. libcunit1-ncurses - Unit Testing Library for C (ncurses)
  11. libcunit1-ncurses-dev - Unit Testing Library for C (ncurses) -- development files
  12. libqxcppunit-dev - A Qt4-based GUI for running tests with CppUnit - development files
  13. libqxcppunitd1 - A Qt4-based GUI for running tests with CppUnit
  14.        
  15. #include <iostream>
  16. #include <cppunit/TestCase.h>
  17. #include <cppunit/extensions/HelperMacros.h>
  18.  
  19. class MyDate
  20. {
  21. private:
  22.     struct Duration
  23.     {
  24.         int year;
  25.         int month;
  26.         int day;
  27.         Duration( int y, int m, int d ) :
  28.             year( y ), month( m ), day( d )
  29.             {}
  30.     } mdata;
  31. public:
  32.     MyDate() : mdata( 2011, 11, 15 )
  33.     {}
  34.     MyDate( int year, int month, int day ) : mdata( year, month, day )
  35.     {}
  36.     int getYear() const
  37.     { return mdata.year; }
  38.     int getMonth() const    
  39.     { return mdata.month; }
  40.     int getDay() const
  41.     { return mdata.day; }
  42.     friend bool operator < ( MyDate const& lhs, MyDate const& rhs )
  43.     {
  44.         if ( lhs.mdata.year > rhs.mdata.year )
  45.             return false;          
  46.         else if ( lhs.mdata.year < rhs.mdata.year )
  47.             return true;
  48.         else if ( lhs.mdata.year == rhs.mdata.year )
  49.         {
  50.             if ( lhs.mdata.month > rhs.mdata.month )
  51.                 return false;          
  52.             else if ( lhs.mdata.month < rhs.mdata.month )
  53.                 return true;
  54.             else if ( lhs.mdata.month == rhs.mdata.month )
  55.             {
  56.                 if ( lhs.mdata.day < rhs.mdata.day )
  57.                     return true;            
  58.                 else
  59.                     return false;          
  60.             }
  61.         }
  62.         return false;
  63.     }
  64. };
  65.  
  66. class MyDateTest : public CppUnit::TestCase
  67. {
  68.     MyDate mybday;
  69.     MyDate today;
  70. public:
  71.     MyDateTest() : mybday( 1951, 10, 1 ) {}
  72.     void run()
  73.     {
  74.         testOps();
  75.     }
  76.     void testOps()
  77.     {
  78.         CPPUNIT_ASSERT( mybday < today );
  79.     }
  80. };
  81.  
  82. int main()
  83. {
  84.     MyDateTest test;
  85.     test.run();
  86.     return 0;
  87. }
  88.        
  89. $ g++ -Wall -pedantic date_module_test.cpp -o date_module_test
  90. /tmp/ccLgvOFj.o: In function `MyDateTest::MyDateTest()':
  91. date_module_test.cpp:(.text._ZN10MyDateTestC2Ev[_ZN10MyDateTestC5Ev]+0xd): undefined reference to `CppUnit::TestCase::TestCase()'
  92. /tmp/ccLgvOFj.o: In function `MyDateTest::~MyDateTest()':
  93. date_module_test.cpp:(.text._ZN10MyDateTestD2Ev[_ZN10MyDateTestD5Ev]+0x20): undefined reference to `CppUnit::TestCase::~TestCase()'
  94. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x10): undefined reference to `CppUnit::TestCase::run(CppUnit::TestResult*)'
  95. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x14): undefined reference to `CppUnit::TestLeaf::countTestCases() const'
  96. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x18): undefined reference to `CppUnit::TestLeaf::getChildTestCount() const'
  97. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x1c): undefined reference to `CppUnit::Test::getChildTestAt(int) const'
  98. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x20): undefined reference to `CppUnit::TestCase::getName() const'
  99. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x24): undefined reference to `CppUnit::Test::findTestPath(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, CppUnit::TestPath&) const'
  100. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x28): undefined reference to `CppUnit::Test::findTestPath(CppUnit::Test const*, CppUnit::TestPath&) const'
  101. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x2c): undefined reference to `CppUnit::Test::findTest(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
  102. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x30): undefined reference to `CppUnit::Test::resolveTestPath(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
  103. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x34): undefined reference to `CppUnit::Test::checkIsValidIndex(int) const'
  104. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x38): undefined reference to `CppUnit::TestLeaf::doGetChildTestAt(int) const'
  105. /tmp/ccLgvOFj.o:(.rodata._ZTV10MyDateTest[vtable for MyDateTest]+0x3c): undefined reference to `CppUnit::TestCase::runTest()'
  106. /tmp/ccLgvOFj.o:(.rodata._ZTI10MyDateTest[typeinfo for MyDateTest]+0x8): undefined reference to `typeinfo for CppUnit::TestCase'
  107. collect2: ld returned 1 exit status