testimage.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #ifndef _WX_TESTS_TESTIMAGE_H_
  9. #define _WX_TESTS_TESTIMAGE_H_
  10. #include "wx/image.h"
  11. CPPUNIT_NS_BEGIN
  12. template <>
  13. struct assertion_traits<wxImage>
  14. {
  15. static bool equal(const wxImage& i1, const wxImage& i2)
  16. {
  17. if ( i1.GetWidth() != i2.GetWidth() )
  18. return false;
  19. if ( i1.GetHeight() != i2.GetHeight() )
  20. return false;
  21. return memcmp(i1.GetData(), i2.GetData(),
  22. i1.GetWidth()*i1.GetHeight()*3) == 0;
  23. }
  24. static std::string toString(const wxImage& image)
  25. {
  26. return wxString::Format("image of size %d*%d with%s alpha",
  27. image.GetWidth(),
  28. image.GetHeight(),
  29. image.HasAlpha() ? "" : "out")
  30. .ToStdString();
  31. }
  32. };
  33. CPPUNIT_NS_END
  34. #endif // _WX_TESTS_TESTIMAGE_H_