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:
@@ -41,5 +41,30 @@ private:
|
||||
wxString m_name;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// TempFile: just a self deleting file
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class TempFile
|
||||
{
|
||||
public:
|
||||
explicit TempFile(const wxString& name = wxString()) : m_name(name) { }
|
||||
|
||||
void Assign(const wxString& name) { m_name = name; }
|
||||
|
||||
const wxString& GetName() const { return m_name; }
|
||||
|
||||
~TempFile()
|
||||
{
|
||||
if ( !m_name.empty() )
|
||||
wxRemoveFile(m_name);
|
||||
}
|
||||
|
||||
private:
|
||||
wxString m_name;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(TempFile);
|
||||
};
|
||||
|
||||
#endif // _WX_TESTS_TEMPFILE_H_
|
||||
|
||||
|
Reference in New Issue
Block a user