aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/platforms/posix/posixFile.cpp6
-rw-r--r--tests/net/maildir/maildirStoreTest.cpp20
-rw-r--r--tests/testUtils.cpp58
-rw-r--r--tests/testUtils.hpp4
4 files changed, 85 insertions, 3 deletions
diff --git a/src/platforms/posix/posixFile.cpp b/src/platforms/posix/posixFile.cpp
index 7ee9f197..b814b758 100644
--- a/src/platforms/posix/posixFile.cpp
+++ b/src/platforms/posix/posixFile.cpp
@@ -396,7 +396,11 @@ void posixFile::rename(const path& newName)
const vmime::string newNativePath = posixFileSystemFactory::pathToStringImpl(newName);
posixFile dest(newName);
- dest.createFile();
+
+ if (isDirectory())
+ dest.createDirectory();
+ else
+ dest.createFile();
if (::rename(m_nativePath.c_str(), newNativePath.c_str()) == -1)
posixFileSystemFactory::reportError(m_path, errno);
diff --git a/tests/net/maildir/maildirStoreTest.cpp b/tests/net/maildir/maildirStoreTest.cpp
index 5aad90b1..5f8c7033 100644
--- a/tests/net/maildir/maildirStoreTest.cpp
+++ b/tests/net/maildir/maildirStoreTest.cpp
@@ -322,12 +322,28 @@ public:
void testRenameFolder_KMail()
{
- testRenameFolderImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);
+ try
+ {
+ testRenameFolderImpl(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);
+ }
+ catch (vmime::exception& e)
+ {
+ std::cerr << e;
+ throw e;
+ }
}
void testRenameFolder_Courier()
{
- testRenameFolderImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);
+ try
+ {
+ testRenameFolderImpl(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);
+ }
+ catch (vmime::exception& e)
+ {
+ std::cerr << e;
+ throw e;
+ }
}
void testRenameFolderImpl(const vmime::string* const dirs, const vmime::string* const files)
diff --git a/tests/testUtils.cpp b/tests/testUtils.cpp
index ee17c923..36455cff 100644
--- a/tests/testUtils.cpp
+++ b/tests/testUtils.cpp
@@ -187,3 +187,61 @@ vmime::ref <vmime::net::timeoutHandler> testTimeoutHandlerFactory::create()
return vmime::create <testTimeoutHandler>();
}
+
+
+// Exception helper
+std::ostream& operator<<(std::ostream& os, const vmime::exception& e)
+{
+ os << "* vmime::exceptions::" << e.name() << std::endl;
+ os << " what = " << e.what() << std::endl;
+
+ // More information for special exceptions
+ if (dynamic_cast <const vmime::exceptions::command_error*>(&e))
+ {
+ const vmime::exceptions::command_error& cee =
+ dynamic_cast <const vmime::exceptions::command_error&>(e);
+
+ os << " command = " << cee.command() << std::endl;
+ os << " response = " << cee.response() << std::endl;
+ }
+
+ if (dynamic_cast <const vmime::exceptions::invalid_response*>(&e))
+ {
+ const vmime::exceptions::invalid_response& ir =
+ dynamic_cast <const vmime::exceptions::invalid_response&>(e);
+
+ os << " response = " << ir.response() << std::endl;
+ }
+
+ if (dynamic_cast <const vmime::exceptions::connection_greeting_error*>(&e))
+ {
+ const vmime::exceptions::connection_greeting_error& cgee =
+ dynamic_cast <const vmime::exceptions::connection_greeting_error&>(e);
+
+ os << " response = " << cgee.response() << std::endl;
+ }
+
+ if (dynamic_cast <const vmime::exceptions::authentication_error*>(&e))
+ {
+ const vmime::exceptions::authentication_error& aee =
+ dynamic_cast <const vmime::exceptions::authentication_error&>(e);
+
+ os << " response = " << aee.response() << std::endl;
+ }
+
+ if (dynamic_cast <const vmime::exceptions::filesystem_exception*>(&e))
+ {
+ const vmime::exceptions::filesystem_exception& fse =
+ dynamic_cast <const vmime::exceptions::filesystem_exception&>(e);
+
+ os << " path = " << vmime::platform::getHandler()->
+ getFileSystemFactory()->pathToString(fse.path()) << std::endl;
+ }
+
+ if (e.other() != NULL)
+ os << *e.other();
+
+ return os;
+}
+
+
diff --git a/tests/testUtils.hpp b/tests/testUtils.hpp
index 227d1b36..9aee153c 100644
--- a/tests/testUtils.hpp
+++ b/tests/testUtils.hpp
@@ -305,3 +305,7 @@ public:
vmime::ref <vmime::net::timeoutHandler> create();
};
+
+// Exception helper
+std::ostream& operator<<(std::ostream& os, const vmime::exception& e);
+