ExceptionTest.cc 785 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "Exception.h"
  2. #include "DownloadFailureException.h"
  3. #include "Util.h"
  4. #include <iostream>
  5. #include <cppunit/extensions/HelperMacros.h>
  6. namespace aria2 {
  7. class ExceptionTest:public CppUnit::TestFixture {
  8. CPPUNIT_TEST_SUITE(ExceptionTest);
  9. CPPUNIT_TEST(testStackTrace);
  10. CPPUNIT_TEST_SUITE_END();
  11. public:
  12. void setUp() {}
  13. void tearDown() {}
  14. void testStackTrace();
  15. };
  16. CPPUNIT_TEST_SUITE_REGISTRATION(ExceptionTest);
  17. void ExceptionTest::testStackTrace()
  18. {
  19. DownloadFailureException c1("cause1");
  20. DownloadFailureException c2("cause2", c1);
  21. DownloadFailureException e("exception thrown", c2);
  22. CPPUNIT_ASSERT_EQUAL(std::string("Exception: exception thrown\n"
  23. " -> cause2\n"
  24. " -> cause1\n"),
  25. e.stackTrace());
  26. }
  27. } // namespace aria2