2007-11-05 15:13:55 +00:00
|
|
|
#include "FileEntry.h"
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
|
|
|
|
2007-11-05 15:13:55 +00:00
|
|
|
class FileEntryTest : public CppUnit::TestFixture {
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(FileEntryTest);
|
|
|
|
CPPUNIT_TEST(testSetupDir);
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
public:
|
|
|
|
void setUp() {}
|
|
|
|
|
|
|
|
void testSetupDir();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( FileEntryTest );
|
|
|
|
|
|
|
|
void FileEntryTest::testSetupDir()
|
|
|
|
{
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string topDir = "/tmp";
|
|
|
|
std::string dir = "aria2-FileEntryTest-testSetupDir";
|
|
|
|
std::string filename = "filename";
|
|
|
|
std::string path = topDir+"/"+dir+"/"+filename;
|
2007-11-05 15:13:55 +00:00
|
|
|
File d(topDir+"/"+dir);
|
|
|
|
if(d.exists()) {
|
|
|
|
CPPUNIT_ASSERT(d.remove());
|
|
|
|
}
|
|
|
|
CPPUNIT_ASSERT(!d.exists());
|
|
|
|
FileEntry fileEntry(dir+"/"+filename, 0, 0);
|
|
|
|
fileEntry.setupDir(topDir);
|
|
|
|
CPPUNIT_ASSERT(d.isDir());
|
|
|
|
File f(path);
|
|
|
|
CPPUNIT_ASSERT(!f.exists());
|
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
} // namespace aria2
|