]> git.saurik.com Git - wxWidgets.git/blob - tests/testimage.h
Fixed capitalisation
[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 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
6 // Licence: wxWindows licence
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #ifndef _WX_TESTS_TESTIMAGE_H_
10 #define _WX_TESTS_TESTIMAGE_H_
11
12 #include "wx/image.h"
13
14 CPPUNIT_NS_BEGIN
15
16 template <>
17 struct assertion_traits<wxImage>
18 {
19 static bool equal(const wxImage& i1, const wxImage& i2)
20 {
21 if ( i1.GetWidth() != i2.GetWidth() )
22 return false;
23
24 if ( i1.GetHeight() != i2.GetHeight() )
25 return false;
26
27 return memcmp(i1.GetData(), i2.GetData(),
28 i1.GetWidth()*i1.GetHeight()*3) == 0;
29 }
30
31 static std::string toString(const wxImage& image)
32 {
33 return wxString::Format("image of size %d*%d with%s alpha",
34 image.GetWidth(),
35 image.GetHeight(),
36 image.HasAlpha() ? "" : "out")
37 .ToStdString();
38 }
39 };
40
41 CPPUNIT_NS_END
42
43 #endif // _WX_TESTS_TESTIMAGE_H_