OpenTTD Source 20250428-master-ga5578166bb
|
Test functionality from string_func. More...
#include "../stdafx.h"
#include "../3rdparty/catch2/catch.hpp"
#include "../string_func.h"
#include "../strings_func.h"
#include "../core/string_builder.hpp"
#include "../table/control_codes.h"
#include "table/strings.h"
#include "../safeguards.h"
Go to the source code of this file.
Functions | |
TEST_CASE ("StrCompareIgnoreCase - std::string") | |
TEST_CASE ("StrCompareIgnoreCase - char pointer") | |
TEST_CASE ("StrCompareIgnoreCase - std::string_view") | |
TEST_CASE ("StrEqualsIgnoreCase - std::string") | |
TEST_CASE ("StrEqualsIgnoreCase - char pointer") | |
TEST_CASE ("StrEqualsIgnoreCase - std::string_view") | |
TEST_CASE ("StrStartsWithIgnoreCase - std::string") | |
TEST_CASE ("StrStartsWithIgnoreCase - char pointer") | |
TEST_CASE ("StrStartsWithIgnoreCase - std::string_view") | |
TEST_CASE ("StrEndsWithIgnoreCase - std::string") | |
TEST_CASE ("StrEndsWithIgnoreCase - char pointer") | |
TEST_CASE ("StrEndsWithIgnoreCase - std::string_view") | |
TEST_CASE ("FormatArrayAsHex") | |
TEST_CASE ("ConvertHexToBytes") | |
TEST_CASE ("StrTrimInPlace") | |
TEST_CASE ("StrTrimView") | |
void | FixSCCEncoded (std::string &str, bool fix_code) |
Scan the string for old values of SCC_ENCODED and fix it to it's new, value. | |
static std::string | FixSCCEncodedWrapper (const std::string &str, bool fix_code) |
static void | ComposePart (StringBuilder &builder, char32_t c) |
static void | ComposePart (StringBuilder &builder, const std::string &value) |
template<typename... Args> | |
static std::string | Compose (Args &&... args) |
TEST_CASE ("FixSCCEncoded") | |
void | FixSCCEncodedNegative (std::string &str) |
Scan the string for SCC_ENCODED_NUMERIC with negative values, and reencode them as uint64_t. | |
static std::string | FixSCCEncodedNegativeWrapper (const std::string &str) |
TEST_CASE ("FixSCCEncodedNegative") | |
TEST_CASE ("EncodedString::ReplaceParam - positive") | |
TEST_CASE ("EncodedString::ReplaceParam - negative") | |
Variables | |
static const std::vector< std::pair< std::string, std::string > > | _str_trim_testcases |
Test functionality from string_func.
Definition in file string_func.cpp.
|
static |
Definition at line 442 of file string_func.cpp.
|
static |
Definition at line 429 of file string_func.cpp.
|
static |
Definition at line 435 of file string_func.cpp.
|
extern |
Scan the string for old values of SCC_ENCODED and fix it to it's new, value.
Note that at the moment this runs, the string has not been validated yet because the validation looks for SCC_ENCODED. If there is something invalid, just bail out and do not continue trying to replace the tokens.
str | the string to fix. |
Definition at line 921 of file saveload.cpp.
References StringConsumer::AnyBytesLeft(), BaseStringBuilder::PutUtf8(), SCC_ENCODED, SCC_ENCODED_NUMERIC, SCC_ENCODED_STRING, and StringConsumer::TryReadUtf8().
Referenced by SlStdString().
|
extern |
Scan the string for SCC_ENCODED_NUMERIC with negative values, and reencode them as uint64_t.
str | the string to fix. |
Definition at line 988 of file saveload.cpp.
References StringConsumer::AnyBytesLeft(), BaseStringBuilder::Put(), BaseStringBuilder::PutIntegerBase(), BaseStringBuilder::PutUtf8(), StringConsumer::READ_ONE_SEPARATOR, StringConsumer::ReadIntegerBase(), StringConsumer::ReadUntilUtf8(), StringConsumer::ReadUtf8If(), SCC_ENCODED, SCC_ENCODED_NUMERIC, and StringConsumer::TryReadIntegerBase().
Referenced by SlStdString().
|
static |
Definition at line 489 of file string_func.cpp.
|
static |
Definition at line 421 of file string_func.cpp.
TEST_CASE | ( | "ConvertHexToBytes" | ) |
Definition at line 353 of file string_func.cpp.
TEST_CASE | ( | "EncodedString::ReplaceParam - negative" | ) |
Definition at line 518 of file string_func.cpp.
TEST_CASE | ( | "EncodedString::ReplaceParam - positive" | ) |
Definition at line 506 of file string_func.cpp.
TEST_CASE | ( | "FixSCCEncoded" | ) |
Definition at line 450 of file string_func.cpp.
TEST_CASE | ( | "FixSCCEncodedNegative" | ) |
Definition at line 496 of file string_func.cpp.
TEST_CASE | ( | "FormatArrayAsHex" | ) |
Definition at line 346 of file string_func.cpp.
TEST_CASE | ( | "StrCompareIgnoreCase - char pointer" | ) |
Definition at line 49 of file string_func.cpp.
TEST_CASE | ( | "StrCompareIgnoreCase - std::string" | ) |
Definition at line 25 of file string_func.cpp.
TEST_CASE | ( | "StrCompareIgnoreCase - std::string_view" | ) |
Definition at line 73 of file string_func.cpp.
TEST_CASE | ( | "StrEndsWithIgnoreCase - char pointer" | ) |
Definition at line 285 of file string_func.cpp.
TEST_CASE | ( | "StrEndsWithIgnoreCase - std::string" | ) |
Definition at line 260 of file string_func.cpp.
TEST_CASE | ( | "StrEndsWithIgnoreCase - std::string_view" | ) |
Definition at line 310 of file string_func.cpp.
TEST_CASE | ( | "StrEqualsIgnoreCase - char pointer" | ) |
Definition at line 125 of file string_func.cpp.
TEST_CASE | ( | "StrEqualsIgnoreCase - std::string" | ) |
Definition at line 107 of file string_func.cpp.
TEST_CASE | ( | "StrEqualsIgnoreCase - std::string_view" | ) |
Definition at line 143 of file string_func.cpp.
TEST_CASE | ( | "StrStartsWithIgnoreCase - char pointer" | ) |
Definition at line 198 of file string_func.cpp.
TEST_CASE | ( | "StrStartsWithIgnoreCase - std::string" | ) |
Definition at line 173 of file string_func.cpp.
TEST_CASE | ( | "StrStartsWithIgnoreCase - std::string_view" | ) |
Definition at line 223 of file string_func.cpp.
TEST_CASE | ( | "StrTrimInPlace" | ) |
Definition at line 404 of file string_func.cpp.
TEST_CASE | ( | "StrTrimView" | ) |
Definition at line 412 of file string_func.cpp.
|
static |
Definition at line 395 of file string_func.cpp.