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:
Richard
2026-08-13 21:42:14 -06:00
parent 77c4110762
commit 035b8ad99f
5 changed files with 11 additions and 6 deletions
+1 -1
View File
@@ -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()));
}
+3 -3
View File
@@ -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));
+1 -1
View File
@@ -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());
+1 -1
View File
@@ -262,7 +262,7 @@ public:
TranslationsTestCatalogs()
: m_prefix("wxintltest-")
{
REQUIRE(!m_prefix.GetName().empty());
REQUIRE(m_prefix.IsOk());
CopyCatalog("en_GB");
CopyCatalog("fr");
+5
View File
@@ -90,6 +90,11 @@ public:
~TempDir() { Remove(); }
bool IsOk() const
{
return !m_name.empty();
}
const wxString& GetName() const { return m_name; }
bool Remove()