text stringlengths 0 2.2M |
|---|
const size_t INITIAL_SIZE = 5;
|
const size_t NEW_SIZE = 8;
|
TextBuffer buffer;
|
Text text(initial_text.c_str(), INITIAL_SIZE, buffer.data(), buffer.size());
|
text.resize(NEW_SIZE);
|
CHECK_EQUAL(text.size(), NEW_SIZE);
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(!text.is_truncated());
|
#endif
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_resize_up_value)
|
{
|
const size_t INITIAL_SIZE = 5;
|
const size_t NEW_SIZE = 8;
|
const value_t INITIAL_VALUE = STR('A');
|
TextBuffer buffer;
|
Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size());
|
text.resize(NEW_SIZE, INITIAL_VALUE);
|
std::array<value_t, NEW_SIZE> compare_text;
|
compare_text.fill(INITIAL_VALUE);
|
bool is_equal = Equal(compare_text, text);
|
CHECK(is_equal);
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(!text.is_truncated());
|
#endif
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_resize_excess)
|
{
|
const size_t INITIAL_SIZE = 5;
|
const size_t NEW_SIZE = SIZE + 1;
|
TextBuffer buffer;
|
Text text(INITIAL_SIZE, STR('A'), buffer.data(), buffer.size());
|
text.resize(NEW_SIZE, STR('A'));
|
CHECK_EQUAL(SIZE, text.size());
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(text.is_truncated());
|
#endif
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_resize_down)
|
{
|
const size_t INITIAL_SIZE = 5;
|
const size_t NEW_SIZE = 2;
|
TextBuffer buffer;
|
Text text(INITIAL_SIZE, STR('A'), buffer.data(), buffer.size());
|
text.resize(NEW_SIZE);
|
CHECK_EQUAL(text.size(), NEW_SIZE);
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(!text.is_truncated());
|
#endif
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_resize_down_value)
|
{
|
const size_t INITIAL_SIZE = 5;
|
const size_t NEW_SIZE = 2;
|
const value_t INITIAL_VALUE = STR('A');
|
TextBuffer buffer;
|
Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size());
|
text.resize(NEW_SIZE, INITIAL_VALUE);
|
CHECK_EQUAL(text.size(), NEW_SIZE);
|
std::array<value_t, NEW_SIZE> compare_text;
|
compare_text.fill(INITIAL_VALUE);
|
bool is_equal = Equal(compare_text, text);
|
CHECK(is_equal);
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(!text.is_truncated());
|
#endif
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_uninitialized_resize_up)
|
{
|
const size_t INITIAL_SIZE = 5;
|
const size_t NEW_SIZE = 8;
|
const value_t INITIAL_VALUE = STR('A');
|
const value_t FILL_VALUE = STR('B');
|
TextBuffer buffer;
|
Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size());
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.