Browse Source

Add more tests for `Text.AppendFormatted()` method

pull/8/head
Anton Tarasenko 3 years ago
parent
commit
1486c937d6
  1. 15
      sources/Text/Tests/TEST_Text.uc

15
sources/Text/Tests/TEST_Text.uc

@ -549,7 +549,7 @@ protected static function Test_AppendGet()
protected static function Test_AppendStringGet() protected static function Test_AppendStringGet()
{ {
local Color testColor; local Color testColor;
local string defaultTag, colorTag, greenTag; local string defaultTag, colorTag, greenTag, limeTag;
local MutableText txt; local MutableText txt;
Context("Testing functionality of `MutableText` to append strings."); Context("Testing functionality of `MutableText` to append strings.");
txt = MutableText(__().memory.Allocate(class'MutableText')); txt = MutableText(__().memory.Allocate(class'MutableText'));
@ -562,18 +562,21 @@ protected static function Test_AppendStringGet()
defaultTag = __().color.GetColorTagRGB(1, 1, 1); defaultTag = __().color.GetColorTagRGB(1, 1, 1);
colorTag = __().color.GetColorTag(testColor); colorTag = __().color.GetColorTag(testColor);
greenTag = __().color.GetColorTagRGB(0, 255, 0); greenTag = __().color.GetColorTagRGB(0, 255, 0);
limeTag = __().color.GetColorTagRGB(50, 205, 50);
txt.AppendString("Prepare to "); txt.AppendString("Prepare to ");
txt.AppendColoredString(colorTag $ "DIE"); txt.AppendColoredString(colorTag $ "DIE");
txt.AppendFormattedString(" and be {#00ff00 reborn}!"); txt.AppendFormattedString(" ^gand {$LimeGreen be }");
txt.AppendFormatted(P("r{#00ff00 eborn}!"));
TEST_ExpectTrue( txt.ToString() TEST_ExpectTrue( txt.ToString()
== "Prepare to DIE and be reborn!"); == "Prepare to DIE and be reborn!");
TEST_ExpectTrue( txt.ToColoredString() TEST_ExpectTrue( txt.ToColoredString()
== ( defaultTag $ "Prepare to " $ colorTag $ "DIE" == ( defaultTag $ "Prepare to " $ colorTag $ "DIE"
$ defaultTag $ " and be " $ greenTag $ "reborn" $ defaultTag $ " " $ greenTag $ "and "
$ defaultTag $ "!")); $ limeTag $ "be " $ defaultTag $ "r"
$ greenTag $ "eborn" $ defaultTag $ "!"));
TEST_ExpectTrue( txt.ToFormattedString() TEST_ExpectTrue( txt.ToFormattedString()
== ("Prepare to {rgb(198,23,7) DIE} and" == ("Prepare to {rgb(198,23,7) DIE} {rgb(0,255,0) and }"
@ "be {rgb(0,255,0) reborn}!")); $ "{rgb(50,205,50) be }r{rgb(0,255,0) eborn}!"));
} }
protected static function Test_SeparateByCharacter() protected static function Test_SeparateByCharacter()

Loading…
Cancel
Save