]> git.saurik.com Git - wxWidgets.git/blame - tests/testimage.h
Remove duplicate wxFileKind definition from documentation.
[wxWidgets.git] / tests / testimage.h
CommitLineData
a25b5bbf
VZ
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
15CPPUNIT_NS_BEGIN
16
17template <>
18struct 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 {
ab176b4b 34 return wxString::Format("image of size %d*%d with%s alpha",
a25b5bbf 35 image.GetWidth(),
ab176b4b
DS
36 image.GetHeight(),
37 image.HasAlpha() ? "" : "out")
a25b5bbf
VZ
38 .ToStdString();
39 }
40};
41
42CPPUNIT_NS_END
43
44#endif // _WX_TESTS_TESTIMAGE_H_