From 2bfe1fc2bc355f455c018a575b97452f5ac8a729 Mon Sep 17 00:00:00 2001
From: Adam Moss <moss@lindenlab.com>
Date: Thu, 8 Oct 2009 12:00:24 +0000
Subject: [PATCH] Extend automated string tests to cover the formerly-crashing
 "[]" substitution case (EXT-1282, DEV-41081)

Also 'fix' string tests to match the new expected behaviour of LLStringUtil::format().  They must have been failing dreadfully before, but the legacy tut tests aren't run in a viewer-only build, so...
---
 indra/llcommon/tests/llstring_test.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/indra/llcommon/tests/llstring_test.cpp b/indra/llcommon/tests/llstring_test.cpp
index 13894efad0c..1f4603631a2 100644
--- a/indra/llcommon/tests/llstring_test.cpp
+++ b/indra/llcommon/tests/llstring_test.cpp
@@ -554,6 +554,7 @@ namespace tut
 		fmt_map["[KEYSHORTER]"] = "Am I not a long string?";
 		fmt_map["?"] = "?";
 		fmt_map["[DELETE]"] = "";
+		fmt_map["[]"] = "[]"; // doesn't do a substitution, but shouldn't crash either
 
 		for (LLStringUtil::format_map_t::const_iterator iter = fmt_map.begin(); iter != fmt_map.end(); ++iter)
 		{
@@ -562,7 +563,7 @@ namespace tut
 			std::string s2 = (std::string)iter->second;
 			subcount = LLStringUtil::format(s1, fmt_map);
 			ensure_equals("LLStringUtil::format: Raw interpolation result", s1, s2);
-			if (s1 == "?")
+			if (s1 == "?" || s1 == "[]") // no interp expected
 			{
 				ensure_equals("LLStringUtil::format: Raw interpolation result count", 0, subcount);
 			}
@@ -580,7 +581,7 @@ namespace tut
 			s = s1 + s1 + s1 + s1;
 			subcount = LLStringUtil::format(s, fmt_map);
 			ensure_equals("LLStringUtil::format: Rawx4 interpolation result", s, s2 + s2 + s2 + s2);
-			if (s1 == "?")
+			if (s1 == "?" || s1 == "[]") // no interp expected
 			{
 				ensure_equals("LLStringUtil::format: Rawx4 interpolation result count", 0, subcount);
 			}
-- 
GitLab