text stringlengths 0 2.2M |
|---|
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, 1, initial_text.size());
|
compare_text.resize(std::min(compare_text.size(), SIZE));
|
text.append(append, 1, append.size());
|
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_subpos_sublen)
|
{
|
TextBuffer buffer;
|
Text text(short_text.c_str(), buffer.data(), buffer.size());
|
TextBufferS buffer2;
|
Text append(short_text.c_str(), buffer2.data(), buffer2.size());
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(append.is_truncated());
|
#endif
|
text.append(append, 1, 2);
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(text.is_truncated());
|
#endif
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_append_c_string)
|
{
|
// Non-overflow.
|
Compare_Text compare_text(short_text.c_str());
|
TextBuffer buffer;
|
Text text(short_text.c_str(), buffer.data(), buffer.size());
|
// Whole string.
|
compare_text.append(insert_text.c_str());
|
text.append(insert_text.c_str());
|
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());
|
compare_text.append(initial_text.c_str());
|
compare_text.resize(std::min(compare_text.size(), SIZE));
|
text.append(initial_text.c_str());
|
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_n_c)
|
{
|
// Non-overflow.
|
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(5, STR('A'));
|
text.append(5, STR('A'));
|
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());
|
compare_text.append(SIZE, STR('A'));
|
compare_text.resize(std::min(compare_text.size(), SIZE));
|
text.append(SIZE, STR('A'));
|
is_equal = Equal(compare_text, text);
|
CHECK(is_equal);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.