text
stringlengths 0
2.2M
|
---|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_make_string)
|
{
|
size_t length = strlen("Hello World");
|
auto ctext = etl::make_string("Hello World");
|
auto wtext = etl::make_string(L"Hello World");
|
auto u16text = etl::make_string(u"Hello World");
|
auto u32text = etl::make_string(U"Hello World");
|
CHECK_EQUAL(length, ctext.max_size());
|
CHECK_EQUAL(length, wtext.max_size());
|
CHECK_EQUAL(length, u16text.max_size());
|
CHECK_EQUAL(length, u32text.max_size());
|
CHECK(Equal(std::string("Hello World"), ctext));
|
CHECK(Equal(std::wstring(L"Hello World"), wtext));
|
CHECK(Equal(std::u16string(u"Hello World"), u16text));
|
CHECK(Equal(std::u32string(U"Hello World"), u32text));
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_make_string_with_capacity)
|
{
|
constexpr size_t CAPACITY = 20UL;
|
size_t length = strlen("Hello World");
|
auto ctext = etl::make_string_with_capacity<CAPACITY>("Hello World");
|
auto wtext = etl::make_string_with_capacity<CAPACITY>(L"Hello World");
|
auto u16text = etl::make_string_with_capacity<CAPACITY>(u"Hello World");
|
auto u32text = etl::make_string_with_capacity<CAPACITY>(U"Hello World");
|
CHECK_EQUAL(CAPACITY, ctext.max_size());
|
CHECK_EQUAL(length, ctext.size());
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(!ctext.is_truncated());
|
#endif
|
CHECK_EQUAL(CAPACITY, wtext.max_size());
|
CHECK_EQUAL(length, wtext.size());
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(!wtext.is_truncated());
|
#endif
|
CHECK_EQUAL(CAPACITY, u16text.max_size());
|
CHECK_EQUAL(length, u16text.size());
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(!u16text.is_truncated());
|
#endif
|
CHECK_EQUAL(CAPACITY, u32text.max_size());
|
CHECK_EQUAL(length, u32text.size());
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(!u32text.is_truncated());
|
#endif
|
CHECK(Equal(std::string("Hello World"), ctext));
|
CHECK(Equal(std::wstring(L"Hello World"), wtext));
|
CHECK(Equal(std::u16string(u"Hello World"), u16text));
|
CHECK(Equal(std::u32string(U"Hello World"), u32text));
|
}
|
//*************************************************************************
|
TEST_FIXTURE(SetupFixture, test_make_string_with_capacity_truncated)
|
{
|
constexpr size_t CAPACITY = 10UL;
|
size_t length = strlen("Hello World");
|
#if defined(ETL_STRING_TRUNCATION_IS_ERROR)
|
CHECK_THROW(auto ctext = etl::make_string_with_capacity<CAPACITY>("Hello World"), etl::string_truncation);
|
CHECK_THROW(auto wtext = etl::make_string_with_capacity<CAPACITY>(L"Hello World"), etl::string_truncation);;
|
CHECK_THROW(auto u16text = etl::make_string_with_capacity<CAPACITY>(u"Hello World"), etl::string_truncation);;
|
CHECK_THROW(auto u32text = etl::make_string_with_capacity<CAPACITY>(U"Hello World"), etl::string_truncation);;
|
#else
|
auto ctext = etl::make_string_with_capacity<CAPACITY>("Hello World");
|
auto wtext = etl::make_string_with_capacity<CAPACITY>(L"Hello World");
|
auto u16text = etl::make_string_with_capacity<CAPACITY>(u"Hello World");
|
auto u32text = etl::make_string_with_capacity<CAPACITY>(U"Hello World");
|
CHECK_EQUAL(CAPACITY, ctext.max_size());
|
CHECK_EQUAL(length - 1, ctext.size());
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(ctext.is_truncated());
|
#endif
|
CHECK_EQUAL(CAPACITY, wtext.max_size());
|
CHECK_EQUAL(length - 1, wtext.size());
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(wtext.is_truncated());
|
#endif
|
CHECK_EQUAL(CAPACITY, u16text.max_size());
|
CHECK_EQUAL(length - 1, u16text.size());
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
CHECK(u16text.is_truncated());
|
#endif
|
CHECK_EQUAL(CAPACITY, u32text.max_size());
|
CHECK_EQUAL(length - 1, u32text.size());
|
#if ETL_STRING_TRUNCATION_CHECKS_ENABLED
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.