Return empty string from wxColour::GetAsString() if it's invalid
This is consistent with wxToString(wxColour) and seems more useful than either returning black string representation (as wxMSW used to do) or asserting (as wxGTK did). Document this behaviour and add a test checking for it. Closes #18623.
This commit is contained in:
@@ -145,6 +145,16 @@ TEST_CASE("wxColour::FromString", "[colour][string]")
|
||||
CHECK( !wxFromString("rgba(1, 2, 3.456, foo)", &col) );
|
||||
}
|
||||
|
||||
TEST_CASE("wxColour::GetAsString", "[colour][string]")
|
||||
{
|
||||
CHECK( wxColour().GetAsString() == "" );
|
||||
|
||||
wxColour red("red");
|
||||
CHECK( red.GetAsString() == "red" );
|
||||
CHECK( red.GetAsString(wxC2S_CSS_SYNTAX) == "rgb(255, 0, 0)" );
|
||||
CHECK( red.GetAsString(wxC2S_HTML_SYNTAX) == "#FF0000" );
|
||||
}
|
||||
|
||||
TEST_CASE("wxColour::GetLuminance", "[colour][luminance]")
|
||||
{
|
||||
CHECK( wxBLACK->GetLuminance() == Approx(0.0) );
|
||||
|
Reference in New Issue
Block a user