text
stringlengths
0
2.2M
CHECK_EQUAL(0U, length1);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos)
{
Compare_Text compare_text(initial_text.c_str());
TextBuffer buffer;
Text text(initial_text.c_str(), buffer.data(), buffer.size());
value_t buffer1[SIZE];
value_t buffer2[SIZE];
size_t length1 = compare_text.copy(buffer1, Compare_Text::npos, 2);
buffer1[length1] = STR('\0');
size_t length2 = text.copy(buffer2, Text::npos, 2);
buffer2[length2] = STR('\0');
CHECK_EQUAL(length1, length2);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
bool is_equal = std::equal(buffer1,
buffer1 + length1,
buffer2);
CHECK(is_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_copy_count_too_large)
{
Compare_Text compare_text(initial_text.c_str());
TextBuffer buffer;
Text text(initial_text.c_str(), buffer.data(), buffer.size());
value_t buffer1[SIZE];
value_t buffer2[SIZE];
size_t length1 = compare_text.copy(buffer1, SIZE, 2);
buffer1[length1] = STR('\0');
size_t length2 = text.copy(buffer2, SIZE, 2);
buffer2[length2] = STR('\0');
CHECK_EQUAL(length1, length2);
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
CHECK(!text.is_truncated());
#endif
bool is_equal = std::equal(buffer1,
buffer1 + length1,
buffer2);
CHECK(is_equal);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_find_string)
{
const value_t* the_haystack = STR("A haystack with a needle and another needle");
std::u16string compare_needle(STR("needle"));
TextBuffer buffer;
Text needle(STR("needle"), buffer.data(), buffer.size());
std::u16string compare_haystack(the_haystack);
TextBufferL buffer2;
Text haystack(the_haystack, buffer2.data(), buffer2.size());
size_t position1 = 0;
size_t position2 = 0;
position1 = compare_haystack.find(compare_needle, position1);
position2 = haystack.find(needle, position2);
CHECK_EQUAL(position1, position2);
position1 = compare_haystack.find(compare_needle, position1 + 1);
position2 = haystack.find(needle, position2 + 1);
CHECK_EQUAL(position1, position2);
position2 = haystack.find(needle, position2 + 1);
CHECK_EQUAL(etl::u16string<50>::npos, position2);
etl::u16string<50> pin(STR("pin"));
position2 = haystack.find(pin);
CHECK_EQUAL(IText::npos, position2);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_find_pointer)
{
const value_t* the_haystack = STR("A haystack with a needle and another needle");