mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-18 17:50:36 +08:00
tests: Add TempDir::IsOk()
Add a small helper for checking whether TempDir was created successfully and use it instead of checking the temporary directory name directly.
This commit is contained in:
@@ -302,7 +302,7 @@ private:
|
||||
ArchiveTempDir::ArchiveTempDir()
|
||||
: m_tmp(wxT("arctest-"))
|
||||
{
|
||||
CPPUNIT_ASSERT(!m_tmp.GetName().empty());
|
||||
CPPUNIT_ASSERT(m_tmp.IsOk());
|
||||
m_original = wxGetCwd();
|
||||
CPPUNIT_ASSERT(wxSetWorkingDirectory(m_tmp.GetName()));
|
||||
}
|
||||
|
||||
@@ -747,7 +747,7 @@ TEST_CASE("wxFileName::Exists", "[filename]")
|
||||
#endif // __LINUX__
|
||||
#ifndef __VMS
|
||||
TempDir socktempdir("socktmpdir");
|
||||
REQUIRE(!socktempdir.GetName().empty());
|
||||
REQUIRE(socktempdir.IsOk());
|
||||
wxFileName sockfilename(socktempdir.GetName(), "socket");
|
||||
wxString sockfile = sockfilename.GetFullPath();
|
||||
wxTCPServer server;
|
||||
@@ -791,7 +791,7 @@ TEST_CASE("wxFileName::SameAs", "[filename]")
|
||||
|
||||
#if defined(__UNIX__)
|
||||
TempDir tempdir("wxfn");
|
||||
REQUIRE(!tempdir.GetName().empty());
|
||||
REQUIRE(tempdir.IsOk());
|
||||
|
||||
wxFileName tempdir1fn;
|
||||
tempdir1fn.AssignDir(tempdir.GetName());
|
||||
@@ -826,7 +826,7 @@ TEST_CASE("wxFileName::SameAs", "[filename]")
|
||||
TEST_CASE("wxFileName::Symlinks", "[filename]")
|
||||
{
|
||||
TempDir tempdirRoot("filenametest");
|
||||
REQUIRE(!tempdirRoot.GetName().empty());
|
||||
REQUIRE(tempdirRoot.IsOk());
|
||||
|
||||
const wxString tmpdir(wxFileName::GetTempDir());
|
||||
wxFileName tmpfn(wxFileName::DirName(tmpdir));
|
||||
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
return ms_watchDir;
|
||||
|
||||
ms_watchDirData.reset(new TempDir("fswatcher_test"));
|
||||
REQUIRE(!ms_watchDirData->GetName().empty());
|
||||
REQUIRE(ms_watchDirData->IsOk());
|
||||
|
||||
TestLogEnabler enableLogs;
|
||||
ms_watchDir.AssignDir(ms_watchDirData->GetName());
|
||||
|
||||
@@ -262,7 +262,7 @@ public:
|
||||
TranslationsTestCatalogs()
|
||||
: m_prefix("wxintltest-")
|
||||
{
|
||||
REQUIRE(!m_prefix.GetName().empty());
|
||||
REQUIRE(m_prefix.IsOk());
|
||||
|
||||
CopyCatalog("en_GB");
|
||||
CopyCatalog("fr");
|
||||
|
||||
@@ -90,6 +90,11 @@ public:
|
||||
|
||||
~TempDir() { Remove(); }
|
||||
|
||||
bool IsOk() const
|
||||
{
|
||||
return !m_name.empty();
|
||||
}
|
||||
|
||||
const wxString& GetName() const { return m_name; }
|
||||
|
||||
bool Remove()
|
||||
|
||||
Reference in New Issue
Block a user