Factor out TempFile class and reuse it in other tests
Ensure we don't leave "mytext.dat" and "test.txt" lying around in any directory the tests are run from by ensuring that these files are destroyed by the test code using them.
This commit is contained in:
@@ -37,6 +37,8 @@
|
||||
#define fileno _fileno
|
||||
#endif
|
||||
|
||||
#include "testfile.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// The test case
|
||||
|
||||
@@ -100,23 +102,17 @@ void FileKindTestCase::TestFd(wxFile& file, bool expected)
|
||||
CPPUNIT_ASSERT(outStream.IsSeekable() == expected);
|
||||
}
|
||||
|
||||
struct TempFile
|
||||
{
|
||||
~TempFile() { if (!m_name.IsEmpty()) wxRemoveFile(m_name); }
|
||||
wxString m_name;
|
||||
};
|
||||
|
||||
// test with an ordinary file
|
||||
//
|
||||
void FileKindTestCase::File()
|
||||
{
|
||||
TempFile tmp; // put first
|
||||
wxFile file;
|
||||
tmp.m_name = wxFileName::CreateTempFileName(wxT("wxft"), &file);
|
||||
tmp.Assign(wxFileName::CreateTempFileName(wxT("wxft"), &file));
|
||||
TestFd(file, true);
|
||||
file.Close();
|
||||
|
||||
wxFFile ffile(tmp.m_name);
|
||||
wxFFile ffile(tmp.GetName());
|
||||
TestFILE(ffile, true);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user