Browse Source

Add tests for TextTemplate's ignoreFormatting flag

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
88292cb89e
  1. 40
      sources/Text/Tests/TEST_TextTemplate.uc

40
sources/Text/Tests/TEST_TextTemplate.uc

@ -31,12 +31,14 @@ protected static function TESTS()
Test_NumericDeclarationsOrder(); Test_NumericDeclarationsOrder();
Test_NumericDeclarationsNoOrder(); Test_NumericDeclarationsNoOrder();
Test_NumericDeclarationsRandomValues(); Test_NumericDeclarationsRandomValues();
Test_NumericDeclarationsIgnoreFormatting();
Context("Testing `TextTemplate` class' ability to handle text" Context("Testing `TextTemplate` class' ability to handle text"
@ "argument declarations."); @ "argument declarations.");
Test_TextDeclarationsGet(); Test_TextDeclarationsGet();
Test_TextDeclarationsEmptyCollect(); Test_TextDeclarationsEmptyCollect();
Test_TextDeclarationsCollect(); Test_TextDeclarationsCollect();
Test_TextDeclarationsOverwriteCollect(); Test_TextDeclarationsOverwriteCollect();
Test_TextDeclarationsIgnoreFormatting();
Context("Testing complex `TextTemplate` scenarios."); Context("Testing complex `TextTemplate` scenarios.");
Test_Reset(); Test_Reset();
Test_Complex(); Test_Complex();
@ -187,6 +189,25 @@ protected static function Test_NumericDeclarationsRandomValues()
== "just a c e b d h f g"); == "just a c e b d h f g");
} }
protected static function Test_NumericDeclarationsIgnoreFormatting()
{
local TextTemplate instance;
Issue("Basic numeric declarations are not using arguments formatting by"
@ "default.");
instance = __().text.MakeTemplate_S("Simple {#ff0000 test %1}");
instance.Arg(F("{#00ff00 arg}"));
TEST_ExpectTrue(instance.CollectFormatted().ToFormattedString()
== "Simple {rgb(255,0,0) test }{rgb(0,255,0) arg}");
Issue("Basic numeric declarations are using arguments formatting when"
@ "method is told to ignore it.");
instance = __().text.MakeTemplate_S("Simple {#ff0000 test %1}");
instance.Arg(F("{#00ff00 arg}"), true);
TEST_ExpectTrue(instance.CollectFormatted().ToFormattedString()
== "Simple {rgb(255,0,0) test arg}");
}
protected static function Test_TextDeclarationsGet() protected static function Test_TextDeclarationsGet()
{ {
local TextTemplate instance; local TextTemplate instance;
@ -285,6 +306,25 @@ protected static function Test_TextDeclarationsOverwriteCollect()
== "More nasty !! here, yes. Very nasty!"); == "More nasty !! here, yes. Very nasty!");
} }
protected static function Test_TextDeclarationsIgnoreFormatting()
{
local TextTemplate instance;
Issue("Basic numeric declarations are not using arguments formatting by"
@ "default.");
instance = __().text.MakeTemplate_S("Simple {#ff0000 test %%it%%}");
instance.TextArg(P("it"), F("{#00ff00 arg}"));
TEST_ExpectTrue(instance.CollectFormatted().ToFormattedString()
== "Simple {rgb(255,0,0) test }{rgb(0,255,0) arg}");
Issue("Basic numeric declarations are using arguments formatting when"
@ "method is told to ignore it.");
instance = __().text.MakeTemplate_S("Simple {#ff0000 test %%it%%}");
instance.TextArg(P("it"), F("{#00ff00 arg}"), true);
TEST_ExpectTrue(instance.CollectFormatted().ToFormattedString()
== "Simple {rgb(255,0,0) test arg}");
}
protected static function Test_Reset() protected static function Test_Reset()
{ {
local TextTemplate instance; local TextTemplate instance;

Loading…
Cancel
Save