FileEntryTest.cc 785 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "FileEntry.h"
  2. #include <cppunit/extensions/HelperMacros.h>
  3. class FileEntryTest : public CppUnit::TestFixture {
  4. CPPUNIT_TEST_SUITE(FileEntryTest);
  5. CPPUNIT_TEST(testSetupDir);
  6. CPPUNIT_TEST_SUITE_END();
  7. public:
  8. void setUp() {}
  9. void testSetupDir();
  10. };
  11. CPPUNIT_TEST_SUITE_REGISTRATION( FileEntryTest );
  12. void FileEntryTest::testSetupDir()
  13. {
  14. string topDir = "/tmp";
  15. string dir = "aria2-FileEntryTest-testSetupDir";
  16. string filename = "filename";
  17. string path = topDir+"/"+dir+"/"+filename;
  18. File d(topDir+"/"+dir);
  19. if(d.exists()) {
  20. CPPUNIT_ASSERT(d.remove());
  21. }
  22. CPPUNIT_ASSERT(!d.exists());
  23. FileEntry fileEntry(dir+"/"+filename, 0, 0);
  24. fileEntry.setupDir(topDir);
  25. CPPUNIT_ASSERT(d.isDir());
  26. File f(path);
  27. CPPUNIT_ASSERT(!f.exists());
  28. }