1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-19 20:49:11 +00:00

Codechange: Use EncodedStrings for News messages. (#13654)

This commit is contained in:
2025-02-23 20:24:02 +00:00
committed by GitHub
parent 0afae7c546
commit 6e10584b91
30 changed files with 304 additions and 293 deletions

View File

@@ -12,8 +12,11 @@
#include "../3rdparty/catch2/catch.hpp"
#include "../string_func.h"
#include "../strings_func.h"
#include "../table/control_codes.h"
#include "table/strings.h"
/**** String compare/equals *****/
TEST_CASE("StrCompareIgnoreCase - std::string")
@@ -473,3 +476,15 @@ TEST_CASE("FixSCCEncoded")
/* Test conversion with one sub-string and two string parameters. */
CHECK(FixSCCEncodedWrapper("\uE000777:\uE0008888:\"Foo\":\"BarBaz\"", false) == Compose(SCC_ENCODED, "777", SCC_RECORD_SEPARATOR, SCC_ENCODED, "8888", SCC_RECORD_SEPARATOR, SCC_ENCODED_STRING, "Foo", SCC_RECORD_SEPARATOR, SCC_ENCODED_STRING, "BarBaz"));
}
TEST_CASE("EncodedString::ReplaceParam")
{
/* Test that two encoded strings with different parameters are not the same. */
EncodedString string1 = GetEncodedString(STR_NULL, "Foo", 10, "Bar");
EncodedString string2 = GetEncodedString(STR_NULL, "Foo", 15, "Bar");
CHECK(string1 != string2);
/* Test that replacing parameter results in the same string. */
EncodedString string3 = string1.ReplaceParam(1, 15);
CHECK(string2 == string3);
}