text
stringlengths 0
2.2M
|
---|
text = STR("GHIJKL");
|
is_equal = Equal(text, rtext);
|
CHECK(is_equal);
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_memcpy_repair_virtual)
|
{
|
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));
|
IText& itext(*reinterpret_cast<IText*>(buffer2));
|
itext.repair();
|
CHECK(!itext.empty());
|
CHECK(!itext.full());
|
bool is_equal = Equal(text, itext);
|
CHECK(is_equal);
|
text = STR("GHIJKL");
|
is_equal = Equal(text, itext);
|
CHECK(is_equal);
|
}
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_truncate_over_many_operations)
|
{
|
TextBuffer buffer;
|
Text text(short_text.c_str(), buffer.data(), buffer.size());
|
CHECK(!text.is_truncated());
|
text.insert(3, initial_text.c_str());
|
CHECK(text.is_truncated());
|
while (text.size() != 0)
|
{
|
text.pop_back();
|
CHECK(text.is_truncated());
|
}
|
text.clear();
|
CHECK(!text.is_truncated());
|
text.assign(longer_text.c_str());
|
CHECK(text.is_truncated());
|
text.assign(short_text.c_str());
|
CHECK(!text.is_truncated());
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_add_from_truncated)
|
{
|
TextBuffer buffer;
|
Text text1(short_text.c_str(), buffer.data(), buffer.size());
|
TextBufferS buffers;
|
Text text2(short_text.c_str(), buffers.data(), buffers.size());
|
CHECK(!text1.is_truncated());
|
CHECK(text2.is_truncated());
|
// text2 has the truncate flag set.
|
text1 += text2;
|
CHECK(text1.is_truncated());
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_add_to_truncated)
|
{
|
TextBuffer buffer;
|
Text text1(longer_text.c_str(), buffer.data(), buffer.size());
|
TextBuffer buffer2;
|
Text text2(short_text.c_str(), buffer2.data(), buffer2.size());
|
CHECK(text1.is_truncated());
|
CHECK(!text2.is_truncated());
|
// Clear text but not the truncate flag.
|
text1.erase(text1.begin(), text1.end());
|
// text1 still has the truncate flag set.
|
text1 += text2;
|
CHECK(text1.is_truncated());
|
}
|
//*************************************************************************
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.