mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-26 20:38:45 +08:00
Merge branch 'feature/#962-Request--allow-(overload)-string-append-a-string_view' into development
# Conflicts: # include/etl/basic_string.h
This commit is contained in:
commit
f2099b5403
@ -500,6 +500,22 @@ namespace etl
|
||||
cleanup();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Resizes the string and overwrites to data using the operation.
|
||||
//*********************************************************************
|
||||
template <typename TOperation>
|
||||
void resize_and_overwrite(size_type new_size, TOperation operation)
|
||||
{
|
||||
if (new_size > CAPACITY)
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(string_out_of_bounds));
|
||||
}
|
||||
|
||||
current_size = operation(p_buffer, new_size);
|
||||
p_buffer[current_size] = '\0';
|
||||
cleanup();
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Resizes the string, but doesn't initialise the free space
|
||||
/// except for a terminator null.
|
||||
@ -702,6 +718,36 @@ namespace etl
|
||||
assign(other, other + length_);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Assigns values to the string from a view.
|
||||
//*********************************************************************
|
||||
template <typename TOtherTraits>
|
||||
void assign(const etl::basic_string_view<T, TOtherTraits>& view)
|
||||
{
|
||||
assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Assigns values to the string.
|
||||
/// Truncates if the string does not have enough free space.
|
||||
///\param other The other string.
|
||||
//*********************************************************************
|
||||
void assign(const_pointer other)
|
||||
{
|
||||
assign(other, other + etl::strlen(other));
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Assigns values to the string.
|
||||
/// Truncates if the string does not have enough free space.
|
||||
///\param other The other string.
|
||||
///\param length The length to copy.
|
||||
//*********************************************************************
|
||||
void assign(const_pointer other, size_type length_)
|
||||
{
|
||||
assign(other, other + length_);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Assigns values to the string from a view.
|
||||
//*********************************************************************
|
||||
@ -876,26 +922,13 @@ namespace etl
|
||||
/// Appends to the string.
|
||||
///\param view An etl::string_view.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
ibasic_string& append(const etl::basic_string_view<T, TTraits>& view)
|
||||
template <typename TOtherTraits>
|
||||
ibasic_string& append(const etl::basic_string_view<T, TOtherTraits>& view)
|
||||
{
|
||||
insert(end(), view.begin(), view.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*********************************************************************
|
||||
/// Appends to the string.
|
||||
///\param view A std::string_view.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
ibasic_string& append(const std::basic_string_view<T, TTraits>& view)
|
||||
{
|
||||
insert(end(), view.begin(), view.end());
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a value to the string.
|
||||
///\param position The position to insert before.
|
||||
@ -1132,26 +1165,12 @@ namespace etl
|
||||
///\param position The position to insert before.
|
||||
///\param view The view element to add.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
iterator insert(const_iterator position, const etl::basic_string_view<T, TTraits>& view)
|
||||
template <typename TOtherTraits>
|
||||
iterator insert(const_iterator position, const etl::basic_string_view<T, TOtherTraits>& view)
|
||||
{
|
||||
return insert(position, view.begin(), view.end());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*********************************************************************
|
||||
/// Inserts a view to the string.
|
||||
/// If asserts or exceptions are enabled, emits string_full if the string does not have enough free space.
|
||||
///\param position The position to insert before.
|
||||
///\param view The view element to add.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
iterator insert(const_iterator position, const std::basic_string_view<T, TTraits>& view)
|
||||
{
|
||||
return insert(position, view.begin(), view.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a string at the specified position.
|
||||
///\param position The position to insert before.
|
||||
@ -1177,6 +1196,21 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a string at the specified position.
|
||||
///\param position The position to insert before.
|
||||
///\param view The view to insert.
|
||||
//*********************************************************************
|
||||
template <typename TOtherTraits>
|
||||
etl::ibasic_string<T>& insert(size_type position, const etl::basic_string_view<T, TOtherTraits>& view)
|
||||
{
|
||||
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
insert(begin() + position, view.cbegin(), view.cend());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a string at the specified position from subposition for sublength.
|
||||
///\param position The position to insert before.
|
||||
@ -1186,7 +1220,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
etl::ibasic_string<T>& insert(size_type position, const etl::ibasic_string<T>& str, size_type subposition, size_type sublength)
|
||||
{
|
||||
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
|
||||
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
|
||||
ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
if ((sublength == npos) || (subposition + sublength > str.size()))
|
||||
@ -1210,6 +1244,29 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a view at the specified position from subposition for sublength.
|
||||
///\param position The position to insert before.
|
||||
///\param view The view to insert.
|
||||
///\param subposition The subposition to start from.
|
||||
///\param sublength The number of characters to insert.
|
||||
//*********************************************************************
|
||||
template <typename TOtherTraits>
|
||||
etl::ibasic_string<T>& insert(size_type position, const etl::basic_string_view<T, TOtherTraits>& view, size_type subposition, size_type sublength)
|
||||
{
|
||||
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
|
||||
ETL_ASSERT(subposition <= view.size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
if ((sublength == npos) || (subposition + sublength > view.size()))
|
||||
{
|
||||
sublength = view.size() - subposition;
|
||||
}
|
||||
|
||||
insert(begin() + position, view.cbegin() + subposition, view.cbegin() + subposition + sublength);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Inserts a string at the specified position from pointer.
|
||||
///\param position The position to insert before.
|
||||
@ -1370,6 +1427,17 @@ namespace etl
|
||||
return find_impl(str.begin(), str.end(), str.size(), pos);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find content within the string
|
||||
///\param view The content to find
|
||||
///\param pos The position to start searching from.
|
||||
//*********************************************************************
|
||||
template <typename TOtherTraits>
|
||||
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);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find content within the string
|
||||
///\param view The content to find
|
||||
@ -1448,6 +1516,17 @@ namespace etl
|
||||
return rfind_impl(str.rbegin(), str.rend(), str.size(), position);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find content within the string
|
||||
///\param view The content to find
|
||||
///\param pos The position to start searching from.
|
||||
//*********************************************************************
|
||||
template <typename TOtherTraits>
|
||||
size_type rfind(const etl::basic_string_view<T, TOtherTraits>& view, size_type pos = 0) const
|
||||
{
|
||||
return rfind_impl(view.rbegin(), view.rend(), view.size(), pos);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Find content within the string
|
||||
///\param view The content to find
|
||||
@ -1526,6 +1605,124 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that the string is within this string
|
||||
//*********************************************************************
|
||||
bool contains(const etl::ibasic_string<T>& str) const
|
||||
{
|
||||
return find(str) != npos;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that the view is within this string
|
||||
//*********************************************************************
|
||||
template <typename TOtherTraits>
|
||||
bool contains(const etl::basic_string_view<T, TOtherTraits>& view) const
|
||||
{
|
||||
return find(view) != npos;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that text is within this string
|
||||
//*********************************************************************
|
||||
bool contains(const_pointer s) const
|
||||
{
|
||||
return find(s) != npos;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that character is within this string
|
||||
//*********************************************************************
|
||||
bool contains(value_type c) const
|
||||
{
|
||||
return find(c) != npos;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that the string is the start of this string
|
||||
//*********************************************************************
|
||||
bool starts_with(const etl::ibasic_string<T>& str) const
|
||||
{
|
||||
return compare(0, str.size(), str) == 0;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that the view is the start of this string
|
||||
//*********************************************************************
|
||||
template <typename TOtherTraits>
|
||||
bool starts_with(const etl::basic_string_view<T, TOtherTraits>& view) const
|
||||
{
|
||||
return compare(0, view.size(), view) == 0;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that the string is the start of this string
|
||||
//*********************************************************************
|
||||
bool starts_with(const_pointer s) const
|
||||
{
|
||||
size_t len = etl::strlen(s);
|
||||
|
||||
return compare(0, len, s, len) == 0;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that the character is the start of this string
|
||||
//*********************************************************************
|
||||
bool starts_with(value_type c) const
|
||||
{
|
||||
return !empty() && (front() == c);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that the string is the end of this string
|
||||
//*********************************************************************
|
||||
bool ends_with(const etl::ibasic_string<T>& str) const
|
||||
{
|
||||
if (str.size() > size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return compare(size() - str.size(), str.size(), str) == 0;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that the view is the end of this string
|
||||
//*********************************************************************
|
||||
template <typename TOtherTraits>
|
||||
bool ends_with(const etl::basic_string_view<T, TOtherTraits>& view) const
|
||||
{
|
||||
if (view.size() > size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return compare(size() - view.size(), view.size(), view) == 0;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that the string is the end of this string
|
||||
//*********************************************************************
|
||||
bool ends_with(const_pointer s) const
|
||||
{
|
||||
size_t len = etl::strlen(s);
|
||||
|
||||
if (len > size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return compare(size() - len, len, s, len) == 0;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that the character is the end of this string
|
||||
//*********************************************************************
|
||||
bool ends_with(value_type c) const
|
||||
{
|
||||
return !empty() && (back() == c);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Replace 'length' characters from 'position' with 'str'.
|
||||
///\param position The position to start from.
|
||||
@ -1554,8 +1751,8 @@ namespace etl
|
||||
///\param length The number of characters to replace.
|
||||
///\param view The string to replace it with.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
ibasic_string& replace(size_type position, size_type length_, const etl::basic_string_view<T, TTraits>& view)
|
||||
template <typename TOtherTraits>
|
||||
ibasic_string& replace(size_type position, size_type length_, const etl::basic_string_view<T, TOtherTraits>& view)
|
||||
{
|
||||
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
@ -1571,31 +1768,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*********************************************************************
|
||||
/// Replace 'length' characters from 'position' with 'view'.
|
||||
///\param position The position to start from.
|
||||
///\param length The number of characters to replace.
|
||||
///\param view The string to replace it with.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
ibasic_string& replace(size_type position, size_type length_, const std::basic_string_view<T, TTraits>& view)
|
||||
{
|
||||
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
// Limit the length.
|
||||
length_ = etl::min(length_, size() - position);
|
||||
|
||||
// Erase the bit we want to replace.
|
||||
erase(position, length_);
|
||||
|
||||
// Insert the new stuff.
|
||||
insert(position, view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************************************************
|
||||
/// Replace characters from 'first' to one before 'last' with 'str'.
|
||||
///\param first The position to start from.
|
||||
@ -1634,8 +1806,8 @@ namespace etl
|
||||
///\param last The one after the position to end at.
|
||||
///\param view The string view to replace it with.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
ibasic_string& replace(const_iterator first, const_iterator last, const etl::basic_string_view<T, TTraits>& view)
|
||||
template <typename TOtherTraits>
|
||||
ibasic_string& replace(const_iterator first, const_iterator last, const etl::basic_string_view<T, TOtherTraits>& view)
|
||||
{
|
||||
// Quick hack, as iterators are pointers.
|
||||
iterator first_ = to_iterator(first);
|
||||
@ -1650,30 +1822,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*********************************************************************
|
||||
/// Replace characters from 'first' to one before 'last' with 'view'.
|
||||
///\param first The position to start from.
|
||||
///\param last The one after the position to end at.
|
||||
///\param view The string view to replace it with.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
ibasic_string& replace(const_iterator first, const_iterator last, const std::basic_string_view<T, TTraits>& view)
|
||||
{
|
||||
// Quick hack, as iterators are pointers.
|
||||
iterator first_ = to_iterator(first);
|
||||
iterator last_ = to_iterator(last);
|
||||
|
||||
// Erase the bit we want to replace.
|
||||
erase(first_, last_);
|
||||
|
||||
// Insert the new stuff.
|
||||
insert(first_, view.begin(), view.end());
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************************************************
|
||||
/// Replace characters from 'position' of 'length' with 'str' from 'subposition' of 'sublength'.
|
||||
//*********************************************************************
|
||||
@ -1709,8 +1857,8 @@ namespace etl
|
||||
//*********************************************************************
|
||||
/// Replace characters from 'position' of 'length' with 'view' from 'subposition' of 'sublength'.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
ibasic_string& replace(size_type position, size_type length_, const etl::basic_string_view<T, TTraits>& view, size_type subposition, size_type sublength)
|
||||
template <typename TOtherTraits>
|
||||
ibasic_string& replace(size_type position, size_type length_, const etl::basic_string_view<T, TOtherTraits>& view, size_type subposition, size_type sublength)
|
||||
{
|
||||
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
|
||||
ETL_ASSERT(subposition <= view.size(), ETL_ERROR(string_out_of_bounds));
|
||||
@ -1728,30 +1876,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*********************************************************************
|
||||
/// Replace characters from 'position' of 'length' with 'view' from 'subposition' of 'sublength'.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
ibasic_string& replace(size_type position, size_type length_, const std::basic_string_view<T, TTraits>& view, size_type subposition, size_type sublength)
|
||||
{
|
||||
ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds));
|
||||
ETL_ASSERT(subposition <= view.size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
// Limit the lengths.
|
||||
length_ = etl::min(length_, size() - position);
|
||||
sublength = etl::min(sublength, view.size() - subposition);
|
||||
|
||||
// Erase the bit we want to replace.
|
||||
erase(position, length_);
|
||||
|
||||
// Insert the new stuff.
|
||||
insert(position, view, subposition, sublength);
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************************************************
|
||||
/// Replace characters from 'position' of 'length' with pointed to string.
|
||||
//*********************************************************************
|
||||
@ -1896,29 +2020,15 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Compare with etl::basic_string_view.
|
||||
//*************************************************************************
|
||||
template <typename TTraits>
|
||||
int compare(const etl::basic_string_view<T, TTraits>& view) const
|
||||
template <typename TOtherTraits>
|
||||
int compare(const etl::basic_string_view<T, TOtherTraits>& view) const
|
||||
{
|
||||
return compare(p_buffer,
|
||||
p_buffer + view.size(),
|
||||
p_buffer + size(),
|
||||
view.data(),
|
||||
view.size());
|
||||
view.data() + view.size());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// Compare with std::basic_string_view.
|
||||
//*************************************************************************
|
||||
template <typename TTraits>
|
||||
int compare(const std::basic_string_view<T, TTraits>& view) const
|
||||
{
|
||||
return compare(p_buffer,
|
||||
p_buffer + view.size(),
|
||||
view.data(),
|
||||
view.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Compare position / length with string.
|
||||
//*************************************************************************
|
||||
@ -1938,29 +2048,15 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Compare position / length with etl::basic_string_view.
|
||||
//*************************************************************************
|
||||
template <typename TTraits>
|
||||
int compare(size_type position, size_type length_, const etl::basic_string_view<T, TTraits>& view) const
|
||||
template <typename TOtherTraits>
|
||||
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_,
|
||||
view.p_buffer,
|
||||
view.p_buffer + view.size());
|
||||
view.data(),
|
||||
view.data() + view.size());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// Compare position / length with std::basic_string_view.
|
||||
//*************************************************************************
|
||||
template <typename TTraits>
|
||||
int compare(size_type position, size_type length_, const std::basic_string_view<T, TTraits>& view) const
|
||||
{
|
||||
return compare(p_buffer + position,
|
||||
p_buffer + position + length_,
|
||||
view.p_buffer,
|
||||
view.p_buffer + view.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Compare position / length with string / subposition / sublength.
|
||||
//*************************************************************************
|
||||
@ -1982,8 +2078,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Compare position / length with etl::basic_string_view. / subposition / sublength.
|
||||
//*************************************************************************
|
||||
template <typename TTraits>
|
||||
int compare(size_type position, size_type length_, const etl::basic_string_view<T, TTraits>& view, size_type subposition, size_type sublength) const
|
||||
template <typename TOtherTraits>
|
||||
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));
|
||||
@ -1994,31 +2090,10 @@ namespace etl
|
||||
|
||||
return compare(p_buffer + position,
|
||||
p_buffer + position + length_,
|
||||
view.p_buffer + subposition,
|
||||
view.p_buffer + subposition + sublength);
|
||||
view.data() + subposition,
|
||||
view.data() + subposition + sublength);
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// Compare position / length with std::basic_string_view. / subposition / sublength.
|
||||
//*************************************************************************
|
||||
template <typename TTraits>
|
||||
int compare(size_type position, size_type length_, const std::basic_string_view<T, TTraits>& 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));
|
||||
|
||||
// Limit the lengths.
|
||||
length_ = etl::min(length_, size() - position);
|
||||
sublength = etl::min(sublength, view.size() - subposition);
|
||||
|
||||
return compare(p_buffer + position,
|
||||
p_buffer + position + length_,
|
||||
view.p_buffer + subposition,
|
||||
view.p_buffer + subposition + sublength);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Compare with C string
|
||||
//*************************************************************************
|
||||
@ -2077,25 +2152,12 @@ namespace etl
|
||||
///\param view The content to find
|
||||
///\param pos The position to start searching from.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
size_type find_first_of(const etl::basic_string_view<T, TTraits>& view, size_type position = 0) const
|
||||
template <typename TOtherTraits>
|
||||
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());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*********************************************************************
|
||||
/// Find first of any of content within the string
|
||||
///\param view The content to find
|
||||
///\param pos The position to start searching from.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
size_type find_first_of(const std::basic_string_view<T, TTraits>& view, size_type position = 0) const
|
||||
{
|
||||
return find_first_of(view.data(), position, view.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************************************************
|
||||
/// Find first of any of content within the string
|
||||
///\param s Pointer to the content to find
|
||||
@ -2167,25 +2229,12 @@ namespace etl
|
||||
///\param view The content to find
|
||||
///\param pos The position to start searching from.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
size_type find_last_of(const etl::basic_string_view<T, TTraits>& view, size_type position = 0) const
|
||||
template <typename TOtherTraits>
|
||||
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());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*********************************************************************
|
||||
/// Find last of any of content within the string
|
||||
///\param view The content to find
|
||||
///\param pos The position to start searching from.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
size_type find_last_of(const std::basic_string_view<T, TTraits>& view, size_type position = 0) const
|
||||
{
|
||||
return find_last_of(view.data(), position, view.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************************************************
|
||||
/// Find last of any of content within the string
|
||||
///\param s Pointer to the content to find
|
||||
@ -2275,25 +2324,12 @@ namespace etl
|
||||
///\param view The content to find
|
||||
///\param pos The position to start searching from.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
size_type find_first_not_of(const etl::basic_string_view<T, TTraits>& view, size_type position = 0) const
|
||||
template <typename TOtherTraits>
|
||||
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());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*********************************************************************
|
||||
/// Find first not of any of content within the string
|
||||
///\param view The content to find
|
||||
///\param pos The position to start searching from.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
size_type find_first_not_of(const std::basic_string_view<T, TTraits>& view, size_type position = 0) const
|
||||
{
|
||||
return find_first_not_of(view.data(), position, view.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************************************************
|
||||
/// Find first not of any of content within the string
|
||||
///\param s Pointer to the content to not find
|
||||
@ -2372,25 +2408,12 @@ namespace etl
|
||||
///\param view The content to find
|
||||
///\param pos The position to start searching from.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
size_type find_last_not_of(const etl::basic_string_view<T, TTraits>& view, size_type position = 0) const
|
||||
template <typename TOtherTraits>
|
||||
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());
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*********************************************************************
|
||||
/// Find last not of any of content within the string
|
||||
///\param view The content to find
|
||||
///\param pos The position to start searching from.
|
||||
//*********************************************************************
|
||||
template <typename TTraits>
|
||||
size_type find_last_not_of(const std::basic_string_view<T, TTraits>& view, size_type position = 0) const
|
||||
{
|
||||
return find_last_not_of(view.data(), position, view.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*********************************************************************
|
||||
/// Find last not of any of content within the string
|
||||
///\param s The pointer to the content to find
|
||||
@ -2483,6 +2506,17 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
template <typename TOtherTraits>
|
||||
ibasic_string& operator = (const etl::basic_string_view<T, TOtherTraits>& view)
|
||||
{
|
||||
assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// += operator.
|
||||
//*************************************************************************
|
||||
@ -2496,27 +2530,14 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// += operator.
|
||||
//*************************************************************************
|
||||
template <typename TTraits>
|
||||
ibasic_string& operator += (const etl::basic_string_view<T, TTraits>& rhs)
|
||||
template <typename TOtherTraits>
|
||||
ibasic_string& operator += (const etl::basic_string_view<T, TOtherTraits>& rhs)
|
||||
{
|
||||
append(rhs);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// += operator.
|
||||
//*************************************************************************
|
||||
template <typename TTraits>
|
||||
ibasic_string& operator += (const std::basic_string_view<T, TTraits>& rhs)
|
||||
{
|
||||
append(rhs);
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// += operator.
|
||||
//*************************************************************************
|
||||
@ -2607,7 +2628,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Compare helper function
|
||||
//*************************************************************************
|
||||
int compare(const_pointer first1, const_pointer last1, const_pointer first2, const_pointer last2) const
|
||||
int compare(const_pointer first1, const_pointer last1, const_pointer first2, const_pointer last2) const
|
||||
{
|
||||
while ((first1 != last1) && (first2 != last2))
|
||||
{
|
||||
|
||||
@ -134,7 +134,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
pointer operator ->()
|
||||
{
|
||||
return &operator*();
|
||||
return p_value;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -142,7 +142,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_pointer operator ->() const
|
||||
{
|
||||
return &operator*();
|
||||
return p_value;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -244,6 +244,16 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
string& operator = (const etl::string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
@ -362,6 +372,16 @@ namespace etl
|
||||
this->resize(count, c);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit string_ext(const etl::string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from an iterator range.
|
||||
///\tparam TIterator The iterator type.
|
||||
@ -386,16 +406,6 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit string_ext(const etl::string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: istring(buffer, buffer_size - 1U)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -409,7 +419,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -433,6 +442,16 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
string_ext& operator = (const etl::string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
|
||||
@ -43,6 +43,10 @@ SOFTWARE.
|
||||
#include "algorithm.h"
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
@ -96,9 +100,9 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef TTraits traits_type;
|
||||
typedef size_t size_type;
|
||||
typedef T value_type;
|
||||
typedef TTraits traits_type;
|
||||
typedef size_t size_type;
|
||||
typedef const T& const_reference;
|
||||
typedef const T* const_pointer;
|
||||
typedef const T* const_iterator;
|
||||
@ -163,6 +167,18 @@ namespace etl
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
/// Constructor from std::basic string_view
|
||||
//*************************************************************************
|
||||
template <typename TStdTraits>
|
||||
explicit ETL_CONSTEXPR basic_string_view(const std::basic_string_view<T, TStdTraits>& other) ETL_NOEXCEPT
|
||||
: mbegin(other.data())
|
||||
, mend(other.data() + other.size())
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the first element.
|
||||
//*************************************************************************
|
||||
@ -747,6 +763,30 @@ namespace etl
|
||||
return find_last_not_of(etl::basic_string_view<T, TTraits>(text), position);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that the view is within this string
|
||||
//*********************************************************************
|
||||
bool contains(const etl::basic_string_view<T, TTraits>& view) const
|
||||
{
|
||||
return find(view) != npos;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that text is within this string
|
||||
//*********************************************************************
|
||||
bool contains(const_pointer s) const
|
||||
{
|
||||
return find(s) != npos;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
/// Checks that character is within this string
|
||||
//*********************************************************************
|
||||
bool contains(value_type c) const
|
||||
{
|
||||
return find(c) != npos;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Equality for string_view.
|
||||
//*************************************************************************
|
||||
|
||||
@ -227,6 +227,16 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u16string& operator = (const etl::u16string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
@ -366,8 +376,8 @@ namespace etl
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// From u16string_view.
|
||||
///\param view The u16string_view.
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit u16string_ext(const etl::u16string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iu16string(buffer, buffer_size - 1U)
|
||||
@ -388,7 +398,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -412,6 +421,16 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u16string_ext& operator = (const etl::u16string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
|
||||
@ -227,6 +227,16 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u32string& operator = (const etl::u32string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
@ -366,8 +376,8 @@ namespace etl
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// From u32string_view.
|
||||
///\param view The u32string_view.
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit u32string_ext(const etl::u32string_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iu32string(buffer, buffer_size - 1U)
|
||||
@ -388,7 +398,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -412,6 +421,16 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u32string_ext& operator = (const etl::u32string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
|
||||
@ -244,6 +244,16 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u8string& operator = (const etl::u8string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
@ -409,7 +419,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -433,6 +442,16 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
u8string_ext& operator = (const etl::u8string_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
|
||||
@ -227,6 +227,16 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
wstring& operator = (const etl::wstring_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
@ -366,8 +376,8 @@ namespace etl
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// From wstring_view.
|
||||
///\param view The wstring_view.
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit wstring_ext(const etl::wstring_view& view, value_type* buffer, size_type buffer_size)
|
||||
: iwstring(buffer, buffer_size - 1U)
|
||||
@ -388,7 +398,6 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
@ -412,6 +421,16 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
wstring_ext& operator = (const etl::wstring_view& view)
|
||||
{
|
||||
this->assign(view);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
|
||||
@ -154,9 +154,9 @@ fi
|
||||
# Set the sanitizer enable. Default OFF
|
||||
#******************************************************************************
|
||||
if [ "$4" = "S" ]; then
|
||||
sanitize="ON"
|
||||
sanitize="On"
|
||||
else
|
||||
sanitize="OFF"
|
||||
sanitize="Off"
|
||||
fi
|
||||
|
||||
#******************************************************************************
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -31,6 +31,7 @@ SOFTWARE.
|
||||
#include "etl/string_view.h"
|
||||
#include "etl/string.h"
|
||||
#include "etl/wstring.h"
|
||||
#include "etl/u8string.h"
|
||||
#include "etl/u16string.h"
|
||||
#include "etl/u32string.h"
|
||||
#include "etl/hash.h"
|
||||
@ -45,12 +46,18 @@ namespace
|
||||
{
|
||||
using View = etl::string_view;
|
||||
using WView = etl::wstring_view;
|
||||
#if ETL_USING_CPP20
|
||||
using U8View = etl::u8string_view;
|
||||
#endif
|
||||
using U16View = etl::u16string_view;
|
||||
using U32View = etl::u32string_view;
|
||||
|
||||
etl::string<11> etltext = "Hello World";
|
||||
std::string text = "Hello World";
|
||||
std::wstring wtext = L"Hello World";
|
||||
#if ETL_USING_CPP20
|
||||
std::u8string u8text = u8"Hello World";
|
||||
#endif
|
||||
std::u16string u16text = u"Hello World";
|
||||
std::u32string u32text = U"Hello World";
|
||||
std::string text_smaller = "Hello Worlc";
|
||||
@ -162,6 +169,86 @@ namespace
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_from_std_string_view)
|
||||
{
|
||||
std::string_view stdview(text.data(), text.size());
|
||||
|
||||
View view(stdview);
|
||||
|
||||
CHECK(stdview.size() == view.size());
|
||||
CHECK(stdview.size() == view.max_size());
|
||||
|
||||
bool isEqual = std::equal(view.begin(), view.end(), stdview.begin());
|
||||
CHECK(isEqual);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_from_std_wstring_view)
|
||||
{
|
||||
std::wstring_view stdview(wtext.data(), wtext.size());
|
||||
|
||||
WView view(stdview);
|
||||
|
||||
CHECK(stdview.size() == view.size());
|
||||
CHECK(stdview.size() == view.max_size());
|
||||
|
||||
bool isEqual = std::equal(view.begin(), view.end(), stdview.begin());
|
||||
CHECK(isEqual);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP20
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_from_std_u8string_view)
|
||||
{
|
||||
std::u8string_view stdview(u8text.begin(), u8text.end());
|
||||
|
||||
U8View view(stdview);
|
||||
|
||||
CHECK(stdview.size() == view.size());
|
||||
CHECK(stdview.size() == view.max_size());
|
||||
|
||||
bool isEqual = std::equal(view.begin(), view.end(), stdview.begin());
|
||||
CHECK(isEqual);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_from_std_u16string_view)
|
||||
{
|
||||
std::u16string_view stdview(u16text.data(), u16text.size());
|
||||
|
||||
U16View view(stdview);
|
||||
|
||||
CHECK(stdview.size() == view.size());
|
||||
CHECK(stdview.size() == view.max_size());
|
||||
|
||||
bool isEqual = std::equal(view.begin(), view.end(), stdview.begin());
|
||||
CHECK(isEqual);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_from_std_u32string_view)
|
||||
{
|
||||
std::u32string_view stdview(u32text.data(), u32text.size());
|
||||
|
||||
U32View view(stdview);
|
||||
|
||||
CHECK(stdview.size() == view.size());
|
||||
CHECK(stdview.size() == view.max_size());
|
||||
|
||||
bool isEqual = std::equal(view.begin(), view.end(), stdview.begin());
|
||||
CHECK(isEqual);
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constructor_pointer_size)
|
||||
{
|
||||
@ -735,6 +822,39 @@ namespace
|
||||
CHECK(!view.ends_with("Hello Worldxxxxxx"));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_contains)
|
||||
{
|
||||
const char* s1 = "Hello";
|
||||
const char* s2 = "llo Wor";
|
||||
const char* s3 = "World";
|
||||
const char* s4 = "Xorld";
|
||||
const char* s5 = "Hello Worldxxxxxx";
|
||||
|
||||
View view(text.c_str());
|
||||
View v1(s1);
|
||||
View v2(s2);
|
||||
View v3(s3);
|
||||
View v4(s4);
|
||||
View v5(s5);
|
||||
|
||||
CHECK_TRUE(view.contains(v1));
|
||||
CHECK_TRUE(view.contains(v2));
|
||||
CHECK_TRUE(view.contains(v3));
|
||||
CHECK_FALSE(view.contains(v4));
|
||||
CHECK_FALSE(view.contains(v5));
|
||||
|
||||
CHECK_TRUE(view.contains('H'));
|
||||
CHECK_TRUE(view.contains('l'));
|
||||
CHECK_FALSE(view.contains('X'));
|
||||
|
||||
CHECK_TRUE(view.contains(s1));
|
||||
CHECK_TRUE(view.contains(s2));
|
||||
CHECK_TRUE(view.contains(s3));
|
||||
CHECK_FALSE(view.contains(s4));
|
||||
CHECK_FALSE(view.contains(s5));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_find)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user