FileNameTest.cpp 1013 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "FileNameTest.h"
  2. using namespace std;
  3. using namespace NICE;
  4. CPPUNIT_TEST_SUITE_REGISTRATION( FileNameTest );
  5. void FileNameTest::setUp() {
  6. }
  7. void FileNameTest::tearDown() {
  8. }
  9. void FileNameTest::testFileName() {
  10. string path("/home/bajramov/VAMPIRE/");
  11. string basename("filename");
  12. string ext(".test");
  13. string name = basename + ext;
  14. string fileNameString = path + name;
  15. FileName fileName(fileNameString);
  16. CPPUNIT_ASSERT_EQUAL(fileNameString, fileName.str());
  17. CPPUNIT_ASSERT_EQUAL(path, fileName.extractPath().str());
  18. CPPUNIT_ASSERT_EQUAL(name, fileName.extractFileName().str());
  19. CPPUNIT_ASSERT_EQUAL(ext, fileName.extractExtension().str());
  20. }
  21. void FileNameTest::testFileNameSlash() {
  22. string path("/home/bajramov/VAMPIRE");
  23. string pathSlash = path + "/";
  24. FileName fileName(path);
  25. fileName.addSlash();
  26. FileName fileNameSlash(pathSlash);
  27. fileNameSlash.removeSlash();
  28. CPPUNIT_ASSERT_EQUAL(path, fileNameSlash.str());
  29. CPPUNIT_ASSERT_EQUAL(pathSlash, fileName.str());
  30. }