Re-enable wxAny<double>::GetAs<wxString>() test.
[wxWidgets.git] / tests / testimage.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/testimage.h
3 // Purpose: Unit test helpers for dealing with wxImage.
4 // Author: Vadim Zeitlin
5 // RCS-ID: $Id$
6 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_TESTS_TESTIMAGE_H_
11 #define _WX_TESTS_TESTIMAGE_H_
12
13 #include "wx/image.h"
14
15 CPPUNIT_NS_BEGIN
16
17 template <>
18 struct assertion_traits<wxImage>
19 {
20 static bool equal(const wxImage& i1, const wxImage& i2)
21 {
22 if ( i1.GetWidth() != i2.GetWidth() )
23 return false;
24
25 if ( i1.GetHeight() != i2.GetHeight() )
26 return false;
27
28 return memcmp(i1.GetData(), i2.GetData(),
29 i1.GetWidth()*i1.GetHeight()*3) == 0;
30 }
31
32 static std::string toString(const wxImage& image)
33 {
34 return wxString::Format("image of size %d*%d with%s alpha",
35 image.GetWidth(),
36 image.GetHeight(),
37 image.HasAlpha() ? "" : "out")
38 .ToStdString();
39 }
40 };
41
42 CPPUNIT_NS_END
43
44 #endif // _WX_TESTS_TESTIMAGE_H_