BtPostDownloadHandlerTest.cc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "BtPostDownloadHandler.h"
  2. #include "BtContext.h"
  3. #include "RequestGroup.h"
  4. #include "Option.h"
  5. #include <cppunit/extensions/HelperMacros.h>
  6. class BtPostDownloadHandlerTest:public CppUnit::TestFixture {
  7. CPPUNIT_TEST_SUITE(BtPostDownloadHandlerTest);
  8. CPPUNIT_TEST(testCanHandle);
  9. CPPUNIT_TEST(testGetNextRequestGroups);
  10. CPPUNIT_TEST_SUITE_END();
  11. private:
  12. public:
  13. void setUp() {}
  14. void testCanHandle();
  15. void testGetNextRequestGroups();
  16. };
  17. CPPUNIT_TEST_SUITE_REGISTRATION( BtPostDownloadHandlerTest );
  18. void BtPostDownloadHandlerTest::testCanHandle()
  19. {
  20. Option op;
  21. BtPostDownloadHandler handler(&op);
  22. CPPUNIT_ASSERT(!handler.canHandle(".torrent!!"));
  23. CPPUNIT_ASSERT(handler.canHandle(".torrent"));
  24. }
  25. void BtPostDownloadHandlerTest::testGetNextRequestGroups()
  26. {
  27. Option op;
  28. BtPostDownloadHandler handler(&op);
  29. RequestGroups groups = handler.getNextRequestGroups("test.torrent");
  30. CPPUNIT_ASSERT_EQUAL((size_t)1, groups.size());
  31. BtContextHandle btctx = groups.front()->getDownloadContext();
  32. CPPUNIT_ASSERT(!btctx.isNull());
  33. CPPUNIT_ASSERT_EQUAL(string("aria2-test"), btctx->getName());
  34. }