text
stringlengths 0
2.2M
|
---|
CHECK_EQUAL(position1, position2);
|
position1 = compare_text.find_last_not_of(STR("ZEXD"), 5, 3);
|
position2 = text.find_last_not_of(STR("ZEXD"), 5, 3);
|
CHECK_EQUAL(position1, position2);
|
position1 = compare_text.find_last_not_of(STR("ZEXD"), 1, 3);
|
position2 = text.find_last_not_of(STR("ZEXD"), 1, 3);
|
CHECK_EQUAL(position1, position2);
|
position1 = compare_text.find_last_not_of(STR("ZEXD"), compare_text.size(), 4);
|
position2 = text.find_last_not_of(STR("ZEXD"), text.size(), 4);
|
CHECK_EQUAL(position1, position2);
|
position1 = compare_text.find_last_not_of(STR("ZEXD"), 100, 4);
|
position2 = text.find_last_not_of(STR("ZEXD"), 100, 4);
|
CHECK_EQUAL(position1, position2);
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position)
|
{
|
Compare_Text compare_text(STR("ABCDEF"));
|
TextBuffer buffer;
|
Text text(STR("ABCDEF"), buffer.data(), buffer.size());
|
size_t position1 = compare_text.find_last_not_of(STR('F'));
|
size_t position2 = text.find_last_not_of(STR('F'));
|
CHECK_EQUAL(position1, position2);
|
position1 = compare_text.find_last_not_of(STR('Z'));
|
position2 = text.find_last_not_of(STR('Z'));
|
CHECK_EQUAL(position1, position2);
|
position1 = compare_text.find_last_not_of(STR('A'), compare_text.size());
|
position2 = text.find_last_not_of(STR('A'), text.size());
|
CHECK_EQUAL(position1, position2);
|
position1 = compare_text.find_last_not_of(STR('C'), 3);
|
position2 = text.find_last_not_of(STR('C'), 3);
|
CHECK_EQUAL(position1, position2);
|
position1 = compare_text.find_last_not_of(STR('C'), compare_text.size());
|
position2 = text.find_last_not_of(STR('C'), text.size());
|
CHECK_EQUAL(position1, position2);
|
position1 = compare_text.find_last_not_of(STR('C'), 100);
|
position2 = text.find_last_not_of(STR('C'), 100);
|
CHECK_EQUAL(position1, position2);
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_hash)
|
{
|
// Test with actual string type.
|
TextBuffer buffer;
|
Text text(STR("ABCDEFHIJKL"), buffer.data(), buffer.size());
|
size_t hash = etl::hash<Text>()(text);
|
size_t compare_hash = etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]), reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
CHECK_EQUAL(compare_hash, hash);
|
// Test with interface string type.
|
IText& itext = text;
|
hash = etl::hash<IText>()(itext);
|
CHECK_EQUAL(compare_hash, hash);
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_memcpy_repair)
|
{
|
TextBuffer buffer;
|
Text text(buffer.data(), buffer.size());
|
text.assign(STR("ABCDEF"));
|
char buffer2[sizeof(Text)];
|
// Will not copy the buffer!
|
memcpy(&buffer2, (const void*)&text, sizeof(text));
|
Text& rtext(*reinterpret_cast<Text*>(buffer2));
|
rtext.repair();
|
CHECK(!rtext.empty());
|
CHECK(!rtext.full());
|
bool is_equal = Equal(text, rtext);
|
CHECK(is_equal);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.