text
stringlengths
0
2.2M
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_append_range)
{
// Non-overflow.
Compare_Text compare_text(short_text.c_str());
TextBuffer buffer;
Text text(short_text.c_str(), buffer.data(), buffer.size());
TextBuffer buffer2;
Text append(insert_text.c_str(), buffer2.data(), buffer2.size());
compare_text.append(insert_text.begin(), insert_text.end());
text.append(append.begin(), append.end());
bool is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
// Overflow.
compare_text.assign(short_text.c_str());
text.assign(short_text.c_str());
append.assign(initial_text.c_str());
compare_text.append(initial_text.begin(), initial_text.end());
compare_text.resize(std::min(compare_text.size(), SIZE));
text.append(append.begin(), append.end());
is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_replace_position_length_string)
{
// Non-overflow short text, npos.
Compare_Text compare_text(short_text.c_str());
TextBuffer buffer;
Text text(short_text.c_str(), buffer.data(), buffer.size());
compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace")));
compare_text.resize(std::min(compare_text.size(), SIZE));
text.replace(2, Text::npos, TextT(STR("Replace")));
bool is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
// Non-overflow short text.
compare_text.assign(short_text.c_str());
text.assign(short_text.c_str());
compare_text.replace(2, 2, Compare_Text(STR("Replace")));
compare_text.resize(std::min(compare_text.size(), SIZE));
text.replace(2, 2, TextT(STR("Replace")));
is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
// Overflow short text.
compare_text.assign(short_text.c_str());
text.assign(short_text.c_str());
compare_text.replace(2, 2, Compare_Text(STR("Replace with some text")));
compare_text.resize(std::min(compare_text.size(), SIZE));
text.replace(2, 2, TextT(STR("Replace with some text")));
is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(text.is_truncated());
#endif
// Overflow short text, npos.
compare_text.assign(short_text.c_str());
text.assign(short_text.c_str());
compare_text.replace(2, Compare_Text::npos, Compare_Text(STR("Replace with some text")));
compare_text.resize(std::min(compare_text.size(), SIZE));
text.replace(2, Text::npos, TextT(STR("Replace with some text")));
is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED