text stringlengths 0 2.2M |
|---|
const value_t* needle = STR("needle");
|
size_t position1 = std::u16string::npos;
|
size_t position2 = etl::u16string<50>::npos;
|
position1 = compare_haystack.rfind(needle, position1);
|
position2 = haystack.rfind(needle, position2);
|
CHECK_EQUAL(position1, position2);
|
position1 = compare_haystack.rfind(needle, compare_haystack.size() - 10);
|
position2 = haystack.rfind(needle, haystack.size() - 10);
|
CHECK_EQUAL(position1, position2);
|
TextBufferL buffer2;
|
Text pin(STR("pin"), buffer2.data(), buffer2.size());
|
position2 = haystack.rfind(pin);
|
CHECK_EQUAL(IText::npos, position2);
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_rfind_pointer_n)
|
{
|
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());
|
const value_t* needle = STR("needle");
|
size_t position1 = std::u16string::npos;
|
size_t position2 = Text::npos;
|
position1 = compare_haystack.rfind(needle, position1, 3);
|
position2 = haystack.rfind(needle, position2, 3);
|
CHECK_EQUAL(position1, position2);
|
position1 = compare_haystack.rfind(needle, compare_haystack.size() - 10, 3);
|
position2 = haystack.rfind(needle, haystack.size() - 10, 3);
|
CHECK_EQUAL(position1, position2);
|
position2 = haystack.rfind(STR("pin"), 3);
|
CHECK_EQUAL(IText::npos, position2);
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_rfind_c_position)
|
{
|
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());
|
size_t position1 = std::u16string::npos;
|
size_t position2 = etl::u16string<50>::npos;
|
position1 = compare_haystack.rfind(STR('e'), position1);
|
position2 = haystack.rfind(STR('e'), position2);
|
CHECK_EQUAL(position1, position2);
|
position1 = compare_haystack.rfind(STR('e'), compare_haystack.size() - 10);
|
position2 = haystack.rfind(STR('e'), haystack.size() - 10);
|
CHECK_EQUAL(position1, position2);
|
position2 = haystack.rfind(STR('z'));
|
CHECK_EQUAL(IText::npos, position2);
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_compare_string)
|
{
|
Compare_Text compare_text(STR("ABCDEF"));
|
TextBuffer buffer;
|
Text text(STR("ABCDEF"), buffer.data(), buffer.size());
|
int compare_result;
|
int result;
|
// Equal.
|
compare_result = compare_text.compare(Compare_Text(STR("ABCDEF")));
|
result = text.compare(TextT(STR("ABCDEF")));
|
CHECK(compares_agree(compare_result, result));
|
// Less.
|
compare_result = compare_text.compare(Compare_Text(STR("ABCDEE")));
|
result = text.compare(TextT(STR("ABCDEE")));
|
CHECK(compares_agree(compare_result, result));
|
// Greater.
|
compare_result = compare_text.compare(Compare_Text(STR("ABCDEG")));
|
result = text.compare(TextT(STR("ABCDEG")));
|
CHECK(compares_agree(compare_result, result));
|
// Shorter.
|
compare_result = compare_text.compare(Compare_Text(STR("ABCDE")));
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.