mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-03-24 11:24:08 +08:00
Simplify showing colour values in failing unit tests
Use wxColour::GetAsString() instead of reimplementing it in the test.
This commit is contained in:
@@ -11,35 +11,9 @@
|
||||
|
||||
#include "asserthelper.h"
|
||||
|
||||
namespace wxTestPrivate
|
||||
{
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const ColourChannel& cc)
|
||||
{
|
||||
os.width(2);
|
||||
os.fill('0');
|
||||
os << static_cast<int>(cc.m_value);
|
||||
return os;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const wxColour& c)
|
||||
{
|
||||
using wxTestPrivate::ColourChannel;
|
||||
|
||||
os << std::hex << std::noshowbase
|
||||
<< "("
|
||||
<< ColourChannel(c.Red()) << ", "
|
||||
<< ColourChannel(c.Green()) << ", "
|
||||
<< ColourChannel(c.Blue());
|
||||
|
||||
if ( const unsigned char a = c.Alpha() )
|
||||
{
|
||||
os << ", " << ColourChannel(a);
|
||||
}
|
||||
|
||||
os << ")";
|
||||
os << c.GetAsString(wxC2S_HTML_SYNTAX);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -14,21 +14,6 @@
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/font.h"
|
||||
|
||||
namespace wxTestPrivate
|
||||
{
|
||||
// by default colour components values are output incorrectly because they
|
||||
// are unsigned chars, define a small helper struct which formats them in
|
||||
// a more useful way
|
||||
struct ColourChannel
|
||||
{
|
||||
ColourChannel(unsigned char value) : m_value(value) { }
|
||||
|
||||
unsigned char m_value;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const ColourChannel& cc);
|
||||
} // wxTestPrivate namespace
|
||||
|
||||
// Operators used to show the values of the corresponding types when comparing
|
||||
// them in the unit tests fails.
|
||||
std::ostream& operator<<(std::ostream& os, const wxColour& c);
|
||||
|
||||
Reference in New Issue
Block a user