Browse Source

Rename `ColorAPI.ParseText()` into `.Parse()`

pull/8/head
Anton Tarasenko 4 years ago
parent
commit
00c01bd7ca
  1. 2
      sources/Color/ColorAPI.uc
  2. 24
      sources/Color/Tests/TEST_ColorAPI.uc

2
sources/Color/ColorAPI.uc

@ -629,7 +629,7 @@ public final function bool ParseString(
* If parsed color did not specify alpha component - 255 will be used. * If parsed color did not specify alpha component - 255 will be used.
* @return `true` if parsing was successful and false otherwise. * @return `true` if parsing was successful and false otherwise.
*/ */
public final function bool ParseText( public final function bool Parse(
Text textWithColor, Text textWithColor,
out Color resultingColor) out Color resultingColor)
{ {

24
sources/Color/Tests/TEST_ColorAPI.uc

@ -431,36 +431,36 @@ protected static function SubTest_ParseText()
{ {
local Color expectedColor, resultColor; local Color expectedColor, resultColor;
expectedColor = _().color.RGBA(154, 255, 0, 187); expectedColor = _().color.RGBA(154, 255, 0, 187);
Issue("`ParseText()` cannot parse hex colors."); Issue("`Parse()` cannot parse hex colors.");
TEST_ExpectTrue(_().color.ParseText(_().text.FromString("#9aff00"), TEST_ExpectTrue(_().color.Parse(_().text.FromString("#9aff00"),
resultColor)); resultColor));
TEST_ExpectTrue(_().color.AreEqual(resultColor, expectedColor)); TEST_ExpectTrue(_().color.AreEqual(resultColor, expectedColor));
Issue("`ParseText()` cannot parse rgb colors."); Issue("`Parse()` cannot parse rgb colors.");
TEST_ExpectTrue(_().color.ParseText(_().text.FromString("rgb(154,255,0)"), TEST_ExpectTrue(_().color.Parse(_().text.FromString("rgb(154,255,0)"),
resultColor)); resultColor));
TEST_ExpectTrue(_().color.AreEqual(resultColor, expectedColor)); TEST_ExpectTrue(_().color.AreEqual(resultColor, expectedColor));
Issue("`ParseText()` cannot parse rgba colors."); Issue("`Parse()` cannot parse rgba colors.");
TEST_ExpectTrue(_().color.ParseText( TEST_ExpectTrue(_().color.Parse(
_().text.FromString("rgba(154,255,0,187)"), _().text.FromString("rgba(154,255,0,187)"),
resultColor)); resultColor));
TEST_ExpectTrue(_().color.AreEqualWithAlpha(resultColor, expectedColor)); TEST_ExpectTrue(_().color.AreEqualWithAlpha(resultColor, expectedColor));
Issue("`ParseText()` cannot parse rgb colors with tags."); Issue("`Parse()` cannot parse rgb colors with tags.");
TEST_ExpectTrue(_().color.ParseText( TEST_ExpectTrue(_().color.Parse(
_().text.FromString("rgb(r=154,g=255,b=0)"), _().text.FromString("rgb(r=154,g=255,b=0)"),
resultColor)); resultColor));
TEST_ExpectTrue(_().color.AreEqual(resultColor, expectedColor)); TEST_ExpectTrue(_().color.AreEqual(resultColor, expectedColor));
Issue("`ParseText()` cannot parse rgba colors with tags."); Issue("`Parse()` cannot parse rgba colors with tags.");
TEST_ExpectTrue(_().color.ParseText( TEST_ExpectTrue(_().color.Parse(
_().text.FromString("rgba(r=154,g=255,b=0,a=187)"), _().text.FromString("rgba(r=154,g=255,b=0,a=187)"),
resultColor)); resultColor));
TEST_ExpectTrue(_().color.AreEqualWithAlpha(resultColor, expectedColor)); TEST_ExpectTrue(_().color.AreEqualWithAlpha(resultColor, expectedColor));
Issue("`ParseText()` reports success when parsing invalid color string."); Issue("`Parse()` reports success when parsing invalid color string.");
TEST_ExpectFalse(_().color.ParseText( _().text.FromString("#9aff0g"), TEST_ExpectFalse(_().color.Parse( _().text.FromString("#9aff0g"),
resultColor)); resultColor));
} }

Loading…
Cancel
Save