Create const_basic_string as a base to all const strings

Removed constexpr from basic_string
This commit is contained in:
John Wellbelove 2025-07-31 19:43:06 +01:00
parent 56fe3dd1ff
commit 76e4a33bef
16 changed files with 3180 additions and 1832 deletions

View File

@ -190,7 +190,7 @@ namespace etl
/// Gets the current size of the string.
///\return The current size of the string.
//*************************************************************************
ETL_CONSTEXPR14 size_type size() const
size_type size() const
{
return current_size;
}
@ -199,7 +199,7 @@ namespace etl
/// Gets the current size of the string.
///\return The current size of the string.
//*************************************************************************
ETL_CONSTEXPR14 size_type length() const
size_type length() const
{
return current_size;
}
@ -208,7 +208,7 @@ namespace etl
/// Checks the 'empty' state of the string.
///\return <b>true</b> if empty.
//*************************************************************************
ETL_CONSTEXPR14 bool empty() const
bool empty() const
{
return (current_size == 0);
}
@ -217,7 +217,7 @@ namespace etl
/// Checks the 'full' state of the string.
///\return <b>true</b> if full.
//*************************************************************************
ETL_CONSTEXPR14 bool full() const
bool full() const
{
return current_size == CAPACITY;
}
@ -226,7 +226,7 @@ namespace etl
/// Returns the capacity of the string.
///\return The capacity of the string.
//*************************************************************************
ETL_CONSTEXPR14 size_type capacity() const
size_type capacity() const
{
return CAPACITY;
}
@ -235,7 +235,7 @@ namespace etl
/// Returns the maximum possible size of the string.
///\return The maximum size of the string.
//*************************************************************************
ETL_CONSTEXPR14 size_type max_size() const
size_type max_size() const
{
return CAPACITY;
}
@ -244,7 +244,7 @@ namespace etl
/// Returns the remaining capacity.
///\return The remaining capacity.
//*************************************************************************
ETL_CONSTEXPR14 size_type available() const
size_type available() const
{
return max_size() - size();
}
@ -253,7 +253,7 @@ namespace etl
/// Returns whether the string was truncated by the last operation.
///\return Whether the string was truncated by the last operation.
//*************************************************************************
ETL_CONSTEXPR14 bool is_truncated() const
bool is_truncated() const
{
#if ETL_HAS_STRING_TRUNCATION_CHECKS
return flags.test<IS_TRUNCATED>();
@ -268,7 +268,7 @@ namespace etl
///\return Whether the string was truncated by the last operation.
//*************************************************************************
ETL_DEPRECATED
ETL_CONSTEXPR14 bool truncated() const
bool truncated() const
{
return is_truncated();
}
@ -296,7 +296,7 @@ namespace etl
//*************************************************************************
/// Gets the 'secure' state flag.
//*************************************************************************
ETL_CONSTEXPR14 bool is_secure() const
bool is_secure() const
{
#if ETL_HAS_STRING_CLEAR_AFTER_USE
return flags.test<CLEAR_AFTER_USE>();
@ -310,7 +310,7 @@ namespace etl
//*************************************************************************
/// Constructor.
//*************************************************************************
ETL_CONSTEXPR14 string_base(size_type max_size_)
string_base(size_type max_size_)
: current_size(0)
, CAPACITY(max_size_)
{
@ -329,7 +329,7 @@ namespace etl
//*************************************************************************
/// Destructor.
//*************************************************************************
ETL_CONSTEXPR14 ~string_base()
ETL_CONSTEXPR20 ~string_base()
{
}
@ -378,7 +378,7 @@ namespace etl
/// Returns a const_iterator to the beginning of the string.
///\return A const iterator to the beginning of the string.
//*********************************************************************
ETL_CONSTEXPR14 const_iterator begin() const
const_iterator begin() const
{
return &p_buffer[0];
}
@ -396,7 +396,7 @@ namespace etl
/// Returns a const_iterator to the end of the string.
///\return A const iterator to the end of the string.
//*********************************************************************
ETL_CONSTEXPR14 const_iterator end() const
const_iterator end() const
{
return &p_buffer[current_size];
}
@ -405,7 +405,7 @@ namespace etl
/// Returns a const_iterator to the beginning of the string.
///\return A const iterator to the beginning of the string.
//*********************************************************************
ETL_CONSTEXPR14 const_iterator cbegin() const
const_iterator cbegin() const
{
return &p_buffer[0];
}
@ -414,7 +414,7 @@ namespace etl
/// Returns a const_iterator to the end of the string.
///\return A const iterator to the end of the string.
//*********************************************************************
ETL_CONSTEXPR14 const_iterator cend() const
const_iterator cend() const
{
return &p_buffer[current_size];
}
@ -432,7 +432,7 @@ namespace etl
/// Returns a const reverse iterator to the reverse beginning of the string.
///\return Const iterator to the reverse beginning of the string.
//*********************************************************************
ETL_CONSTEXPR14 const_reverse_iterator rbegin() const
const_reverse_iterator rbegin() const
{
return const_reverse_iterator(end());
}
@ -441,7 +441,7 @@ namespace etl
/// Returns a reverse iterator to the end + 1 of the string.
///\return Reverse iterator to the end + 1 of the string.
//*********************************************************************
ETL_CONSTEXPR14 reverse_iterator rend()
reverse_iterator rend()
{
return reverse_iterator(begin());
}
@ -450,7 +450,7 @@ namespace etl
/// Returns a const reverse iterator to the end + 1 of the string.
///\return Const reverse iterator to the end + 1 of the string.
//*********************************************************************
ETL_CONSTEXPR14 const_reverse_iterator rend() const
const_reverse_iterator rend() const
{
return const_reverse_iterator(begin());
}
@ -459,7 +459,7 @@ namespace etl
/// Returns a const reverse iterator to the reverse beginning of the string.
///\return Const reverse iterator to the reverse beginning of the string.
//*********************************************************************
ETL_CONSTEXPR14 const_reverse_iterator crbegin() const
const_reverse_iterator crbegin() const
{
return const_reverse_iterator(cend());
}
@ -468,7 +468,7 @@ namespace etl
/// Returns a const reverse iterator to the end + 1 of the string.
///\return Const reverse iterator to the end + 1 of the string.
//*********************************************************************
ETL_CONSTEXPR14 const_reverse_iterator crend() const
const_reverse_iterator crend() const
{
return const_reverse_iterator(cbegin());
}
@ -568,7 +568,7 @@ namespace etl
///\param i The index.
///\return A const reference to the value at index 'i'
//*********************************************************************
ETL_CONSTEXPR14 const_reference operator [](size_type i) const
const_reference operator [](size_type i) const
{
return p_buffer[i];
}
@ -591,7 +591,7 @@ namespace etl
///\param i The index.
///\return A const reference to the value at index 'i'
//*********************************************************************
ETL_CONSTEXPR14 const_reference at(size_type i) const
const_reference at(size_type i) const
{
ETL_ASSERT(i < size(), ETL_ERROR(string_out_of_bounds));
return p_buffer[i];
@ -610,7 +610,7 @@ namespace etl
/// Returns a const reference to the first element.
///\return A const reference to the first element.
//*********************************************************************
ETL_CONSTEXPR14 const_reference front() const
const_reference front() const
{
return p_buffer[0];
}
@ -628,7 +628,7 @@ namespace etl
/// Returns a const reference to the last element.
///\return A const reference to the last element.
//*********************************************************************
ETL_CONSTEXPR14 const_reference back() const
const_reference back() const
{
return p_buffer[current_size - 1];
}
@ -664,7 +664,7 @@ namespace etl
/// Returns a const pointer to the beginning of the string data.
///\return A const pointer to the beginning of the string data.
//*********************************************************************
ETL_CONSTEXPR14 const_pointer data_end() const
const_pointer data_end() const
{
return p_buffer + current_size;
}
@ -1371,7 +1371,7 @@ namespace etl
//*********************************************************************
/// Return a pointer to a C string.
//*********************************************************************
ETL_CONSTEXPR14 const_pointer c_str() const
const_pointer c_str() const
{
return p_buffer;
}
@ -1382,7 +1382,7 @@ namespace etl
///\param count The number of characters to copy.
///\param pos The position to start copying from.
//*********************************************************************
ETL_CONSTEXPR14 size_type copy(pointer dest, size_type count, size_type pos = 0) const
size_type copy(pointer dest, size_type count, size_type pos = 0) const
{
if (pos < size())
{
@ -1410,7 +1410,7 @@ namespace etl
///\param str The content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find(const ibasic_string<T>& str, size_type pos = 0) const
size_type find(const ibasic_string<T>& str, size_type pos = 0) const
{
return find_impl(str.begin(), str.end(), str.size(), pos);
}
@ -1421,7 +1421,7 @@ namespace etl
///\param pos The position to start searching from.
//*********************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 size_type find(const etl::basic_string_view<T, TOtherTraits>& view, size_type pos = 0) const
size_type find(const etl::basic_string_view<T, TOtherTraits>& view, size_type pos = 0) const
{
return find_impl(view.begin(), view.end(), view.size(), pos);
}
@ -1431,7 +1431,7 @@ namespace etl
///\param s Pointer to the content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find(const_pointer s, size_type pos = 0) const
size_type find(const_pointer s, size_type pos = 0) const
{
size_t sz = etl::strlen(s);
@ -1444,7 +1444,7 @@ namespace etl
///\param pos The position to start searching from.
///\param n The number of characters to search for.
//*********************************************************************
ETL_CONSTEXPR14 size_type find(const_pointer s, size_type pos, size_type n) const
size_type find(const_pointer s, size_type pos, size_type n) const
{
size_t sz = etl::strlen(s);
@ -1456,7 +1456,7 @@ namespace etl
///\param c The character to find.
///\param position The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find(T c, size_type position = 0) const
size_type find(T c, size_type position = 0) const
{
const_iterator i = etl::find(begin() + position, end(), c);
@ -1475,7 +1475,7 @@ namespace etl
///\param str The content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type rfind(const ibasic_string<T>& str, size_type position = npos) const
size_type rfind(const ibasic_string<T>& str, size_type position = npos) const
{
return rfind_impl(str.rbegin(), str.rend(), str.size(), position);
}
@ -1486,7 +1486,7 @@ namespace etl
///\param pos The position to start searching from.
//*********************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 size_type rfind(const etl::basic_string_view<T, TOtherTraits>& view, size_type pos = npos) const
size_type rfind(const etl::basic_string_view<T, TOtherTraits>& view, size_type pos = npos) const
{
return rfind_impl(view.rbegin(), view.rend(), view.size(), pos);
}
@ -1496,7 +1496,7 @@ namespace etl
///\param str The content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type rfind(const_pointer s, size_type position = npos) const
size_type rfind(const_pointer s, size_type position = npos) const
{
size_type len = etl::strlen(s);
@ -1511,7 +1511,7 @@ namespace etl
///\param str The content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type rfind(const_pointer s, size_type position, size_type length_) const
size_type rfind(const_pointer s, size_type position, size_type length_) const
{
const_reverse_iterator srbegin(s + length_);
const_reverse_iterator srend(s);
@ -1524,7 +1524,7 @@ namespace etl
///\param c The character to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type rfind(T c, size_type position = npos) const
size_type rfind(T c, size_type position = npos) const
{
if (position >= size())
{
@ -1548,7 +1548,7 @@ namespace etl
//*********************************************************************
/// Checks that the string is within this string
//*********************************************************************
ETL_CONSTEXPR14 bool contains(const etl::ibasic_string<T>& str) const
bool contains(const etl::ibasic_string<T>& str) const
{
return find(str) != npos;
}
@ -1557,7 +1557,7 @@ namespace etl
/// Checks that the view is within this string
//*********************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 bool contains(const etl::basic_string_view<T, TOtherTraits>& view) const
bool contains(const etl::basic_string_view<T, TOtherTraits>& view) const
{
return find(view) != npos;
}
@ -1565,7 +1565,7 @@ namespace etl
//*********************************************************************
/// Checks that text is within this string
//*********************************************************************
ETL_CONSTEXPR14 bool contains(const_pointer s) const
bool contains(const_pointer s) const
{
return find(s) != npos;
}
@ -1573,7 +1573,7 @@ namespace etl
//*********************************************************************
/// Checks that character is within this string
//*********************************************************************
ETL_CONSTEXPR14 bool contains(value_type c) const
bool contains(value_type c) const
{
return find(c) != npos;
}
@ -1581,7 +1581,7 @@ namespace etl
//*********************************************************************
/// Checks that the string is the start of this string
//*********************************************************************
ETL_CONSTEXPR14 bool starts_with(const etl::ibasic_string<T>& str) const
bool starts_with(const etl::ibasic_string<T>& str) const
{
return compare(0, str.size(), str) == 0;
}
@ -1590,7 +1590,7 @@ namespace etl
/// Checks that the view is the start of this string
//*********************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 bool starts_with(const etl::basic_string_view<T, TOtherTraits>& view) const
bool starts_with(const etl::basic_string_view<T, TOtherTraits>& view) const
{
return compare(0, view.size(), view) == 0;
}
@ -1598,7 +1598,7 @@ namespace etl
//*********************************************************************
/// Checks that the string is the start of this string
//*********************************************************************
ETL_CONSTEXPR14 bool starts_with(const_pointer s) const
bool starts_with(const_pointer s) const
{
size_t len = etl::strlen(s);
@ -1608,7 +1608,7 @@ namespace etl
//*********************************************************************
/// Checks that the character is the start of this string
//*********************************************************************
ETL_CONSTEXPR14 bool starts_with(value_type c) const
bool starts_with(value_type c) const
{
return !empty() && (front() == c);
}
@ -1616,7 +1616,7 @@ namespace etl
//*********************************************************************
/// Checks that the string is the end of this string
//*********************************************************************
ETL_CONSTEXPR14 bool ends_with(const etl::ibasic_string<T>& str) const
bool ends_with(const etl::ibasic_string<T>& str) const
{
if (str.size() > size())
{
@ -1630,7 +1630,7 @@ namespace etl
/// Checks that the view is the end of this string
//*********************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 bool ends_with(const etl::basic_string_view<T, TOtherTraits>& view) const
bool ends_with(const etl::basic_string_view<T, TOtherTraits>& view) const
{
if (view.size() > size())
{
@ -1643,7 +1643,7 @@ namespace etl
//*********************************************************************
/// Checks that the string is the end of this string
//*********************************************************************
ETL_CONSTEXPR14 bool ends_with(const_pointer s) const
bool ends_with(const_pointer s) const
{
size_t len = etl::strlen(s);
@ -1658,7 +1658,7 @@ namespace etl
//*********************************************************************
/// Checks that the character is the end of this string
//*********************************************************************
ETL_CONSTEXPR14 bool ends_with(value_type c) const
bool ends_with(value_type c) const
{
return !empty() && (back() == c);
}
@ -1949,7 +1949,7 @@ namespace etl
//*************************************************************************
/// Compare with string.
//*************************************************************************
ETL_CONSTEXPR14 int compare(const ibasic_string& str) const
int compare(const ibasic_string& str) const
{
return compare(p_buffer,
p_buffer + size(),
@ -1961,7 +1961,7 @@ namespace etl
/// Compare with etl::basic_string_view.
//*************************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 int compare(const etl::basic_string_view<T, TOtherTraits>& view) const
int compare(const etl::basic_string_view<T, TOtherTraits>& view) const
{
return compare(p_buffer,
p_buffer + size(),
@ -1972,7 +1972,7 @@ namespace etl
//*************************************************************************
/// Compare position / length with string.
//*************************************************************************
ETL_CONSTEXPR14 int compare(size_type position, size_type length_, const ibasic_string& str) const
int compare(size_type position, size_type length_, const ibasic_string& str) const
{
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
@ -1989,7 +1989,7 @@ namespace etl
/// Compare position / length with etl::basic_string_view.
//*************************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 int compare(size_type position, size_type length_, const etl::basic_string_view<T, TOtherTraits>& view) const
int compare(size_type position, size_type length_, const etl::basic_string_view<T, TOtherTraits>& view) const
{
return compare(p_buffer + position,
p_buffer + position + length_,
@ -2000,7 +2000,7 @@ namespace etl
//*************************************************************************
/// Compare position / length with string / subposition / sublength.
//*************************************************************************
ETL_CONSTEXPR14 int compare(size_type position, size_type length_, const ibasic_string& str, size_type subposition, size_type sublength) const
int compare(size_type position, size_type length_, const ibasic_string& str, size_type subposition, size_type sublength) const
{
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds));
@ -2019,7 +2019,7 @@ namespace etl
/// Compare position / length with etl::basic_string_view. / subposition / sublength.
//*************************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 int compare(size_type position, size_type length_, const etl::basic_string_view<T, TOtherTraits>& view, size_type subposition, size_type sublength) const
int compare(size_type position, size_type length_, const etl::basic_string_view<T, TOtherTraits>& view, size_type subposition, size_type sublength) const
{
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
ETL_ASSERT(subposition <= view.size(), ETL_ERROR(string_out_of_bounds));
@ -2037,7 +2037,7 @@ namespace etl
//*************************************************************************
/// Compare with C string
//*************************************************************************
ETL_CONSTEXPR14 int compare(const value_type* s) const
int compare(const value_type* s) const
{
return compare(p_buffer,
p_buffer + size(),
@ -2048,7 +2048,7 @@ namespace etl
//*************************************************************************
/// Compare position / length with C string.
//*************************************************************************
ETL_CONSTEXPR14 int compare(size_type position, size_type length_, const_pointer s) const
int compare(size_type position, size_type length_, const_pointer s) const
{
return compare(p_buffer + position,
p_buffer + position + length_,
@ -2059,7 +2059,7 @@ namespace etl
//*************************************************************************
/// Compare position / length with C string / n.
//*************************************************************************
ETL_CONSTEXPR14 int compare(size_type position, size_type length_, const_pointer s, size_type n) const
int compare(size_type position, size_type length_, const_pointer s, size_type n) const
{
return compare(p_buffer + position,
p_buffer + position + length_,
@ -2072,7 +2072,7 @@ namespace etl
///\param str The content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_first_of(const ibasic_string<T>& str, size_type position = 0) const
size_type find_first_of(const ibasic_string<T>& str, size_type position = 0) const
{
return find_first_of(str.c_str(), position, str.size());
}
@ -2082,7 +2082,7 @@ namespace etl
///\param s Pointer to the content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_first_of(const_pointer s, size_type position = 0) const
size_type find_first_of(const_pointer s, size_type position = 0) const
{
return find_first_of(s, position, etl::strlen(s));
}
@ -2093,7 +2093,7 @@ namespace etl
///\param pos The position to start searching from.
//*********************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 size_type find_first_of(const etl::basic_string_view<T, TOtherTraits>& view, size_type position = 0) const
size_type find_first_of(const etl::basic_string_view<T, TOtherTraits>& view, size_type position = 0) const
{
return find_first_of(view.data(), position, view.size());
}
@ -2104,7 +2104,7 @@ namespace etl
///\param pos The position to start searching from.
///\param n The number of characters to search for.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_first_of(const_pointer s, size_type position, size_type n) const
size_type find_first_of(const_pointer s, size_type position, size_type n) const
{
if (position < size())
{
@ -2128,7 +2128,7 @@ namespace etl
///\param c The character to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_first_of(value_type c, size_type position = 0) const
size_type find_first_of(value_type c, size_type position = 0) const
{
if (position < size())
{
@ -2149,7 +2149,7 @@ namespace etl
///\param str The content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_last_of(const ibasic_string<T>& str, size_type position = npos) const
size_type find_last_of(const ibasic_string<T>& str, size_type position = npos) const
{
return find_last_of(str.c_str(), position, str.size());
}
@ -2159,7 +2159,7 @@ namespace etl
///\param s Pointer to the content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_last_of(const_pointer s, size_type position = npos) const
size_type find_last_of(const_pointer s, size_type position = npos) const
{
return find_last_of(s, position, etl::strlen(s));
}
@ -2170,7 +2170,7 @@ namespace etl
///\param pos The position to start searching from.
//*********************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 size_type find_last_of(const etl::basic_string_view<T, TOtherTraits>& view, size_type position = npos) const
size_type find_last_of(const etl::basic_string_view<T, TOtherTraits>& view, size_type position = npos) const
{
return find_last_of(view.data(), position, view.size());
}
@ -2181,7 +2181,7 @@ namespace etl
///\param pos The position to start searching from.
///\param n The number of characters to search for.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_last_of(const_pointer s, size_type position, size_type n) const
size_type find_last_of(const_pointer s, size_type position, size_type n) const
{
if (empty())
{
@ -2214,7 +2214,7 @@ namespace etl
///\param c The character to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_last_of(value_type c, size_type position = npos) const
size_type find_last_of(value_type c, size_type position = npos) const
{
if (empty())
{
@ -2244,7 +2244,7 @@ namespace etl
///\param str The content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_first_not_of(const ibasic_string<T>& str, size_type position = 0) const
size_type find_first_not_of(const ibasic_string<T>& str, size_type position = 0) const
{
return find_first_not_of(str.c_str(), position, str.size());
}
@ -2254,7 +2254,7 @@ namespace etl
///\param s Pointer to the content to not find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_first_not_of(const_pointer s, size_type position = 0) const
size_type find_first_not_of(const_pointer s, size_type position = 0) const
{
return find_first_not_of(s, position, etl::strlen(s));
}
@ -2265,7 +2265,7 @@ namespace etl
///\param pos The position to start searching from.
//*********************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 size_type find_first_not_of(const etl::basic_string_view<T, TOtherTraits>& view, size_type position = 0) const
size_type find_first_not_of(const etl::basic_string_view<T, TOtherTraits>& view, size_type position = 0) const
{
return find_first_not_of(view.data(), position, view.size());
}
@ -2276,7 +2276,7 @@ namespace etl
///\param pos The position to start searching from.
///\param n The number of characters to search for.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_first_not_of(const_pointer s, size_type position, size_type n) const
size_type find_first_not_of(const_pointer s, size_type position, size_type n) const
{
if (position < size())
{
@ -2307,7 +2307,7 @@ namespace etl
///\param c The character to not find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_first_not_of(value_type c, size_type position = 0) const
size_type find_first_not_of(value_type c, size_type position = 0) const
{
if (position < size())
{
@ -2328,7 +2328,7 @@ namespace etl
///\param str The content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_last_not_of(const ibasic_string<T>& str, size_type position = npos) const
size_type find_last_not_of(const ibasic_string<T>& str, size_type position = npos) const
{
return find_last_not_of(str.c_str(), position, str.size());
}
@ -2338,7 +2338,7 @@ namespace etl
///\param s The pointer to the content to find
///\param pos The position to start searching from.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_last_not_of(const_pointer s, size_type position = npos) const
size_type find_last_not_of(const_pointer s, size_type position = npos) const
{
return find_last_not_of(s, position, etl::strlen(s));
}
@ -2349,7 +2349,7 @@ namespace etl
///\param pos The position to start searching from.
//*********************************************************************
template <typename TOtherTraits>
ETL_CONSTEXPR14 size_type find_last_not_of(const etl::basic_string_view<T, TOtherTraits>& view, size_type position = npos) const
size_type find_last_not_of(const etl::basic_string_view<T, TOtherTraits>& view, size_type position = npos) const
{
return find_last_not_of(view.data(), position, view.size());
}
@ -2360,7 +2360,7 @@ namespace etl
///\param pos The position to start searching from.
///\param n The number of characters to use.
//*********************************************************************
ETL_CONSTEXPR14 size_type find_last_not_of(const_pointer s, size_type position, size_type n) const
size_type find_last_not_of(const_pointer s, size_type position, size_type n) const
{
if (empty())
{
@ -2398,7 +2398,7 @@ namespace etl
//*********************************************************************
//
//*********************************************************************
ETL_CONSTEXPR14 size_type find_last_not_of(value_type c, size_type position = npos) const
size_type find_last_not_of(value_type c, size_type position = npos) const
{
if (empty())
{
@ -2536,7 +2536,7 @@ namespace etl
//*********************************************************************
/// Constructor.
//*********************************************************************
ETL_CONSTEXPR14 ibasic_string(T* p_buffer_, size_type MAX_SIZE_)
ibasic_string(T* p_buffer_, size_type MAX_SIZE_)
: string_base(MAX_SIZE_),
p_buffer(p_buffer_)
{
@ -2545,7 +2545,7 @@ namespace etl
//*********************************************************************
/// Initialise the string.
//*********************************************************************
ETL_CONSTEXPR14 void initialise()
void initialise()
{
current_size = 0U;
p_buffer[0] = 0;
@ -2567,7 +2567,7 @@ namespace etl
//*************************************************************************
/// Compare helper function
//*************************************************************************
ETL_CONSTEXPR14 static int compare(const_pointer first1, const_pointer last1,
static int compare(const_pointer first1, const_pointer last1,
const_pointer first2, const_pointer last2)
{
typedef typename etl::make_unsigned<value_type>::type type;
@ -2644,7 +2644,7 @@ namespace etl
#else
protected:
#endif
ETL_CONSTEXPR14 ~ibasic_string()
ETL_CONSTEXPR20 ~ibasic_string()
{
#if ETL_HAS_STRING_CLEAR_AFTER_USE
if (is_secure())
@ -2659,7 +2659,7 @@ namespace etl
//*************************************************************************
/// Convert from const_iterator to iterator
//*************************************************************************
ETL_CONSTEXPR14 iterator to_iterator(const_iterator itr) const
iterator to_iterator(const_iterator itr) const
{
return const_cast<iterator>(itr);
}
@ -2782,7 +2782,7 @@ namespace etl
/// Common implementation for 'find'.
//*************************************************************************
template <typename TIterator>
ETL_CONSTEXPR14 size_type find_impl(TIterator first, TIterator last, size_type sz, size_type pos = 0) const
size_type find_impl(TIterator first, TIterator last, size_type sz, size_type pos = 0) const
{
if ((pos + sz) > size())
{
@ -2805,7 +2805,7 @@ namespace etl
/// Common implementation for 'rfind'.
//*************************************************************************
template <typename TIterator>
ETL_CONSTEXPR14 size_type rfind_impl(TIterator rfirst, TIterator rlast, size_type sz, size_type pos = 0) const
size_type rfind_impl(TIterator rfirst, TIterator rlast, size_type sz, size_type pos = 0) const
{
if (sz > size())
{

View File

@ -0,0 +1,313 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2025 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CONST_BASIC_STRING_INCLUDED
#define ETL_CONST_BASIC_STRING_INCLUDED
#include "platform.h"
#include "iterator.h"
#include "char_traits.h"
#if ETL_USING_CPP14
namespace etl
{
//***************************************************************************
/// A string implementation that uses a fixed size external const buffer.
///\ingroup string
//***************************************************************************
template <typename T>
class const_basic_string
{
public:
using value_type = T;
using size_type = size_t;
using const_pointer = const value_type*;
using const_reference = const value_type&;
using const_iterator = const value_type*;
using const_reverse_iterator = etl::reverse_iterator<const_iterator>;
//*************************************************************************
/// Gets the size of the string.
//*************************************************************************
ETL_NODISCARD
constexpr size_t size() const noexcept
{
return buffer_size;
}
//*************************************************************************
/// Gets the size of the string.
//*************************************************************************
ETL_NODISCARD
constexpr size_t length() const noexcept
{
return buffer_size;
}
//*************************************************************************
/// Gets the capacity of the string.
//*************************************************************************
ETL_NODISCARD
constexpr size_t capacity() const noexcept
{
return buffer_size;
}
//*************************************************************************
/// Gets the maximum size of the string.
//*************************************************************************
ETL_NODISCARD
constexpr size_t max_size() const noexcept
{
return buffer_size;
}
//*************************************************************************
/// Gets the amount of free space in the string.
//*************************************************************************
ETL_NODISCARD
constexpr size_t available() const noexcept
{
return 0U;
}
//*************************************************************************
/// Gets the start of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_iterator begin() const noexcept
{
return p_buffer;
}
//*************************************************************************
/// Gets the start of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_iterator cbegin() const noexcept
{
return p_buffer;
}
//*************************************************************************
/// Gets the reverse start of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_reverse_iterator rbegin() const noexcept
{
return const_reverse_iterator(end());
}
//*************************************************************************
/// Gets the reverse start of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_reverse_iterator crbegin() const noexcept
{
return const_reverse_iterator(end());
}
//*************************************************************************
/// Gets the end of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_iterator end() const noexcept
{
return p_buffer + buffer_size;
}
//*************************************************************************
/// Gets the end of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_iterator cend() const noexcept
{
return p_buffer + buffer_size;
}
//*************************************************************************
/// Gets the reverse end of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_reverse_iterator rend() const noexcept
{
return const_reverse_iterator(begin());
}
//*************************************************************************
/// Gets the reverse end of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_reverse_iterator crend() const noexcept
{
return const_reverse_iterator(begin());
}
//*************************************************************************
/// Gets the start of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_pointer data() const noexcept
{
return p_buffer;
}
//*************************************************************************
/// Gets the end of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_pointer data_end() const noexcept
{
return p_buffer + buffer_size;
}
//*********************************************************************
/// Return a pointer to a C string.
//*********************************************************************
ETL_NODISCARD
constexpr const_pointer c_str() const
{
return p_buffer;
}
//*************************************************************************
/// Is the string empty?
//*************************************************************************
ETL_NODISCARD
constexpr bool empty() const noexcept
{
return buffer_size == 0U;
}
//*************************************************************************
/// Is the string full?
//*************************************************************************
ETL_NODISCARD
constexpr bool full() const noexcept
{
return true;
}
//*************************************************************************
/// Is the string truncated?
//*************************************************************************
ETL_NODISCARD
constexpr bool is_truncated() const noexcept
{
return truncated_state;
}
//*************************************************************************
/// Is the string secure?
//*************************************************************************
ETL_NODISCARD
constexpr bool is_secure() const noexcept
{
return false;
}
//*************************************************************************
/// Returns a const reference to the value at the index.
//*************************************************************************
ETL_NODISCARD
constexpr const_reference operator [](int i) const noexcept
{
return p_buffer[i];
}
//*************************************************************************
/// Returns a const reference to the value at the index.
//*************************************************************************
ETL_NODISCARD
constexpr const_reference at(int i) const noexcept
{
return p_buffer[i];
}
//*************************************************************************
/// Returns a const reference to the value at the front of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_reference front() const noexcept
{
return p_buffer[0];
}
//*************************************************************************
/// Returns a const reference to the value at the front of the string.
//*************************************************************************
ETL_NODISCARD
constexpr const_reference back() const noexcept
{
return p_buffer[buffer_size - 1U];
}
protected:
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_basic_string(const value_type* buffer, size_t buff_size, bool is_truncated)
: p_buffer(buffer)
, buffer_size(buff_size)
, truncated_state(is_truncated)
{
}
private:
const value_type* p_buffer;
const size_t buffer_size;
const bool truncated_state;
};
//***************************************************************************
/// Operator overload to write to std basic_ostream
///\param os Reference to the output stream.
///\param str Reference to the string to write.
///\return Reference to the output stream, for chaining write operations.
///\ingroup string
//***************************************************************************
#if ETL_USING_STL
template <typename T>
std::basic_ostream<T, std::char_traits<T> > &operator<<(std::basic_ostream<T, std::char_traits<T> > &os,
const etl::const_basic_string<T>& str)
{
os.write(str.data(), str.size());
return os;
}
#endif
}
#endif
#endif

View File

@ -32,111 +32,63 @@ SOFTWARE.
#define ETL_CONST_STRING_INCLUDED
#include "platform.h"
#include "string.h"
#include "hash.h"
#include "iterator.h"
#include "char_traits.h"
#include "const_basic_string.h"
#include <ctype.h>
#include "private/minmax_push.h"
#if ETL_USING_CPP14
namespace etl
{
//***************************************************************************
/// A string implementation that uses a fixed size external buffer.
/// A string implementation that uses a fixed size external const buffer.
///\ingroup string
//***************************************************************************
class const_string : public istring
class const_string : public etl::const_basic_string<char>
{
public:
typedef istring base_type;
typedef istring interface_type;
using value_type = const_basic_string<char>::value_type;
using size_type = const_basic_string<char>::size_type;
using const_pointer = const_basic_string<char>::const_pointer;
using const_reference = const_basic_string<char>::const_reference;
using const_iterator = const_basic_string<char>::const_iterator;
typedef istring::value_type value_type;
typedef istring::size_type size_type;
using const_reverse_iterator = const_basic_string<char>::const_reverse_iterator;
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_string(const value_type* buffer)
: istring(const_cast<value_type*>(buffer), etl::strlen(buffer))
{
this->current_size = etl::strlen(buffer);
constexpr const_string(const value_type* buffer, bool is_truncated = false)
: const_basic_string(buffer, etl::strlen(buffer), is_truncated)
{
}
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_string(const value_type* buffer, size_t length)
: istring(const_cast<value_type*>(buffer), length)
constexpr const_string(const value_type* buffer, size_t length, bool is_truncated = false)
: const_basic_string(buffer, length, is_truncated)
{
this->current_size = length;
}
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_string(const value_type* buffer, const value_type* buffer_end)
: istring(const_cast<value_type*>(buffer), buffer_end - buffer)
constexpr const_string(const value_type* buffer, const value_type* buffer_end, bool is_truncated = false)
: const_basic_string(buffer, buffer_end - buffer, is_truncated)
{
this->current_size = buffer_end - buffer;
}
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_string(const etl::string_view& view)
: istring(const_cast<value_type*>(view.data()), view.size())
{
this->current_size = view.size();
}
//*************************************************************************
/// Copy constructor.
//*************************************************************************
constexpr const_string(const etl::const_string& other)
: istring(const_cast<value_type*>(other.data()), other.size())
{
this->current_size = other.size();
}
//*************************************************************************
/// Returns a sub-string.
///\param position The position of the first character. Default = 0.
///\param length The number of characters. Default = npos.
//*************************************************************************
constexpr etl::const_string substr(size_type position = 0, size_type length_ = npos) const
{
if (position < this->size())
{
length_ = etl::min(length_, this->size() - position);
return etl::const_string(data() + position, length_);
}
return etl::const_string("");
}
//*************************************************************************
/// Fix the internal pointers after a low level memory copy.
//*************************************************************************
#if ETL_HAS_ISTRING_REPAIR
constexpr virtual void repair() ETL_OVERRIDE
#else
constexpr void repair()
#endif
: const_basic_string(other.data(), other.size(), other.is_truncated())
{
}
private:
//*************************************************************************
/// Deleted.
//*************************************************************************
//const_string(const const_string& other) ETL_DELETE;
};
}
#include "private/minmax_pop.h"
#endif
#endif

View File

@ -0,0 +1,92 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2025 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CONST_U16STRING_INCLUDED
#define ETL_CONST_U16STRING_INCLUDED
#include "platform.h"
#include "const_basic_string.h"
#if ETL_USING_CPP14
namespace etl
{
//***************************************************************************
/// A string implementation that uses a fixed size external const buffer.
///\ingroup string
//***************************************************************************
class const_u16string : public etl::const_basic_string<char16_t>
{
public:
using value_type = const_basic_string<char16_t>::value_type;
using size_type = const_basic_string<char16_t>::size_type;
using const_pointer = const_basic_string<char16_t>::const_pointer;
using const_reference = const_basic_string<char16_t>::const_reference;
using const_iterator = const_basic_string<char16_t>::const_iterator;
using const_reverse_iterator = const_basic_string<char16_t>::const_reverse_iterator;
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_u16string(const value_type* buffer, bool is_truncated = false)
: const_basic_string(buffer, etl::strlen(buffer), is_truncated)
{
}
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_u16string(const value_type* buffer, size_t length, bool is_truncated = false)
: const_basic_string(buffer, length, is_truncated)
{
}
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_u16string(const value_type* buffer, const value_type* buffer_end, bool is_truncated = false)
: const_basic_string(buffer, buffer_end - buffer, is_truncated)
{
}
//*************************************************************************
/// Copy constructor.
//*************************************************************************
constexpr const_u16string(const etl::const_u16string& other)
: const_basic_string(other.data(), other.size(), other.is_truncated())
{
}
};
}
#endif
#endif

View File

@ -0,0 +1,92 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2025 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CONST_U32STRING_INCLUDED
#define ETL_CONST_U32STRING_INCLUDED
#include "platform.h"
#include "const_basic_string.h"
#if ETL_USING_CPP14
namespace etl
{
//***************************************************************************
/// A string implementation that uses a fixed size external const buffer.
///\ingroup string
//***************************************************************************
class const_u32string : public etl::const_basic_string<char32_t>
{
public:
using value_type = const_basic_string<char32_t>::value_type;
using size_type = const_basic_string<char32_t>::size_type;
using const_pointer = const_basic_string<char32_t>::const_pointer;
using const_reference = const_basic_string<char32_t>::const_reference;
using const_iterator = const_basic_string<char32_t>::const_iterator;
using const_reverse_iterator = const_basic_string<char32_t>::const_reverse_iterator;
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_u32string(const value_type* buffer, bool is_truncated = false)
: const_basic_string(buffer, etl::strlen(buffer), is_truncated)
{
}
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_u32string(const value_type* buffer, size_t length, bool is_truncated = false)
: const_basic_string(buffer, length, is_truncated)
{
}
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_u32string(const value_type* buffer, const value_type* buffer_end, bool is_truncated = false)
: const_basic_string(buffer, buffer_end - buffer, is_truncated)
{
}
//*************************************************************************
/// Copy constructor.
//*************************************************************************
constexpr const_u32string(const etl::const_u32string& other)
: const_basic_string(other.data(), other.size(), other.is_truncated())
{
}
};
}
#endif
#endif

View File

@ -0,0 +1,94 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2025 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CONST_U8STRING_INCLUDED
#define ETL_CONST_U8STRING_INCLUDED
#include "platform.h"
#include "const_basic_string.h"
#if ETL_USING_CPP14
#if ETL_HAS_CHAR8_T
namespace etl
{
//***************************************************************************
/// A string implementation that uses a fixed size external const buffer.
///\ingroup string
//***************************************************************************
class const_u8string : public etl::const_basic_string<char8_t>
{
public:
using value_type = const_basic_string<char8_t>::value_type;
using size_type = const_basic_string<char8_t>::size_type;
using const_pointer = const_basic_string<char8_t>::const_pointer;
using const_reference = const_basic_string<char8_t>::const_reference;
using const_iterator = const_basic_string<char8_t>::const_iterator;
using const_reverse_iterator = const_basic_string<char8_t>::const_reverse_iterator;
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_u8string(const value_type* buffer, bool is_truncated = false)
: const_basic_string(buffer, etl::strlen(buffer), is_truncated)
{
}
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_u8string(const value_type* buffer, size_t length, bool is_truncated = false)
: const_basic_string(buffer, length, is_truncated)
{
}
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_u8string(const value_type* buffer, const value_type* buffer_end, bool is_truncated = false)
: const_basic_string(buffer, buffer_end - buffer, is_truncated)
{
}
//*************************************************************************
/// Copy constructor.
//*************************************************************************
constexpr const_u8string(const etl::const_u8string& other)
: const_basic_string(other.data(), other.size(), other.is_truncated())
{
}
};
}
#endif
#endif
#endif

View File

@ -0,0 +1,92 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2025 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_CONST_WSTRING_INCLUDED
#define ETL_CONST_WSTRING_INCLUDED
#include "platform.h"
#include "const_basic_string.h"
#if ETL_USING_CPP14
namespace etl
{
//***************************************************************************
/// A string implementation that uses a fixed size external const buffer.
///\ingroup string
//***************************************************************************
class const_wstring : public etl::const_basic_string<wchar_t>
{
public:
using value_type = const_basic_string<wchar_t>::value_type;
using size_type = const_basic_string<wchar_t>::size_type;
using const_pointer = const_basic_string<wchar_t>::const_pointer;
using const_reference = const_basic_string<wchar_t>::const_reference;
using const_iterator = const_basic_string<wchar_t>::const_iterator;
using const_reverse_iterator = const_basic_string<wchar_t>::const_reverse_iterator;
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_wstring(const value_type* buffer, bool is_truncated = false)
: const_basic_string(buffer, etl::strlen(buffer), is_truncated)
{
}
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_wstring(const value_type* buffer, size_t length, bool is_truncated = false)
: const_basic_string(buffer, length, is_truncated)
{
}
//*************************************************************************
/// Constructor.
//*************************************************************************
constexpr const_wstring(const value_type* buffer, const value_type* buffer_end, bool is_truncated = false)
: const_basic_string(buffer, buffer_end - buffer, is_truncated)
{
}
//*************************************************************************
/// Copy constructor.
//*************************************************************************
constexpr const_wstring(const etl::const_wstring& other)
: const_basic_string(other.data(), other.size(), other.is_truncated())
{
}
};
}
#endif
#endif

View File

@ -40,6 +40,7 @@ SOFTWARE.
#include "integral_limits.h"
#include "hash.h"
#include "basic_string.h"
#include "const_basic_string.h"
#include "algorithm.h"
#include "private/minmax_push.h"
@ -69,7 +70,7 @@ namespace etl
};
//***************************************************************************
///\ingroup stack
///\ingroup string
/// The exception thrown when the index is out of bounds.
//***************************************************************************
class string_view_bounds : public string_view_exception
@ -83,7 +84,7 @@ namespace etl
};
//***************************************************************************
///\ingroup stack
///\ingroup string
/// The exception thrown when the view is uninitialised.
//***************************************************************************
class string_view_uninitialised : public string_view_exception
@ -138,6 +139,17 @@ namespace etl
{
}
#if ETL_USING_CPP14
//*************************************************************************
/// Construct from const_string.
//*************************************************************************
ETL_CONSTEXPR basic_string_view(const etl::const_basic_string<T>& str)
: mbegin(str.begin())
, mend(str.end())
{
}
#endif
//*************************************************************************
/// Construct from T*.
//*************************************************************************
@ -563,9 +575,9 @@ namespace etl
position = etl::min(position, size());
const_iterator iposition = etl::find_end(begin(),
begin() + position,
view.begin(),
view.end());
begin() + position,
view.begin(),
view.end());
if (iposition == end())
{

View File

@ -61,6 +61,11 @@ add_executable(etl_tests
test_const_map_constexpr.cpp
test_const_multimap.cpp
test_const_multimap_constexpr.cpp
test_const_string_char.cpp
test_const_string_u16.cpp
test_const_string_u32.cpp
test_const_string_u8.cpp
test_const_string_wchar_t.cpp
test_char_traits.cpp
test_checksum.cpp
test_chrono_clocks.cpp

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,525 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2025 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "unit_test_framework.h"
#include <string>
#include <array>
#include <algorithm>
#include <atomic>
#include "etl/const_u16string.h"
#include "etl/string_view.h"
#if ETL_USING_CPP14
#undef STR
#define STR(x) u##x
namespace
{
SUITE(test_const_string_char16_t)
{
using Text = etl::const_u16string;
using View = etl::u16string_view;
using TextSTD = std::u16string;
static constexpr Text::const_pointer text_pointer = STR("Hello World");
static constexpr Text text(STR("Hello World"));
static constexpr size_t Length = etl::strlen(STR("Hello World"));
//*************************************************************************
template <typename T1, typename T2>
bool Equal(const T1& compare_text, const T2& test_text)
{
return (compare_text.size() == test_text.size()) && std::equal(test_text.begin(), test_text.end(), compare_text.begin());
}
//*************************************************************************
template <typename T1, typename T2>
bool Equal(const T1* compare_text, const T2& test_text)
{
return (etl::strlen(compare_text) == test_text.size()) && std::equal(test_text.begin(), test_text.end(), compare_text);
}
//*************************************************************************
TEST(test_constructor_null_string)
{
static constexpr Text text_from_literal_empty(STR(""));
static constexpr auto text_empty = text_from_literal_empty.empty();
CHECK_TRUE(text_empty);
static constexpr auto text_full = text_from_literal_empty.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_literal_empty.capacity();
CHECK_EQUAL(0, text_capacity);
static constexpr auto text_max_size = text_from_literal_empty.max_size();
CHECK_EQUAL(0, text_max_size);
static constexpr auto text_size = text_from_literal_empty.size();
CHECK_EQUAL(0, text_size);
static constexpr auto text_length = text_from_literal_empty.length();
CHECK_EQUAL(0, text_length);
static constexpr auto text_available = text_from_literal_empty.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_literal_empty.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_literal_empty.is_secure();
CHECK_FALSE(text_is_secure);
}
//*************************************************************************
TEST(test_constructor_char_pointer)
{
static constexpr Text text_from_pointer(text_pointer);
static constexpr auto text_empty = text_from_pointer.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_from_pointer.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_pointer.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_from_pointer.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_from_pointer.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_from_pointer.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_from_pointer.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_pointer.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_pointer.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_from_pointer.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_from_pointer.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_from_pointer.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_from_pointer.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_from_pointer.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_from_pointer.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_from_pointer.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_from_pointer.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_from_pointer.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_from_pointer.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u16string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_constructor_from_literal)
{
static constexpr Text text_from_literal(STR("Hello World"));
static constexpr auto text_empty = text_from_literal.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_from_literal.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_literal.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_from_literal.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_from_literal.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_from_literal.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_from_literal.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_literal.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_literal.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_from_literal.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_from_literal.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_from_literal.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_from_literal.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_from_literal.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_from_literal.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_from_literal.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_from_literal.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_from_literal.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_from_literal.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u16string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_constructor_truncated)
{
static constexpr Text text_from_pointer(text_pointer, true);
static constexpr Text text_from_literal(STR("Hello World"), true);
static constexpr auto text_from_pointer_is_truncated = text_from_pointer.is_truncated();
CHECK_TRUE(text_from_pointer_is_truncated);
static constexpr auto text_from_literal_is_truncated = text_from_literal.is_truncated();
CHECK_TRUE(text_from_literal_is_truncated);
}
//*************************************************************************
TEST(test_copy_constructor)
{
static constexpr Text text_copy(text);
static constexpr auto text_empty = text_copy.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_copy.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_copy.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_copy.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_copy.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_copy.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_copy.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_copy.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_copy.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_copy.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_copy.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_copy.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_copy.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_copy.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_copy.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_copy.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_copy.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_copy.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_copy.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u16string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_copy_constructor_from_truncated)
{
static constexpr Text text_original(STR("Hello World"), true);
static constexpr Text text_copy(text_original);
static constexpr auto text_empty = text_copy.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_copy.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_copy.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_copy.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_copy.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_copy.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_copy.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_copy.is_truncated();
CHECK_TRUE(text_is_truncated);
static constexpr auto text_is_secure = text_copy.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_copy.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_copy.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_copy.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_copy.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_copy.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_copy.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_copy.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_copy.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_copy.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_copy.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u16string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_begin)
{
static constexpr Text::const_iterator p_begin = text.begin();
static constexpr Text::const_iterator p_cbegin = text.cbegin();
CHECK_EQUAL(&text_pointer[0], p_begin);
CHECK_EQUAL(&text_pointer[0], p_cbegin);
}
//*************************************************************************
TEST(test_index)
{
static constexpr Text::value_type c0 = text[0];
static constexpr Text::value_type c1 = text[1];
static constexpr Text::value_type c2 = text[2];
static constexpr Text::value_type c3 = text[3];
static constexpr Text::value_type c4 = text[4];
static constexpr Text::value_type c5 = text[5];
static constexpr Text::value_type c6 = text[6];
static constexpr Text::value_type c7 = text[7];
static constexpr Text::value_type c8 = text[8];
static constexpr Text::value_type c9 = text[9];
static constexpr Text::value_type c10 = text[10];
static constexpr Text::value_type c11 = text[11];
CHECK_EQUAL(text_pointer[0], c0);
CHECK_EQUAL(text_pointer[1], c1);
CHECK_EQUAL(text_pointer[2], c2);
CHECK_EQUAL(text_pointer[3], c3);
CHECK_EQUAL(text_pointer[4], c4);
CHECK_EQUAL(text_pointer[5], c5);
CHECK_EQUAL(text_pointer[6], c6);
CHECK_EQUAL(text_pointer[7], c7);
CHECK_EQUAL(text_pointer[8], c8);
CHECK_EQUAL(text_pointer[9], c9);
CHECK_EQUAL(text_pointer[10], c10);
CHECK_EQUAL(text_pointer[11], c11);
}
//*************************************************************************
TEST(test_at)
{
static constexpr Text::value_type c0 = text.at(0);
static constexpr Text::value_type c1 = text.at(1);
static constexpr Text::value_type c2 = text.at(2);
static constexpr Text::value_type c3 = text.at(3);
static constexpr Text::value_type c4 = text.at(4);
static constexpr Text::value_type c5 = text.at(5);
static constexpr Text::value_type c6 = text.at(6);
static constexpr Text::value_type c7 = text.at(7);
static constexpr Text::value_type c8 = text.at(8);
static constexpr Text::value_type c9 = text.at(9);
static constexpr Text::value_type c10 = text.at(10);
CHECK_EQUAL(text_pointer[0], c0);
CHECK_EQUAL(text_pointer[1], c1);
CHECK_EQUAL(text_pointer[2], c2);
CHECK_EQUAL(text_pointer[3], c3);
CHECK_EQUAL(text_pointer[4], c4);
CHECK_EQUAL(text_pointer[5], c5);
CHECK_EQUAL(text_pointer[6], c6);
CHECK_EQUAL(text_pointer[7], c7);
CHECK_EQUAL(text_pointer[8], c8);
CHECK_EQUAL(text_pointer[9], c9);
CHECK_EQUAL(text_pointer[10], c10);
}
//*************************************************************************
TEST(test_front)
{
CHECK_TRUE(text_pointer[0] == text.front());
}
//*************************************************************************
TEST(test_back)
{
CHECK_TRUE(text_pointer[Length - 1] == text.back());
}
//*************************************************************************
TEST(test_data)
{
static constexpr Text::const_pointer p_data = text.data();
CHECK_EQUAL(&text[0], p_data);
}
//*************************************************************************
TEST(test_data_end)
{
static constexpr Text::const_pointer p_data = text.data_end();
CHECK_EQUAL(&text[Length], p_data);
}
//*************************************************************************
TEST(test_c_str)
{
static constexpr Text::const_pointer p_data = text.c_str();
CHECK_EQUAL(&text[0], p_data);
CHECK_EQUAL(Length, etl::strlen(p_data));
}
//*************************************************************************
TEST(test_const_iterator)
{
static constexpr Text::const_iterator itr = text.begin();
Text::const_iterator begin = text.begin();
Text::const_iterator end = text.end();
bool is_equal = std::equal(begin, end, itr);
CHECK_TRUE(is_equal);
}
//*************************************************************************
TEST(test_const_reverse_iterator)
{
static constexpr Text::const_reverse_iterator ritr = text.rbegin();
etl::reverse_iterator<Text::const_pointer> rbegin(text_pointer + Length);
etl::reverse_iterator<Text::const_pointer> rend(text_pointer);
bool is_equal = std::equal(rbegin, rend, ritr);
CHECK_TRUE(is_equal);
}
//*************************************************************************
TEST(test_to_view)
{
static constexpr View view(text);
CHECK_TRUE(text.begin() == view.begin());
CHECK_TRUE(text.end() == view.end());
bool is_equal = std::equal(text.begin(), text.end(), view.begin());
CHECK_TRUE(is_equal);
}
};
}
#endif

View File

@ -0,0 +1,525 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2025 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "unit_test_framework.h"
#include <string>
#include <array>
#include <algorithm>
#include <atomic>
#include "etl/const_u32string.h"
#include "etl/string_view.h"
#if ETL_USING_CPP14
#undef STR
#define STR(x) U##x
namespace
{
SUITE(test_const_string_char32_t)
{
using Text = etl::const_u32string;
using View = etl::u32string_view;
using TextSTD = std::u32string;
static constexpr Text::const_pointer text_pointer = STR("Hello World");
static constexpr Text text(STR("Hello World"));
static constexpr size_t Length = etl::strlen(STR("Hello World"));
//*************************************************************************
template <typename T1, typename T2>
bool Equal(const T1& compare_text, const T2& test_text)
{
return (compare_text.size() == test_text.size()) && std::equal(test_text.begin(), test_text.end(), compare_text.begin());
}
//*************************************************************************
template <typename T1, typename T2>
bool Equal(const T1* compare_text, const T2& test_text)
{
return (etl::strlen(compare_text) == test_text.size()) && std::equal(test_text.begin(), test_text.end(), compare_text);
}
//*************************************************************************
TEST(test_constructor_null_string)
{
static constexpr Text text_from_literal_empty(STR(""));
static constexpr auto text_empty = text_from_literal_empty.empty();
CHECK_TRUE(text_empty);
static constexpr auto text_full = text_from_literal_empty.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_literal_empty.capacity();
CHECK_EQUAL(0, text_capacity);
static constexpr auto text_max_size = text_from_literal_empty.max_size();
CHECK_EQUAL(0, text_max_size);
static constexpr auto text_size = text_from_literal_empty.size();
CHECK_EQUAL(0, text_size);
static constexpr auto text_length = text_from_literal_empty.length();
CHECK_EQUAL(0, text_length);
static constexpr auto text_available = text_from_literal_empty.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_literal_empty.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_literal_empty.is_secure();
CHECK_FALSE(text_is_secure);
}
//*************************************************************************
TEST(test_constructor_char_pointer)
{
static constexpr Text text_from_pointer(text_pointer);
static constexpr auto text_empty = text_from_pointer.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_from_pointer.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_pointer.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_from_pointer.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_from_pointer.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_from_pointer.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_from_pointer.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_pointer.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_pointer.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_from_pointer.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_from_pointer.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_from_pointer.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_from_pointer.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_from_pointer.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_from_pointer.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_from_pointer.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_from_pointer.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_from_pointer.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_from_pointer.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u32string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_constructor_from_literal)
{
static constexpr Text text_from_literal(STR("Hello World"));
static constexpr auto text_empty = text_from_literal.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_from_literal.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_literal.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_from_literal.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_from_literal.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_from_literal.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_from_literal.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_literal.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_literal.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_from_literal.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_from_literal.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_from_literal.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_from_literal.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_from_literal.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_from_literal.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_from_literal.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_from_literal.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_from_literal.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_from_literal.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u32string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_constructor_truncated)
{
static constexpr Text text_from_pointer(text_pointer, true);
static constexpr Text text_from_literal(STR("Hello World"), true);
static constexpr auto text_from_pointer_is_truncated = text_from_pointer.is_truncated();
CHECK_TRUE(text_from_pointer_is_truncated);
static constexpr auto text_from_literal_is_truncated = text_from_literal.is_truncated();
CHECK_TRUE(text_from_literal_is_truncated);
}
//*************************************************************************
TEST(test_copy_constructor)
{
static constexpr Text text_copy(text);
static constexpr auto text_empty = text_copy.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_copy.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_copy.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_copy.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_copy.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_copy.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_copy.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_copy.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_copy.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_copy.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_copy.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_copy.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_copy.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_copy.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_copy.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_copy.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_copy.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_copy.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_copy.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u32string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_copy_constructor_from_truncated)
{
static constexpr Text text_original(STR("Hello World"), true);
static constexpr Text text_copy(text_original);
static constexpr auto text_empty = text_copy.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_copy.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_copy.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_copy.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_copy.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_copy.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_copy.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_copy.is_truncated();
CHECK_TRUE(text_is_truncated);
static constexpr auto text_is_secure = text_copy.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_copy.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_copy.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_copy.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_copy.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_copy.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_copy.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_copy.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_copy.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_copy.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_copy.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u32string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_begin)
{
static constexpr Text::const_iterator p_begin = text.begin();
static constexpr Text::const_iterator p_cbegin = text.cbegin();
CHECK_EQUAL(&text_pointer[0], p_begin);
CHECK_EQUAL(&text_pointer[0], p_cbegin);
}
//*************************************************************************
TEST(test_index)
{
static constexpr Text::value_type c0 = text[0];
static constexpr Text::value_type c1 = text[1];
static constexpr Text::value_type c2 = text[2];
static constexpr Text::value_type c3 = text[3];
static constexpr Text::value_type c4 = text[4];
static constexpr Text::value_type c5 = text[5];
static constexpr Text::value_type c6 = text[6];
static constexpr Text::value_type c7 = text[7];
static constexpr Text::value_type c8 = text[8];
static constexpr Text::value_type c9 = text[9];
static constexpr Text::value_type c10 = text[10];
static constexpr Text::value_type c11 = text[11];
CHECK_EQUAL(text_pointer[0], c0);
CHECK_EQUAL(text_pointer[1], c1);
CHECK_EQUAL(text_pointer[2], c2);
CHECK_EQUAL(text_pointer[3], c3);
CHECK_EQUAL(text_pointer[4], c4);
CHECK_EQUAL(text_pointer[5], c5);
CHECK_EQUAL(text_pointer[6], c6);
CHECK_EQUAL(text_pointer[7], c7);
CHECK_EQUAL(text_pointer[8], c8);
CHECK_EQUAL(text_pointer[9], c9);
CHECK_EQUAL(text_pointer[10], c10);
CHECK_EQUAL(text_pointer[11], c11);
}
//*************************************************************************
TEST(test_at)
{
static constexpr Text::value_type c0 = text.at(0);
static constexpr Text::value_type c1 = text.at(1);
static constexpr Text::value_type c2 = text.at(2);
static constexpr Text::value_type c3 = text.at(3);
static constexpr Text::value_type c4 = text.at(4);
static constexpr Text::value_type c5 = text.at(5);
static constexpr Text::value_type c6 = text.at(6);
static constexpr Text::value_type c7 = text.at(7);
static constexpr Text::value_type c8 = text.at(8);
static constexpr Text::value_type c9 = text.at(9);
static constexpr Text::value_type c10 = text.at(10);
CHECK_EQUAL(text_pointer[0], c0);
CHECK_EQUAL(text_pointer[1], c1);
CHECK_EQUAL(text_pointer[2], c2);
CHECK_EQUAL(text_pointer[3], c3);
CHECK_EQUAL(text_pointer[4], c4);
CHECK_EQUAL(text_pointer[5], c5);
CHECK_EQUAL(text_pointer[6], c6);
CHECK_EQUAL(text_pointer[7], c7);
CHECK_EQUAL(text_pointer[8], c8);
CHECK_EQUAL(text_pointer[9], c9);
CHECK_EQUAL(text_pointer[10], c10);
}
//*************************************************************************
TEST(test_front)
{
CHECK_TRUE(text_pointer[0] == text.front());
}
//*************************************************************************
TEST(test_back)
{
CHECK_TRUE(text_pointer[Length - 1] == text.back());
}
//*************************************************************************
TEST(test_data)
{
static constexpr Text::const_pointer p_data = text.data();
CHECK_EQUAL(&text[0], p_data);
}
//*************************************************************************
TEST(test_data_end)
{
static constexpr Text::const_pointer p_data = text.data_end();
CHECK_EQUAL(&text[Length], p_data);
}
//*************************************************************************
TEST(test_c_str)
{
static constexpr Text::const_pointer p_data = text.c_str();
CHECK_EQUAL(&text[0], p_data);
CHECK_EQUAL(Length, etl::strlen(p_data));
}
//*************************************************************************
TEST(test_const_iterator)
{
static constexpr Text::const_iterator itr = text.begin();
Text::const_iterator begin = text.begin();
Text::const_iterator end = text.end();
bool is_equal = std::equal(begin, end, itr);
CHECK_TRUE(is_equal);
}
//*************************************************************************
TEST(test_const_reverse_iterator)
{
static constexpr Text::const_reverse_iterator ritr = text.rbegin();
etl::reverse_iterator<Text::const_pointer> rbegin(text_pointer + Length);
etl::reverse_iterator<Text::const_pointer> rend(text_pointer);
bool is_equal = std::equal(rbegin, rend, ritr);
CHECK_TRUE(is_equal);
}
//*************************************************************************
TEST(test_to_view)
{
static constexpr View view(text);
CHECK_TRUE(text.begin() == view.begin());
CHECK_TRUE(text.end() == view.end());
bool is_equal = std::equal(text.begin(), text.end(), view.begin());
CHECK_TRUE(is_equal);
}
};
}
#endif

View File

@ -0,0 +1,528 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2025 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "unit_test_framework.h"
#include "etl/platform.h"
#if ETL_USING_CPP20
#include <string>
#include <array>
#include <algorithm>
#include <atomic>
#include "etl/const_u8string.h"
#include "etl/string_view.h"
#undef STR
#define STR(x) u8##x
namespace
{
SUITE(test_const_string_char8_t)
{
using Text = etl::const_u8string;
using View = etl::u8string_view;
#if ETL_USING_CPP20
using TextSTD = std::u8string;
#endif
static constexpr const char8_t* text_pointer = u8"Hello World";
static constexpr Text text(STR("Hello World"));
static constexpr size_t Length = etl::strlen(STR("Hello World"));
//*************************************************************************
template <typename T1, typename T2>
bool Equal(const T1& compare_text, const T2& test_text)
{
return (compare_text.size() == test_text.size()) && std::equal(test_text.begin(), test_text.end(), compare_text.begin());
}
//*************************************************************************
template <typename T1, typename T2>
bool Equal(const T1* compare_text, const T2& test_text)
{
return (etl::strlen(compare_text) == test_text.size()) && std::equal(test_text.begin(), test_text.end(), compare_text);
}
//*************************************************************************
TEST(test_constructor_null_string)
{
static constexpr Text text_from_literal_empty(STR(""));
static constexpr auto text_empty = text_from_literal_empty.empty();
CHECK_TRUE(text_empty);
static constexpr auto text_full = text_from_literal_empty.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_literal_empty.capacity();
CHECK_EQUAL(0, text_capacity);
static constexpr auto text_max_size = text_from_literal_empty.max_size();
CHECK_EQUAL(0, text_max_size);
static constexpr auto text_size = text_from_literal_empty.size();
CHECK_EQUAL(0, text_size);
static constexpr auto text_length = text_from_literal_empty.length();
CHECK_EQUAL(0, text_length);
static constexpr auto text_available = text_from_literal_empty.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_literal_empty.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_literal_empty.is_secure();
CHECK_FALSE(text_is_secure);
}
//*************************************************************************
TEST(test_constructor_char_pointer)
{
static constexpr Text text_from_pointer(text_pointer);
static constexpr auto text_empty = text_from_pointer.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_from_pointer.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_pointer.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_from_pointer.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_from_pointer.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_from_pointer.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_from_pointer.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_pointer.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_pointer.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_from_pointer.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_from_pointer.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_from_pointer.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_from_pointer.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_from_pointer.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_from_pointer.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_from_pointer.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_from_pointer.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_from_pointer.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_from_pointer.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u8string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_constructor_from_literal)
{
static constexpr Text text_from_literal(STR("Hello World"));
static constexpr auto text_empty = text_from_literal.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_from_literal.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_literal.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_from_literal.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_from_literal.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_from_literal.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_from_literal.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_literal.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_literal.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_from_literal.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_from_literal.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_from_literal.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_from_literal.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_from_literal.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_from_literal.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_from_literal.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_from_literal.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_from_literal.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_from_literal.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u8string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_constructor_truncated)
{
static constexpr Text text_from_pointer(text_pointer, true);
static constexpr Text text_from_literal(STR("Hello World"), true);
static constexpr auto text_from_pointer_is_truncated = text_from_pointer.is_truncated();
CHECK_TRUE(text_from_pointer_is_truncated);
static constexpr auto text_from_literal_is_truncated = text_from_literal.is_truncated();
CHECK_TRUE(text_from_literal_is_truncated);
}
//*************************************************************************
TEST(test_copy_constructor)
{
static constexpr Text text_copy(text);
static constexpr auto text_empty = text_copy.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_copy.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_copy.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_copy.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_copy.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_copy.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_copy.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_copy.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_copy.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_copy.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_copy.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_copy.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_copy.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_copy.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_copy.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_copy.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_copy.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_copy.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_copy.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u8string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_copy_constructor_from_truncated)
{
static constexpr Text text_original(STR("Hello World"), true);
static constexpr Text text_copy(text_original);
static constexpr auto text_empty = text_copy.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_copy.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_copy.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_copy.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_copy.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_copy.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_copy.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_copy.is_truncated();
CHECK_TRUE(text_is_truncated);
static constexpr auto text_is_secure = text_copy.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_copy.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_copy.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_copy.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_copy.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_copy.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_copy.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_copy.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_copy.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_copy.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_copy.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::u8string(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_begin)
{
static constexpr Text::const_iterator p_begin = text.begin();
static constexpr Text::const_iterator p_cbegin = text.cbegin();
CHECK_EQUAL(&text_pointer[0], p_begin);
CHECK_EQUAL(&text_pointer[0], p_cbegin);
}
//*************************************************************************
TEST(test_index)
{
static constexpr Text::value_type c0 = text[0];
static constexpr Text::value_type c1 = text[1];
static constexpr Text::value_type c2 = text[2];
static constexpr Text::value_type c3 = text[3];
static constexpr Text::value_type c4 = text[4];
static constexpr Text::value_type c5 = text[5];
static constexpr Text::value_type c6 = text[6];
static constexpr Text::value_type c7 = text[7];
static constexpr Text::value_type c8 = text[8];
static constexpr Text::value_type c9 = text[9];
static constexpr Text::value_type c10 = text[10];
static constexpr Text::value_type c11 = text[11];
CHECK_EQUAL(text_pointer[0], c0);
CHECK_EQUAL(text_pointer[1], c1);
CHECK_EQUAL(text_pointer[2], c2);
CHECK_EQUAL(text_pointer[3], c3);
CHECK_EQUAL(text_pointer[4], c4);
CHECK_EQUAL(text_pointer[5], c5);
CHECK_EQUAL(text_pointer[6], c6);
CHECK_EQUAL(text_pointer[7], c7);
CHECK_EQUAL(text_pointer[8], c8);
CHECK_EQUAL(text_pointer[9], c9);
CHECK_EQUAL(text_pointer[10], c10);
CHECK_EQUAL(text_pointer[11], c11);
}
//*************************************************************************
TEST(test_at)
{
static constexpr Text::value_type c0 = text.at(0);
static constexpr Text::value_type c1 = text.at(1);
static constexpr Text::value_type c2 = text.at(2);
static constexpr Text::value_type c3 = text.at(3);
static constexpr Text::value_type c4 = text.at(4);
static constexpr Text::value_type c5 = text.at(5);
static constexpr Text::value_type c6 = text.at(6);
static constexpr Text::value_type c7 = text.at(7);
static constexpr Text::value_type c8 = text.at(8);
static constexpr Text::value_type c9 = text.at(9);
static constexpr Text::value_type c10 = text.at(10);
CHECK_EQUAL(text_pointer[0], c0);
CHECK_EQUAL(text_pointer[1], c1);
CHECK_EQUAL(text_pointer[2], c2);
CHECK_EQUAL(text_pointer[3], c3);
CHECK_EQUAL(text_pointer[4], c4);
CHECK_EQUAL(text_pointer[5], c5);
CHECK_EQUAL(text_pointer[6], c6);
CHECK_EQUAL(text_pointer[7], c7);
CHECK_EQUAL(text_pointer[8], c8);
CHECK_EQUAL(text_pointer[9], c9);
CHECK_EQUAL(text_pointer[10], c10);
}
//*************************************************************************
TEST(test_front)
{
CHECK_TRUE(text_pointer[0] == text.front());
}
//*************************************************************************
TEST(test_back)
{
CHECK_TRUE(text_pointer[Length - 1] == text.back());
}
//*************************************************************************
TEST(test_data)
{
static constexpr Text::const_pointer p_data = text.data();
CHECK_EQUAL(&text[0], p_data);
}
//*************************************************************************
TEST(test_data_end)
{
static constexpr Text::const_pointer p_data = text.data_end();
CHECK_EQUAL(&text[Length], p_data);
}
//*************************************************************************
TEST(test_c_str)
{
static constexpr Text::const_pointer p_data = text.c_str();
CHECK_EQUAL(&text[0], p_data);
CHECK_EQUAL(Length, etl::strlen(p_data));
}
//*************************************************************************
TEST(test_const_iterator)
{
static constexpr Text::const_iterator itr = text.begin();
Text::const_iterator begin = text.begin();
Text::const_iterator end = text.end();
bool is_equal = std::equal(begin, end, itr);
CHECK_TRUE(is_equal);
}
//*************************************************************************
TEST(test_const_reverse_iterator)
{
static constexpr Text::const_reverse_iterator ritr = text.rbegin();
etl::reverse_iterator<Text::const_pointer> rbegin(text_pointer + Length);
etl::reverse_iterator<Text::const_pointer> rend(text_pointer);
bool is_equal = std::equal(rbegin, rend, ritr);
CHECK_TRUE(is_equal);
}
//*************************************************************************
TEST(test_to_view)
{
static constexpr View view(text);
CHECK_TRUE(text.begin() == view.begin());
CHECK_TRUE(text.end() == view.end());
bool is_equal = std::equal(text.begin(), text.end(), view.begin());
CHECK_TRUE(is_equal);
}
};
}
#endif

View File

@ -0,0 +1,543 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2025 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "unit_test_framework.h"
#include <string>
#include <array>
#include <algorithm>
#include <atomic>
#include "etl/const_wstring.h"
#include "etl/string_view.h"
#if ETL_USING_CPP14
#undef STR
#define STR(x) L##x
namespace
{
SUITE(test_const_string_wchar_t)
{
using Text = etl::const_wstring;
using View = etl::wstring_view;
using TextSTD = std::wstring;
static constexpr Text::const_pointer text_pointer = STR("Hello World");
static constexpr Text text(STR("Hello World"));
static constexpr size_t Length = etl::strlen(STR("Hello World"));
//*************************************************************************
template <typename T1, typename T2>
bool Equal(const T1& compare_text, const T2& test_text)
{
return (compare_text.size() == test_text.size()) && std::equal(test_text.begin(), test_text.end(), compare_text.begin());
}
//*************************************************************************
template <typename T1, typename T2>
bool Equal(const T1* compare_text, const T2& test_text)
{
return (etl::strlen(compare_text) == test_text.size()) && std::equal(test_text.begin(), test_text.end(), compare_text);
}
//*************************************************************************
TEST(test_constructor_null_string)
{
static constexpr Text text_from_literal_empty(STR(""));
static constexpr auto text_empty = text_from_literal_empty.empty();
CHECK_TRUE(text_empty);
static constexpr auto text_full = text_from_literal_empty.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_literal_empty.capacity();
CHECK_EQUAL(0, text_capacity);
static constexpr auto text_max_size = text_from_literal_empty.max_size();
CHECK_EQUAL(0, text_max_size);
static constexpr auto text_size = text_from_literal_empty.size();
CHECK_EQUAL(0, text_size);
static constexpr auto text_length = text_from_literal_empty.length();
CHECK_EQUAL(0, text_length);
static constexpr auto text_available = text_from_literal_empty.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_literal_empty.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_literal_empty.is_secure();
CHECK_FALSE(text_is_secure);
}
//*************************************************************************
TEST(test_constructor_char_pointer)
{
static constexpr Text text_from_pointer(text_pointer);
static constexpr auto text_empty = text_from_pointer.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_from_pointer.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_pointer.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_from_pointer.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_from_pointer.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_from_pointer.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_from_pointer.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_pointer.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_pointer.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_from_pointer.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_from_pointer.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_from_pointer.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_from_pointer.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_from_pointer.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_from_pointer.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_from_pointer.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_from_pointer.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_from_pointer.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_from_pointer.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::wstring(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_constructor_from_literal)
{
static constexpr Text text_from_literal(STR("Hello World"));
static constexpr auto text_empty = text_from_literal.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_from_literal.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_from_literal.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_from_literal.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_from_literal.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_from_literal.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_from_literal.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_from_literal.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_from_literal.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_from_literal.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_from_literal.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_from_literal.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_from_literal.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_from_literal.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_from_literal.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_from_literal.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_from_literal.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_from_literal.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_from_literal.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::wstring(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_constructor_truncated)
{
static constexpr Text text_from_pointer(text_pointer, true);
static constexpr Text text_from_literal(STR("Hello World"), true);
static constexpr auto text_from_pointer_is_truncated = text_from_pointer.is_truncated();
CHECK_TRUE(text_from_pointer_is_truncated);
static constexpr auto text_from_literal_is_truncated = text_from_literal.is_truncated();
CHECK_TRUE(text_from_literal_is_truncated);
}
//*************************************************************************
TEST(test_copy_constructor)
{
static constexpr Text text_copy(text);
static constexpr auto text_empty = text_copy.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_copy.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_copy.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_copy.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_copy.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_copy.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_copy.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_copy.is_truncated();
CHECK_FALSE(text_is_truncated);
static constexpr auto text_is_secure = text_copy.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_copy.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_copy.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_copy.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_copy.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_copy.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_copy.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_copy.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_copy.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_copy.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_copy.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::wstring(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_copy_constructor_from_truncated)
{
static constexpr Text text_original(STR("Hello World"), true);
static constexpr Text text_copy(text_original);
static constexpr auto text_empty = text_copy.empty();
CHECK_FALSE(text_empty);
static constexpr auto text_full = text_copy.full();
CHECK_TRUE(text_full);
static constexpr auto text_capacity = text_copy.capacity();
CHECK_EQUAL(Length, text_capacity);
static constexpr auto text_max_size = text_copy.max_size();
CHECK_EQUAL(Length, text_max_size);
static constexpr auto text_size = text_copy.size();
CHECK_EQUAL(Length, text_size);
static constexpr auto text_length = text_copy.length();
CHECK_EQUAL(Length, text_length);
static constexpr auto text_available = text_copy.available();
CHECK_EQUAL(0, text_available);
static constexpr auto text_is_truncated = text_copy.is_truncated();
CHECK_TRUE(text_is_truncated);
static constexpr auto text_is_secure = text_copy.is_secure();
CHECK_FALSE(text_is_secure);
static constexpr Text::const_pointer text_data = text_copy.data();
CHECK_EQUAL(&text_pointer[0], text_data);
static constexpr Text::const_pointer text_data_end = text_copy.data_end();
CHECK_EQUAL(&text_pointer[Length], text_data_end);
static constexpr auto text_begin = text_copy.begin();
CHECK_EQUAL(&text_pointer[0], text_begin);
static constexpr auto text_cbegin = text_copy.cbegin();
CHECK_EQUAL(&text_pointer[0], text_cbegin);
static constexpr auto text_rbegin = text_copy.rbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_rbegin));
static constexpr auto text_crbegin = text_copy.crbegin();
CHECK_EQUAL(&text_pointer[Length - 1], etl::addressof(*text_crbegin));
static constexpr auto text_end = text_copy.end();
CHECK_EQUAL(&text_pointer[Length], text_end);
static constexpr auto text_cend = text_copy.cend();
CHECK_EQUAL(&text_pointer[Length], text_cend);
static constexpr auto text_rend = text_copy.rend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_rend));
static constexpr auto text_crend = text_copy.crend();
CHECK_EQUAL(&text_pointer[0] - 1, etl::addressof(*text_crend));
bool is_equal = Equal(std::wstring(text_pointer), text);
CHECK(is_equal);
}
//*************************************************************************
TEST(test_begin)
{
static constexpr Text::const_iterator p_begin = text.begin();
static constexpr Text::const_iterator p_cbegin = text.cbegin();
CHECK_EQUAL(&text_pointer[0], p_begin);
CHECK_EQUAL(&text_pointer[0], p_cbegin);
}
//*************************************************************************
TEST(test_index)
{
static constexpr Text::value_type c0 = text[0];
static constexpr Text::value_type c1 = text[1];
static constexpr Text::value_type c2 = text[2];
static constexpr Text::value_type c3 = text[3];
static constexpr Text::value_type c4 = text[4];
static constexpr Text::value_type c5 = text[5];
static constexpr Text::value_type c6 = text[6];
static constexpr Text::value_type c7 = text[7];
static constexpr Text::value_type c8 = text[8];
static constexpr Text::value_type c9 = text[9];
static constexpr Text::value_type c10 = text[10];
static constexpr Text::value_type c11 = text[11];
CHECK_EQUAL(text_pointer[0], c0);
CHECK_EQUAL(text_pointer[1], c1);
CHECK_EQUAL(text_pointer[2], c2);
CHECK_EQUAL(text_pointer[3], c3);
CHECK_EQUAL(text_pointer[4], c4);
CHECK_EQUAL(text_pointer[5], c5);
CHECK_EQUAL(text_pointer[6], c6);
CHECK_EQUAL(text_pointer[7], c7);
CHECK_EQUAL(text_pointer[8], c8);
CHECK_EQUAL(text_pointer[9], c9);
CHECK_EQUAL(text_pointer[10], c10);
CHECK_EQUAL(text_pointer[11], c11);
}
//*************************************************************************
TEST(test_at)
{
static constexpr Text::value_type c0 = text.at(0);
static constexpr Text::value_type c1 = text.at(1);
static constexpr Text::value_type c2 = text.at(2);
static constexpr Text::value_type c3 = text.at(3);
static constexpr Text::value_type c4 = text.at(4);
static constexpr Text::value_type c5 = text.at(5);
static constexpr Text::value_type c6 = text.at(6);
static constexpr Text::value_type c7 = text.at(7);
static constexpr Text::value_type c8 = text.at(8);
static constexpr Text::value_type c9 = text.at(9);
static constexpr Text::value_type c10 = text.at(10);
CHECK_EQUAL(text_pointer[0], c0);
CHECK_EQUAL(text_pointer[1], c1);
CHECK_EQUAL(text_pointer[2], c2);
CHECK_EQUAL(text_pointer[3], c3);
CHECK_EQUAL(text_pointer[4], c4);
CHECK_EQUAL(text_pointer[5], c5);
CHECK_EQUAL(text_pointer[6], c6);
CHECK_EQUAL(text_pointer[7], c7);
CHECK_EQUAL(text_pointer[8], c8);
CHECK_EQUAL(text_pointer[9], c9);
CHECK_EQUAL(text_pointer[10], c10);
}
//*************************************************************************
TEST(test_front)
{
CHECK_TRUE(text_pointer[0] == text.front());
}
//*************************************************************************
TEST(test_back)
{
CHECK_TRUE(text_pointer[Length - 1] == text.back());
}
//*************************************************************************
TEST(test_data)
{
static constexpr Text::const_pointer p_data = text.data();
CHECK_EQUAL(&text[0], p_data);
}
//*************************************************************************
TEST(test_data_end)
{
static constexpr Text::const_pointer p_data = text.data_end();
CHECK_EQUAL(&text[Length], p_data);
}
//*************************************************************************
TEST(test_c_str)
{
static constexpr Text::const_pointer p_data = text.c_str();
CHECK_EQUAL(&text[0], p_data);
CHECK_EQUAL(Length, etl::strlen(p_data));
}
//*************************************************************************
TEST(test_const_iterator)
{
static constexpr Text::const_iterator itr = text.begin();
Text::const_iterator begin = text.begin();
Text::const_iterator end = text.end();
bool is_equal = std::equal(begin, end, itr);
CHECK_TRUE(is_equal);
}
//*************************************************************************
TEST(test_const_reverse_iterator)
{
static constexpr Text::const_reverse_iterator ritr = text.rbegin();
etl::reverse_iterator<Text::const_pointer> rbegin(text_pointer + Length);
etl::reverse_iterator<Text::const_pointer> rend(text_pointer);
bool is_equal = std::equal(rbegin, rend, ritr);
CHECK_TRUE(is_equal);
}
//*************************************************************************
TEST(test_to_view)
{
static constexpr View view(text);
CHECK_TRUE(text.begin() == view.begin());
CHECK_TRUE(text.end() == view.end());
bool is_equal = std::equal(text.begin(), text.end(), view.begin());
CHECK_TRUE(is_equal);
}
//*************************************************************************
#if ETL_USING_STL
TEST(test_write_string_to_std_basic_ostream)
{
Text text1(STR("Hello World"));
std::wstringstream sstream;
sstream << text1;
TextSTD sstream_string = sstream.str();
View sstream_view(sstream_string.data(), sstream_string.size());
CHECK(text1 == sstream_view);
}
#endif
};
}
#endif

View File

@ -1403,7 +1403,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1429,7 +1429,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS;ETL_NO_STL;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS;ETL_NO_STL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1455,7 +1455,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03_IMPLEMENTATION;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03_IMPLEMENTATION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1481,7 +1481,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03_IMPLEMENTATION;ETL_MESSAGES_ARE_NOT_VIRTUAL;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_FORCE_TEST_CPP03_IMPLEMENTATION;ETL_MESSAGES_ARE_NOT_VIRTUAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1507,7 +1507,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_MESSAGES_ARE_NOT_VIRTUAL;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_MESSAGES_ARE_NOT_VIRTUAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1533,7 +1533,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_IMESSAGE_IS_NON_VIRTUAL;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_IMESSAGE_IS_NON_VIRTUAL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1559,7 +1559,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1585,7 +1585,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1611,7 +1611,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1636,7 +1636,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1661,7 +1661,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;ETL_FORCE_STD_INITIALIZER_LIST;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;ETL_FORCE_STD_INITIALIZER_LIST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1686,7 +1686,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;ETL_FORCE_STD_INITIALIZER_LIST;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;ETL_FORCE_STD_INITIALIZER_LIST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1711,7 +1711,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;ETL_FORCE_STD_INITIALIZER_LIST;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;ETL_FORCE_STD_INITIALIZER_LIST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1737,7 +1737,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;ETL_FORCE_STD_INITIALIZER_LIST;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;ETL_FORCE_STD_INITIALIZER_LIST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -1948,7 +1948,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING;ETL_NO_STL;ETL_FORCE_STD_INITIALIZER_LIST;%(PreprocessorDefinitions);N = 123456789;N</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING;ETL_NO_STL;ETL_FORCE_STD_INITIALIZER_LIST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>./;../../../unittest-cpp/;../../include;../../test</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -3293,11 +3293,16 @@
<ClInclude Include="..\..\include\etl\combinations.h" />
<ClInclude Include="..\..\include\etl\compare.h" />
<ClInclude Include="..\..\include\etl\constant.h" />
<ClInclude Include="..\..\include\etl\const_basic_string.h" />
<ClInclude Include="..\..\include\etl\const_map.h" />
<ClInclude Include="..\..\include\etl\const_multimap.h" />
<ClInclude Include="..\..\include\etl\const_multiset.h" />
<ClInclude Include="..\..\include\etl\const_set.h" />
<ClInclude Include="..\..\include\etl\const_string.h" />
<ClInclude Include="..\..\include\etl\const_u16string.h" />
<ClInclude Include="..\..\include\etl\const_u32string.h" />
<ClInclude Include="..\..\include\etl\const_u8string.h" />
<ClInclude Include="..\..\include\etl\const_wstring.h" />
<ClInclude Include="..\..\include\etl\correlation.h" />
<ClInclude Include="..\..\include\etl\covariance.h" />
<ClInclude Include="..\..\include\etl\crc.h" />
@ -9333,6 +9338,10 @@
<ClCompile Include="..\test_const_set_ext.cpp" />
<ClCompile Include="..\test_const_set_ext_constexpr.cpp" />
<ClCompile Include="..\test_const_string_char.cpp" />
<ClCompile Include="..\test_const_string_u16.cpp" />
<ClCompile Include="..\test_const_string_u32.cpp" />
<ClCompile Include="..\test_const_string_u8.cpp" />
<ClCompile Include="..\test_const_string_wchar_t.cpp" />
<ClCompile Include="..\test_correlation.cpp" />
<ClCompile Include="..\test_covariance.cpp" />
<ClCompile Include="..\test_crc1.cpp" />

View File

@ -1533,6 +1533,21 @@
<ClInclude Include="..\..\include\etl\const_string.h">
<Filter>ETL\Strings</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\const_wstring.h">
<Filter>ETL\Strings</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\const_u16string.h">
<Filter>ETL\Strings</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\const_u32string.h">
<Filter>ETL\Strings</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\const_u8string.h">
<Filter>ETL\Strings</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\const_basic_string.h">
<Filter>ETL\Strings</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\test_string_char.cpp">
@ -3695,6 +3710,18 @@
<ClCompile Include="..\test_const_string_char.cpp">
<Filter>Tests\Strings</Filter>
</ClCompile>
<ClCompile Include="..\test_const_string_wchar_t.cpp">
<Filter>Tests\Strings</Filter>
</ClCompile>
<ClCompile Include="..\test_const_string_u16.cpp">
<Filter>Tests\Strings</Filter>
</ClCompile>
<ClCompile Include="..\test_const_string_u32.cpp">
<Filter>Tests\Strings</Filter>
</ClCompile>
<ClCompile Include="..\test_const_string_u8.cpp">
<Filter>Tests\Strings</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\library.properties">
@ -3853,6 +3880,12 @@
<None Include="..\..\CONTRIBUTING.md">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\scripts\convert_headers_to_use_guards.bat">
<Filter>Tests</Filter>
</None>
<None Include="..\..\scripts\convert_headers_to_use_once.bat">
<Filter>Tests</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\support\Release notes.txt">
@ -3891,6 +3924,7 @@
<Text Include="..\syntax_check\CMakeLists.txt">
<Filter>Tests\Syntax Checks</Filter>
</Text>
<Text Include="..\..\Converting header guards.txt" />
</ItemGroup>
<ItemGroup>
<Image Include="..\..\etl.ico">