text
stringlengths
0
2.2M
{
Text text(p_text, p_text, etl::strlen(p_text) + 1);
CHECK_EQUAL(text.size(), etl::strlen(p_text));
CHECK(!text.empty());
CHECK_EQUAL(etl::strlen(p_text), text.capacity());
CHECK_EQUAL(etl::strlen(p_text), text.max_size());
CHECK(text.begin() != text.end());
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer)
{
Text text(array_text, std::size(array_text));
CHECK_EQUAL(0U, text.size());
CHECK(text.empty());
CHECK_EQUAL(std::size(array_text) - 1, text.capacity());
CHECK_EQUAL(std::size(array_text) - 1, text.max_size());
CHECK(text.begin() == text.end());
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_default_constructor_use_array_buffer_text)
{
Text text(array_text, array_text, std::size(array_text));
CHECK_EQUAL(text.size(), etl::strlen(array_text));
CHECK(!text.empty());
CHECK_EQUAL(std::size(array_text) - 1, text.capacity());
CHECK_EQUAL(std::size(array_text) - 1, text.max_size());
CHECK(text.begin() != text.end());
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
}
//*************************************************************************
TEST(test_iterator_comparison_empty)
{
TextBuffer buffer;
Text text(buffer.data(), buffer.size());
CHECK(text.begin() == text.end());
CHECK(text.cbegin() == text.cend());
CHECK(text.rbegin() == text.rend());
CHECK(text.crbegin() == text.crend());
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_constructor_size_value)
{
const size_t INITIAL_SIZE = 5;
const value_t INITIAL_VALUE = STR('A');
TextBuffer buffer;
Compare_Text compare_text(INITIAL_SIZE, INITIAL_VALUE);
Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size());
CHECK(text.size() == INITIAL_SIZE);
CHECK(!text.empty());
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_constructor_size_excess)
{
TextBuffer buffer;
Text text(buffer.size() + 1, STR('A'), buffer.data(), buffer.size());
CHECK_EQUAL(buffer.size() - 1, text.size());
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_constructor_char_pointer)
{
TextBuffer buffer;
Compare_Text compare_text(initial_text.c_str());
Text text(initial_text.c_str(), buffer.data(), buffer.size());
CHECK(!text.empty());