summaryrefslogtreecommitdiff
path: root/test/FileEntryTest.cc
blob: 5b6465bc22171f452050d28a28782fcf88b84eb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "FileEntry.h"
#include <cppunit/extensions/HelperMacros.h>

namespace aria2 {

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()
{
  std::string topDir = "/tmp";
  std::string dir = "aria2-FileEntryTest-testSetupDir";
  std::string filename = "filename";
  std::string path = topDir+"/"+dir+"/"+filename;
  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());
}

} // namespace aria2