]> git.saurik.com Git - wxWidgets.git/blob - tests/testfile.h
Update the web sample to use images from the art provider if possible. Scale existing...
[wxWidgets.git] / tests / testfile.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/testfile.h
3 // Purpose: TestFile class
4 // Author: Mike Wetherell
5 // RCS-ID: $Id$
6 // Copyright: (c) 2005 Mike Wetherell
7 // Licence: wxWindows licence
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
16 #include <ostream>
17
18 // define stream inserter for wxFileName to use it in CPPUNIT_ASSERT_EQUAL()
19 inline std::ostream& operator<<(std::ostream& o, const wxFileName& fn)
20 {
21 return o << fn.GetFullPath();
22 }
23
24 // ----------------------------------------------------------------------------
25 // TestFile: self deleting test file in temporary directory
26 // ----------------------------------------------------------------------------
27
28 class TestFile
29 {
30 public:
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
41 private:
42 wxString m_name;
43 };
44
45 #endif // _WX_TESTS_TEMPFILE_H_
46