text
stringlengths
0
2.2M
Text text(buffer.data(), buffer.size());
for (size_t i = 0UL; i < SIZE; ++i)
{
compare_text.push_back(STR('A') + value_t(i));
}
for (size_t i = 0UL; i < SIZE; ++i)
{
text.push_back(STR('A') + value_t(i));
}
CHECK_EQUAL(etl::strlen(compare_text.data()), etl::strlen(text.data()));
CHECK_EQUAL(compare_text.size(), text.size());
bool is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_push_back_excess)
{
Compare_Text compare_text;
TextBuffer buffer;
Text text(buffer.data(), buffer.size());
for (size_t i = 0UL; i < SIZE; ++i)
{
compare_text.push_back(STR('A') + value_t(i));
}
for (size_t i = 0UL; i < SIZE; ++i)
{
text.push_back(STR('A') + value_t(i));
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
}
text.push_back(STR('A') + value_t(SIZE));
CHECK_EQUAL(etl::strlen(compare_text.data()), etl::strlen(text.data()));
CHECK_EQUAL(compare_text.size(), text.size());
bool is_equal = Equal(compare_text, text);
CHECK(is_equal);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_pop_back)
{
Compare_Text compare_text(initial_text.c_str());
TextBuffer buffer;
Text text(initial_text.c_str(), buffer.data(), buffer.size());
compare_text.pop_back();
compare_text.pop_back();
text.pop_back();
text.pop_back();
CHECK_EQUAL(compare_text.size(), text.size());
bool is_equal = Equal(compare_text, text);
CHECK(is_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_insert_position_value)
{
const size_t INITIAL_SIZE = 5;
const value_t INITIAL_VALUE = STR('A');
for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset)
{
Compare_Text compare_text;
TextBuffer buffer;
Text text(buffer.data(), buffer.size());
text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE);
compare_text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE);
text.insert(text.begin() + offset, INITIAL_VALUE);
compare_text.insert(compare_text.begin() + offset, INITIAL_VALUE);
CHECK_EQUAL(compare_text.size(), text.size());
bool is_equal = Equal(compare_text, text);
CHECK(is_equal);