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