text
stringlengths
0
2.2M
const value_t* needle = STR("needle");
std::u16string compare_haystack(the_haystack);
TextBufferL buffer;
Text haystack(the_haystack, buffer.data(), buffer.size());
size_t position1 = 0;
size_t position2 = 0;
position1 = compare_haystack.find(needle, position1);
position2 = haystack.find(needle, position2);
CHECK_EQUAL(position1, position2);
position1 = compare_haystack.find(needle, position1 + 1);
position2 = haystack.find(needle, position2 + 1);
CHECK_EQUAL(position1, position2);
position2 = haystack.find(needle, position2 + 1);
CHECK_EQUAL(IText::npos, position2);
const value_t* pin = STR("pin");
position2 = haystack.find(pin);
CHECK_EQUAL(IText::npos, position2);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_find_char_pointer_n)
{
const value_t* the_haystack = STR("A haystack with a needle and another needle");
const value_t* needle = STR("needle");
std::u16string compare_haystack(the_haystack);
TextBufferL buffer;
Text haystack(the_haystack, buffer.data(), buffer.size());
size_t position1 = 0;
size_t position2 = 0;
position1 = compare_haystack.find(needle, position1, 3);
position2 = haystack.find(needle, position2, 3);
CHECK_EQUAL(position1, position2);
position1 = compare_haystack.find(needle, position1 + 1, 3);
position2 = haystack.find(needle, position2 + 1, 3);
CHECK_EQUAL(position1, position2);
position2 = haystack.find(needle, position2 + 1, 3);
CHECK_EQUAL(IText::npos, position2);
const value_t* pin = STR("pin");
position2 = haystack.find(pin, 0, 3);
CHECK_EQUAL(IText::npos, position2);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_rfind_string)
{
const value_t* the_haystack = STR("A haystack with a needle and another needle");
std::u16string compare_needle(STR("needle"));
TextBufferL 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 = std::u16string::npos;
size_t position2 = etl::u16string<50>::npos;
position1 = compare_haystack.rfind(compare_needle, position1);
position2 = haystack.rfind(needle, position2);
CHECK_EQUAL(position1, position2);
position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10);
position2 = haystack.rfind(needle, haystack.size() - 10);
CHECK_EQUAL(position1, position2);
TextBufferL buffer3;
Text pin(STR("pin"), buffer3.data(), buffer3.size());
position2 = haystack.rfind(pin);
CHECK_EQUAL(IText::npos, position2);
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_rfind_pointer)
{
const value_t* the_haystack = STR("A haystack with a needle and another needle");
std::u16string compare_haystack(the_haystack);
TextBufferL buffer;
Text haystack(the_haystack, buffer.data(), buffer.size());