]> git.saurik.com Git - wxWidgets.git/blame - tests/testfile.h
Convert wxFSW_EVENT_{WARNING,ERROR} to string correctly.
[wxWidgets.git] / tests / testfile.h
CommitLineData
caa96da7
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/testfile.h
3// Purpose: TestFile class
4// Author: Mike Wetherell
5// RCS-ID: $Id$
6// Copyright: (c) 2005 Mike Wetherell
526954c5 7// Licence: wxWindows licence
caa96da7
VZ
8///////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_TESTS_TEMPFILE_H_
11#define _WX_TESTS_TEMPFILE_H_
12
13#include "wx/filefn.h"
14#include "wx/filename.h"
15
40152925
VZ
16#include <ostream>
17
18// define stream inserter for wxFileName to use it in CPPUNIT_ASSERT_EQUAL()
19inline std::ostream& operator<<(std::ostream& o, const wxFileName& fn)
20{
21 return o << fn.GetFullPath();
22}
23
caa96da7
VZ
24// ----------------------------------------------------------------------------
25// TestFile: self deleting test file in temporary directory
26// ----------------------------------------------------------------------------
27
28class TestFile
29{
30public:
31 TestFile()
32 {
33 wxFile file;
34 m_name = wxFileName::CreateTempFileName(wxT("wxtest"), &file);
35 file.Write("Before", 6);
36 }
37
38 ~TestFile() { if (wxFileExists(m_name)) wxRemoveFile(m_name); }
39 wxString GetName() const { return m_name; }
40
41private:
42 wxString m_name;
43};
44
45#endif // _WX_TESTS_TEMPFILE_H_
46