text
stringlengths
0
2.2M
// 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);
compare_text.resize(std::min(compare_text.size(), SIZE));
text.append(append);
is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_append_truncated_string)
{
TextBuffer buffer;
Text text(short_text.c_str(), buffer.data(), buffer.size());
TextBufferS buffers;
Text append(short_text.c_str(), buffers.data(), buffers.size());
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(append.is_truncated());
#endif
text.append(append);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_append_string_to_self)
{
Compare_Text compare_text(short_text.c_str());
TextBuffer buffer;
Text text(short_text.c_str(), buffer.data(), buffer.size());
// Non-overflow.
compare_text.append(compare_text);
text.append(text);
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(shorter_text.c_str());
text.assign(shorter_text.c_str());
compare_text.append(compare_text);
compare_text.resize(std::min(compare_text.size(), SIZE));
text.append(text);
is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen)
{
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());
// Whole string.
compare_text.append(insert_text, 0, std::u16string::npos);
text.append(append, 0, Text::npos);
bool is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
// Partial string.
compare_text.assign(short_text.c_str());
text.assign(short_text.c_str());
append.assign(initial_text.c_str());
compare_text.append(short_text, 1, 3);
compare_text.resize(std::min(compare_text.size(), SIZE));
text.append(append, 1, 3);
is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED