From 5828ba05c9b7aa4559cedb9f8ff82f4af069f2b8 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 13 Nov 2024 11:15:01 +0000 Subject: [PATCH 01/18] Change internal constants from all-caps snake case to initial-caps snake case --- include/etl/bip_buffer_spsc_atomic.h | 42 ++++++++--------- include/etl/queue_spsc_atomic.h | 70 ++++++++++++++-------------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/include/etl/bip_buffer_spsc_atomic.h b/include/etl/bip_buffer_spsc_atomic.h index 5333dc68..f8c0eff1 100644 --- a/include/etl/bip_buffer_spsc_atomic.h +++ b/include/etl/bip_buffer_spsc_atomic.h @@ -86,13 +86,13 @@ namespace etl //*************************************************************************** /// The common base for a bip_buffer_spsc_atomic_base. //*************************************************************************** - template + template class bip_buffer_spsc_atomic_base { public: /// The type used for determining the size of buffer. - typedef typename etl::size_type_lookup::type size_type; + typedef typename etl::size_type_lookup::type size_type; //************************************************************************* /// Returns true if the buffer is empty. @@ -168,7 +168,7 @@ namespace etl //************************************************************************* size_type capacity() const { - return RESERVED; + return Reserved; } //************************************************************************* @@ -176,7 +176,7 @@ namespace etl //************************************************************************* size_type max_size() const { - return RESERVED; + return Reserved; } protected: @@ -188,7 +188,7 @@ namespace etl : read(0) , write(0) , last(0) - , RESERVED(reserved_) + , Reserved(reserved_) { } @@ -341,7 +341,7 @@ namespace etl etl::atomic read; etl::atomic write; etl::atomic last; - const size_type RESERVED; + const size_type Reserved; #if defined(ETL_POLYMORPHIC_SPSC_BIP_BUFFER_ATOMIC) || defined(ETL_POLYMORPHIC_CONTAINERS) public: @@ -361,12 +361,12 @@ namespace etl //*************************************************************************** /// A fixed capacity bipartite buffer. //*************************************************************************** - template - class ibip_buffer_spsc_atomic : public bip_buffer_spsc_atomic_base + template + class ibip_buffer_spsc_atomic : public bip_buffer_spsc_atomic_base { private: - typedef typename etl::bip_buffer_spsc_atomic_base base_t; + typedef typename etl::bip_buffer_spsc_atomic_base base_t; using base_t::reset; using base_t::get_read_reserve; using base_t::apply_read_reserve; @@ -486,15 +486,15 @@ namespace etl /// A fixed capacity bipartite buffer. /// This buffer supports concurrent access by one producer and one consumer. /// \tparam T The type this buffer should support. - /// \tparam SIZE The maximum capacity of the buffer. - /// \tparam MEMORY_MODEL The memory model for the buffer. Determines the type of the internal counter variables. + /// \tparam Size The maximum capacity of the buffer. + /// \tparam Memory_Model The memory model for the buffer. Determines the type of the internal counter variables. //*************************************************************************** - template - class bip_buffer_spsc_atomic : public ibip_buffer_spsc_atomic + template + class bip_buffer_spsc_atomic : public ibip_buffer_spsc_atomic { private: - typedef typename etl::ibip_buffer_spsc_atomic base_t; + typedef typename etl::ibip_buffer_spsc_atomic base_t; public: @@ -502,19 +502,19 @@ namespace etl private: - static ETL_CONSTANT size_type RESERVED_SIZE = size_type(SIZE); + static ETL_CONSTANT size_type Reserved_Size = size_type(Size); public: - ETL_STATIC_ASSERT((SIZE <= (etl::integral_limits::max)), "Size too large for memory model"); + ETL_STATIC_ASSERT((Size <= (etl::integral_limits::max)), "Size too large for memory model"); - static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE); + static ETL_CONSTANT size_type MAX_SIZE = size_type(Size); //************************************************************************* /// Default constructor. //************************************************************************* bip_buffer_spsc_atomic() - : base_t(reinterpret_cast(buffer.raw), RESERVED_SIZE) + : base_t(reinterpret_cast(buffer.raw), Reserved_Size) { } @@ -529,11 +529,11 @@ namespace etl private: /// The uninitialised buffer of T used in the bip_buffer_spsc. - etl::uninitialized_buffer_of buffer; + etl::uninitialized_buffer_of buffer; }; - template - ETL_CONSTANT typename bip_buffer_spsc_atomic::size_type bip_buffer_spsc_atomic::RESERVED_SIZE; + template + ETL_CONSTANT typename bip_buffer_spsc_atomic::size_type bip_buffer_spsc_atomic::Reserved_Size; } #endif /* ETL_HAS_ATOMIC && ETL_USING_CPP11 */ diff --git a/include/etl/queue_spsc_atomic.h b/include/etl/queue_spsc_atomic.h index d06dce2d..d7929919 100644 --- a/include/etl/queue_spsc_atomic.h +++ b/include/etl/queue_spsc_atomic.h @@ -47,13 +47,13 @@ SOFTWARE. namespace etl { - template + template class queue_spsc_atomic_base { public: /// The type used for determining the size of queue. - typedef typename etl::size_type_lookup::type size_type; + typedef typename etl::size_type_lookup::type size_type; //************************************************************************* /// Is the queue empty? @@ -72,7 +72,7 @@ namespace etl //************************************************************************* bool full() const { - size_type next_index = get_next_index(write.load(etl::memory_order_acquire), RESERVED); + size_type next_index = get_next_index(write.load(etl::memory_order_acquire), Reserved); return (next_index == read.load(etl::memory_order_acquire)); } @@ -94,7 +94,7 @@ namespace etl } else { - n = RESERVED - read_index + write_index; + n = Reserved - read_index + write_index; } return n; @@ -106,7 +106,7 @@ namespace etl //************************************************************************* size_type available() const { - return RESERVED - size() - 1; + return Reserved - size() - 1; } //************************************************************************* @@ -114,7 +114,7 @@ namespace etl //************************************************************************* size_type capacity() const { - return RESERVED - 1; + return Reserved - 1; } //************************************************************************* @@ -122,7 +122,7 @@ namespace etl //************************************************************************* size_type max_size() const { - return RESERVED - 1; + return Reserved - 1; } protected: @@ -130,7 +130,7 @@ namespace etl queue_spsc_atomic_base(size_type reserved_) : write(0), read(0), - RESERVED(reserved_) + Reserved(reserved_) { } @@ -151,7 +151,7 @@ namespace etl etl::atomic write; ///< Where to input new data. etl::atomic read; ///< Where to get the oldest data. - const size_type RESERVED; ///< The maximum number of items in the queue. + const size_type Reserved; ///< The maximum number of items in the queue. private: @@ -182,12 +182,12 @@ namespace etl /// This queue supports concurrent access by one producer and one consumer. /// \tparam T The type of value that the queue_spsc_atomic holds. //*************************************************************************** - template - class iqueue_spsc_atomic : public queue_spsc_atomic_base + template + class iqueue_spsc_atomic : public queue_spsc_atomic_base { private: - typedef typename etl::queue_spsc_atomic_base base_t; + typedef typename etl::queue_spsc_atomic_base base_t; public: @@ -201,7 +201,7 @@ namespace etl using base_t::write; using base_t::read; - using base_t::RESERVED; + using base_t::Reserved; using base_t::get_next_index; //************************************************************************* @@ -210,7 +210,7 @@ namespace etl bool push(const_reference value) { size_type write_index = write.load(etl::memory_order_relaxed); - size_type next_index = get_next_index(write_index, RESERVED); + size_type next_index = get_next_index(write_index, Reserved); if (next_index != read.load(etl::memory_order_acquire)) { @@ -232,7 +232,7 @@ namespace etl bool push(rvalue_reference value) { size_type write_index = write.load(etl::memory_order_relaxed); - size_type next_index = get_next_index(write_index, RESERVED); + size_type next_index = get_next_index(write_index, Reserved); if (next_index != read.load(etl::memory_order_acquire)) { @@ -257,7 +257,7 @@ namespace etl bool emplace(Args&&... args) { size_type write_index = write.load(etl::memory_order_relaxed); - size_type next_index = get_next_index(write_index, RESERVED); + size_type next_index = get_next_index(write_index, Reserved); if (next_index != read.load(etl::memory_order_acquire)) { @@ -279,7 +279,7 @@ namespace etl bool emplace() { size_type write_index = write.load(etl::memory_order_relaxed); - size_type next_index = get_next_index(write_index, RESERVED); + size_type next_index = get_next_index(write_index, Reserved); if (next_index != read.load(etl::memory_order_acquire)) { @@ -302,7 +302,7 @@ namespace etl bool emplace(const T1& value1) { size_type write_index = write.load(etl::memory_order_relaxed); - size_type next_index = get_next_index(write_index, RESERVED); + size_type next_index = get_next_index(write_index, Reserved); if (next_index != read.load(etl::memory_order_acquire)) { @@ -325,7 +325,7 @@ namespace etl bool emplace(const T1& value1, const T2& value2) { size_type write_index = write.load(etl::memory_order_relaxed); - size_type next_index = get_next_index(write_index, RESERVED); + size_type next_index = get_next_index(write_index, Reserved); if (next_index != read.load(etl::memory_order_acquire)) { @@ -348,7 +348,7 @@ namespace etl bool emplace(const T1& value1, const T2& value2, const T3& value3) { size_type write_index = write.load(etl::memory_order_relaxed); - size_type next_index = get_next_index(write_index, RESERVED); + size_type next_index = get_next_index(write_index, Reserved); if (next_index != read.load(etl::memory_order_acquire)) { @@ -371,7 +371,7 @@ namespace etl bool emplace(const T1& value1, const T2& value2, const T3& value3, const T4& value4) { size_type write_index = write.load(etl::memory_order_relaxed); - size_type next_index = get_next_index(write_index, RESERVED); + size_type next_index = get_next_index(write_index, Reserved); if (next_index != read.load(etl::memory_order_acquire)) { @@ -418,7 +418,7 @@ namespace etl return false; } - size_type next_index = get_next_index(read_index, RESERVED); + size_type next_index = get_next_index(read_index, Reserved); #if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKABLE_FORCE_CPP03_IMPLEMENTATION) value = etl::move(p_buffer[read_index]); @@ -446,7 +446,7 @@ namespace etl return false; } - size_type next_index = get_next_index(read_index, RESERVED); + size_type next_index = get_next_index(read_index, Reserved); p_buffer[read_index].~T(); @@ -518,15 +518,15 @@ namespace etl /// A fixed capacity spsc queue. /// This queue supports concurrent access by one producer and one consumer. /// \tparam T The type this queue should support. - /// \tparam SIZE The maximum capacity of the queue. - /// \tparam MEMORY_MODEL The memory model for the queue. Determines the type of the internal counter variables. + /// \tparam Size The maximum capacity of the queue. + /// \tparam Memory_Model The memory model for the queue. Determines the type of the internal counter variables. //*************************************************************************** - template - class queue_spsc_atomic : public iqueue_spsc_atomic + template + class queue_spsc_atomic : public iqueue_spsc_atomic { private: - typedef typename etl::iqueue_spsc_atomic base_t; + typedef typename etl::iqueue_spsc_atomic base_t; public: @@ -534,19 +534,19 @@ namespace etl private: - static ETL_CONSTANT size_type RESERVED_SIZE = size_type(SIZE + 1); + static ETL_CONSTANT size_type Reserved_Size = size_type(Size + 1); public: - ETL_STATIC_ASSERT((SIZE <= (etl::integral_limits::max - 1)), "Size too large for memory model"); + ETL_STATIC_ASSERT((Size <= (etl::integral_limits::max - 1)), "Size too large for memory model"); - static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE); + static ETL_CONSTANT size_type MAX_SIZE = size_type(Size); //************************************************************************* /// Default constructor. //************************************************************************* queue_spsc_atomic() - : base_t(reinterpret_cast(&buffer[0]), RESERVED_SIZE) + : base_t(reinterpret_cast(&buffer[0]), Reserved_Size) { } @@ -561,11 +561,11 @@ namespace etl private: /// The uninitialised buffer of T used in the queue_spsc. - typename etl::aligned_storage::value>::type buffer[RESERVED_SIZE]; + typename etl::aligned_storage::value>::type buffer[Reserved_Size]; }; - template - ETL_CONSTANT typename queue_spsc_atomic::size_type queue_spsc_atomic::MAX_SIZE; + template + ETL_CONSTANT typename queue_spsc_atomic::size_type queue_spsc_atomic::MAX_SIZE; } #endif From e8fcace1cbb6691025c45d79e291c3e2b32a7cae Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 16 Nov 2024 12:37:29 +0000 Subject: [PATCH 02/18] Added string_view API. Created common implementations for member algorithms. --- include/etl/basic_string.h | 835 +++++++++++++++++++++++++++---------- 1 file changed, 608 insertions(+), 227 deletions(-) diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 1371e80a..1bf29002 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -52,6 +52,10 @@ SOFTWARE. #include #include +#if ETL_USING_STL && ETL_USING_CPP17 + #include +#endif + #include "private/minmax_push.h" //***************************************************************************** @@ -60,6 +64,13 @@ SOFTWARE. ///\ingroup containers //***************************************************************************** +// Forward declaration of string_view +namespace etl +{ + template + class basic_string_view; +} + namespace etl { //*************************************************************************** @@ -635,27 +646,7 @@ namespace etl //********************************************************************* void assign(const etl::ibasic_string& other) { - assign(other.begin(), other.end()); - -#if ETL_HAS_STRING_TRUNCATION_CHECKS - if (other.is_truncated()) - { - set_truncated(true); - -#if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); -#endif - } -#endif - -#if ETL_HAS_STRING_CLEAR_AFTER_USE - if (other.is_secure()) - { - set_secure(); - } -#endif - - cleanup(); + assign_impl(other.begin(), other.end(), other.is_truncated(), other.is_secure()); } //********************************************************************* @@ -674,76 +665,7 @@ namespace etl ETL_ASSERT(subposition <= other.size(), ETL_ERROR(string_out_of_bounds)); - assign(other.begin() + subposition, sublength); - -#if ETL_HAS_STRING_TRUNCATION_CHECKS - if (other.is_truncated()) - { - this->set_truncated(true); - -#if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); -#endif - } -#endif - -#if ETL_HAS_STRING_CLEAR_AFTER_USE - if (other.is_secure()) - { - set_secure(); - } -#endif - } - - //********************************************************************* - /// 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) - { - initialise(); - - while ((*other != 0) && (current_size < CAPACITY)) - { - p_buffer[current_size++] = *other++; - } - -#if ETL_HAS_STRING_TRUNCATION_CHECKS - set_truncated(*other != 0); - -#if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)); -#endif -#endif - - p_buffer[current_size] = 0; - } - - //********************************************************************* - /// 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_) - { - initialise(); - -#if ETL_HAS_STRING_TRUNCATION_CHECKS - set_truncated(length_ > CAPACITY); - -#if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)); -#endif -#endif - - length_ = etl::min(length_, CAPACITY); - - etl::copy_n(other, length_, begin()); - - current_size = length_; - p_buffer[current_size] = 0; + assign_impl(other.begin() + subposition, other.begin() + subposition + sublength, other.is_truncated(), other.is_secure()); } //********************************************************************* @@ -756,29 +678,50 @@ namespace etl template void assign(TIterator first, TIterator last) { -#if ETL_IS_DEBUG_BUILD - difference_type d = etl::distance(first, last); - ETL_ASSERT(d >= 0, ETL_ERROR(string_iterator)); -#endif - - initialise(); - - while ((first != last) && (current_size != CAPACITY)) - { - p_buffer[current_size++] = *first++; - } - - p_buffer[current_size] = 0; - -#if ETL_HAS_STRING_TRUNCATION_CHECKS - set_truncated(first != last); - -#if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)); -#endif -#endif + assign_impl(first, last, false, false); } + //********************************************************************* + /// 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. + //********************************************************************* + template + void assign(const etl::basic_string_view& view) + { + assign(view.begin(), view.end()); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //********************************************************************* + /// Assigns values to the string from a view. + //********************************************************************* + template + void assign(const std::basic_string_view& view) + { + assign(view.begin(), view.end()); + } +#endif + //********************************************************************* /// Assigns values to the string. /// Truncates if the string does not have enough free space. @@ -929,6 +872,30 @@ namespace etl return *this; } + //********************************************************************* + /// Appends to the string. + ///\param view An etl::string_view. + //********************************************************************* + template + ibasic_string& append(const etl::basic_string_view& 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 + ibasic_string& append(const std::basic_string_view& view) + { + insert(end(), view.begin(), view.end()); + return *this; + } +#endif + //********************************************************************* /// Inserts a value to the string. ///\param position The position to insert before. @@ -1159,6 +1126,32 @@ namespace etl return position_; } + //********************************************************************* + /// 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 + iterator insert(const_iterator position, const etl::basic_string_view& 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 + iterator insert(const_iterator position, const std::basic_string_view& view) + { + return insert(position, view.begin(), view.end()); + } +#endif + //********************************************************************* /// Inserts a string at the specified position. ///\param position The position to insert before. @@ -1374,23 +1367,33 @@ namespace etl //********************************************************************* size_type find(const ibasic_string& str, size_type pos = 0) const { - if ((pos + str.size()) > size()) - { - return npos; - } - - const_iterator iposition = etl::search(begin() + pos, end(), str.begin(), str.end()); - - if (iposition == end()) - { - return npos; - } - else - { - return etl::distance(begin(), iposition); - } + 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 + size_type find(const etl::basic_string_view& view, size_type pos = 0) const + { + return find_impl(view.begin(), view.end(), view.size(), pos); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //********************************************************************* + /// Find content within the string + ///\param view The content to find + ///\param pos The position to start searching from. + //********************************************************************* + template + size_type find(const std::basic_string_view& view, size_type pos = 0) const + { + return find_impl(view.begin(), view.end(), view.size(), pos); + } +#endif + //********************************************************************* /// Find content within the string ///\param s Pointer to the content to find @@ -1398,23 +1401,9 @@ namespace etl //********************************************************************* size_type find(const_pointer s, size_type pos = 0) const { -#if ETL_IS_DEBUG_BUILD - if ((pos + etl::strlen(s)) > size()) - { - return npos; - } -#endif + size_t sz = etl::strlen(s); - const_iterator iposition = etl::search(begin() + pos, end(), s, s + etl::strlen(s)); - - if (iposition == end()) - { - return npos; - } - else - { - return etl::distance(begin(), iposition); - } + return find_impl(s, s + sz, sz, pos); } //********************************************************************* @@ -1425,23 +1414,9 @@ namespace etl //********************************************************************* size_type find(const_pointer s, size_type pos, size_type n) const { -#if ETL_IS_DEBUG_BUILD - if ((pos + etl::strlen(s) - n) > size()) - { - return npos; - } -#endif + size_t sz = etl::strlen(s); - const_iterator iposition = etl::search(begin() + pos, end(), s, s + n); - - if (iposition == end()) - { - return npos; - } - else - { - return etl::distance(begin(), iposition); - } + return find_impl(s, s + n, sz, pos); } //********************************************************************* @@ -1470,30 +1445,33 @@ namespace etl //********************************************************************* size_type rfind(const ibasic_string& str, size_type position = npos) const { - if ((str.size()) > size()) - { - return npos; - } - - if (position >= size()) - { - position = size(); - } - - position = size() - position; - - const_reverse_iterator iposition = etl::search(rbegin() + position, rend(), str.rbegin(), str.rend()); - - if (iposition == rend()) - { - return npos; - } - else - { - return size() - str.size() - etl::distance(rbegin(), iposition); - } + 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 + size_type rfind(const etl::basic_string_view& view, size_type pos = 0) const + { + return rfind_impl(view.rbegin(), view.rend(), view.size(), pos); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //********************************************************************* + /// Find content within the string + ///\param view The content to find + ///\param pos The position to start searching from. + //********************************************************************* + template + size_type rfind(const std::basic_string_view& view, size_type pos = 0) const + { + return rfind_impl(view.rbegin(), view.rend(), view.size(), pos); + } +#endif + //********************************************************************* /// Find content within the string ///\param str The content to find @@ -1503,31 +1481,10 @@ namespace etl { size_type len = etl::strlen(s); - if (len > size()) - { - return npos; - } - - if (position >= size()) - { - position = size(); - } - - position = size() - position; - const_reverse_iterator srbegin(s + len); const_reverse_iterator srend(s); - const_reverse_iterator iposition = etl::search(rbegin() + position, rend(), srbegin, srend); - - if (iposition == rend()) - { - return npos; - } - else - { - return size() - len - etl::distance(rbegin(), iposition); - } + return rfind_impl(srbegin, srend, len, position); } //********************************************************************* @@ -1537,31 +1494,10 @@ namespace etl //********************************************************************* size_type rfind(const_pointer s, size_type position, size_type length_) const { - if (length_ > size()) - { - return npos; - } - - if (position >= size()) - { - position = size(); - } - - position = size() - position; - const_reverse_iterator srbegin(s + length_); const_reverse_iterator srend(s); - const_reverse_iterator iposition = etl::search(rbegin() + position, rend(), srbegin, srend); - - if (iposition == rend()) - { - return npos; - } - else - { - return size() - length_ - etl::distance(rbegin(), iposition); - } + return rfind_impl(srbegin, srend, length_, position); } //********************************************************************* @@ -1612,6 +1548,54 @@ namespace etl return *this; } + //********************************************************************* + /// 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 + ibasic_string& replace(size_type position, size_type length_, const etl::basic_string_view& 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; + } + +#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 + ibasic_string& replace(size_type position, size_type length_, const std::basic_string_view& 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. @@ -1622,7 +1606,7 @@ namespace etl { // Quick hack, as iterators are pointers. iterator first_ = to_iterator(first); - iterator last_ = to_iterator(last); + iterator last_ = to_iterator(last); // Erase the bit we want to replace. erase(first_, last_); @@ -1644,6 +1628,52 @@ namespace etl return *this; } + //********************************************************************* + /// 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 + ibasic_string& replace(const_iterator first, const_iterator last, const etl::basic_string_view& 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; + } + +#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 + ibasic_string& replace(const_iterator first, const_iterator last, const std::basic_string_view& 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'. //********************************************************************* @@ -1653,7 +1683,7 @@ namespace etl ETL_ASSERT(subposition <= str.size(), ETL_ERROR(string_out_of_bounds)); // Limit the lengths. - length_ = etl::min(length_, size() - position); + length_ = etl::min(length_, size() - position); sublength = etl::min(sublength, str.size() - subposition); // Erase the bit we want to replace. @@ -1676,6 +1706,52 @@ namespace etl return *this; } + //********************************************************************* + /// Replace characters from 'position' of 'length' with 'view' from 'subposition' of 'sublength'. + //********************************************************************* + template + ibasic_string& replace(size_type position, size_type length_, const etl::basic_string_view& 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; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //********************************************************************* + /// Replace characters from 'position' of 'length' with 'view' from 'subposition' of 'sublength'. + //********************************************************************* + template + ibasic_string& replace(size_type position, size_type length_, const std::basic_string_view& 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. //********************************************************************* @@ -1817,6 +1893,32 @@ namespace etl str.p_buffer + str.size()); } + //************************************************************************* + /// Compare with etl::basic_string_view. + //************************************************************************* + template + int compare(const etl::basic_string_view& view) const + { + return compare(p_buffer, + p_buffer + view.size(), + view.data(), + view.size()); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Compare with std::basic_string_view. + //************************************************************************* + template + int compare(const std::basic_string_view& view) const + { + return compare(p_buffer, + p_buffer + view.size(), + view.data(), + view.size()); + } +#endif + //************************************************************************* /// Compare position / length with string. //************************************************************************* @@ -1833,6 +1935,32 @@ namespace etl str.p_buffer + str.size()); } + //************************************************************************* + /// Compare position / length with etl::basic_string_view. + //************************************************************************* + template + int compare(size_type position, size_type length_, const etl::basic_string_view& view) const + { + return compare(p_buffer + position, + p_buffer + position + length_, + view.p_buffer, + view.p_buffer + view.size()); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Compare position / length with std::basic_string_view. + //************************************************************************* + template + int compare(size_type position, size_type length_, const std::basic_string_view& 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. //************************************************************************* @@ -1851,6 +1979,46 @@ namespace etl str.p_buffer + subposition + sublength); } + //************************************************************************* + /// Compare position / length with etl::basic_string_view. / subposition / sublength. + //************************************************************************* + template + int compare(size_type position, size_type length_, const etl::basic_string_view& 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); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Compare position / length with std::basic_string_view. / subposition / sublength. + //************************************************************************* + template + int compare(size_type position, size_type length_, const std::basic_string_view& 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 //************************************************************************* @@ -1904,6 +2072,30 @@ namespace etl return find_first_of(s, position, etl::strlen(s)); } + //********************************************************************* + /// Find first of any of content within the string + ///\param view The content to find + ///\param pos The position to start searching from. + //********************************************************************* + template + size_type find_first_of(const etl::basic_string_view& 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 + size_type find_first_of(const std::basic_string_view& 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 @@ -1970,6 +2162,30 @@ namespace etl return find_last_of(s, position, etl::strlen(s)); } + //********************************************************************* + /// Find last of any of content within the string + ///\param view The content to find + ///\param pos The position to start searching from. + //********************************************************************* + template + size_type find_last_of(const etl::basic_string_view& view, size_type position = 0) 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 + size_type find_last_of(const std::basic_string_view& 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 @@ -2054,6 +2270,30 @@ namespace etl return find_first_not_of(s, position, etl::strlen(s)); } + //********************************************************************* + /// 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 + size_type find_first_not_of(const etl::basic_string_view& 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 + size_type find_first_not_of(const std::basic_string_view& 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 @@ -2127,6 +2367,30 @@ namespace etl return find_last_not_of(s, position, etl::strlen(s)); } + //********************************************************************* + /// 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 + size_type find_last_not_of(const etl::basic_string_view& view, size_type position = 0) 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 + size_type find_last_not_of(const std::basic_string_view& 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 @@ -2229,6 +2493,30 @@ namespace etl return *this; } + //************************************************************************* + /// += operator. + //************************************************************************* + template + ibasic_string& operator += (const etl::basic_string_view& rhs) + { + append(rhs); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// += operator. + //************************************************************************* + template + ibasic_string& operator += (const std::basic_string_view& rhs) + { + append(rhs); + + return *this; + } +#endif + //************************************************************************* /// += operator. //************************************************************************* @@ -2407,6 +2695,99 @@ namespace etl { return const_cast(itr); } + + private: + + //********************************************************************* + /// Common implementation for 'assign'. + //********************************************************************* + template + void assign_impl(TIterator first, TIterator last, bool truncated, bool secure) + { +#if ETL_IS_DEBUG_BUILD + difference_type d = etl::distance(first, last); + ETL_ASSERT(d >= 0, ETL_ERROR(string_iterator)); +#endif + + initialise(); + + while ((first != last) && (current_size != CAPACITY)) + { + p_buffer[current_size++] = *first++; + } + + p_buffer[current_size] = 0; + +#if ETL_HAS_STRING_TRUNCATION_CHECKS + set_truncated((first != last) || truncated); + +#if ETL_HAS_ERROR_ON_STRING_TRUNCATION + ETL_ASSERT(flags.test() == false, ETL_ERROR(string_truncation)); +#endif +#endif + +#if ETL_HAS_STRING_CLEAR_AFTER_USE + if (secure) + { + set_secure(); + } +#endif + + cleanup(); + } + + //************************************************************************* + /// Common implementation for 'find'. + //************************************************************************* + template + size_type find_impl(TIterator first, TIterator last, size_type sz, size_type pos = 0) const + { + if ((pos + sz) > size()) + { + return npos; + } + + const_iterator iposition = etl::search(begin() + pos, end(), first, last); + + if (iposition == end()) + { + return npos; + } + else + { + return etl::distance(begin(), iposition); + } + } + + //************************************************************************* + /// Common implementation for 'rfind'. + //************************************************************************* + template + size_type rfind_impl(TIterator rfirst, TIterator rlast, size_type sz, size_type pos = 0) const + { + if (sz > size()) + { + return npos; + } + + if (pos >= size()) + { + pos = size(); + } + + pos = size() - pos; + + const_reverse_iterator iposition = etl::search(rbegin() + pos, rend(), rfirst, rlast); + + if (iposition == rend()) + { + return npos; + } + else + { + return size() - sz - etl::distance(rbegin(), iposition); + } + } }; //*************************************************************************** From f5e8a5400ec2cae8b3d6ec249a569225f29676cb Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 18 Nov 2024 20:20:38 +0000 Subject: [PATCH 03/18] Added construction from std::basic_string_view --- include/etl/string_view.h | 16 ++++++++++ test/test_string_view.cpp | 64 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/include/etl/string_view.h b/include/etl/string_view.h index 7ddce503..4078bc4f 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -43,6 +43,10 @@ SOFTWARE. #include "algorithm.h" #include "private/minmax_push.h" +#if ETL_USING_STL && ETL_USING_CPP17 + #include +#endif + #include namespace etl @@ -163,6 +167,18 @@ namespace etl { } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Constructor from std::basic string_view + //************************************************************************* + template + ETL_CONSTEXPR basic_string_view(const std::basic_string_view& other) ETL_NOEXCEPT + : mbegin(other.data()) + , mend(other.data() + other.size()) + { + } +#endif + //************************************************************************* /// Returns a const reference to the first element. //************************************************************************* diff --git a/test/test_string_view.cpp b/test/test_string_view.cpp index 08c28a55..bff4c211 100644 --- a/test/test_string_view.cpp +++ b/test/test_string_view.cpp @@ -162,6 +162,70 @@ namespace CHECK(isEqual); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST(test_constructor_from_std_string_view) + { + std::string_view stdview(etltext.begin(), etltext.end()); + + 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.begin(), wtext.end()); + + 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_CPP17 + //************************************************************************* + TEST(test_constructor_from_std_u16string_view) + { + std::u16string_view stdview(u16text.begin(), u16text.end()); + + 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.begin(), u32text.end()); + + 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) { From 65596152422a2425c0e795fa73503b4942671e45 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 20 Nov 2024 09:51:02 +0000 Subject: [PATCH 04/18] Added string_view API. For all string types except _ext --- include/etl/basic_string.h | 140 +++- include/etl/string.h | 34 + include/etl/string_view.h | 2 +- include/etl/u16string.h | 34 + include/etl/u32string.h | 34 + include/etl/u8string.h | 34 + include/etl/wstring.h | 34 + test/test_string_char.cpp | 1385 +++++++++++++++++++++++++++++++- test/test_string_u16.cpp | 1390 ++++++++++++++++++++++++++++++++- test/test_string_u32.cpp | 1430 +++++++++++++++++++++++++++++++++- test/test_string_u8.cpp | 1390 ++++++++++++++++++++++++++++++++- test/test_string_wchar_t.cpp | 1418 ++++++++++++++++++++++++++++++++- 12 files changed, 7242 insertions(+), 83 deletions(-) diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 1bf29002..344e7d3b 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -1177,6 +1177,38 @@ 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 + etl::ibasic_string& insert(size_type position, const etl::basic_string_view& view) + { + ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); + + insert(begin() + position, view.cbegin(), view.cend()); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //********************************************************************* + /// Inserts a string at the specified position. + ///\param position The position to insert before. + ///\param view The view to insert. + //********************************************************************* + template + etl::ibasic_string& insert(size_type position, const std::basic_string_view& view) + { + ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); + + insert(begin() + position, view.cbegin(), view.cend()); + + return *this; + } +#endif + //********************************************************************* /// Inserts a string at the specified position from subposition for sublength. ///\param position The position to insert before. @@ -1186,7 +1218,7 @@ namespace etl //********************************************************************* etl::ibasic_string& insert(size_type position, const etl::ibasic_string& 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 +1242,54 @@ 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 + etl::ibasic_string& insert(size_type position, const etl::basic_string_view& 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; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //********************************************************************* + /// 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 + etl::ibasic_string& insert(size_type position, const std::basic_string_view& 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; + } +#endif + //********************************************************************* /// Inserts a string at the specified position from pointer. ///\param position The position to insert before. @@ -1900,9 +1980,9 @@ namespace etl int compare(const etl::basic_string_view& 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 @@ -1913,9 +1993,9 @@ namespace etl int compare(const std::basic_string_view& view) const { return compare(p_buffer, - p_buffer + view.size(), + p_buffer + size(), view.data(), - view.size()); + view.data() + view.size()); } #endif @@ -1943,8 +2023,8 @@ namespace etl { 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 @@ -1956,8 +2036,8 @@ namespace etl { return compare(p_buffer + position, p_buffer + position + length_, - view.p_buffer, - view.p_buffer + view.size()); + view.data(), + view.data() + view.size()); } #endif @@ -1994,8 +2074,8 @@ 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 @@ -2014,8 +2094,8 @@ 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); } #endif @@ -2168,7 +2248,7 @@ namespace etl ///\param pos The position to start searching from. //********************************************************************* template - size_type find_last_of(const etl::basic_string_view& view, size_type position = 0) const + size_type find_last_of(const etl::basic_string_view& view, size_type position = npos) const { return find_last_of(view.data(), position, view.size()); } @@ -2180,7 +2260,7 @@ namespace etl ///\param pos The position to start searching from. //********************************************************************* template - size_type find_last_of(const std::basic_string_view& view, size_type position = 0) const + size_type find_last_of(const std::basic_string_view& view, size_type position = npos) const { return find_last_of(view.data(), position, view.size()); } @@ -2373,7 +2453,7 @@ namespace etl ///\param pos The position to start searching from. //********************************************************************* template - size_type find_last_not_of(const etl::basic_string_view& view, size_type position = 0) const + size_type find_last_not_of(const etl::basic_string_view& view, size_type position = npos) const { return find_last_not_of(view.data(), position, view.size()); } @@ -2385,7 +2465,7 @@ namespace etl ///\param pos The position to start searching from. //********************************************************************* template - size_type find_last_not_of(const std::basic_string_view& view, size_type position = 0) const + size_type find_last_not_of(const std::basic_string_view& view, size_type position = npos) const { return find_last_not_of(view.data(), position, view.size()); } @@ -2483,6 +2563,30 @@ namespace etl return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + template + ibasic_string& operator = (const etl::basic_string_view& view) + { + assign(view); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Assignment operator. + //************************************************************************* + template + ibasic_string& operator = (const std::basic_string_view& view) + { + assign(view); + + return *this; + } +#endif + //************************************************************************* /// += operator. //************************************************************************* @@ -2607,7 +2711,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)) { diff --git a/include/etl/string.h b/include/etl/string.h index 50b3bf62..74942df4 100644 --- a/include/etl/string.h +++ b/include/etl/string.h @@ -186,6 +186,18 @@ namespace etl this->assign(view.begin(), view.end()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// From string_view. + ///\param view The string_view. + //************************************************************************* + explicit string(const std::string_view& view) + : istring(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(view.begin(), view.end()); + } +#endif + //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -244,6 +256,28 @@ namespace etl return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + string& operator = (const etl::string_view& view) + { + this->assign(view); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Assignment operator. + //************************************************************************* + string& operator = (const std::string_view& view) + { + this->assign(view); + + return *this; + } +#endif + //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/string_view.h b/include/etl/string_view.h index 4078bc4f..3558d2ef 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -172,7 +172,7 @@ namespace etl /// Constructor from std::basic string_view //************************************************************************* template - ETL_CONSTEXPR basic_string_view(const std::basic_string_view& other) ETL_NOEXCEPT + ETL_CONSTEXPR basic_string_view(const std::basic_string_view& other) ETL_NOEXCEPT : mbegin(other.data()) , mend(other.data() + other.size()) { diff --git a/include/etl/u16string.h b/include/etl/u16string.h index c0fea3a2..8e317dfb 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -183,6 +183,18 @@ namespace etl this->assign(view.begin(), view.end()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// From string_view. + ///\param view The string_view. + //************************************************************************* + explicit u16string(const std::u16string_view& view) + : iu16string(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(view.begin(), view.end()); + } +#endif + //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -227,6 +239,28 @@ namespace etl return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u16string& operator = (const etl::u16string_view& view) + { + this->assign(view); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u16string& operator = (const std::u16string_view& view) + { + this->assign(view); + + return *this; + } +#endif + //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/u32string.h b/include/etl/u32string.h index 766a0cbc..c22924fa 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -183,6 +183,18 @@ namespace etl this->assign(view.begin(), view.end()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// From string_view. + ///\param view The string_view. + //************************************************************************* + explicit u32string(const std::u32string_view& view) + : iu32string(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(view.begin(), view.end()); + } +#endif + //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -227,6 +239,28 @@ namespace etl return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u32string& operator = (const etl::u32string_view& view) + { + this->assign(view); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u32string& operator = (const std::u32string_view& view) + { + this->assign(view); + + return *this; + } +#endif + //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/u8string.h b/include/etl/u8string.h index 015ef3c1..fc5eefa0 100644 --- a/include/etl/u8string.h +++ b/include/etl/u8string.h @@ -186,6 +186,18 @@ namespace etl this->assign(view.begin(), view.end()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// From string_view. + ///\param view The string_view. + //************************************************************************* + explicit u8string(const std::u8string_view& view) + : iu8string(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(view.begin(), view.end()); + } +#endif + //************************************************************************* /// Returns a sub-u8string. ///\param position The position of the first character. Default = 0. @@ -244,6 +256,28 @@ namespace etl return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u8string& operator = (const etl::u8string_view& view) + { + this->assign(view); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u8string& operator = (const std::u8string_view& view) + { + this->assign(view); + + return *this; + } +#endif + //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/wstring.h b/include/etl/wstring.h index 683359de..5409d166 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -183,6 +183,18 @@ namespace etl this->assign(view.begin(), view.end()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// From string_view. + ///\param view The string_view. + //************************************************************************* + explicit wstring(const std::wstring_view& view) + : iwstring(reinterpret_cast(&buffer), MAX_SIZE) + { + this->assign(view.begin(), view.end()); + } +#endif + //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -227,6 +239,28 @@ namespace etl return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + wstring& operator = (const etl::wstring_view& view) + { + this->assign(view); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Assignment operator. + //************************************************************************* + wstring& operator = (const std::wstring_view& view) + { + this->assign(view); + + return *this; + } +#endif + //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index b49e8814..913ce0dd 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -33,8 +33,13 @@ SOFTWARE. #include #include "etl/string.h" +#include "etl/string_view.h" #include "etl/fnv_1.h" +#if ETL_USING_STL && ETL_USING_CPP17 + #include +#endif + #undef STR #define STR(x) x @@ -57,6 +62,10 @@ namespace using value_t = Text::value_type; using TextL = etl::string<52>; using TextS = etl::string<4>; + using ViewETL = etl::string_view; +#if ETL_USING_STL && ETL_USING_CPP17 + using ViewSTD = std::string_view; +#endif CompareText initial_text; CompareText less_text; @@ -288,9 +297,9 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) + TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - etl::string_view view(initial_text.data(), initial_text.size()); + ViewETL view(initial_text.data(), initial_text.size()); Text text(view); bool is_equal = Equal(initial_text, text); @@ -299,6 +308,20 @@ namespace CHECK(!text.empty()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) + { + ViewSTD view(initial_text.data(), initial_text.size()); + Text text(view); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -575,6 +598,36 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + { + Text text; + + text = ViewETL(STR("Hello World")); + + bool is_equal = Equal(std::string(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) + { + Text text; + + text = ViewSTD(STR("Hello World")); + + bool is_equal = Equal(std::string(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1008,6 +1061,48 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_etl_view) + { + CompareText compare_input(initial_text.c_str()); + Text input(initial_text.c_str()); + ViewETL view(input); + + CompareText compare_text; + Text text; + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_std_view) + { + CompareText compare_input(initial_text.c_str()); + Text input(initial_text.c_str()); + ViewSTD view(input.data(), input.data_end()); + + CompareText compare_text; + Text text; + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1525,6 +1620,50 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + CompareText compare_text(short_text.cbegin(), short_text.cend()); + Text text(short_text.cbegin(), short_text.cend()); + ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + CompareText compare_text(short_text.cbegin(), short_text.cend()); + Text text(short_text.cbegin(), short_text.cend()); + ViewSTD view(insert_text.data(), insert_text.data() + insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -1648,6 +1787,74 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_etl_view) + { + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + view.assign(initial_text.data(), initial_text.data() + initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(view); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_std_view) + { + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + ViewSTD append(insert_text.data(), insert_text.data() + insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(append); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append = ViewSTD(initial_text.data(), initial_text.data() + initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -1958,6 +2165,212 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + { + // Non-overflow short text, npos. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) + { + // Non-overflow short text, npos. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2018,6 +2431,128 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2134,6 +2669,240 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -3145,6 +3914,72 @@ namespace CHECK_EQUAL(etl::istring::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::string compare_needle(STR("needle")); + etl::string<50> needle(STR("needle")); + ViewETL needle_view(needle); + + std::string compare_haystack(the_haystack); + etl::string<50> haystack(the_haystack); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(etl::string<50>::npos, position2); + + etl::string<50> pin(STR("pin")); + ViewETL pin_view(pin); + position2 = haystack.find(pin_view); + CHECK_EQUAL(etl::istring::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::string compare_needle(STR("needle")); + std::string needle(STR("needle")); + ViewSTD needle_view(needle); + + std::string compare_haystack(the_haystack); + etl::string<50> haystack(the_haystack); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(etl::string<50>::npos, position2); + + std::string pin(STR("pin")); + ViewSTD pin_view(pin); + position2 = haystack.find(pin_view); + CHECK_EQUAL(etl::istring::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -3230,6 +4065,66 @@ namespace CHECK_EQUAL(etl::istring::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::string compare_needle(STR("needle")); + etl::string<50> needle(STR("needle")); + ViewETL needle_view(needle); + + std::string compare_haystack(the_haystack); + etl::string<50> haystack(the_haystack); + + size_t position1 = std::string::npos; + size_t position2 = etl::string<50>::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + etl::string<50> pin(STR("pin")); + ViewETL pin_view(pin); + position2 = haystack.rfind(pin); + CHECK_EQUAL(etl::istring::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::string compare_needle(STR("needle")); + std::string needle(STR("needle")); + ViewSTD needle_view(needle); + + std::string compare_haystack(the_haystack); + etl::string<50> haystack(the_haystack); + + size_t position1 = std::string::npos; + size_t position2 = etl::string<50>::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + std::string pin(STR("pin")); + ViewSTD pin_view(pin); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(etl::istring::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -3377,6 +4272,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_etl_view) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + result = text.compare(ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + result = text.compare(ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + result = text.compare(ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + result = text.compare(ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + result = text.compare(ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_std_view) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + result = text.compare(ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + result = text.compare(ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + result = text.compare(ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + result = text.compare(ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + result = text.compare(ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -3412,6 +4379,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -3447,6 +4486,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -3581,6 +4692,66 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -3717,6 +4888,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -3866,6 +5107,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -4012,6 +5323,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 7d529521..20671aa5 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -66,12 +66,12 @@ namespace { static const size_t SIZE = 11; - using Text = etl::u16string; - using IText = etl::iu16string; + using Text = etl::u16string; + using IText = etl::iu16string; using CompareText = std::u16string; - using value_t = Text::value_type; - using TextL = etl::u16string<52>; - using TextS = etl::u16string<4>; + using value_t = Text::value_type; + using TextL = etl::u16string<52>; + using TextS = etl::u16string<4>; CompareText initial_text; CompareText less_text; @@ -81,6 +81,10 @@ namespace CompareText insert_text; CompareText longer_text; CompareText short_text; + using ViewETL = etl::u16string_view; +#if ETL_USING_STL && ETL_USING_CPP17 + using ViewSTD = std::u16string_view; +#endif const value_t* pinitial_text = STR("Hello World"); @@ -304,9 +308,9 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) + TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - etl::u16string_view view(initial_text.data(), initial_text.size()); + ViewETL view(initial_text.data(), initial_text.size()); Text text(view); bool is_equal = Equal(initial_text, text); @@ -315,6 +319,20 @@ namespace CHECK(!text.empty()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) + { + ViewSTD view(initial_text.data(), initial_text.size()); + Text text(view); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -591,6 +609,36 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + { + Text text; + + text = ViewETL(STR("Hello World")); + + bool is_equal = Equal(std::u16string(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) + { + Text text; + + text = ViewSTD(STR("Hello World")); + + bool is_equal = Equal(std::u16string(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1023,6 +1071,48 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_etl_view) + { + CompareText compare_input(initial_text.c_str()); + Text input(initial_text.c_str()); + ViewETL view(input); + + CompareText compare_text; + Text text; + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_std_view) + { + CompareText compare_input(initial_text.c_str()); + Text input(initial_text.c_str()); + ViewSTD view(input.data(), input.data_end()); + + CompareText compare_text; + Text text; + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1540,6 +1630,50 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + CompareText compare_text(short_text.cbegin(), short_text.cend()); + Text text(short_text.cbegin(), short_text.cend()); + ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + CompareText compare_text(short_text.cbegin(), short_text.cend()); + Text text(short_text.cbegin(), short_text.cend()); + ViewSTD view(insert_text.data(), insert_text.data() + insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -1663,6 +1797,74 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_etl_view) + { + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + view.assign(initial_text.data(), initial_text.data() + initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(view); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_std_view) + { + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + ViewSTD append(insert_text.data(), insert_text.data() + insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(append); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append = ViewSTD(initial_text.data(), initial_text.data() + initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -1973,6 +2175,212 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + { + // Non-overflow short text, npos. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) + { + // Non-overflow short text, npos. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2033,6 +2441,128 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2149,6 +2679,240 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -3160,6 +3924,72 @@ namespace CHECK_EQUAL(etl::iu16string::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u16string compare_needle(STR("needle")); + etl::u16string<50> needle(STR("needle")); + ViewETL needle_view(needle); + + std::u16string compare_haystack(the_haystack); + etl::u16string<50> haystack(the_haystack); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(etl::u16string<50>::npos, position2); + + etl::u16string<50> pin(STR("pin")); + ViewETL pin_view(pin); + position2 = haystack.find(pin_view); + CHECK_EQUAL(etl::iu16string::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u16string compare_needle(STR("needle")); + std::u16string needle(STR("needle")); + ViewSTD needle_view(needle); + + std::u16string compare_haystack(the_haystack); + etl::u16string<50> haystack(the_haystack); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(etl::u16string<50>::npos, position2); + + std::u16string pin(STR("pin")); + ViewSTD pin_view(pin); + position2 = haystack.find(pin_view); + CHECK_EQUAL(etl::iu16string::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -3245,6 +4075,66 @@ namespace CHECK_EQUAL(etl::iu16string::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u16string compare_needle(STR("needle")); + etl::u16string<50> needle(STR("needle")); + ViewETL needle_view(needle); + + std::u16string compare_haystack(the_haystack); + etl::u16string<50> haystack(the_haystack); + + size_t position1 = std::u16string::npos; + size_t position2 = etl::u16string<50>::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + etl::u16string<50> pin(STR("pin")); + ViewETL pin_view(pin); + position2 = haystack.rfind(pin); + CHECK_EQUAL(etl::iu16string::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u16string compare_needle(STR("needle")); + std::u16string needle(STR("needle")); + ViewSTD needle_view(needle); + + std::u16string compare_haystack(the_haystack); + etl::u16string<50> haystack(the_haystack); + + size_t position1 = std::u16string::npos; + size_t position2 = etl::u16string<50>::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + std::u16string pin(STR("pin")); + ViewSTD pin_view(pin); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(etl::iu16string::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -3392,6 +4282,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_etl_view) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + result = text.compare(ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + result = text.compare(ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + result = text.compare(ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + result = text.compare(ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + result = text.compare(ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_std_view) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + result = text.compare(ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + result = text.compare(ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + result = text.compare(ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + result = text.compare(ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + result = text.compare(ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -3427,6 +4389,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -3462,6 +4496,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -3596,6 +4702,66 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -3732,6 +4898,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -3881,6 +5117,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -4027,6 +5333,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index fa1c199c..31f9fdad 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -66,12 +66,12 @@ namespace { static const size_t SIZE = 11; - using Text = etl::u32string; - using IText = etl::iu32string; + using Text = etl::u32string; + using IText = etl::iu32string; using CompareText = std::u32string; - using value_t = Text::value_type; - using TextL = etl::u32string<52>; - using TextS = etl::u32string<4>; + using value_t = Text::value_type; + using TextL = etl::u32string<52>; + using TextS = etl::u32string<4>; CompareText initial_text; CompareText less_text; @@ -81,6 +81,10 @@ namespace CompareText insert_text; CompareText longer_text; CompareText short_text; + using ViewETL = etl::u32string_view; +#if ETL_USING_STL && ETL_USING_CPP17 + using ViewSTD = std::u32string_view; +#endif const value_t* pinitial_text = STR("Hello World"); @@ -96,15 +100,15 @@ namespace { SetupFixture() { - initial_text = STR("Hello World"); - initial_text = STR("Hello World"); - insert_text = STR("Insert"); - less_text = STR("Hello Vorld"); - greater_text = STR("Hello Xorld"); - shorter_text = STR("Hello Worl"); + initial_text = STR("Hello World"); + initial_text = STR("Hello World"); + insert_text = STR("Insert"); + less_text = STR("Hello Vorld"); + greater_text = STR("Hello Xorld"); + shorter_text = STR("Hello Worl"); different_text = STR("Byee Planet"); - longer_text = STR("Hello World There"); - short_text = STR("Hello"); + longer_text = STR("Hello World There"); + short_text = STR("Hello"); } }; @@ -304,9 +308,9 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) + TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - etl::u32string_view view(initial_text.data(), initial_text.size()); + ViewETL view(initial_text.data(), initial_text.size()); Text text(view); bool is_equal = Equal(initial_text, text); @@ -315,6 +319,20 @@ namespace CHECK(!text.empty()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) + { + ViewSTD view(initial_text.data(), initial_text.size()); + Text text(view); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -410,10 +428,10 @@ namespace TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; + STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; Text text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), - STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; + STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), + STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -591,13 +609,43 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + { + Text text; + + text = ViewETL(STR("Hello World")); + + bool is_equal = Equal(std::u32string(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) + { + Text text; + + text = ViewSTD(STR("Hello World")); + + bool is_equal = Equal(std::u32string(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { Text text(initial_text.c_str()); - const Text constText(initial_text.c_str()); + const Text constText(initial_text.c_str()); - CHECK_EQUAL(&text[0], text.begin()); + CHECK_EQUAL(&text[0], text.begin()); CHECK_EQUAL(&constText[0], constText.begin()); } @@ -607,7 +655,7 @@ namespace Text text(initial_text.c_str()); const Text constText(initial_text.c_str()); - CHECK_EQUAL(&text[initial_text.size()], text.end()); + CHECK_EQUAL(&text[initial_text.size()], text.end()); CHECK_EQUAL(&constText[initial_text.size()], constText.end()); } @@ -1023,6 +1071,48 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_etl_view) + { + CompareText compare_input(initial_text.c_str()); + Text input(initial_text.c_str()); + ViewETL view(input); + + CompareText compare_text; + Text text; + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_std_view) + { + CompareText compare_input(initial_text.c_str()); + Text input(initial_text.c_str()); + ViewSTD view(input.data(), input.data_end()); + + CompareText compare_text; + Text text; + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1540,6 +1630,50 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + CompareText compare_text(short_text.cbegin(), short_text.cend()); + Text text(short_text.cbegin(), short_text.cend()); + ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + CompareText compare_text(short_text.cbegin(), short_text.cend()); + Text text(short_text.cbegin(), short_text.cend()); + ViewSTD view(insert_text.data(), insert_text.data() + insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -1663,6 +1797,74 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_etl_view) + { + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + view.assign(initial_text.data(), initial_text.data() + initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(view); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_std_view) + { + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + ViewSTD append(insert_text.data(), insert_text.data() + insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(append); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append = ViewSTD(initial_text.data(), initial_text.data() + initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -1973,6 +2175,212 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + { + // Non-overflow short text, npos. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) + { + // Non-overflow short text, npos. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2033,6 +2441,128 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2149,6 +2679,240 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -3058,8 +3822,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3099,8 +3863,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3125,8 +3889,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3160,6 +3924,72 @@ namespace CHECK_EQUAL(etl::iu32string::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u32string compare_needle(STR("needle")); + etl::u32string<50> needle(STR("needle")); + ViewETL needle_view(needle); + + std::u32string compare_haystack(the_haystack); + etl::u32string<50> haystack(the_haystack); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(etl::u32string<50>::npos, position2); + + etl::u32string<50> pin(STR("pin")); + ViewETL pin_view(pin); + position2 = haystack.find(pin_view); + CHECK_EQUAL(etl::iu32string::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u32string compare_needle(STR("needle")); + std::u32string needle(STR("needle")); + ViewSTD needle_view(needle); + + std::u32string compare_haystack(the_haystack); + etl::u32string<50> haystack(the_haystack); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(etl::u32string<50>::npos, position2); + + std::u32string pin(STR("pin")); + ViewSTD pin_view(pin); + position2 = haystack.find(pin_view); + CHECK_EQUAL(etl::iu32string::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -3245,6 +4075,66 @@ namespace CHECK_EQUAL(etl::iu32string::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u32string compare_needle(STR("needle")); + etl::u32string<50> needle(STR("needle")); + ViewETL needle_view(needle); + + std::u32string compare_haystack(the_haystack); + etl::u32string<50> haystack(the_haystack); + + size_t position1 = std::u32string::npos; + size_t position2 = etl::u32string<50>::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + etl::u32string<50> pin(STR("pin")); + ViewETL pin_view(pin); + position2 = haystack.rfind(pin); + CHECK_EQUAL(etl::iu32string::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u32string compare_needle(STR("needle")); + std::u32string needle(STR("needle")); + ViewSTD needle_view(needle); + + std::u32string compare_haystack(the_haystack); + etl::u32string<50> haystack(the_haystack); + + size_t position1 = std::u32string::npos; + size_t position2 = etl::u32string<50>::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + std::u32string pin(STR("pin")); + ViewSTD pin_view(pin); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(etl::iu32string::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -3392,6 +4282,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_etl_view) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + result = text.compare(ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + result = text.compare(ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + result = text.compare(ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + result = text.compare(ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + result = text.compare(ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_std_view) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + result = text.compare(ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + result = text.compare(ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + result = text.compare(ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + result = text.compare(ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + result = text.compare(ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -3427,6 +4389,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -3462,6 +4496,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -3596,6 +4702,66 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -3732,6 +4898,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -3881,6 +5117,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -4027,6 +5333,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_u8.cpp b/test/test_string_u8.cpp index 2165231f..361ae40d 100644 --- a/test/test_string_u8.cpp +++ b/test/test_string_u8.cpp @@ -69,12 +69,16 @@ namespace { static const size_t SIZE = 11; - using Text = etl::u8string; - using IText = etl::iu8string; + using Text = etl::u8string; + using IText = etl::iu8string; using CompareText = std::u8string; - using value_t = Text::value_type; - using TextL = etl::u8string<52>; - using TextS = etl::u8string<4>; + using value_t = Text::value_type; + using TextL = etl::u8string<52>; + using TextS = etl::u8string<4>; + using ViewETL = etl::u8string_view; +#if ETL_USING_STL && ETL_USING_CPP17 + using ViewSTD = std::u8string_view; +#endif CompareText initial_text; CompareText less_text; @@ -307,9 +311,9 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) + TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - etl::u8string_view view(initial_text.data(), initial_text.size()); + ViewETL view(initial_text.data(), initial_text.size()); Text text(view); bool is_equal = Equal(initial_text, text); @@ -318,6 +322,20 @@ namespace CHECK(!text.empty()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) + { + ViewSTD view(initial_text.data(), initial_text.size()); + Text text(view); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -594,6 +612,36 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + { + Text text; + + text = ViewETL(STR("Hello World")); + + bool is_equal = Equal(std::u8string(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) + { + Text text; + + text = ViewSTD(STR("Hello World")); + + bool is_equal = Equal(std::u8string(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1026,6 +1074,48 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_etl_view) + { + CompareText compare_input(initial_text.c_str()); + Text input(initial_text.c_str()); + ViewETL view(input); + + CompareText compare_text; + Text text; + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_std_view) + { + CompareText compare_input(initial_text.c_str()); + Text input(initial_text.c_str()); + ViewSTD view(input.data(), input.data_end()); + + CompareText compare_text; + Text text; + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1543,6 +1633,50 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + CompareText compare_text(short_text.cbegin(), short_text.cend()); + Text text(short_text.cbegin(), short_text.cend()); + ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + CompareText compare_text(short_text.cbegin(), short_text.cend()); + Text text(short_text.cbegin(), short_text.cend()); + ViewSTD view(insert_text.data(), insert_text.data() + insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -1666,6 +1800,74 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_etl_view) + { + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + view.assign(initial_text.data(), initial_text.data() + initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(view); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_std_view) + { + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + ViewSTD append(insert_text.data(), insert_text.data() + insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(append); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append = ViewSTD(initial_text.data(), initial_text.data() + initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -1976,6 +2178,212 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + { + // Non-overflow short text, npos. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) + { + // Non-overflow short text, npos. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2036,6 +2444,128 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2152,6 +2682,240 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -3163,6 +3927,72 @@ namespace CHECK_EQUAL(etl::iu8string::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u8string compare_needle(STR("needle")); + etl::u8string<50> needle(STR("needle")); + ViewETL needle_view(needle); + + std::u8string compare_haystack(the_haystack); + etl::u8string<50> haystack(the_haystack); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(etl::u8string<50>::npos, position2); + + etl::u8string<50> pin(STR("pin")); + ViewETL pin_view(pin); + position2 = haystack.find(pin_view); + CHECK_EQUAL(etl::iu8string::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u8string compare_needle(STR("needle")); + std::u8string needle(STR("needle")); + ViewSTD needle_view(needle); + + std::u8string compare_haystack(the_haystack); + etl::u8string<50> haystack(the_haystack); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(etl::u8string<50>::npos, position2); + + std::u8string pin(STR("pin")); + ViewSTD pin_view(pin); + position2 = haystack.find(pin_view); + CHECK_EQUAL(etl::iu8string::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -3248,6 +4078,66 @@ namespace CHECK_EQUAL(etl::iu8string::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u8string compare_needle(STR("needle")); + etl::u8string<50> needle(STR("needle")); + ViewETL needle_view(needle); + + std::u8string compare_haystack(the_haystack); + etl::u8string<50> haystack(the_haystack); + + size_t position1 = std::u8string::npos; + size_t position2 = etl::u8string<50>::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + etl::u8string<50> pin(STR("pin")); + ViewETL pin_view(pin); + position2 = haystack.rfind(pin); + CHECK_EQUAL(etl::iu8string::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::u8string compare_needle(STR("needle")); + std::u8string needle(STR("needle")); + ViewSTD needle_view(needle); + + std::u8string compare_haystack(the_haystack); + etl::u8string<50> haystack(the_haystack); + + size_t position1 = std::u8string::npos; + size_t position2 = etl::u8string<50>::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + std::u8string pin(STR("pin")); + ViewSTD pin_view(pin); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(etl::iu8string::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -3395,6 +4285,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_etl_view) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + result = text.compare(ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + result = text.compare(ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + result = text.compare(ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + result = text.compare(ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + result = text.compare(ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_std_view) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + result = text.compare(ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + result = text.compare(ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + result = text.compare(ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + result = text.compare(ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + result = text.compare(ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -3430,6 +4392,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -3465,6 +4499,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -3599,6 +4705,66 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -3735,6 +4901,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -3884,6 +5120,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -4030,6 +5336,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index f3e852b7..862565c0 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -66,12 +66,12 @@ namespace { static const size_t SIZE = 11; - using Text = etl::wstring; - using IText = etl::iwstring; + using Text = etl::wstring; + using IText = etl::iwstring; using CompareText = std::wstring; - using value_t = Text::value_type; - using TextL = etl::wstring<52>; - using TextS = etl::wstring<4>; + using value_t = Text::value_type; + using TextL = etl::wstring<52>; + using TextS = etl::wstring<4>; CompareText initial_text; CompareText less_text; @@ -79,10 +79,14 @@ namespace CompareText shorter_text; CompareText different_text; CompareText insert_text; - CompareText short_text; CompareText longer_text; + CompareText short_text; + using ViewETL = etl::wstring_view; +#if ETL_USING_STL && ETL_USING_CPP17 + using ViewSTD = std::wstring_view; +#endif - const Text::value_type* pinitial_text = STR("Hello World"); + const value_t* pinitial_text = STR("Hello World"); //************************************************************************* template @@ -304,9 +308,9 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) + TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - etl::wstring_view view(initial_text.data(), initial_text.size()); + ViewETL view(initial_text.data(), initial_text.size()); Text text(view); bool is_equal = Equal(initial_text, text); @@ -315,6 +319,20 @@ namespace CHECK(!text.empty()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) + { + ViewSTD view(initial_text.data(), initial_text.size()); + Text text(view); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -410,10 +428,10 @@ namespace TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; + STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; Text text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), - STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; + STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), + STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -591,13 +609,43 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + { + Text text; + + text = ViewETL(STR("Hello World")); + + bool is_equal = Equal(std::wstring(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) + { + Text text; + + text = ViewSTD(STR("Hello World")); + + bool is_equal = Equal(std::wstring(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { Text text(initial_text.c_str()); const Text constText(initial_text.c_str()); - - CHECK_EQUAL(&text[0], text.begin()); + + CHECK_EQUAL(&text[0], text.begin()); CHECK_EQUAL(&constText[0], constText.begin()); } @@ -607,7 +655,7 @@ namespace Text text(initial_text.c_str()); const Text constText(initial_text.c_str()); - CHECK_EQUAL(&text[initial_text.size()], text.end()); + CHECK_EQUAL(&text[initial_text.size()], text.end()); CHECK_EQUAL(&constText[initial_text.size()], constText.end()); } @@ -1023,6 +1071,48 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_etl_view) + { + CompareText compare_input(initial_text.c_str()); + Text input(initial_text.c_str()); + ViewETL view(input); + + CompareText compare_text; + Text text; + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_std_view) + { + CompareText compare_input(initial_text.c_str()); + Text input(initial_text.c_str()); + ViewSTD view(input.data(), input.data_end()); + + CompareText compare_text; + Text text; + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1540,6 +1630,50 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + CompareText compare_text(short_text.cbegin(), short_text.cend()); + Text text(short_text.cbegin(), short_text.cend()); + ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + CompareText compare_text(short_text.cbegin(), short_text.cend()); + Text text(short_text.cbegin(), short_text.cend()); + ViewSTD view(insert_text.data(), insert_text.data() + insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -1663,6 +1797,74 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_etl_view) + { + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + view.assign(initial_text.data(), initial_text.data() + initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(view); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_std_view) + { + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + ViewSTD append(insert_text.data(), insert_text.data() + insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(append); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append = ViewSTD(initial_text.data(), initial_text.data() + initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -1973,6 +2175,212 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + { + // Non-overflow short text, npos. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) + { + // Non-overflow short text, npos. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2033,6 +2441,128 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2149,6 +2679,240 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) + { + // Non-overflow short text. + CompareText compare_text(short_text.c_str()); + Text text(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -3058,8 +3822,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3099,8 +3863,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3125,8 +3889,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3160,6 +3924,72 @@ namespace CHECK_EQUAL(etl::iwstring::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::wstring compare_needle(STR("needle")); + etl::wstring<50> needle(STR("needle")); + ViewETL needle_view(needle); + + std::wstring compare_haystack(the_haystack); + etl::wstring<50> haystack(the_haystack); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(etl::wstring<50>::npos, position2); + + etl::wstring<50> pin(STR("pin")); + ViewETL pin_view(pin); + position2 = haystack.find(pin_view); + CHECK_EQUAL(etl::iwstring::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::wstring compare_needle(STR("needle")); + std::wstring needle(STR("needle")); + ViewSTD needle_view(needle); + + std::wstring compare_haystack(the_haystack); + etl::wstring<50> haystack(the_haystack); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(etl::wstring<50>::npos, position2); + + std::wstring pin(STR("pin")); + ViewSTD pin_view(pin); + position2 = haystack.find(pin_view); + CHECK_EQUAL(etl::iwstring::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -3245,6 +4075,66 @@ namespace CHECK_EQUAL(etl::iwstring::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::wstring compare_needle(STR("needle")); + etl::wstring<50> needle(STR("needle")); + ViewETL needle_view(needle); + + std::wstring compare_haystack(the_haystack); + etl::wstring<50> haystack(the_haystack); + + size_t position1 = std::wstring::npos; + size_t position2 = etl::wstring<50>::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + etl::wstring<50> pin(STR("pin")); + ViewETL pin_view(pin); + position2 = haystack.rfind(pin); + CHECK_EQUAL(etl::iwstring::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + std::wstring compare_needle(STR("needle")); + std::wstring needle(STR("needle")); + ViewSTD needle_view(needle); + + std::wstring compare_haystack(the_haystack); + etl::wstring<50> haystack(the_haystack); + + size_t position1 = std::wstring::npos; + size_t position2 = etl::wstring<50>::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + std::wstring pin(STR("pin")); + ViewSTD pin_view(pin); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(etl::iwstring::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -3392,6 +4282,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_etl_view) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + result = text.compare(ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + result = text.compare(ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + result = text.compare(ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + result = text.compare(ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + result = text.compare(ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_std_view) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + result = text.compare(ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + result = text.compare(ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + result = text.compare(ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + result = text.compare(ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + result = text.compare(ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -3427,6 +4389,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -3462,6 +4496,78 @@ namespace CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) + { + CompareText compare_text(STR("xxxABCDEFyyy")); + Text text(STR("xxxABCDEFyyy")); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -3596,6 +4702,66 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -3732,6 +4898,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -3881,6 +5117,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) + { + CompareText compare_text(STR("ABCDEF")); + Text text(STR("ABCDEF")); + + size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -4027,6 +5333,76 @@ namespace #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) + { + CompareText compare_text(STR("ABCDEFABCDE")); + Text text(STR("ABCDEFABCDE")); + + size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { From bc44bf7a46830054f530966a987e104b49987b7e Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 22 Nov 2024 12:25:02 +0000 Subject: [PATCH 05/18] Fixed C++ standard compatibility issues --- include/etl/string.h | 55 +- include/etl/u16string.h | 39 +- include/etl/u32string.h | 39 +- include/etl/u8string.h | 39 +- include/etl/wstring.h | 39 +- test/test_string_char.cpp | 878 ++++---- test/test_string_char_external_buffer.cpp | 1840 +++++++++++++-- test/test_string_u16.cpp | 844 ++++--- test/test_string_u16_external_buffer.cpp | 2070 ++++++++++++++--- test/test_string_u32.cpp | 832 ++++--- test/test_string_u32_external_buffer.cpp | 2075 ++++++++++++++--- test/test_string_u8.cpp | 868 ++++---- test/test_string_u8_external_buffer.cpp | 2018 ++++++++++++++--- test/test_string_view.cpp | 31 +- test/test_string_wchar_t.cpp | 832 ++++--- test/test_string_wchar_t_external_buffer.cpp | 2089 +++++++++++++++--- 16 files changed, 10833 insertions(+), 3755 deletions(-) diff --git a/include/etl/string.h b/include/etl/string.h index 74942df4..55bfa452 100644 --- a/include/etl/string.h +++ b/include/etl/string.h @@ -396,6 +396,28 @@ 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()); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// From string_view. + ///\param view The string_view. + //************************************************************************* + explicit string_ext(const std::string_view& view, value_type* buffer, size_type buffer_size) + : istring(buffer, buffer_size - 1U) + { + this->assign(view.begin(), view.end()); + } +#endif + //************************************************************************* /// Constructor, from an iterator range. ///\tparam TIterator The iterator type. @@ -420,16 +442,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. //************************************************************************* @@ -443,7 +455,6 @@ namespace etl return *this; } - //************************************************************************* /// Assignment operator. //************************************************************************* @@ -467,6 +478,28 @@ namespace etl return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + string_ext& operator = (const etl::string_view& view) + { + this->assign(view); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Assignment operator. + //************************************************************************* + string_ext& operator = (const std::string_view& view) + { + this->assign(view); + + return *this; + } +#endif + //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/u16string.h b/include/etl/u16string.h index 8e317dfb..b18bc07d 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -400,8 +400,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) @@ -409,6 +409,18 @@ namespace etl this->assign(view.begin(), view.end()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// From string_view. + ///\param view The string_view. + //************************************************************************* + explicit u16string_ext(const std::u16string_view& view, value_type* buffer, size_type buffer_size) + : iu16string(buffer, buffer_size - 1U) + { + this->assign(view.begin(), view.end()); + } +#endif + //************************************************************************* /// Assignment operator. //************************************************************************* @@ -422,7 +434,6 @@ namespace etl return *this; } - //************************************************************************* /// Assignment operator. //************************************************************************* @@ -446,6 +457,28 @@ namespace etl return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u16string_ext& operator = (const etl::u16string_view& view) + { + this->assign(view); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u16string_ext& operator = (const std::u16string_view& view) + { + this->assign(view); + + return *this; + } +#endif + //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/u32string.h b/include/etl/u32string.h index c22924fa..068e9e3c 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -400,8 +400,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) @@ -409,6 +409,18 @@ namespace etl this->assign(view.begin(), view.end()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// From string_view. + ///\param view The string_view. + //************************************************************************* + explicit u32string_ext(const std::u32string_view& view, value_type* buffer, size_type buffer_size) + : iu32string(buffer, buffer_size - 1U) + { + this->assign(view.begin(), view.end()); + } +#endif + //************************************************************************* /// Assignment operator. //************************************************************************* @@ -422,7 +434,6 @@ namespace etl return *this; } - //************************************************************************* /// Assignment operator. //************************************************************************* @@ -446,6 +457,28 @@ namespace etl return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u32string_ext& operator = (const etl::u32string_view& view) + { + this->assign(view); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u32string_ext& operator = (const std::u32string_view& view) + { + this->assign(view); + + return *this; + } +#endif + //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/u8string.h b/include/etl/u8string.h index fc5eefa0..7cc1964f 100644 --- a/include/etl/u8string.h +++ b/include/etl/u8string.h @@ -186,7 +186,7 @@ namespace etl this->assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP17 +#if ETL_USING_STL && ETL_USING_CPP20 //************************************************************************* /// From string_view. ///\param view The string_view. @@ -266,7 +266,7 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 +#if ETL_USING_STL && ETL_USING_CPP20 //************************************************************************* /// Assignment operator. //************************************************************************* @@ -430,6 +430,18 @@ namespace etl this->assign(view.begin(), view.end()); } +#if ETL_USING_STL && ETL_USING_CPP20 + //************************************************************************* + /// From string_view. + ///\param view The string_view. + //************************************************************************* + explicit u8string_ext(const std::u8string_view& view, value_type* buffer, size_type buffer_size) + : iu8string(buffer, buffer_size - 1U) + { + this->assign(view.begin(), view.end()); + } +#endif + //************************************************************************* /// Assignment operator. //************************************************************************* @@ -443,7 +455,6 @@ namespace etl return *this; } - //************************************************************************* /// Assignment operator. //************************************************************************* @@ -467,6 +478,28 @@ namespace etl return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u8string_ext& operator = (const etl::u8string_view& view) + { + this->assign(view); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP20 + //************************************************************************* + /// Assignment operator. + //************************************************************************* + u8string_ext& operator = (const std::u8string_view& view) + { + this->assign(view); + + return *this; + } +#endif + //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/wstring.h b/include/etl/wstring.h index 5409d166..93964638 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -400,8 +400,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) @@ -409,6 +409,18 @@ namespace etl this->assign(view.begin(), view.end()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// From string_view. + ///\param view The string_view. + //************************************************************************* + explicit wstring_ext(const std::wstring_view& view, value_type* buffer, size_type buffer_size) + : iwstring(buffer, buffer_size - 1U) + { + this->assign(view.begin(), view.end()); + } +#endif + //************************************************************************* /// Assignment operator. //************************************************************************* @@ -422,7 +434,6 @@ namespace etl return *this; } - //************************************************************************* /// Assignment operator. //************************************************************************* @@ -446,6 +457,28 @@ namespace etl return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + wstring_ext& operator = (const etl::wstring_view& view) + { + this->assign(view); + + return *this; + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + /// Assignment operator. + //************************************************************************* + wstring_ext& operator = (const std::wstring_view& view) + { + this->assign(view); + + return *this; + } +#endif + //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 913ce0dd..cb3de463 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -56,25 +56,25 @@ namespace { static const size_t SIZE = 11UL; - using Text = etl::string; - using IText = etl::istring; - using CompareText = std::string; - using value_t = Text::value_type; - using TextL = etl::string<52>; - using TextS = etl::string<4>; - using ViewETL = etl::string_view; + using Text = etl::string; + using IText = etl::istring; + using TextSTD = std::string; + using value_t = Text::value_type; + using TextL = etl::string<52>; + using TextS = etl::string<4>; + using ViewETL = etl::string_view; #if ETL_USING_STL && ETL_USING_CPP17 using ViewSTD = std::string_view; #endif - CompareText initial_text; - CompareText less_text; - CompareText greater_text; - CompareText shorter_text; - CompareText different_text; - CompareText insert_text; - CompareText longer_text; - CompareText short_text; + TextSTD initial_text; + TextSTD less_text; + TextSTD greater_text; + TextSTD shorter_text; + TextSTD different_text; + TextSTD insert_text; + TextSTD longer_text; + TextSTD short_text; const value_t* pinitial_text = STR("Hello World"); @@ -136,7 +136,7 @@ namespace const size_t INITIAL_SIZE = 5UL; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text(INITIAL_SIZE, INITIAL_VALUE); + TextSTD compare_text(INITIAL_SIZE, INITIAL_VALUE); Text text(INITIAL_SIZE, INITIAL_VALUE); CHECK(text.size() == INITIAL_SIZE); @@ -164,7 +164,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); @@ -180,7 +180,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(longer_text.c_str()); @@ -196,7 +196,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); Text text(SIZE, STR('A')); @@ -212,7 +212,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); Text text(SIZE + 1, STR('A')); @@ -228,7 +228,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char) { - CompareText compare_text(initial_text.c_str(), initial_text.size() / 2); + TextSTD compare_text(initial_text.c_str(), initial_text.size() / 2); Text text(initial_text.c_str(), initial_text.size() / 2); @@ -244,7 +244,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) { - CompareText compare_text(initial_text.c_str(), initial_text.size()); + TextSTD compare_text(initial_text.c_str(), initial_text.size()); Text text(longer_text.c_str(), longer_text.size()); @@ -260,7 +260,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(compare_text.begin(), compare_text.end()); @@ -370,8 +370,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length) { - CompareText compare_text(initial_text.c_str()); - CompareText compare_text2(compare_text, 2, 4); + TextSTD compare_text(initial_text.c_str()); + TextSTD compare_text2(compare_text, 2, 4); Text text(initial_text.c_str()); Text text2(text, 2, 4); @@ -386,8 +386,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) { - CompareText compare_text(longer_text.c_str()); - CompareText compare_text2(compare_text, 2, 11); + TextSTD compare_text(longer_text.c_str()); + TextSTD compare_text2(compare_text, 2, 11); TextL textl(longer_text.c_str()); Text text2(textl, 2, 12); @@ -403,7 +403,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list) { - CompareText compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; Text text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; bool is_equal = Equal(compare_text, text); @@ -416,7 +416,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { - CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + TextSTD compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; Text text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), @@ -547,7 +547,7 @@ namespace text = STR("Hello World"); - bool is_equal = Equal(std::string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -561,7 +561,7 @@ namespace text = STR("Hello World There"); - bool is_equal = Equal(std::string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(text.is_truncated()); @@ -576,7 +576,7 @@ namespace itext = STR("Hello World"); - bool is_equal = Equal(std::string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!itext.is_truncated()); @@ -591,7 +591,7 @@ namespace itext = STR("Hello World There"); - bool is_equal = Equal(std::string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(itext.is_truncated()); @@ -605,7 +605,7 @@ namespace text = ViewETL(STR("Hello World")); - bool is_equal = Equal(std::string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -620,7 +620,7 @@ namespace text = ViewSTD(STR("Hello World")); - bool is_equal = Equal(std::string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -895,7 +895,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -911,7 +911,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -927,7 +927,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -945,7 +945,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -963,7 +963,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); CHECK(text.front() == compare_text.front()); @@ -975,7 +975,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); CHECK(text.front() == compare_text.front()); @@ -987,7 +987,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); CHECK(text.back() == compare_text.back()); @@ -999,7 +999,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); CHECK(text.back() == compare_text.back()); @@ -1011,7 +1011,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(compare_text.begin(), compare_text.end()); @@ -1028,7 +1028,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data_const) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); const Text text(compare_text.begin(), compare_text.end()); @@ -1045,10 +1045,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1064,11 +1064,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_etl_view) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); ViewETL view(input); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1085,11 +1085,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_std_view) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - ViewSTD view(input.data(), input.data_end()); + ViewSTD view(input.data(), input.size()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1106,10 +1106,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextL input(longer_text.c_str()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1125,7 +1125,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(initial_text.c_str()); @@ -1140,7 +1140,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(longer_text.c_str()); @@ -1155,7 +1155,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(initial_text.c_str(), initial_text.size()); @@ -1170,7 +1170,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) { - CompareText compare_text(longer_text.c_str()); + TextSTD compare_text(longer_text.c_str()); Text text; text.assign(longer_text.c_str(), longer_text.size()); @@ -1187,7 +1187,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; @@ -1259,7 +1259,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { - CompareText compare_text; + TextSTD compare_text; Text text; for (size_t i = 0UL; i < SIZE; ++i) @@ -1285,7 +1285,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_excess) { - CompareText compare_text; + TextSTD compare_text; Text text; for (size_t i = 0UL; i < SIZE; ++i) @@ -1316,7 +1316,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); compare_text.pop_back(); @@ -1340,7 +1340,7 @@ namespace for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; Text text; text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); @@ -1360,7 +1360,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(initial_text.begin(), initial_text.end()); const value_t INITIAL_VALUE = STR('A'); @@ -1405,7 +1405,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { - CompareText compare_text; + TextSTD compare_text; Text text; const size_t INITIAL_SIZE = 5UL; @@ -1431,7 +1431,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { - CompareText compare_text; + TextSTD compare_text; Text text; const size_t INSERT_SIZE = 4UL; @@ -1504,7 +1504,7 @@ namespace for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; Text text; text.assign(initial_text.cbegin(), initial_text.cbegin() + INITIAL_SIZE); @@ -1527,7 +1527,7 @@ namespace const size_t INITIAL_SIZE = 5UL; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text; + TextSTD compare_text; Text text; size_t offset = 0UL; @@ -1585,7 +1585,7 @@ namespace for (size_t offset = 10UL; offset < length; ++offset) { - CompareText compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextSTD compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); TextL text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); text.insert(text.cbegin() + offset, text.cbegin() + 5, text.cbegin() + 10); @@ -1604,7 +1604,7 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); Text insert(insert_text.cbegin(), insert_text.cend()); @@ -1625,9 +1625,9 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewETL view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1647,9 +1647,9 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewSTD view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewSTD view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1669,7 +1669,7 @@ namespace { for (size_t offset = 0UL; offset <= initial_text.size(); ++offset) { - CompareText compare_text(initial_text.cbegin(), initial_text.cend()); + TextSTD compare_text(initial_text.cbegin(), initial_text.cend()); Text text(initial_text.cbegin(), initial_text.cend()); Text insert(insert_text.cbegin(), insert_text.cend()); @@ -1690,7 +1690,7 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); Text insert(longer_text.cbegin(), longer_text.cend()); insert.erase(insert.cbegin(), insert.cend()); @@ -1711,7 +1711,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); Text insert(insert_text.cbegin(), insert_text.cend()); @@ -1757,7 +1757,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -1790,9 +1790,9 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_etl_view) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewETL view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1807,7 +1807,7 @@ namespace // Overflow. compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - view.assign(initial_text.data(), initial_text.data() + initial_text.size()); + view.assign(initial_text.data(), initial_text.size()); compare_text.append(initial_text); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -1824,9 +1824,9 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_std_view) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewSTD append(insert_text.data(), insert_text.data() + insert_text.size()); + ViewSTD append(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1841,7 +1841,7 @@ namespace // Overflow. compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.data() + initial_text.size()); + append = ViewSTD(initial_text.data(), initial_text.size()); compare_text.append(initial_text); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -1875,7 +1875,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_to_self) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Non-overflow. @@ -1906,12 +1906,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); // Whole string. - compare_text.append(insert_text, 0, std::string::npos); + compare_text.append(insert_text, 0, TextSTD::npos); text.append(append, 0, Text::npos); bool is_equal = Equal(compare_text, text); @@ -1970,7 +1970,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_c_string) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Whole string. @@ -2002,7 +2002,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_n_c) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Non-overflow. @@ -2034,7 +2034,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_range) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -2067,10 +2067,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace"))); @@ -2084,7 +2084,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace"))); @@ -2098,7 +2098,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2112,7 +2112,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2126,7 +2126,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace"))); @@ -2140,7 +2140,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2154,7 +2154,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2169,10 +2169,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace"))); @@ -2186,7 +2186,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace"))); @@ -2200,7 +2200,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace with some text"))); @@ -2214,7 +2214,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); @@ -2228,7 +2228,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewETL(STR("Replace"))); @@ -2242,7 +2242,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace with some text"))); @@ -2256,7 +2256,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); @@ -2272,10 +2272,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace"))); @@ -2289,7 +2289,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace"))); @@ -2303,7 +2303,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace with some text"))); @@ -2317,7 +2317,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); @@ -2331,7 +2331,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewSTD(STR("Replace"))); @@ -2345,7 +2345,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace with some text"))); @@ -2359,7 +2359,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); @@ -2375,10 +2375,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace"))); @@ -2392,7 +2392,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2406,7 +2406,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace"))); @@ -2420,7 +2420,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2435,10 +2435,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); @@ -2452,7 +2452,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); @@ -2466,7 +2466,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); @@ -2480,7 +2480,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); @@ -2496,10 +2496,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); @@ -2513,7 +2513,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); @@ -2527,7 +2527,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); @@ -2541,7 +2541,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); @@ -2557,10 +2557,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")), 1, 5); @@ -2574,7 +2574,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2588,7 +2588,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2602,7 +2602,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2616,7 +2616,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")), 1, 5); @@ -2630,7 +2630,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2644,7 +2644,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2658,7 +2658,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2673,10 +2673,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); @@ -2690,7 +2690,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); @@ -2704,7 +2704,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); @@ -2718,7 +2718,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); @@ -2732,7 +2732,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); @@ -2746,7 +2746,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); @@ -2760,7 +2760,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); @@ -2774,7 +2774,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); @@ -2790,10 +2790,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); @@ -2807,7 +2807,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); @@ -2821,7 +2821,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); @@ -2835,7 +2835,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); @@ -2849,7 +2849,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); @@ -2863,7 +2863,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); @@ -2877,7 +2877,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); @@ -2891,7 +2891,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); @@ -2907,10 +2907,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")).c_str()); @@ -2924,7 +2924,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); @@ -2938,7 +2938,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); @@ -2952,7 +2952,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); @@ -2966,7 +2966,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")).c_str()); @@ -2980,7 +2980,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); @@ -2994,7 +2994,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); @@ -3008,7 +3008,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); @@ -3023,10 +3023,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str()); @@ -3040,7 +3040,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); @@ -3054,7 +3054,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str()); @@ -3068,7 +3068,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); @@ -3083,10 +3083,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")).c_str(), 5); @@ -3100,7 +3100,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); @@ -3114,7 +3114,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -3128,7 +3128,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); @@ -3142,7 +3142,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")).c_str(), 5); @@ -3156,7 +3156,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); @@ -3170,7 +3170,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -3184,7 +3184,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); @@ -3199,10 +3199,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str(), 5); @@ -3218,7 +3218,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -3234,7 +3234,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str(), 5); @@ -3250,7 +3250,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -3267,7 +3267,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(2, 4, 7, STR('A')); @@ -3284,7 +3284,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -3312,7 +3312,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -3340,7 +3340,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -3368,7 +3368,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -3383,7 +3383,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, 7, STR('A')); @@ -3443,11 +3443,11 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - CompareText replace(STR("Replace")); - CompareText replace_long(STR("Replace with some text")); + TextSTD replace(STR("Replace")); + TextSTD replace_long(STR("Replace with some text")); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -3505,10 +3505,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.begin() + 2); + TextSTD::iterator citr = compare_text.erase(compare_text.begin() + 2); Text::iterator ditr = text.erase(text.begin() + 2); CHECK(*citr == *ditr); @@ -3522,10 +3522,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2); + TextSTD::iterator citr = compare_text.erase(compare_text.cbegin() + 2); Text::iterator ditr = text.erase(text.cbegin() + 2); CHECK(*citr == *ditr); @@ -3539,10 +3539,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); + TextSTD::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); Text::iterator ditr = text.erase(text.cbegin() + 2, text.cbegin() + 4); CHECK(*citr == *ditr); @@ -3568,7 +3568,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.begin(), text.end(), compare_text.begin()); @@ -3581,7 +3581,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.cbegin(), text.cend(), compare_text.cbegin()); @@ -3594,7 +3594,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.rbegin(), text.rend(), compare_text.rbegin()); @@ -3607,7 +3607,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.crbegin(), text.crend(), compare_text.crbegin()); @@ -3794,7 +3794,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; @@ -3835,13 +3835,13 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; value_t buffer2[SIZE]; - size_t length1 = compare_text.copy(buffer1, CompareText::npos, 2); + size_t length1 = compare_text.copy(buffer1, TextSTD::npos, 2); buffer1[length1] = STR('\0'); size_t length2 = text.copy(buffer2, Text::npos, 2); @@ -3861,7 +3861,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_too_large) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; @@ -3889,11 +3889,11 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_needle(STR("needle")); - etl::string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); - std::string compare_haystack(the_haystack); - etl::string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -3907,11 +3907,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.find(pin); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -3919,12 +3919,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_needle(STR("needle")); - etl::string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); ViewETL needle_view(needle); - std::string compare_haystack(the_haystack); - etl::string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -3938,12 +3938,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(etl::string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::string<50> pin(STR("pin")); - ViewETL pin_view(pin); + ViewETL pin_view(STR("pin")); position2 = haystack.find(pin_view); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } #if ETL_USING_STL && ETL_USING_CPP17 @@ -3952,12 +3951,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_needle(STR("needle")); - std::string needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); ViewSTD needle_view(needle); - std::string compare_haystack(the_haystack); - etl::string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -3971,12 +3970,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(etl::string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - std::string pin(STR("pin")); - ViewSTD pin_view(pin); + ViewSTD pin_view(STR("pin")); position2 = haystack.find(pin_view); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } #endif @@ -3987,8 +3985,8 @@ namespace const value_t* needle = STR("needle"); - std::string compare_haystack(the_haystack); - etl::string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -4002,11 +4000,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); const value_t *pin = STR("pin"); position2 = haystack.find(pin); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4016,8 +4014,8 @@ namespace const value_t* needle = STR("needle"); - std::string compare_haystack(the_haystack); - etl::string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -4031,11 +4029,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1, 3); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); const value_t *pin = STR("pin"); position2 = haystack.find(pin, 0, 3); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4043,14 +4041,14 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_needle(STR("needle")); - etl::string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); - std::string compare_haystack(the_haystack); - etl::string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); - size_t position1 = std::string::npos; - size_t position2 = etl::string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle, position2); @@ -4060,9 +4058,9 @@ namespace position2 = haystack.rfind(needle, haystack.size() - 10); CHECK_EQUAL(position1, position2); - etl::string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4070,45 +4068,15 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_needle(STR("needle")); - etl::string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); ViewETL needle_view(needle); - std::string compare_haystack(the_haystack); - etl::string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); - size_t position1 = std::string::npos; - size_t position2 = etl::string<50>::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - etl::string<50> pin(STR("pin")); - ViewETL pin_view(pin); - position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::istring::npos, position2); - } - -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - std::string compare_needle(STR("needle")); - std::string needle(STR("needle")); - ViewSTD needle_view(needle); - - std::string compare_haystack(the_haystack); - etl::string<50> haystack(the_haystack); - - size_t position1 = std::string::npos; - size_t position2 = etl::string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle_view, position2); @@ -4118,10 +4086,38 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - std::string pin(STR("pin")); - ViewSTD pin_view(pin); + ViewETL pin_view(STR("pin")); position2 = haystack.rfind(pin_view); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); + ViewSTD needle_view(needle); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = Text::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); } #endif @@ -4130,13 +4126,13 @@ namespace { const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_haystack(the_haystack); - etl::string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); const value_t* needle = STR("needle"); - size_t position1 = std::string::npos; - size_t position2 = etl::string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(needle, position1); position2 = haystack.rfind(needle, position2); @@ -4146,9 +4142,9 @@ namespace position2 = haystack.rfind(needle, haystack.size() - 10); CHECK_EQUAL(position1, position2); - etl::string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4156,13 +4152,13 @@ namespace { const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_haystack(the_haystack); - etl::string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); const value_t* needle = STR("needle"); - size_t position1 = std::string::npos; - size_t position2 = etl::string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(needle, position1, 3); position2 = haystack.rfind(needle, position2, 3); @@ -4173,7 +4169,7 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.rfind(STR("pin"), 3); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4181,11 +4177,11 @@ namespace { const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_haystack(the_haystack); - etl::string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); - etl::istring::size_type position1 = etl::istring::npos; - size_t position2 = etl::string<50>::npos; + etl::istring::size_type position1 = TextL::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(STR('e'), position1); position2 = haystack.rfind(STR('e'), position2); @@ -4196,16 +4192,16 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.rfind(STR('z')); - CHECK_EQUAL(etl::istring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_substr) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText compare_result; + TextSTD compare_result; Text result; // Equal. @@ -4240,34 +4236,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(Text(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(Text(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(Text(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(Text(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(Text(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4275,34 +4271,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_etl_view) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(ViewETL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(ViewETL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(ViewETL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(ViewETL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(ViewETL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4311,34 +4307,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_std_view) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(ViewSTD(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(ViewSTD(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(ViewSTD(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(ViewSTD(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(ViewSTD(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4347,34 +4343,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, Text(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, Text(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, Text(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, Text(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, Text(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4382,34 +4378,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, ViewETL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4418,34 +4414,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4454,34 +4450,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, Text(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, Text(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4489,34 +4485,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4525,34 +4521,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4561,7 +4557,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; @@ -4596,7 +4592,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; @@ -4631,7 +4627,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; @@ -4666,26 +4662,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(Text(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(Text(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(Text(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(Text(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4695,26 +4691,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(ViewETL(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4725,26 +4721,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4755,7 +4751,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR("ZCXF")); @@ -4784,7 +4780,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR("ZCXF"), 0, 4); @@ -4818,7 +4814,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR('C')); @@ -4857,31 +4853,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(Text(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(Text(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(Text(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(Text(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(Text(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4891,31 +4887,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4926,31 +4922,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4961,7 +4957,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(STR("ZCXE")); @@ -5000,7 +4996,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(STR("AZCXE"), 0, 4); @@ -5037,7 +5033,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_last_of(STR('C')); @@ -5076,31 +5072,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(Text(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(Text(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(Text(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(Text(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(Text(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5110,31 +5106,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5145,31 +5141,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5180,7 +5176,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR("ZAXB")); @@ -5214,7 +5210,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR("ZAXB"), 0, 4); @@ -5253,7 +5249,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR('A')); @@ -5292,31 +5288,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(Text(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(Text(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(Text(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(Text(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(Text(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5326,31 +5322,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5361,31 +5357,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5396,7 +5392,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(STR("ZEXD")); @@ -5430,7 +5426,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(STR("ZEXD"), 0, 4); @@ -5462,7 +5458,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_last_not_of(STR('F')); diff --git a/test/test_string_char_external_buffer.cpp b/test/test_string_char_external_buffer.cpp index d934dafe..e2704e81 100644 --- a/test/test_string_char_external_buffer.cpp +++ b/test/test_string_char_external_buffer.cpp @@ -33,6 +33,7 @@ SOFTWARE. #include #include "etl/string.h" +#include "etl/string_view.h" #include "etl/fnv_1.h" #undef STR @@ -53,24 +54,29 @@ namespace static constexpr size_t SIZE_L = 52UL; static constexpr size_t SIZE_S = 4UL; - using Text = etl::string_ext; - using IText = etl::istring; - using TextL = etl::string; - using CompareText = std::string; - using value_t = Text::value_type; + using Text = etl::string_ext; + using IText = etl::istring; + using TextL = etl::string; + using TextSTD = std::string; + using value_t = Text::value_type; using TextBuffer = std::array; using TextBufferL = std::array; using TextBufferS = std::array; - CompareText initial_text; - CompareText less_text; - CompareText greater_text; - CompareText shorter_text; - CompareText different_text; - CompareText insert_text; - CompareText longer_text; - CompareText short_text; + using ViewETL = etl::string_view; +#if ETL_USING_STL && ETL_USING_CPP17 + using ViewSTD = std::string_view; +#endif + + TextSTD initial_text; + TextSTD less_text; + TextSTD greater_text; + TextSTD shorter_text; + TextSTD different_text; + TextSTD insert_text; + TextSTD longer_text; + TextSTD short_text; const value_t* pinitial_text = STR("Hello World"); @@ -201,7 +207,7 @@ namespace const value_t INITIAL_VALUE = STR('A'); TextBuffer buffer{0}; - CompareText compare_text(INITIAL_SIZE, INITIAL_VALUE); + TextSTD compare_text(INITIAL_SIZE, INITIAL_VALUE); Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); CHECK(text.size() == INITIAL_SIZE); @@ -231,7 +237,7 @@ namespace TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) { TextBuffer buffer{0}; - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -247,7 +253,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(longer_text.c_str(), buffer.data(), buffer.size()); @@ -264,7 +270,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); TextBuffer buffer{0}; Text text(SIZE, STR('A'), buffer.data(), buffer.size()); @@ -281,7 +287,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); TextBuffer buffer{0}; Text text(SIZE + 1, STR('A'), buffer.data(), buffer.size()); @@ -298,7 +304,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char) { - CompareText compare_text(initial_text.c_str(), initial_text.size() / 2); + TextSTD compare_text(initial_text.c_str(), initial_text.size() / 2); TextBuffer buffer{0}; Text text(initial_text.c_str(), initial_text.size() / 2, buffer.data(), buffer.size()); @@ -315,7 +321,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) { - CompareText compare_text(initial_text.c_str(), initial_text.size()); + TextSTD compare_text(initial_text.c_str(), initial_text.size()); TextBuffer buffer{0}; Text text(longer_text.c_str(), longer_text.size(), buffer.data(), buffer.size()); @@ -332,7 +338,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); TextBuffer buffer{0}; Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -372,10 +378,9 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) + TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - etl::string_view view(initial_text.data(), initial_text.size()); - + ViewETL view(initial_text.data(), initial_text.size()); TextBuffer buffer{0}; Text text(view, buffer.data(), buffer.size()); @@ -385,6 +390,21 @@ namespace CHECK(!text.empty()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) + { + ViewSTD view(initial_text.data(), initial_text.size()); + TextBuffer buffer{0}; + Text text(view, buffer.data(), buffer.size()); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -448,8 +468,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length) { - CompareText compare_text(initial_text.c_str()); - CompareText compare_text2(compare_text, 2, 4); + TextSTD compare_text(initial_text.c_str()); + TextSTD compare_text2(compare_text, 2, 4); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -467,8 +487,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) { - CompareText compare_text(longer_text.c_str()); - CompareText compare_text2(compare_text, 2, 11); + TextSTD compare_text(longer_text.c_str()); + TextSTD compare_text2(compare_text, 2, 11); TextBufferL bufferl{0}; Text textl(longer_text.c_str(), bufferl.data(), bufferl.size()); @@ -487,7 +507,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list) { - CompareText compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; std::initializer_list il = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; TextBuffer buffer{0}; @@ -503,7 +523,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { - CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + TextSTD compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; std::initializer_list il = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), @@ -656,7 +676,7 @@ namespace text = STR("Hello World"); - bool is_equal = Equal(std::string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -671,7 +691,7 @@ namespace text = STR("Hello World There"); - bool is_equal = Equal(std::string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(text.is_truncated()); @@ -687,7 +707,7 @@ namespace itext = STR("Hello World"); - bool is_equal = Equal(std::string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!itext.is_truncated()); @@ -703,13 +723,45 @@ namespace itext = STR("Hello World There"); - bool is_equal = Equal(std::string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(itext.is_truncated()); #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = ViewETL(STR("Hello World")); + + bool is_equal = Equal(TextSTD(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = ViewSTD(STR("Hello World")); + + bool is_equal = Equal(TextSTD(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -981,7 +1033,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -999,7 +1051,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1017,7 +1069,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1037,7 +1089,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1057,7 +1109,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1071,7 +1123,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1085,7 +1137,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1099,7 +1151,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1113,7 +1165,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -1131,7 +1183,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data_const) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -1149,12 +1201,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextBuffer buffer{0}; Text input(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer2{0}; Text text(buffer2.data(), buffer2.size()); @@ -1169,15 +1221,61 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_etl_view) + { + TextSTD compare_input(initial_text.c_str()); + TextBuffer buffer{0}; + Text input(initial_text.c_str(), buffer.data(), buffer.size()); + ViewETL view(input); + + TextSTD compare_text; + TextBuffer buffer2{0}; + Text text(buffer2.data(), buffer2.size()); + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_std_view) + { + TextSTD compare_input(initial_text.c_str()); + TextBuffer buffer{0}; + Text input(initial_text.c_str(), buffer.data(), buffer.size()); + ViewSTD view(input.data(), input.size()); + + TextSTD compare_text; + TextBuffer buffer2{0}; + Text text(buffer2.data(), buffer2.size()); + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextBufferL bufferl{0}; Text input(longer_text.c_str(), bufferl.data(), bufferl.size()); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1195,7 +1293,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1211,7 +1309,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1227,7 +1325,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1243,7 +1341,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) { - CompareText compare_text(longer_text.c_str()); + TextSTD compare_text(longer_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1261,7 +1359,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1337,7 +1435,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1365,7 +1463,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_excess) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1398,7 +1496,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1424,7 +1522,7 @@ namespace for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1446,7 +1544,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); TextBuffer buffer{0}; Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); @@ -1492,7 +1590,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1519,7 +1617,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1593,7 +1691,7 @@ namespace for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1617,7 +1715,7 @@ namespace const size_t INITIAL_SIZE = 5UL; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1676,7 +1774,7 @@ namespace for (size_t offset = 10UL; offset < length; ++offset) { - CompareText compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextSTD compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); TextBufferL bufferl{0}; Text text(bufferl.data(), bufferl.size()); text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); @@ -1697,7 +1795,7 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1717,12 +1815,60 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { for (size_t offset = 0UL; offset <= initial_text.size(); ++offset) { - CompareText compare_text(initial_text.cbegin(), initial_text.cend()); + TextSTD compare_text(initial_text.cbegin(), initial_text.cend()); TextBuffer buffer{0}; Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); @@ -1747,7 +1893,7 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer{0}; Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1773,7 +1919,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer{0}; Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1823,7 +1969,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1857,6 +2003,76 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_etl_view) + { + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + view.assign(initial_text.data(), initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(view); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_std_view) + { + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + ViewSTD append(insert_text.data(), insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(append); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append = ViewSTD(initial_text.data(), initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -1880,7 +2096,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_to_self) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1913,7 +2129,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1922,7 +2138,7 @@ namespace Text append(insert_text.c_str(), buffer2.data(), buffer2.size()); // Whole string. - compare_text.append(insert_text, 0, std::string::npos); + compare_text.append(insert_text, 0, TextSTD::npos); text.append(append, 0, Text::npos); bool is_equal = Equal(compare_text, text); @@ -1984,7 +2200,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_c_string) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2018,7 +2234,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_n_c) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2052,7 +2268,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_range) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2089,12 +2305,12 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace"))); @@ -2108,7 +2324,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace"))); @@ -2122,7 +2338,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2136,7 +2352,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2150,7 +2366,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace"))); @@ -2164,7 +2380,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2178,7 +2394,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2189,16 +2405,224 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + { + // Non-overflow short text, npos. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) + { + // Non-overflow short text, npos. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace"))); @@ -2212,7 +2636,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2226,7 +2650,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace"))); @@ -2240,7 +2664,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2251,16 +2675,140 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")), 1, 5); @@ -2274,7 +2822,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2288,7 +2836,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2302,7 +2850,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2316,7 +2864,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")), 1, 5); @@ -2330,7 +2878,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2344,7 +2892,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2358,7 +2906,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2369,16 +2917,252 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")).c_str()); @@ -2392,7 +3176,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); @@ -2406,7 +3190,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); @@ -2420,7 +3204,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); @@ -2434,7 +3218,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")).c_str()); @@ -2448,7 +3232,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); @@ -2462,7 +3246,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); @@ -2476,7 +3260,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); @@ -2491,12 +3275,12 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str()); @@ -2510,7 +3294,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); @@ -2524,7 +3308,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str()); @@ -2538,7 +3322,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); @@ -2553,12 +3337,12 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")).c_str(), 5); @@ -2572,7 +3356,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); @@ -2586,7 +3370,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -2600,7 +3384,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); @@ -2614,7 +3398,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")).c_str(), 5); @@ -2628,7 +3412,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); @@ -2642,7 +3426,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -2656,7 +3440,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); @@ -2671,12 +3455,12 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str(), 5); @@ -2692,7 +3476,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -2708,7 +3492,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str(), 5); @@ -2724,7 +3508,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -2741,7 +3525,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2760,7 +3544,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -2788,7 +3572,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -2816,7 +3600,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -2844,7 +3628,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -2859,7 +3643,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2921,13 +3705,13 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - CompareText replace(STR("Replace")); - CompareText replace_long(STR("Replace with some text")); + TextSTD replace(STR("Replace")); + TextSTD replace_long(STR("Replace with some text")); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -2985,7 +3769,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3003,7 +3787,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3035,7 +3819,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3050,7 +3834,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3065,7 +3849,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3080,7 +3864,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3299,7 +4083,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3343,7 +4127,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3351,7 +4135,7 @@ namespace value_t buffer1[SIZE]; value_t buffer2[SIZE]; - size_t length1 = compare_text.copy(buffer1, CompareText::npos, 2); + size_t length1 = compare_text.copy(buffer1, TextSTD::npos, 2); buffer1[length1] = STR('\0'); size_t length2 = text.copy(buffer2, Text::npos, 2); @@ -3371,7 +4155,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_too_large) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3401,12 +4185,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_needle(STR("needle")); + TextSTD compare_needle(STR("needle")); TextBuffer buffer{0}; Text needle(STR("needle"), buffer.data(), buffer.size()); - std::string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; Text haystack(the_haystack, buffer2.data(), buffer2.size()); @@ -3423,13 +4207,77 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::string<50> pin(STR("pin")); + Text pin(STR("pin"), buffer.data(), buffer.size()); position2 = haystack.find(pin); CHECK_EQUAL(IText::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + ViewETL needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(TextL::npos, position2); + + ViewETL pin_view(STR("pin")); + position2 = haystack.find(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + ViewSTD needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(TextL::npos, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.find(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -3437,7 +4285,7 @@ namespace const value_t* needle = STR("needle"); - std::string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); @@ -3468,7 +4316,7 @@ namespace const value_t* needle = STR("needle"); - std::string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); @@ -3497,18 +4345,18 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_needle(STR("needle")); + TextSTD compare_needle(STR("needle")); TextBufferL buffer{0}; Text needle(STR("needle"), buffer.data(), buffer.size()); - std::string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; Text haystack(the_haystack, buffer2.data(), buffer2.size()); - size_t position1 = std::string::npos; - size_t position2 = etl::string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle, position2); @@ -3524,20 +4372,77 @@ namespace CHECK_EQUAL(IText::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + ViewETL needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewETL pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); + ViewSTD needle_view(needle); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); const value_t* needle = STR("needle"); - size_t position1 = std::string::npos; - size_t position2 = etl::string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(needle, position1); position2 = haystack.rfind(needle, position2); @@ -3558,14 +4463,14 @@ namespace { const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); const value_t* needle = STR("needle"); - size_t position1 = std::string::npos; + size_t position1 = TextSTD::npos; size_t position2 = Text::npos; @@ -3586,13 +4491,13 @@ namespace { const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); - size_t position1 = std::string::npos; - size_t position2 = etl::string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(STR('e'), position1); position2 = haystack.rfind(STR('e'), position2); @@ -3609,7 +4514,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3618,35 +4523,110 @@ namespace int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(TextL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(TextL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(TextL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(TextL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(TextL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_etl_view) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); + result = text.compare(ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); + result = text.compare(ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); + result = text.compare(ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); + result = text.compare(ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); + result = text.compare(ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_std_view) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); + result = text.compare(ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); + result = text.compare(ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); + result = text.compare(ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); + result = text.compare(ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); + result = text.compare(ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3655,35 +4635,109 @@ namespace int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, TextL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, TextL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, TextL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, TextL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, TextL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3692,35 +4746,109 @@ namespace int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, TextL(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, TextL(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3757,7 +4885,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3794,7 +4922,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3831,38 +4959,100 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(TextL(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(TextL(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(TextL(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(TextL(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); + position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); + position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3893,7 +5083,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3929,7 +5119,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3970,43 +5160,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(TextL(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(TextL(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(TextL(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(TextL(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(TextL(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4047,7 +5309,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4088,7 +5350,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4129,43 +5391,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(TextL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(TextL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(TextL(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(TextL(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(TextL(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4201,7 +5535,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4242,7 +5576,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4283,43 +5617,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(TextL(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(TextL(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4355,7 +5761,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4389,7 +5795,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 20671aa5..98557a8e 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -66,21 +66,21 @@ namespace { static const size_t SIZE = 11; - using Text = etl::u16string; - using IText = etl::iu16string; - using CompareText = std::u16string; - using value_t = Text::value_type; - using TextL = etl::u16string<52>; - using TextS = etl::u16string<4>; + using Text = etl::u16string; + using IText = etl::iu16string; + using TextSTD = std::u16string; + using value_t = Text::value_type; + using TextL = etl::u16string<52>; + using TextS = etl::u16string<4>; - CompareText initial_text; - CompareText less_text; - CompareText greater_text; - CompareText shorter_text; - CompareText different_text; - CompareText insert_text; - CompareText longer_text; - CompareText short_text; + TextSTD initial_text; + TextSTD less_text; + TextSTD greater_text; + TextSTD shorter_text; + TextSTD different_text; + TextSTD insert_text; + TextSTD longer_text; + TextSTD short_text; using ViewETL = etl::u16string_view; #if ETL_USING_STL && ETL_USING_CPP17 using ViewSTD = std::u16string_view; @@ -147,7 +147,7 @@ namespace const size_t INITIAL_SIZE = 5; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text(INITIAL_SIZE, INITIAL_VALUE); + TextSTD compare_text(INITIAL_SIZE, INITIAL_VALUE); Text text(INITIAL_SIZE, INITIAL_VALUE); CHECK(text.size() == INITIAL_SIZE); @@ -175,7 +175,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); @@ -191,7 +191,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(longer_text.c_str()); @@ -207,7 +207,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); Text text(SIZE, STR('A')); @@ -223,7 +223,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); Text text(SIZE + 1, STR('A')); @@ -239,7 +239,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char) { - CompareText compare_text(initial_text.c_str(), initial_text.size() / 2); + TextSTD compare_text(initial_text.c_str(), initial_text.size() / 2); Text text(initial_text.c_str(), initial_text.size() / 2); @@ -255,7 +255,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) { - CompareText compare_text(initial_text.c_str(), initial_text.size()); + TextSTD compare_text(initial_text.c_str(), initial_text.size()); Text text(longer_text.c_str(), longer_text.size()); @@ -271,7 +271,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(compare_text.begin(), compare_text.end()); @@ -381,8 +381,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length) { - CompareText compare_text(initial_text.c_str()); - CompareText compare_text2(compare_text, 2, 4); + TextSTD compare_text(initial_text.c_str()); + TextSTD compare_text2(compare_text, 2, 4); Text text(initial_text.c_str()); Text text2(text, 2, 4); @@ -397,8 +397,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) { - CompareText compare_text(longer_text.c_str()); - CompareText compare_text2(compare_text, 2, 11); + TextSTD compare_text(longer_text.c_str()); + TextSTD compare_text2(compare_text, 2, 11); TextL textl(longer_text.c_str()); Text text2(textl, 2, 12); @@ -414,7 +414,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list) { - CompareText compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; Text text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; bool is_equal = Equal(compare_text, text); @@ -427,7 +427,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { - CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + TextSTD compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; Text text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), @@ -558,7 +558,7 @@ namespace text = STR("Hello World"); - bool is_equal = Equal(std::u16string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -572,7 +572,7 @@ namespace text = STR("Hello World There"); - bool is_equal = Equal(std::u16string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(text.is_truncated()); @@ -587,7 +587,7 @@ namespace itext = STR("Hello World"); - bool is_equal = Equal(std::u16string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!itext.is_truncated()); @@ -602,7 +602,7 @@ namespace itext = STR("Hello World There"); - bool is_equal = Equal(std::u16string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(itext.is_truncated()); @@ -616,7 +616,7 @@ namespace text = ViewETL(STR("Hello World")); - bool is_equal = Equal(std::u16string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -631,7 +631,7 @@ namespace text = ViewSTD(STR("Hello World")); - bool is_equal = Equal(std::u16string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -905,7 +905,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -921,7 +921,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -937,7 +937,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -955,7 +955,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -973,7 +973,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); CHECK(text.front() == compare_text.front()); @@ -985,7 +985,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); CHECK(text.front() == compare_text.front()); @@ -997,7 +997,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); CHECK(text.back() == compare_text.back()); @@ -1009,7 +1009,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); CHECK(text.back() == compare_text.back()); @@ -1021,7 +1021,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(compare_text.begin(), compare_text.end()); @@ -1038,7 +1038,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data_const) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); const Text text(compare_text.begin(), compare_text.end()); @@ -1055,10 +1055,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1074,11 +1074,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_etl_view) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); ViewETL view(input); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1095,11 +1095,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_std_view) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - ViewSTD view(input.data(), input.data_end()); + ViewSTD view(input.data(), input.size()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1116,10 +1116,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextL input(longer_text.c_str()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1135,7 +1135,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(initial_text.c_str()); @@ -1150,7 +1150,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(longer_text.c_str()); @@ -1165,7 +1165,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(initial_text.c_str(), initial_text.size()); @@ -1180,7 +1180,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) { - CompareText compare_text(longer_text.c_str()); + TextSTD compare_text(longer_text.c_str()); Text text; text.assign(longer_text.c_str(), longer_text.size()); @@ -1197,7 +1197,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; @@ -1269,7 +1269,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { - CompareText compare_text; + TextSTD compare_text; Text text; for (size_t i = 0UL; i < SIZE; ++i) @@ -1295,7 +1295,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_excess) { - CompareText compare_text; + TextSTD compare_text; Text text; for (size_t i = 0UL; i < SIZE; ++i) @@ -1326,7 +1326,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); compare_text.pop_back(); @@ -1350,7 +1350,7 @@ namespace for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; Text text; text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); @@ -1370,7 +1370,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(initial_text.begin(), initial_text.end()); const value_t INITIAL_VALUE = STR('A'); @@ -1415,7 +1415,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { - CompareText compare_text; + TextSTD compare_text; Text text; const size_t INITIAL_SIZE = 5; @@ -1441,7 +1441,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { - CompareText compare_text; + TextSTD compare_text; Text text; const size_t INSERT_SIZE = 4; @@ -1514,7 +1514,7 @@ namespace for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; Text text; text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); @@ -1537,7 +1537,7 @@ namespace const size_t INITIAL_SIZE = 5; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text; + TextSTD compare_text; Text text; size_t offset = 0; @@ -1595,7 +1595,7 @@ namespace for (size_t offset = 10; offset < length; ++offset) { - CompareText compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextSTD compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); TextL text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); text.insert(text.begin() + offset, text.begin() + 5, text.begin() + 10); @@ -1614,7 +1614,7 @@ namespace { for (size_t offset = 0; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1635,9 +1635,9 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewETL view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1657,9 +1657,9 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewSTD view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewSTD view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1679,7 +1679,7 @@ namespace { for (size_t offset = 0; offset <= initial_text.size(); ++offset) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(initial_text.begin(), initial_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1700,7 +1700,7 @@ namespace { for (size_t offset = 0; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(longer_text.begin(), longer_text.end()); insert.erase(insert.begin(), insert.end()); @@ -1721,7 +1721,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1767,7 +1767,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -1800,9 +1800,9 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_etl_view) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewETL view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1817,7 +1817,7 @@ namespace // Overflow. compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - view.assign(initial_text.data(), initial_text.data() + initial_text.size()); + view.assign(initial_text.data(), initial_text.size()); compare_text.append(initial_text); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -1834,9 +1834,9 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_std_view) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewSTD append(insert_text.data(), insert_text.data() + insert_text.size()); + ViewSTD append(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1851,7 +1851,7 @@ namespace // Overflow. compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.data() + initial_text.size()); + append = ViewSTD(initial_text.data(), initial_text.size()); compare_text.append(initial_text); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -1885,7 +1885,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_to_self) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Non-overflow. @@ -1916,12 +1916,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); // Whole string. - compare_text.append(insert_text, 0, std::u16string::npos); + compare_text.append(insert_text, 0, TextSTD::npos); text.append(append, 0, Text::npos); bool is_equal = Equal(compare_text, text); @@ -1980,7 +1980,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_c_string) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Whole string. @@ -2012,7 +2012,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_n_c) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Non-overflow. @@ -2044,7 +2044,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_range) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -2077,10 +2077,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace"))); @@ -2094,7 +2094,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace"))); @@ -2108,7 +2108,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2122,7 +2122,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2136,7 +2136,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace"))); @@ -2150,7 +2150,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2164,7 +2164,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2179,10 +2179,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace"))); @@ -2196,7 +2196,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace"))); @@ -2210,7 +2210,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace with some text"))); @@ -2224,7 +2224,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); @@ -2238,7 +2238,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewETL(STR("Replace"))); @@ -2252,7 +2252,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace with some text"))); @@ -2266,7 +2266,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); @@ -2282,10 +2282,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace"))); @@ -2299,7 +2299,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace"))); @@ -2313,7 +2313,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace with some text"))); @@ -2327,7 +2327,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); @@ -2341,7 +2341,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewSTD(STR("Replace"))); @@ -2355,7 +2355,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace with some text"))); @@ -2369,7 +2369,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); @@ -2385,10 +2385,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace"))); @@ -2402,7 +2402,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2416,7 +2416,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace"))); @@ -2430,7 +2430,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2445,10 +2445,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); @@ -2462,7 +2462,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); @@ -2476,7 +2476,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); @@ -2490,7 +2490,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); @@ -2506,10 +2506,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); @@ -2523,7 +2523,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); @@ -2537,7 +2537,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); @@ -2551,7 +2551,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); @@ -2567,10 +2567,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")), 1, 5); @@ -2584,7 +2584,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2598,7 +2598,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2612,7 +2612,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2626,7 +2626,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")), 1, 5); @@ -2640,7 +2640,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2654,7 +2654,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2668,7 +2668,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2683,10 +2683,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); @@ -2700,7 +2700,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); @@ -2714,7 +2714,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); @@ -2728,7 +2728,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); @@ -2742,7 +2742,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); @@ -2756,7 +2756,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); @@ -2770,7 +2770,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); @@ -2784,7 +2784,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); @@ -2800,10 +2800,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); @@ -2817,7 +2817,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); @@ -2831,7 +2831,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); @@ -2845,7 +2845,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); @@ -2859,7 +2859,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); @@ -2873,7 +2873,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); @@ -2887,7 +2887,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); @@ -2901,7 +2901,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); @@ -2917,7 +2917,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(2, 4, STR("Replace")); @@ -2934,7 +2934,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, STR("Replace")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace")); @@ -2962,7 +2962,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text")); @@ -2990,7 +2990,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, STR("Replace")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace")); @@ -3018,7 +3018,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text")); @@ -3033,7 +3033,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace")); @@ -3093,7 +3093,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(2, 4, STR("Replace"), 5); @@ -3110,7 +3110,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, STR("Replace"), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace"), 5); @@ -3138,7 +3138,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text"), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text"), 15); @@ -3166,7 +3166,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, STR("Replace"), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace"), 5); @@ -3194,7 +3194,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text"), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text"), 15); @@ -3209,7 +3209,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace"), 5); @@ -3277,7 +3277,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(2, 4, 7, STR('A')); @@ -3294,7 +3294,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -3322,7 +3322,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -3350,7 +3350,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -3378,7 +3378,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -3393,7 +3393,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, 7, STR('A')); @@ -3453,11 +3453,11 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - CompareText replace(STR("Replace")); - CompareText replace_long(STR("Replace with some text")); + TextSTD replace(STR("Replace")); + TextSTD replace_long(STR("Replace with some text")); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -3515,10 +3515,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.begin() + 2); + TextSTD::iterator citr = compare_text.erase(compare_text.begin() + 2); Text::iterator ditr = text.erase(text.begin() + 2); CHECK(*citr == *ditr); @@ -3532,10 +3532,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2); + TextSTD::iterator citr = compare_text.erase(compare_text.cbegin() + 2); Text::iterator ditr = text.erase(text.cbegin() + 2); CHECK(*citr == *ditr); @@ -3549,10 +3549,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); + TextSTD::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); Text::iterator ditr = text.erase(text.cbegin() + 2, text.cbegin() + 4); CHECK(*citr == *ditr); @@ -3578,7 +3578,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.begin(), text.end(), compare_text.begin()); @@ -3591,7 +3591,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.cbegin(), text.cend(), compare_text.cbegin()); @@ -3604,7 +3604,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.rbegin(), text.rend(), compare_text.rbegin()); @@ -3617,7 +3617,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.crbegin(), text.crend(), compare_text.crbegin()); @@ -3804,7 +3804,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; @@ -3845,13 +3845,13 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; value_t buffer2[SIZE]; - size_t length1 = compare_text.copy(buffer1, CompareText::npos, 2); + size_t length1 = compare_text.copy(buffer1, TextSTD::npos, 2); buffer1[length1] = STR('\0'); size_t length2 = text.copy(buffer2, Text::npos, 2); @@ -3871,7 +3871,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_too_large) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; @@ -3899,11 +3899,11 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_needle(STR("needle")); - etl::u16string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); - std::u16string compare_haystack(the_haystack); - etl::u16string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -3917,11 +3917,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::u16string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::u16string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.find(pin); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -3929,12 +3929,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_needle(STR("needle")); - etl::u16string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); ViewETL needle_view(needle); - std::u16string compare_haystack(the_haystack); - etl::u16string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -3948,12 +3948,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(etl::u16string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::u16string<50> pin(STR("pin")); - ViewETL pin_view(pin); + ViewETL pin_view(STR("pin")); position2 = haystack.find(pin_view); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } #if ETL_USING_STL && ETL_USING_CPP17 @@ -3962,12 +3961,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_needle(STR("needle")); - std::u16string needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); ViewSTD needle_view(needle); - std::u16string compare_haystack(the_haystack); - etl::u16string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -3981,12 +3980,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(etl::u16string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - std::u16string pin(STR("pin")); - ViewSTD pin_view(pin); + ViewSTD pin_view(STR("pin")); position2 = haystack.find(pin_view); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } #endif @@ -3997,8 +3995,8 @@ namespace const value_t* needle = STR("needle"); - std::u16string compare_haystack(the_haystack); - etl::u16string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -4012,11 +4010,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); const value_t* pin = STR("pin"); position2 = haystack.find(pin); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4026,8 +4024,8 @@ namespace const value_t* needle = STR("needle"); - std::u16string compare_haystack(the_haystack); - etl::u16string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -4041,11 +4039,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1, 3); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); const value_t* pin = STR("pin"); position2 = haystack.find(pin, 0, 3); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4053,14 +4051,14 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_needle(STR("needle")); - etl::u16string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); - std::u16string compare_haystack(the_haystack); - etl::u16string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); - size_t position1 = std::u16string::npos; - size_t position2 = etl::u16string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle, position2); @@ -4070,9 +4068,9 @@ namespace position2 = haystack.rfind(needle, haystack.size() - 10); CHECK_EQUAL(position1, position2); - etl::u16string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4080,45 +4078,15 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_needle(STR("needle")); - etl::u16string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); ViewETL needle_view(needle); - std::u16string compare_haystack(the_haystack); - etl::u16string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); - size_t position1 = std::u16string::npos; - size_t position2 = etl::u16string<50>::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - etl::u16string<50> pin(STR("pin")); - ViewETL pin_view(pin); - position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iu16string::npos, position2); - } - -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - std::u16string compare_needle(STR("needle")); - std::u16string needle(STR("needle")); - ViewSTD needle_view(needle); - - std::u16string compare_haystack(the_haystack); - etl::u16string<50> haystack(the_haystack); - - size_t position1 = std::u16string::npos; - size_t position2 = etl::u16string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle_view, position2); @@ -4128,10 +4096,38 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - std::u16string pin(STR("pin")); - ViewSTD pin_view(pin); + ViewETL pin_view(STR("pin")); position2 = haystack.rfind(pin_view); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); + ViewSTD needle_view(needle); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = Text::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); } #endif @@ -4140,13 +4136,13 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_haystack(the_haystack); - etl::u16string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); const value_t* needle = STR("needle"); - size_t position1 = std::u16string::npos; - size_t position2 = etl::u16string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(needle, position1); position2 = haystack.rfind(needle, position2); @@ -4156,9 +4152,9 @@ namespace position2 = haystack.rfind(needle, haystack.size() - 10); CHECK_EQUAL(position1, position2); - etl::u16string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4166,13 +4162,13 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_haystack(the_haystack); - etl::u16string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); const value_t* needle = STR("needle"); - size_t position1 = std::u16string::npos; - size_t position2 = etl::u16string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(needle, position1, 3); position2 = haystack.rfind(needle, position2, 3); @@ -4183,7 +4179,7 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.rfind(STR("pin"), 3); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4191,11 +4187,11 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_haystack(the_haystack); - etl::u16string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); - size_t position1 = std::u16string::npos; - size_t position2 = etl::u16string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(STR('e'), position1); position2 = haystack.rfind(STR('e'), position2); @@ -4206,16 +4202,16 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.rfind(STR('z')); - CHECK_EQUAL(etl::iu16string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_substr) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText compare_result; + TextSTD compare_result; Text result; // Equal. @@ -4250,34 +4246,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(Text(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(Text(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(Text(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(Text(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(Text(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4285,34 +4281,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_etl_view) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(ViewETL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(ViewETL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(ViewETL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(ViewETL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(ViewETL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4321,34 +4317,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_std_view) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(ViewSTD(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(ViewSTD(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(ViewSTD(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(ViewSTD(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(ViewSTD(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4357,34 +4353,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, Text(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, Text(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, Text(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, Text(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, Text(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4392,34 +4388,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, ViewETL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4428,34 +4424,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4464,34 +4460,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, Text(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, Text(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4499,34 +4495,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4535,34 +4531,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4571,7 +4567,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; @@ -4606,7 +4602,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; @@ -4641,7 +4637,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; @@ -4676,26 +4672,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(Text(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(Text(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(Text(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(Text(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4705,26 +4701,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(ViewETL(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4735,26 +4731,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4765,7 +4761,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR("ZCXF")); @@ -4794,7 +4790,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR("ZCXF"), 0, 4); @@ -4828,7 +4824,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR('C')); @@ -4867,31 +4863,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(Text(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(Text(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(Text(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(Text(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(Text(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4901,31 +4897,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4936,31 +4932,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4971,7 +4967,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(STR("ZCXE")); @@ -5010,7 +5006,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(STR("AZCXE"), 0, 4); @@ -5047,7 +5043,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_last_of(STR('C')); @@ -5086,31 +5082,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(Text(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(Text(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(Text(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(Text(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(Text(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5120,31 +5116,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5155,31 +5151,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5190,7 +5186,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR("ZAXB")); @@ -5224,7 +5220,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR("ZAXB"), 0, 4); @@ -5263,7 +5259,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR('A')); @@ -5302,31 +5298,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(Text(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(Text(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(Text(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(Text(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(Text(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5336,31 +5332,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5371,31 +5367,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5406,7 +5402,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(STR("ZEXD")); @@ -5440,7 +5436,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(STR("ZEXD"), 0, 4); @@ -5472,7 +5468,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_last_not_of(STR('F')); diff --git a/test/test_string_u16_external_buffer.cpp b/test/test_string_u16_external_buffer.cpp index 8e271ad6..867a799e 100644 --- a/test/test_string_u16_external_buffer.cpp +++ b/test/test_string_u16_external_buffer.cpp @@ -72,20 +72,25 @@ namespace using Text = etl::u16string_ext; using IText = etl::iu16string; using TextL = etl::u16string; - using CompareText = std::u16string; + using TextSTD = std::u16string; using value_t = Text::value_type; using TextBuffer = std::array; using TextBufferL = std::array; using TextBufferS = std::array; - CompareText initial_text; - CompareText less_text; - CompareText greater_text; - CompareText shorter_text; - CompareText different_text; - CompareText insert_text; - CompareText longer_text; - CompareText short_text; + using ViewETL = etl::u16string_view; +#if ETL_USING_STL && ETL_USING_CPP17 + using ViewSTD = std::u16string_view; +#endif + + TextSTD initial_text; + TextSTD less_text; + TextSTD greater_text; + TextSTD shorter_text; + TextSTD different_text; + TextSTD insert_text; + TextSTD longer_text; + TextSTD short_text; const value_t* pinitial_text = STR("Hello World"); @@ -200,9 +205,9 @@ namespace TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); - CHECK(text.begin() == text.end()); - CHECK(text.cbegin() == text.cend()); - CHECK(text.rbegin() == text.rend()); + CHECK(text.begin() == text.end()); + CHECK(text.cbegin() == text.cend()); + CHECK(text.rbegin() == text.rend()); CHECK(text.crbegin() == text.crend()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -212,11 +217,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_value) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const value_t INITIAL_VALUE = STR('A'); TextBuffer buffer{0}; - CompareText compare_text(INITIAL_SIZE, INITIAL_VALUE); + TextSTD compare_text(INITIAL_SIZE, INITIAL_VALUE); Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); CHECK(text.size() == INITIAL_SIZE); @@ -246,7 +251,7 @@ namespace TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) { TextBuffer buffer{0}; - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -262,7 +267,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(longer_text.c_str(), buffer.data(), buffer.size()); @@ -279,7 +284,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); TextBuffer buffer{0}; Text text(SIZE, STR('A'), buffer.data(), buffer.size()); @@ -296,7 +301,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); TextBuffer buffer{0}; Text text(SIZE + 1, STR('A'), buffer.data(), buffer.size()); @@ -313,7 +318,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char) { - CompareText compare_text(initial_text.c_str(), initial_text.size() / 2); + TextSTD compare_text(initial_text.c_str(), initial_text.size() / 2); TextBuffer buffer{0}; Text text(initial_text.c_str(), initial_text.size() / 2, buffer.data(), buffer.size()); @@ -330,7 +335,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) { - CompareText compare_text(initial_text.c_str(), initial_text.size()); + TextSTD compare_text(initial_text.c_str(), initial_text.size()); TextBuffer buffer{0}; Text text(longer_text.c_str(), longer_text.size(), buffer.data(), buffer.size()); @@ -347,7 +352,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); TextBuffer buffer{0}; Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -387,10 +392,9 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) + TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - etl::u16string_view view(initial_text.data(), initial_text.size()); - + ViewETL view(initial_text.data(), initial_text.size()); TextBuffer buffer{0}; Text text(view, buffer.data(), buffer.size()); @@ -400,6 +404,21 @@ namespace CHECK(!text.empty()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) + { + ViewSTD view(initial_text.data(), initial_text.size()); + TextBuffer buffer{0}; + Text text(view, buffer.data(), buffer.size()); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -463,8 +482,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length) { - CompareText compare_text(initial_text.c_str()); - CompareText compare_text2(compare_text, 2, 4); + TextSTD compare_text(initial_text.c_str()); + TextSTD compare_text2(compare_text, 2, 4); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -482,8 +501,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) { - CompareText compare_text(longer_text.c_str()); - CompareText compare_text2(compare_text, 2, 11); + TextSTD compare_text(longer_text.c_str()); + TextSTD compare_text2(compare_text, 2, 11); TextBufferL bufferl{0}; Text textl(longer_text.c_str(), bufferl.data(), bufferl.size()); @@ -502,7 +521,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list) { - CompareText compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; std::initializer_list il = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; TextBuffer buffer{0}; @@ -518,12 +537,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { - CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; std::initializer_list il = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), - STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; + STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), + STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; TextBuffer buffer{0}; Text text(il, buffer.data(), buffer.size()); @@ -671,7 +690,7 @@ namespace text = STR("Hello World"); - bool is_equal = Equal(std::u16string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -686,7 +705,7 @@ namespace text = STR("Hello World There"); - bool is_equal = Equal(std::u16string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(text.is_truncated()); @@ -702,7 +721,7 @@ namespace itext = STR("Hello World"); - bool is_equal = Equal(std::u16string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!itext.is_truncated()); @@ -718,13 +737,45 @@ namespace itext = STR("Hello World There"); - bool is_equal = Equal(std::u16string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(itext.is_truncated()); #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = ViewETL(STR("Hello World")); + + bool is_equal = Equal(TextSTD(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = ViewSTD(STR("Hello World")); + + bool is_equal = Equal(TextSTD(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -847,7 +898,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_uninitialized_resize_up) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const size_t NEW_SIZE = 8; const value_t INITIAL_VALUE = STR('A'); const value_t FILL_VALUE = STR('B'); @@ -891,7 +942,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_uninitialized_resize_down) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const size_t NEW_SIZE = 2; const value_t INITIAL_VALUE = STR('A'); const value_t FILL_VALUE = STR('B'); @@ -917,24 +968,6 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_fill) - { - TextBuffer buffer1{ 0 }; - TextBuffer buffer2{ 0 }; - Text text(11, STR('A'), buffer1.data(), buffer1.size()); - Text expected(11, STR('B'), buffer2.data(), buffer2.size()); - - text.fill(STR('B')); - - bool is_equal = Equal(expected, text); - CHECK(is_equal); - -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { @@ -1014,7 +1047,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1032,7 +1065,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1050,7 +1083,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1070,7 +1103,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1090,7 +1123,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1104,7 +1137,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1118,7 +1151,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1132,7 +1165,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1146,7 +1179,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -1164,7 +1197,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data_const) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -1182,12 +1215,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextBuffer buffer{0}; Text input(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer2{0}; Text text(buffer2.data(), buffer2.size()); @@ -1202,15 +1235,61 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_etl_view) + { + TextSTD compare_input(initial_text.c_str()); + TextBuffer buffer{0}; + Text input(initial_text.c_str(), buffer.data(), buffer.size()); + ViewETL view(input); + + TextSTD compare_text; + TextBuffer buffer2{0}; + Text text(buffer2.data(), buffer2.size()); + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_std_view) + { + TextSTD compare_input(initial_text.c_str()); + TextBuffer buffer{0}; + Text input(initial_text.c_str(), buffer.data(), buffer.size()); + ViewSTD view(input.data(), input.size()); + + TextSTD compare_text; + TextBuffer buffer2{0}; + Text text(buffer2.data(), buffer2.size()); + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextBufferL bufferl{0}; Text input(longer_text.c_str(), bufferl.data(), bufferl.size()); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1228,7 +1307,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1244,7 +1323,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1260,7 +1339,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1276,7 +1355,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) { - CompareText compare_text(longer_text.c_str()); + TextSTD compare_text(longer_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1294,7 +1373,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1370,7 +1449,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1398,7 +1477,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_excess) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1431,7 +1510,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1453,11 +1532,11 @@ namespace TEST_FIXTURE(SetupFixture, test_insert_position_value) { const size_t INITIAL_SIZE = 5; - const value_t INITIAL_VALUE = STR('A'); + const value_t INITIAL_VALUE = STR('A'); for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1479,7 +1558,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); TextBuffer buffer{0}; Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); @@ -1525,7 +1604,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1552,7 +1631,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1626,7 +1705,7 @@ namespace for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1650,7 +1729,7 @@ namespace const size_t INITIAL_SIZE = 5UL; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1709,7 +1788,7 @@ namespace for (size_t offset = 10UL; offset < length; ++offset) { - CompareText compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextSTD compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); TextBufferL bufferl{0}; Text text(bufferl.data(), bufferl.size()); text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); @@ -1728,18 +1807,14 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string) { - size_t s = short_text.size(); - (void)s; - - assert(s <= 5); - - for (size_t offset = s; offset <= short_text.size(); ++offset) + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - TextBuffer buffer2{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + TextBuffer buffer2{0}; Text insert(insert_text.begin(), insert_text.end(), buffer2.data(), buffer2.size()); text.insert(offset, insert); @@ -1755,23 +1830,64 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_2) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } } - //************************************************************************* +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } +#endif + + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { -#include "etl/private/diagnostic_array_bounds_push.h" for (size_t offset = 0UL; offset <= initial_text.size(); ++offset) { - CompareText compare_text(initial_text.cbegin(), initial_text.cend()); + TextSTD compare_text(initial_text.cbegin(), initial_text.cend()); - TextBuffer buffer{ 0 }; + TextBuffer buffer{0}; Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); - TextBuffer buffer2{ 0 }; + TextBuffer buffer2{0}; Text insert(insert_text.begin(), insert_text.end(), buffer2.data(), buffer2.size()); text.insert(offset, insert); @@ -1784,7 +1900,6 @@ namespace CHECK(text.is_truncated()); #endif } -#include "etl/private/diagnostic_pop.h" } //************************************************************************* @@ -1792,7 +1907,7 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer{0}; Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1818,7 +1933,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer{0}; Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1868,7 +1983,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1902,6 +2017,76 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_etl_view) + { + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + view.assign(initial_text.data(), initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(view); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_std_view) + { + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + ViewSTD append(insert_text.data(), insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(append); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append = ViewSTD(initial_text.data(), initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -1925,7 +2110,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_to_self) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1958,7 +2143,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1967,7 +2152,7 @@ namespace Text append(insert_text.c_str(), buffer2.data(), buffer2.size()); // Whole string. - compare_text.append(insert_text, 0, std::u16string::npos); + compare_text.append(insert_text, 0, TextSTD::npos); text.append(append, 0, Text::npos); bool is_equal = Equal(compare_text, text); @@ -2029,7 +2214,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_c_string) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2063,7 +2248,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_n_c) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2097,7 +2282,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_range) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2134,12 +2319,12 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace"))); @@ -2153,7 +2338,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace"))); @@ -2167,7 +2352,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2181,7 +2366,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2195,7 +2380,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace"))); @@ -2209,7 +2394,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2223,7 +2408,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2234,16 +2419,224 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + { + // Non-overflow short text, npos. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) + { + // Non-overflow short text, npos. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace"))); @@ -2257,7 +2650,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2271,7 +2664,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace"))); @@ -2285,7 +2678,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2296,16 +2689,140 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")), 1, 5); @@ -2319,7 +2836,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2333,7 +2850,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2347,7 +2864,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2361,7 +2878,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")), 1, 5); @@ -2375,7 +2892,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2389,7 +2906,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2403,7 +2920,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2415,17 +2932,16 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); - + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, STR("Replace")); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace")); + text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2437,9 +2953,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace")); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2451,9 +2967,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text")); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text")); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2465,9 +2981,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text")); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2479,9 +2995,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, STR("Replace")); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, STR("Replace")); + text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2493,9 +3009,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace")); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2507,9 +3023,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text")); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text")); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2521,9 +3037,246 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text")); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextL(STR("Replace")).c_str()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, TextL(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2536,14 +3289,14 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace")); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace")); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str()); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2555,9 +3308,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace with some text")); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text")); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2569,9 +3322,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, STR("Replace")); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, STR("Replace")); + text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2583,9 +3336,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace with some text")); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text")); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2598,14 +3351,14 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, STR("Replace"), 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace"), 5); + text.replace(2, 4, TextL(STR("Replace")).c_str(), 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2617,9 +3370,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace"), 5); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2631,9 +3384,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text"), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text"), 15); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2645,9 +3398,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text"), 15); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2659,9 +3412,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, STR("Replace"), 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, STR("Replace"), 5); + text.replace(2, 7, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2673,9 +3426,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace"), 5); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2687,9 +3440,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text"), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text"), 15); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2701,9 +3454,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text"), 15); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2716,14 +3469,14 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace"), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace"), 5); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str(), 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2737,9 +3490,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace with some text"), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text"), 15); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2753,9 +3506,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, STR("Replace"), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, STR("Replace"), 5); + text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2769,9 +3522,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace with some text"), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text"), 15); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2786,7 +3539,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2805,7 +3558,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -2833,7 +3586,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -2861,7 +3614,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -2889,7 +3642,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -2904,7 +3657,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2966,13 +3719,13 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - CompareText replace(STR("Replace")); - CompareText replace_long(STR("Replace with some text")); + TextSTD replace(STR("Replace")); + TextSTD replace_long(STR("Replace with some text")); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -3028,33 +3781,15 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_erase_single_iterator) + TEST_FIXTURE(SetupFixture, test_erase_single) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText::iterator citr = compare_text.erase(compare_text.begin() + 2); - Text::iterator ditr = text.erase(text.begin() + 2); - CHECK(*citr == *ditr); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) - { - CompareText compare_text(initial_text.c_str()); - TextBuffer buffer{0}; - Text text(initial_text.c_str(), buffer.data(), buffer.size()); - - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2); - Text::iterator ditr = text.erase(text.cbegin() + 2); - CHECK(*citr == *ditr); + compare_text.erase(compare_text.begin() + 2); + text.erase(text.begin() + 2); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3066,13 +3801,14 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); - Text::iterator ditr = text.erase(text.cbegin() + 2, text.cbegin() + 4); - CHECK(*citr == *ditr); + compare_text.erase(compare_text.begin() + 2, compare_text.begin() + 4); + + text.erase(text.begin() + 2, text.begin() + 4); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3097,7 +3833,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3112,7 +3848,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3127,7 +3863,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3142,7 +3878,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3208,7 +3944,7 @@ namespace const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); // String-String - CHECK((less < initial) == (less_text < initial_text)); + CHECK((less < initial) == (less_text < initial_text)); CHECK((initial < less) == (initial_text < less_text)); TextBuffer buffer3; @@ -3225,17 +3961,17 @@ namespace CHECK((initial < initial) == (initial_text < initial_text)); // String-Pointer Pointer-String - CHECK((less < pinitial_text) == (less_text < pinitial_text)); - CHECK((pinitial_text < less) == (pinitial_text < less_text)); + CHECK((less < pinitial_text) == (less_text < pinitial_text)); + CHECK((pinitial_text < less) == (pinitial_text < less_text)); - CHECK((greater < pinitial_text) == (greater_text < pinitial_text)); - CHECK((pinitial_text < greater) == (pinitial_text < greater_text)); + CHECK((greater < pinitial_text) == (greater_text < pinitial_text)); + CHECK((pinitial_text < greater) == (pinitial_text < greater_text)); - CHECK((shorter < pinitial_text) == (shorter_text < pinitial_text)); - CHECK((pinitial_text < shorter) == (pinitial_text < shorter_text)); + CHECK((shorter < pinitial_text) == (shorter_text < pinitial_text)); + CHECK((pinitial_text < shorter) == (pinitial_text < shorter_text)); - CHECK((initial < pinitial_text) == (initial_text < pinitial_text)); - CHECK((pinitial_text < initial) == (pinitial_text < initial_text)); + CHECK((initial < pinitial_text) == (initial_text < pinitial_text)); + CHECK((pinitial_text < initial) == (pinitial_text < initial_text)); } //************************************************************************* @@ -3248,8 +3984,8 @@ namespace const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); // String-String - CHECK((less <= initial) == (less_text <= initial_text)); - CHECK((initial <= less) == (initial_text <= less_text)); + CHECK((less <= initial) == (less_text <= initial_text)); + CHECK((initial <= less) == (initial_text <= less_text)); TextBuffer buffer3; const Text greater(greater_text.c_str(), buffer3.data(), buffer3.size()); @@ -3265,17 +4001,17 @@ namespace CHECK((initial <= initial) == (initial_text <= initial_text)); // String-Pointer Pointer-String - CHECK((less <= pinitial_text) == (less_text <= pinitial_text)); - CHECK((pinitial_text <= less) == (pinitial_text <= less_text)); + CHECK((less <= pinitial_text) == (less_text <= pinitial_text)); + CHECK((pinitial_text <= less) == (pinitial_text <= less_text)); - CHECK((greater <= pinitial_text) == (greater_text <= pinitial_text)); - CHECK((pinitial_text <= greater) == (pinitial_text <= greater_text)); + CHECK((greater <= pinitial_text) == (greater_text <= pinitial_text)); + CHECK((pinitial_text <= greater) == (pinitial_text <= greater_text)); - CHECK((shorter <= pinitial_text) == (shorter_text <= pinitial_text)); - CHECK((pinitial_text <= shorter) == (pinitial_text <= shorter_text)); + CHECK((shorter <= pinitial_text) == (shorter_text <= pinitial_text)); + CHECK((pinitial_text <= shorter) == (pinitial_text <= shorter_text)); - CHECK((initial <= pinitial_text) == (initial_text <= pinitial_text)); - CHECK((pinitial_text <= initial) == (pinitial_text <= initial_text)); + CHECK((initial <= pinitial_text) == (initial_text <= pinitial_text)); + CHECK((pinitial_text <= initial) == (pinitial_text <= initial_text)); } //************************************************************************* @@ -3305,17 +4041,17 @@ namespace CHECK((initial > initial) == (initial_text > initial_text)); // String-Pointer Pointer-String - CHECK((less > pinitial_text) == (less_text > pinitial_text)); - CHECK((pinitial_text > less) == (pinitial_text > less_text)); + CHECK((less > pinitial_text) == (less_text > pinitial_text)); + CHECK((pinitial_text > less) == (pinitial_text > less_text)); - CHECK((greater > pinitial_text) == (greater_text > pinitial_text)); - CHECK((pinitial_text > greater) == (pinitial_text > greater_text)); + CHECK((greater > pinitial_text) == (greater_text > pinitial_text)); + CHECK((pinitial_text > greater) == (pinitial_text > greater_text)); - CHECK((shorter > pinitial_text) == (shorter_text > pinitial_text)); - CHECK((pinitial_text > shorter) == (pinitial_text > shorter_text)); + CHECK((shorter > pinitial_text) == (shorter_text > pinitial_text)); + CHECK((pinitial_text > shorter) == (pinitial_text > shorter_text)); - CHECK((initial > pinitial_text) == (initial_text > pinitial_text)); - CHECK((pinitial_text > initial) == (pinitial_text > initial_text)); + CHECK((initial > pinitial_text) == (initial_text > pinitial_text)); + CHECK((pinitial_text > initial) == (pinitial_text > initial_text)); } //************************************************************************* @@ -3328,8 +4064,8 @@ namespace const Text initial(initial_text.begin(), initial_text.end(), buffer2.data(), buffer2.size()); // String-String - CHECK((less >= initial) == (less_text >= initial_text)); - CHECK((initial >= less) == (initial_text >= less_text)); + CHECK((less >= initial) == (less_text >= initial_text)); + CHECK((initial >= less) == (initial_text >= less_text)); TextBuffer buffer3; const Text greater(greater_text.begin(), greater_text.end(), buffer3.data(), buffer3.size()); @@ -3345,24 +4081,24 @@ namespace CHECK((initial >= initial) == (initial_text >= initial_text)); // String-Pointer Pointer-String - CHECK((less >= pinitial_text) == (less_text >= pinitial_text)); - CHECK((pinitial_text >= less) == (pinitial_text >= less_text)); + CHECK((less >= pinitial_text) == (less_text >= pinitial_text)); + CHECK((pinitial_text >= less) == (pinitial_text >= less_text)); - CHECK((greater >= pinitial_text) == (greater_text >= pinitial_text)); - CHECK((pinitial_text >= greater) == (pinitial_text >= greater_text)); + CHECK((greater >= pinitial_text) == (greater_text >= pinitial_text)); + CHECK((pinitial_text >= greater) == (pinitial_text >= greater_text)); - CHECK((shorter >= pinitial_text) == (shorter_text >= pinitial_text)); - CHECK((pinitial_text >= shorter) == (pinitial_text >= shorter_text)); + CHECK((shorter >= pinitial_text) == (shorter_text >= pinitial_text)); + CHECK((pinitial_text >= shorter) == (pinitial_text >= shorter_text)); - CHECK((initial >= pinitial_text) == (initial_text >= pinitial_text)); - CHECK((pinitial_text >= initial) == (pinitial_text >= initial_text)); + CHECK((initial >= pinitial_text) == (initial_text >= pinitial_text)); + CHECK((pinitial_text >= initial) == (pinitial_text >= initial_text)); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy) { - CompareText compare_text(initial_text.c_str()); - + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3381,8 +4117,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3405,7 +4141,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3413,7 +4149,7 @@ namespace value_t buffer1[SIZE]; value_t buffer2[SIZE]; - size_t length1 = compare_text.copy(buffer1, CompareText::npos, 2); + size_t length1 = compare_text.copy(buffer1, TextSTD::npos, 2); buffer1[length1] = STR('\0'); size_t length2 = text.copy(buffer2, Text::npos, 2); @@ -3425,15 +4161,15 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_too_large) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3453,8 +4189,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3463,12 +4199,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_needle(STR("needle")); + TextSTD compare_needle(STR("needle")); TextBuffer buffer{0}; Text needle(STR("needle"), buffer.data(), buffer.size()); - std::u16string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; Text haystack(the_haystack, buffer2.data(), buffer2.size()); @@ -3485,13 +4221,77 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::u16string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::u16string<50> pin(STR("pin")); + Text pin(STR("pin"), buffer.data(), buffer.size()); position2 = haystack.find(pin); CHECK_EQUAL(IText::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + ViewETL needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(TextL::npos, position2); + + ViewETL pin_view(STR("pin")); + position2 = haystack.find(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + ViewSTD needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(TextL::npos, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.find(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -3499,7 +4299,7 @@ namespace const value_t* needle = STR("needle"); - std::u16string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); @@ -3518,7 +4318,7 @@ namespace position2 = haystack.find(needle, position2 + 1); CHECK_EQUAL(IText::npos, position2); - const value_t* pin = STR("pin"); + const value_t *pin = STR("pin"); position2 = haystack.find(pin); CHECK_EQUAL(IText::npos, position2); } @@ -3530,7 +4330,7 @@ namespace const value_t* needle = STR("needle"); - std::u16string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); @@ -3549,7 +4349,7 @@ namespace position2 = haystack.find(needle, position2 + 1, 3); CHECK_EQUAL(IText::npos, position2); - const value_t* pin = STR("pin"); + const value_t *pin = STR("pin"); position2 = haystack.find(pin, 0, 3); CHECK_EQUAL(IText::npos, position2); } @@ -3559,18 +4359,18 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_needle(STR("needle")); + TextSTD compare_needle(STR("needle")); TextBufferL buffer{0}; Text needle(STR("needle"), buffer.data(), buffer.size()); - std::u16string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; Text haystack(the_haystack, buffer2.data(), buffer2.size()); - size_t position1 = std::u16string::npos; - size_t position2 = etl::u16string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle, position2); @@ -3587,19 +4387,76 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_pointer) + TEST_FIXTURE(SetupFixture, test_rfind_etl_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_haystack(the_haystack); + TextSTD compare_needle(STR("needle")); + ViewETL needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewETL pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); + ViewSTD needle_view(needle); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } +#endif + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_pointer) + { + const value_t*the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); const value_t* needle = STR("needle"); - size_t position1 = std::u16string::npos; - size_t position2 = etl::u16string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(needle, position1); position2 = haystack.rfind(needle, position2); @@ -3618,16 +4475,16 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer_n) { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); + const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); const value_t* needle = STR("needle"); - size_t position1 = std::u16string::npos; + size_t position1 = TextSTD::npos; size_t position2 = Text::npos; @@ -3646,15 +4503,15 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_c_position) { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); + const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::u16string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); - size_t position1 = std::u16string::npos; - size_t position2 = etl::u16string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(STR('e'), position1); position2 = haystack.rfind(STR('e'), position2); @@ -3671,7 +4528,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3680,35 +4537,110 @@ namespace int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(TextL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(TextL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(TextL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(TextL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(TextL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_etl_view) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); + result = text.compare(ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); + result = text.compare(ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); + result = text.compare(ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); + result = text.compare(ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); + result = text.compare(ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_std_view) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); + result = text.compare(ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); + result = text.compare(ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); + result = text.compare(ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); + result = text.compare(ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); + result = text.compare(ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3717,35 +4649,109 @@ namespace int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, TextL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, TextL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, TextL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, TextL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, TextL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3754,35 +4760,109 @@ namespace int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, TextL(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, TextL(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3819,7 +4899,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3856,7 +4936,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3893,38 +4973,100 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(TextL(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(TextL(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(TextL(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(TextL(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); + position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); + position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3955,7 +5097,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3991,7 +5133,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4032,43 +5174,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(TextL(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(TextL(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(TextL(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(TextL(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(TextL(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4109,7 +5323,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4139,16 +5353,18 @@ namespace CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(STR("ZCXE"), 100, 4); position2 = text.find_last_of(STR("ZCXE"), 100, 4); CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" } //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4189,43 +5405,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(TextL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(TextL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(TextL(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(TextL(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(TextL(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4261,7 +5549,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4302,7 +5590,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4343,43 +5631,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(TextL(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(TextL(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4415,7 +5775,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4449,7 +5809,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index 31f9fdad..2d9ef322 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -66,21 +66,21 @@ namespace { static const size_t SIZE = 11; - using Text = etl::u32string; - using IText = etl::iu32string; - using CompareText = std::u32string; - using value_t = Text::value_type; - using TextL = etl::u32string<52>; - using TextS = etl::u32string<4>; + using Text = etl::u32string; + using IText = etl::iu32string; + using TextSTD = std::u32string; + using value_t = Text::value_type; + using TextL = etl::u32string<52>; + using TextS = etl::u32string<4>; - CompareText initial_text; - CompareText less_text; - CompareText greater_text; - CompareText shorter_text; - CompareText different_text; - CompareText insert_text; - CompareText longer_text; - CompareText short_text; + TextSTD initial_text; + TextSTD less_text; + TextSTD greater_text; + TextSTD shorter_text; + TextSTD different_text; + TextSTD insert_text; + TextSTD longer_text; + TextSTD short_text; using ViewETL = etl::u32string_view; #if ETL_USING_STL && ETL_USING_CPP17 using ViewSTD = std::u32string_view; @@ -147,7 +147,7 @@ namespace const size_t INITIAL_SIZE = 5; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text(INITIAL_SIZE, INITIAL_VALUE); + TextSTD compare_text(INITIAL_SIZE, INITIAL_VALUE); Text text(INITIAL_SIZE, INITIAL_VALUE); CHECK(text.size() == INITIAL_SIZE); @@ -175,7 +175,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); @@ -191,7 +191,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(longer_text.c_str()); @@ -207,7 +207,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); Text text(SIZE, STR('A')); @@ -223,7 +223,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); Text text(SIZE + 1, STR('A')); @@ -239,7 +239,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char) { - CompareText compare_text(initial_text.c_str(), initial_text.size() / 2); + TextSTD compare_text(initial_text.c_str(), initial_text.size() / 2); Text text(initial_text.c_str(), initial_text.size() / 2); @@ -255,7 +255,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) { - CompareText compare_text(initial_text.c_str(), initial_text.size()); + TextSTD compare_text(initial_text.c_str(), initial_text.size()); Text text(longer_text.c_str(), longer_text.size()); @@ -271,7 +271,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(compare_text.begin(), compare_text.end()); @@ -381,8 +381,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length) { - CompareText compare_text(initial_text.c_str()); - CompareText compare_text2(compare_text, 2, 4); + TextSTD compare_text(initial_text.c_str()); + TextSTD compare_text2(compare_text, 2, 4); Text text(initial_text.c_str()); Text text2(text, 2, 4); @@ -397,8 +397,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) { - CompareText compare_text(longer_text.c_str()); - CompareText compare_text2(compare_text, 2, 11); + TextSTD compare_text(longer_text.c_str()); + TextSTD compare_text2(compare_text, 2, 11); TextL textl(longer_text.c_str()); Text text2(textl, 2, 12); @@ -414,7 +414,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list) { - CompareText compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; Text text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; bool is_equal = Equal(compare_text, text); @@ -427,7 +427,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { - CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + TextSTD compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; Text text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), @@ -558,7 +558,7 @@ namespace text = STR("Hello World"); - bool is_equal = Equal(std::u32string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -572,7 +572,7 @@ namespace text = STR("Hello World There"); - bool is_equal = Equal(std::u32string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(text.is_truncated()); @@ -587,7 +587,7 @@ namespace itext = STR("Hello World"); - bool is_equal = Equal(std::u32string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!itext.is_truncated()); @@ -602,7 +602,7 @@ namespace itext = STR("Hello World There"); - bool is_equal = Equal(std::u32string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(itext.is_truncated()); @@ -616,7 +616,7 @@ namespace text = ViewETL(STR("Hello World")); - bool is_equal = Equal(std::u32string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -631,7 +631,7 @@ namespace text = ViewSTD(STR("Hello World")); - bool is_equal = Equal(std::u32string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -905,7 +905,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -921,7 +921,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -937,7 +937,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -955,7 +955,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -973,7 +973,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); CHECK(text.front() == compare_text.front()); @@ -985,7 +985,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); CHECK(text.front() == compare_text.front()); @@ -997,7 +997,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); CHECK(text.back() == compare_text.back()); @@ -1009,7 +1009,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); CHECK(text.back() == compare_text.back()); @@ -1021,7 +1021,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(compare_text.begin(), compare_text.end()); @@ -1038,7 +1038,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data_const) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); const Text text(compare_text.begin(), compare_text.end()); @@ -1055,10 +1055,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1074,11 +1074,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_etl_view) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); ViewETL view(input); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1095,11 +1095,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_std_view) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - ViewSTD view(input.data(), input.data_end()); + ViewSTD view(input.data(), input.size()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1116,10 +1116,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextL input(longer_text.c_str()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1135,7 +1135,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(initial_text.c_str()); @@ -1150,7 +1150,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(longer_text.c_str()); @@ -1165,7 +1165,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(initial_text.c_str(), initial_text.size()); @@ -1180,7 +1180,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) { - CompareText compare_text(longer_text.c_str()); + TextSTD compare_text(longer_text.c_str()); Text text; text.assign(longer_text.c_str(), longer_text.size()); @@ -1197,7 +1197,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; @@ -1269,7 +1269,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { - CompareText compare_text; + TextSTD compare_text; Text text; for (size_t i = 0UL; i < SIZE; ++i) @@ -1295,7 +1295,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_excess) { - CompareText compare_text; + TextSTD compare_text; Text text; for (size_t i = 0UL; i < SIZE; ++i) @@ -1326,7 +1326,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); compare_text.pop_back(); @@ -1350,7 +1350,7 @@ namespace for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; Text text; text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); @@ -1370,7 +1370,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(initial_text.begin(), initial_text.end()); const value_t INITIAL_VALUE = STR('A'); @@ -1415,7 +1415,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { - CompareText compare_text; + TextSTD compare_text; Text text; const size_t INITIAL_SIZE = 5; @@ -1441,7 +1441,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { - CompareText compare_text; + TextSTD compare_text; Text text; const size_t INSERT_SIZE = 4; @@ -1514,7 +1514,7 @@ namespace for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; Text text; text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); @@ -1537,7 +1537,7 @@ namespace const size_t INITIAL_SIZE = 5; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text; + TextSTD compare_text; Text text; size_t offset = 0; @@ -1595,7 +1595,7 @@ namespace for (size_t offset = 10; offset < length; ++offset) { - CompareText compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextSTD compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); TextL text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); text.insert(text.begin() + offset, text.begin() + 5, text.begin() + 10); @@ -1614,7 +1614,7 @@ namespace { for (size_t offset = 0; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1635,9 +1635,9 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewETL view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1657,9 +1657,9 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewSTD view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewSTD view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1679,7 +1679,7 @@ namespace { for (size_t offset = 0; offset <= initial_text.size(); ++offset) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(initial_text.begin(), initial_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1700,7 +1700,7 @@ namespace { for (size_t offset = 0; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(longer_text.begin(), longer_text.end()); insert.erase(insert.begin(), insert.end()); @@ -1721,7 +1721,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1767,7 +1767,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -1800,9 +1800,9 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_etl_view) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewETL view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1817,7 +1817,7 @@ namespace // Overflow. compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - view.assign(initial_text.data(), initial_text.data() + initial_text.size()); + view.assign(initial_text.data(), initial_text.size()); compare_text.append(initial_text); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -1834,9 +1834,9 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_std_view) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewSTD append(insert_text.data(), insert_text.data() + insert_text.size()); + ViewSTD append(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1851,7 +1851,7 @@ namespace // Overflow. compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.data() + initial_text.size()); + append = ViewSTD(initial_text.data(), initial_text.size()); compare_text.append(initial_text); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -1885,7 +1885,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_to_self) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Non-overflow. @@ -1916,7 +1916,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -1980,7 +1980,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_c_string) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Whole string. @@ -2012,7 +2012,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_n_c) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Non-overflow. @@ -2044,7 +2044,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_range) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -2077,10 +2077,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace"))); @@ -2094,7 +2094,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace"))); @@ -2108,7 +2108,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2122,7 +2122,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2136,7 +2136,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace"))); @@ -2150,7 +2150,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2164,7 +2164,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2179,10 +2179,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace"))); @@ -2196,7 +2196,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace"))); @@ -2210,7 +2210,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace with some text"))); @@ -2224,7 +2224,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); @@ -2238,7 +2238,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewETL(STR("Replace"))); @@ -2252,7 +2252,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace with some text"))); @@ -2266,7 +2266,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); @@ -2282,10 +2282,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace"))); @@ -2299,7 +2299,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace"))); @@ -2313,7 +2313,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace with some text"))); @@ -2327,7 +2327,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); @@ -2341,7 +2341,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewSTD(STR("Replace"))); @@ -2355,7 +2355,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace with some text"))); @@ -2369,7 +2369,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); @@ -2385,10 +2385,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace"))); @@ -2402,7 +2402,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2416,7 +2416,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace"))); @@ -2430,7 +2430,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2445,10 +2445,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); @@ -2462,7 +2462,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); @@ -2476,7 +2476,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); @@ -2490,7 +2490,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); @@ -2506,10 +2506,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); @@ -2523,7 +2523,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); @@ -2537,7 +2537,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); @@ -2551,7 +2551,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); @@ -2567,10 +2567,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")), 1, 5); @@ -2584,7 +2584,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2598,7 +2598,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2612,7 +2612,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2626,7 +2626,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")), 1, 5); @@ -2640,7 +2640,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2654,7 +2654,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2668,7 +2668,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2683,10 +2683,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); @@ -2700,7 +2700,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); @@ -2714,7 +2714,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); @@ -2728,7 +2728,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); @@ -2742,7 +2742,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); @@ -2756,7 +2756,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); @@ -2770,7 +2770,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); @@ -2784,7 +2784,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); @@ -2800,10 +2800,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); @@ -2817,7 +2817,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); @@ -2831,7 +2831,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); @@ -2845,7 +2845,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); @@ -2859,7 +2859,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); @@ -2873,7 +2873,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); @@ -2887,7 +2887,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); @@ -2901,7 +2901,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); @@ -2917,7 +2917,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(2, 4, STR("Replace")); @@ -2934,7 +2934,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, STR("Replace")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace")); @@ -2962,7 +2962,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text")); @@ -2990,7 +2990,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, STR("Replace")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace")); @@ -3018,7 +3018,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text")); @@ -3033,7 +3033,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace")); @@ -3093,7 +3093,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(2, 4, STR("Replace"), 5); @@ -3110,7 +3110,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, STR("Replace"), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace"), 5); @@ -3138,7 +3138,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text"), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text"), 15); @@ -3166,7 +3166,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, STR("Replace"), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace"), 5); @@ -3194,7 +3194,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text"), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text"), 15); @@ -3209,7 +3209,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace"), 5); @@ -3277,7 +3277,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(2, 4, 7, STR('A')); @@ -3294,7 +3294,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -3322,7 +3322,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -3350,7 +3350,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -3378,7 +3378,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -3393,7 +3393,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, 7, STR('A')); @@ -3453,11 +3453,11 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - CompareText replace(STR("Replace")); - CompareText replace_long(STR("Replace with some text")); + TextSTD replace(STR("Replace")); + TextSTD replace_long(STR("Replace with some text")); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -3515,10 +3515,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.begin() + 2); + TextSTD::iterator citr = compare_text.erase(compare_text.begin() + 2); Text::iterator ditr = text.erase(text.begin() + 2); CHECK(*citr == *ditr); @@ -3532,10 +3532,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2); + TextSTD::iterator citr = compare_text.erase(compare_text.cbegin() + 2); Text::iterator ditr = text.erase(text.cbegin() + 2); CHECK(*citr == *ditr); @@ -3549,10 +3549,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); + TextSTD::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); Text::iterator ditr = text.erase(text.cbegin() + 2, text.cbegin() + 4); CHECK(*citr == *ditr); @@ -3578,7 +3578,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.begin(), text.end(), compare_text.begin()); @@ -3591,7 +3591,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.cbegin(), text.cend(), compare_text.cbegin()); @@ -3604,7 +3604,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.rbegin(), text.rend(), compare_text.rbegin()); @@ -3617,7 +3617,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.crbegin(), text.crend(), compare_text.crbegin()); @@ -3804,7 +3804,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; @@ -3845,13 +3845,13 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; value_t buffer2[SIZE]; - size_t length1 = compare_text.copy(buffer1, CompareText::npos, 2); + size_t length1 = compare_text.copy(buffer1, TextSTD::npos, 2); buffer1[length1] = STR('\0'); size_t length2 = text.copy(buffer2, Text::npos, 2); @@ -3871,7 +3871,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_too_large) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; @@ -3899,11 +3899,11 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_needle(STR("needle")); - etl::u32string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); - std::u32string compare_haystack(the_haystack); - etl::u32string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -3917,11 +3917,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::u32string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::u32string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.find(pin); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -3929,12 +3929,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_needle(STR("needle")); - etl::u32string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); ViewETL needle_view(needle); - std::u32string compare_haystack(the_haystack); - etl::u32string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -3948,12 +3948,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(etl::u32string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::u32string<50> pin(STR("pin")); - ViewETL pin_view(pin); + ViewETL pin_view(STR("pin")); position2 = haystack.find(pin_view); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } #if ETL_USING_STL && ETL_USING_CPP17 @@ -3962,12 +3961,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_needle(STR("needle")); - std::u32string needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); ViewSTD needle_view(needle); - std::u32string compare_haystack(the_haystack); - etl::u32string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -3981,12 +3980,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(etl::u32string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - std::u32string pin(STR("pin")); - ViewSTD pin_view(pin); + ViewSTD pin_view(STR("pin")); position2 = haystack.find(pin_view); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } #endif @@ -3997,8 +3995,8 @@ namespace const value_t* needle = STR("needle"); - std::u32string compare_haystack(the_haystack); - etl::u32string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -4012,11 +4010,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); const value_t* pin = STR("pin"); position2 = haystack.find(pin); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4026,8 +4024,8 @@ namespace const value_t* needle = STR("needle"); - std::u32string compare_haystack(the_haystack); - etl::u32string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -4041,11 +4039,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1, 3); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); const value_t* pin = STR("pin"); position2 = haystack.find(pin, 0, 3); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4053,14 +4051,14 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_needle(STR("needle")); - etl::u32string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); - std::u32string compare_haystack(the_haystack); - etl::u32string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = std::u32string::npos; - size_t position2 = etl::u32string<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle, position2); @@ -4070,9 +4068,9 @@ namespace position2 = haystack.rfind(needle, haystack.size() - 10); CHECK_EQUAL(position1, position2); - etl::u32string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4080,45 +4078,15 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_needle(STR("needle")); - etl::u32string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); ViewETL needle_view(needle); - std::u32string compare_haystack(the_haystack); - etl::u32string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = std::u32string::npos; - size_t position2 = etl::u32string<50>::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - etl::u32string<50> pin(STR("pin")); - ViewETL pin_view(pin); - position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iu32string::npos, position2); - } - -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - std::u32string compare_needle(STR("needle")); - std::u32string needle(STR("needle")); - ViewSTD needle_view(needle); - - std::u32string compare_haystack(the_haystack); - etl::u32string<50> haystack(the_haystack); - - size_t position1 = std::u32string::npos; - size_t position2 = etl::u32string<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle_view, position2); @@ -4128,10 +4096,38 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - std::u32string pin(STR("pin")); - ViewSTD pin_view(pin); + ViewETL pin_view(STR("pin")); position2 = haystack.rfind(pin_view); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); + ViewSTD needle_view(needle); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = std::u32string::npos; + size_t position2 = Text::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); } #endif @@ -4140,13 +4136,13 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_haystack(the_haystack); - etl::u32string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); const value_t* needle = STR("needle"); size_t position1 = std::u32string::npos; - size_t position2 = etl::u32string<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(needle, position1); position2 = haystack.rfind(needle, position2); @@ -4156,9 +4152,9 @@ namespace position2 = haystack.rfind(needle, haystack.size() - 10); CHECK_EQUAL(position1, position2); - etl::u32string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4166,13 +4162,13 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_haystack(the_haystack); - etl::u32string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); const value_t* needle = STR("needle"); size_t position1 = std::u32string::npos; - size_t position2 = etl::u32string<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(needle, position1, 3); position2 = haystack.rfind(needle, position2, 3); @@ -4183,7 +4179,7 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.rfind(STR("pin"), 3); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4191,11 +4187,11 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_haystack(the_haystack); - etl::u32string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = std::u32string::npos; - size_t position2 = etl::u32string<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(STR('e'), position1); position2 = haystack.rfind(STR('e'), position2); @@ -4206,16 +4202,16 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.rfind(STR('z')); - CHECK_EQUAL(etl::iu32string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_substr) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText compare_result; + TextSTD compare_result; Text result; // Equal. @@ -4250,34 +4246,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(Text(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(Text(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(Text(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(Text(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(Text(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4285,34 +4281,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_etl_view) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(ViewETL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(ViewETL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(ViewETL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(ViewETL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(ViewETL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4321,34 +4317,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_std_view) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(ViewSTD(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(ViewSTD(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(ViewSTD(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(ViewSTD(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(ViewSTD(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4357,34 +4353,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, Text(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, Text(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, Text(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, Text(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, Text(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4392,34 +4388,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, ViewETL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4428,34 +4424,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4464,34 +4460,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, Text(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, Text(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4499,34 +4495,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4535,34 +4531,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4571,7 +4567,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; @@ -4606,7 +4602,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; @@ -4641,7 +4637,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; @@ -4676,26 +4672,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(Text(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(Text(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(Text(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(Text(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4705,26 +4701,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(ViewETL(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4735,26 +4731,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4765,7 +4761,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR("ZCXF")); @@ -4794,7 +4790,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR("ZCXF"), 0, 4); @@ -4828,7 +4824,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR('C')); @@ -4867,31 +4863,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(Text(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(Text(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(Text(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(Text(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(Text(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4901,31 +4897,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4936,31 +4932,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4971,7 +4967,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(STR("ZCXE")); @@ -5010,7 +5006,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(STR("AZCXE"), 0, 4); @@ -5047,7 +5043,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_last_of(STR('C')); @@ -5086,31 +5082,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(Text(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(Text(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(Text(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(Text(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(Text(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5120,31 +5116,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5155,31 +5151,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5190,7 +5186,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR("ZAXB")); @@ -5224,7 +5220,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR("ZAXB"), 0, 4); @@ -5263,7 +5259,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR('A')); @@ -5302,31 +5298,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(Text(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(Text(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(Text(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(Text(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(Text(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5336,31 +5332,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5371,31 +5367,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5406,7 +5402,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(STR("ZEXD")); @@ -5440,7 +5436,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(STR("ZEXD"), 0, 4); @@ -5472,7 +5468,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_last_not_of(STR('F')); diff --git a/test/test_string_u32_external_buffer.cpp b/test/test_string_u32_external_buffer.cpp index 96650015..2461206b 100644 --- a/test/test_string_u32_external_buffer.cpp +++ b/test/test_string_u32_external_buffer.cpp @@ -72,20 +72,25 @@ namespace using Text = etl::u32string_ext; using IText = etl::iu32string; using TextL = etl::u32string; - using CompareText = std::u32string; + using TextSTD = std::u32string; using value_t = Text::value_type; using TextBuffer = std::array; using TextBufferL = std::array; using TextBufferS = std::array; - CompareText initial_text; - CompareText less_text; - CompareText greater_text; - CompareText shorter_text; - CompareText different_text; - CompareText insert_text; - CompareText longer_text; - CompareText short_text; + using ViewETL = etl::u32string_view; +#if ETL_USING_STL && ETL_USING_CPP17 + using ViewSTD = std::u32string_view; +#endif + + TextSTD initial_text; + TextSTD less_text; + TextSTD greater_text; + TextSTD shorter_text; + TextSTD different_text; + TextSTD insert_text; + TextSTD longer_text; + TextSTD short_text; const value_t* pinitial_text = STR("Hello World"); @@ -200,9 +205,9 @@ namespace TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); - CHECK(text.begin() == text.end()); - CHECK(text.cbegin() == text.cend()); - CHECK(text.rbegin() == text.rend()); + CHECK(text.begin() == text.end()); + CHECK(text.cbegin() == text.cend()); + CHECK(text.rbegin() == text.rend()); CHECK(text.crbegin() == text.crend()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -212,11 +217,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_value) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const value_t INITIAL_VALUE = STR('A'); TextBuffer buffer{0}; - CompareText compare_text(INITIAL_SIZE, INITIAL_VALUE); + TextSTD compare_text(INITIAL_SIZE, INITIAL_VALUE); Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); CHECK(text.size() == INITIAL_SIZE); @@ -246,7 +251,7 @@ namespace TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) { TextBuffer buffer{0}; - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -262,7 +267,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(longer_text.c_str(), buffer.data(), buffer.size()); @@ -279,7 +284,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); TextBuffer buffer{0}; Text text(SIZE, STR('A'), buffer.data(), buffer.size()); @@ -296,7 +301,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); TextBuffer buffer{0}; Text text(SIZE + 1, STR('A'), buffer.data(), buffer.size()); @@ -313,7 +318,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char) { - CompareText compare_text(initial_text.c_str(), initial_text.size() / 2); + TextSTD compare_text(initial_text.c_str(), initial_text.size() / 2); TextBuffer buffer{0}; Text text(initial_text.c_str(), initial_text.size() / 2, buffer.data(), buffer.size()); @@ -330,7 +335,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) { - CompareText compare_text(initial_text.c_str(), initial_text.size()); + TextSTD compare_text(initial_text.c_str(), initial_text.size()); TextBuffer buffer{0}; Text text(longer_text.c_str(), longer_text.size(), buffer.data(), buffer.size()); @@ -347,7 +352,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); TextBuffer buffer{0}; Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -387,10 +392,9 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) + TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - etl::u32string_view view(initial_text.data(), initial_text.size()); - + ViewETL view(initial_text.data(), initial_text.size()); TextBuffer buffer{0}; Text text(view, buffer.data(), buffer.size()); @@ -400,6 +404,21 @@ namespace CHECK(!text.empty()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) + { + ViewSTD view(initial_text.data(), initial_text.size()); + TextBuffer buffer{0}; + Text text(view, buffer.data(), buffer.size()); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -463,8 +482,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length) { - CompareText compare_text(initial_text.c_str()); - CompareText compare_text2(compare_text, 2, 4); + TextSTD compare_text(initial_text.c_str()); + TextSTD compare_text2(compare_text, 2, 4); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -482,8 +501,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) { - CompareText compare_text(longer_text.c_str()); - CompareText compare_text2(compare_text, 2, 11); + TextSTD compare_text(longer_text.c_str()); + TextSTD compare_text2(compare_text, 2, 11); TextBufferL bufferl{0}; Text textl(longer_text.c_str(), bufferl.data(), bufferl.size()); @@ -502,7 +521,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list) { - CompareText compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; std::initializer_list il = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; TextBuffer buffer{0}; @@ -518,12 +537,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { - CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; std::initializer_list il = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), - STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; + STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), + STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; TextBuffer buffer{0}; Text text(il, buffer.data(), buffer.size()); @@ -671,7 +690,7 @@ namespace text = STR("Hello World"); - bool is_equal = Equal(std::u32string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -686,7 +705,7 @@ namespace text = STR("Hello World There"); - bool is_equal = Equal(std::u32string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(text.is_truncated()); @@ -702,7 +721,7 @@ namespace itext = STR("Hello World"); - bool is_equal = Equal(std::u32string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!itext.is_truncated()); @@ -718,13 +737,45 @@ namespace itext = STR("Hello World There"); - bool is_equal = Equal(std::u32string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(itext.is_truncated()); #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = ViewETL(STR("Hello World")); + + bool is_equal = Equal(TextSTD(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = ViewSTD(STR("Hello World")); + + bool is_equal = Equal(TextSTD(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -738,6 +789,7 @@ namespace CHECK_EQUAL(&constText[0], constText.begin()); } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_end) { @@ -846,7 +898,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_uninitialized_resize_up) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const size_t NEW_SIZE = 8; const value_t INITIAL_VALUE = STR('A'); const value_t FILL_VALUE = STR('B'); @@ -890,7 +942,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_uninitialized_resize_down) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const size_t NEW_SIZE = 2; const value_t INITIAL_VALUE = STR('A'); const value_t FILL_VALUE = STR('B'); @@ -916,24 +968,6 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_fill) - { - TextBuffer buffer1{ 0 }; - TextBuffer buffer2{ 0 }; - Text text(11, STR('A'), buffer1.data(), buffer1.size()); - Text expected(11, STR('B'), buffer2.data(), buffer2.size()); - - text.fill(STR('B')); - - bool is_equal = Equal(expected, text); - CHECK(is_equal); - -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { @@ -1013,7 +1047,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1031,7 +1065,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1049,7 +1083,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1069,7 +1103,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1089,7 +1123,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1103,7 +1137,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1117,7 +1151,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1131,7 +1165,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1145,7 +1179,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -1163,7 +1197,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data_const) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -1181,12 +1215,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextBuffer buffer{0}; Text input(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer2{0}; Text text(buffer2.data(), buffer2.size()); @@ -1201,15 +1235,61 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_etl_view) + { + TextSTD compare_input(initial_text.c_str()); + TextBuffer buffer{0}; + Text input(initial_text.c_str(), buffer.data(), buffer.size()); + ViewETL view(input); + + TextSTD compare_text; + TextBuffer buffer2{0}; + Text text(buffer2.data(), buffer2.size()); + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_std_view) + { + TextSTD compare_input(initial_text.c_str()); + TextBuffer buffer{0}; + Text input(initial_text.c_str(), buffer.data(), buffer.size()); + ViewSTD view(input.data(), input.size()); + + TextSTD compare_text; + TextBuffer buffer2{0}; + Text text(buffer2.data(), buffer2.size()); + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextBufferL bufferl{0}; Text input(longer_text.c_str(), bufferl.data(), bufferl.size()); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1227,7 +1307,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1243,7 +1323,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1259,7 +1339,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1275,7 +1355,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) { - CompareText compare_text(longer_text.c_str()); + TextSTD compare_text(longer_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1293,7 +1373,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1369,7 +1449,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1397,7 +1477,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_excess) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1430,7 +1510,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1452,11 +1532,11 @@ namespace TEST_FIXTURE(SetupFixture, test_insert_position_value) { const size_t INITIAL_SIZE = 5; - const value_t INITIAL_VALUE = STR('A'); + const value_t INITIAL_VALUE = STR('A'); for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1478,7 +1558,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); TextBuffer buffer{0}; Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); @@ -1524,7 +1604,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1551,7 +1631,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1625,7 +1705,7 @@ namespace for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1649,7 +1729,7 @@ namespace const size_t INITIAL_SIZE = 5UL; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1708,7 +1788,7 @@ namespace for (size_t offset = 10UL; offset < length; ++offset) { - CompareText compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextSTD compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); TextBufferL bufferl{0}; Text text(bufferl.data(), bufferl.size()); text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); @@ -1729,13 +1809,12 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - TextBuffer buffer2; - buffer2.fill(0); + TextBuffer buffer2{0}; Text insert(insert_text.begin(), insert_text.end(), buffer2.data(), buffer2.size()); text.insert(offset, insert); @@ -1750,12 +1829,60 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { for (size_t offset = 0UL; offset <= initial_text.size(); ++offset) { - CompareText compare_text(initial_text.cbegin(), initial_text.cend()); + TextSTD compare_text(initial_text.cbegin(), initial_text.cend()); TextBuffer buffer{0}; Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); @@ -1780,7 +1907,7 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer{0}; Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1806,7 +1933,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer{0}; Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1856,7 +1983,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1890,6 +2017,76 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_etl_view) + { + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + view.assign(initial_text.data(), initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(view); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_std_view) + { + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + ViewSTD append(insert_text.data(), insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(append); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append = ViewSTD(initial_text.data(), initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -1913,7 +2110,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_to_self) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1946,7 +2143,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1955,7 +2152,7 @@ namespace Text append(insert_text.c_str(), buffer2.data(), buffer2.size()); // Whole string. - compare_text.append(insert_text, 0, std::u32string::npos); + compare_text.append(insert_text, 0, TextSTD::npos); text.append(append, 0, Text::npos); bool is_equal = Equal(compare_text, text); @@ -2017,7 +2214,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_c_string) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2051,7 +2248,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_n_c) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2085,7 +2282,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_range) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2122,12 +2319,12 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace"))); @@ -2141,7 +2338,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace"))); @@ -2155,7 +2352,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2169,7 +2366,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2183,7 +2380,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace"))); @@ -2197,7 +2394,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2211,7 +2408,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2222,16 +2419,224 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + { + // Non-overflow short text, npos. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) + { + // Non-overflow short text, npos. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace"))); @@ -2245,7 +2650,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2259,7 +2664,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace"))); @@ -2273,7 +2678,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2284,16 +2689,140 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")), 1, 5); @@ -2307,7 +2836,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2321,7 +2850,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2335,7 +2864,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2349,7 +2878,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")), 1, 5); @@ -2363,7 +2892,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2377,7 +2906,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2391,7 +2920,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2403,17 +2932,16 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); - + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, STR("Replace")); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace")); + text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2425,9 +2953,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace")); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2439,9 +2967,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text")); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text")); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2453,9 +2981,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text")); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2467,9 +2995,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, STR("Replace")); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, STR("Replace")); + text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2481,9 +3009,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace")); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2495,9 +3023,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text")); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text")); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2509,9 +3037,246 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text")); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextL(STR("Replace")).c_str()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, TextL(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2524,14 +3289,14 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace")); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace")); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str()); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2543,9 +3308,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace with some text")); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text")); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2557,9 +3322,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, STR("Replace")); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, STR("Replace")); + text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2571,9 +3336,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace with some text")); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text")); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2586,14 +3351,14 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, STR("Replace"), 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace"), 5); + text.replace(2, 4, TextL(STR("Replace")).c_str(), 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2605,9 +3370,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace"), 5); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2619,9 +3384,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text"), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text"), 15); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2633,9 +3398,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text"), 15); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2647,9 +3412,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, STR("Replace"), 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, STR("Replace"), 5); + text.replace(2, 7, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2661,9 +3426,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace"), 5); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2675,9 +3440,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text"), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text"), 15); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2689,9 +3454,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text"), 15); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2704,14 +3469,14 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace"), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace"), 5); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str(), 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2725,9 +3490,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace with some text"), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text"), 15); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2741,9 +3506,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, STR("Replace"), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, STR("Replace"), 5); + text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2757,9 +3522,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace with some text"), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text"), 15); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2774,7 +3539,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2793,7 +3558,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -2821,7 +3586,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -2849,7 +3614,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -2877,7 +3642,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -2892,7 +3657,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2954,13 +3719,13 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - CompareText replace(STR("Replace")); - CompareText replace_long(STR("Replace with some text")); + TextSTD replace(STR("Replace")); + TextSTD replace_long(STR("Replace with some text")); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -3016,33 +3781,15 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_erase_single_iterator) + TEST_FIXTURE(SetupFixture, test_erase_single) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText::iterator citr = compare_text.erase(compare_text.begin() + 2); - Text::iterator ditr = text.erase(text.begin() + 2); - CHECK(*citr == *ditr); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) - { - CompareText compare_text(initial_text.c_str()); - TextBuffer buffer{0}; - Text text(initial_text.c_str(), buffer.data(), buffer.size()); - - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2); - Text::iterator ditr = text.erase(text.cbegin() + 2); - CHECK(*citr == *ditr); + compare_text.erase(compare_text.begin() + 2); + text.erase(text.begin() + 2); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3054,13 +3801,14 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); - Text::iterator ditr = text.erase(text.cbegin() + 2, text.cbegin() + 4); - CHECK(*citr == *ditr); + compare_text.erase(compare_text.begin() + 2, compare_text.begin() + 4); + + text.erase(text.begin() + 2, text.begin() + 4); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3085,7 +3833,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3100,7 +3848,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3115,7 +3863,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3130,7 +3878,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3196,7 +3944,7 @@ namespace const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); // String-String - CHECK((less < initial) == (less_text < initial_text)); + CHECK((less < initial) == (less_text < initial_text)); CHECK((initial < less) == (initial_text < less_text)); TextBuffer buffer3; @@ -3213,17 +3961,17 @@ namespace CHECK((initial < initial) == (initial_text < initial_text)); // String-Pointer Pointer-String - CHECK((less < pinitial_text) == (less_text < pinitial_text)); - CHECK((pinitial_text < less) == (pinitial_text < less_text)); + CHECK((less < pinitial_text) == (less_text < pinitial_text)); + CHECK((pinitial_text < less) == (pinitial_text < less_text)); - CHECK((greater < pinitial_text) == (greater_text < pinitial_text)); - CHECK((pinitial_text < greater) == (pinitial_text < greater_text)); + CHECK((greater < pinitial_text) == (greater_text < pinitial_text)); + CHECK((pinitial_text < greater) == (pinitial_text < greater_text)); - CHECK((shorter < pinitial_text) == (shorter_text < pinitial_text)); - CHECK((pinitial_text < shorter) == (pinitial_text < shorter_text)); + CHECK((shorter < pinitial_text) == (shorter_text < pinitial_text)); + CHECK((pinitial_text < shorter) == (pinitial_text < shorter_text)); - CHECK((initial < pinitial_text) == (initial_text < pinitial_text)); - CHECK((pinitial_text < initial) == (pinitial_text < initial_text)); + CHECK((initial < pinitial_text) == (initial_text < pinitial_text)); + CHECK((pinitial_text < initial) == (pinitial_text < initial_text)); } //************************************************************************* @@ -3236,8 +3984,8 @@ namespace const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); // String-String - CHECK((less <= initial) == (less_text <= initial_text)); - CHECK((initial <= less) == (initial_text <= less_text)); + CHECK((less <= initial) == (less_text <= initial_text)); + CHECK((initial <= less) == (initial_text <= less_text)); TextBuffer buffer3; const Text greater(greater_text.c_str(), buffer3.data(), buffer3.size()); @@ -3253,17 +4001,17 @@ namespace CHECK((initial <= initial) == (initial_text <= initial_text)); // String-Pointer Pointer-String - CHECK((less <= pinitial_text) == (less_text <= pinitial_text)); - CHECK((pinitial_text <= less) == (pinitial_text <= less_text)); + CHECK((less <= pinitial_text) == (less_text <= pinitial_text)); + CHECK((pinitial_text <= less) == (pinitial_text <= less_text)); - CHECK((greater <= pinitial_text) == (greater_text <= pinitial_text)); - CHECK((pinitial_text <= greater) == (pinitial_text <= greater_text)); + CHECK((greater <= pinitial_text) == (greater_text <= pinitial_text)); + CHECK((pinitial_text <= greater) == (pinitial_text <= greater_text)); - CHECK((shorter <= pinitial_text) == (shorter_text <= pinitial_text)); - CHECK((pinitial_text <= shorter) == (pinitial_text <= shorter_text)); + CHECK((shorter <= pinitial_text) == (shorter_text <= pinitial_text)); + CHECK((pinitial_text <= shorter) == (pinitial_text <= shorter_text)); - CHECK((initial <= pinitial_text) == (initial_text <= pinitial_text)); - CHECK((pinitial_text <= initial) == (pinitial_text <= initial_text)); + CHECK((initial <= pinitial_text) == (initial_text <= pinitial_text)); + CHECK((pinitial_text <= initial) == (pinitial_text <= initial_text)); } //************************************************************************* @@ -3293,17 +4041,17 @@ namespace CHECK((initial > initial) == (initial_text > initial_text)); // String-Pointer Pointer-String - CHECK((less > pinitial_text) == (less_text > pinitial_text)); - CHECK((pinitial_text > less) == (pinitial_text > less_text)); + CHECK((less > pinitial_text) == (less_text > pinitial_text)); + CHECK((pinitial_text > less) == (pinitial_text > less_text)); - CHECK((greater > pinitial_text) == (greater_text > pinitial_text)); - CHECK((pinitial_text > greater) == (pinitial_text > greater_text)); + CHECK((greater > pinitial_text) == (greater_text > pinitial_text)); + CHECK((pinitial_text > greater) == (pinitial_text > greater_text)); - CHECK((shorter > pinitial_text) == (shorter_text > pinitial_text)); - CHECK((pinitial_text > shorter) == (pinitial_text > shorter_text)); + CHECK((shorter > pinitial_text) == (shorter_text > pinitial_text)); + CHECK((pinitial_text > shorter) == (pinitial_text > shorter_text)); - CHECK((initial > pinitial_text) == (initial_text > pinitial_text)); - CHECK((pinitial_text > initial) == (pinitial_text > initial_text)); + CHECK((initial > pinitial_text) == (initial_text > pinitial_text)); + CHECK((pinitial_text > initial) == (pinitial_text > initial_text)); } //************************************************************************* @@ -3316,8 +4064,8 @@ namespace const Text initial(initial_text.begin(), initial_text.end(), buffer2.data(), buffer2.size()); // String-String - CHECK((less >= initial) == (less_text >= initial_text)); - CHECK((initial >= less) == (initial_text >= less_text)); + CHECK((less >= initial) == (less_text >= initial_text)); + CHECK((initial >= less) == (initial_text >= less_text)); TextBuffer buffer3; const Text greater(greater_text.begin(), greater_text.end(), buffer3.data(), buffer3.size()); @@ -3333,24 +4081,24 @@ namespace CHECK((initial >= initial) == (initial_text >= initial_text)); // String-Pointer Pointer-String - CHECK((less >= pinitial_text) == (less_text >= pinitial_text)); - CHECK((pinitial_text >= less) == (pinitial_text >= less_text)); + CHECK((less >= pinitial_text) == (less_text >= pinitial_text)); + CHECK((pinitial_text >= less) == (pinitial_text >= less_text)); - CHECK((greater >= pinitial_text) == (greater_text >= pinitial_text)); - CHECK((pinitial_text >= greater) == (pinitial_text >= greater_text)); + CHECK((greater >= pinitial_text) == (greater_text >= pinitial_text)); + CHECK((pinitial_text >= greater) == (pinitial_text >= greater_text)); - CHECK((shorter >= pinitial_text) == (shorter_text >= pinitial_text)); - CHECK((pinitial_text >= shorter) == (pinitial_text >= shorter_text)); + CHECK((shorter >= pinitial_text) == (shorter_text >= pinitial_text)); + CHECK((pinitial_text >= shorter) == (pinitial_text >= shorter_text)); - CHECK((initial >= pinitial_text) == (initial_text >= pinitial_text)); - CHECK((pinitial_text >= initial) == (pinitial_text >= initial_text)); + CHECK((initial >= pinitial_text) == (initial_text >= pinitial_text)); + CHECK((pinitial_text >= initial) == (pinitial_text >= initial_text)); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy) { - CompareText compare_text(initial_text.c_str()); - + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3369,8 +4117,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3393,7 +4141,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3401,7 +4149,7 @@ namespace value_t buffer1[SIZE]; value_t buffer2[SIZE]; - size_t length1 = compare_text.copy(buffer1, CompareText::npos, 2); + size_t length1 = compare_text.copy(buffer1, TextSTD::npos, 2); buffer1[length1] = STR('\0'); size_t length2 = text.copy(buffer2, Text::npos, 2); @@ -3413,15 +4161,15 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_too_large) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3441,8 +4189,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3451,12 +4199,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_needle(STR("needle")); + TextSTD compare_needle(STR("needle")); TextBuffer buffer{0}; Text needle(STR("needle"), buffer.data(), buffer.size()); - std::u32string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; Text haystack(the_haystack, buffer2.data(), buffer2.size()); @@ -3473,13 +4221,77 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::u32string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::u32string<50> pin(STR("pin")); + Text pin(STR("pin"), buffer.data(), buffer.size()); position2 = haystack.find(pin); CHECK_EQUAL(IText::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + ViewETL needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(TextL::npos, position2); + + ViewETL pin_view(STR("pin")); + position2 = haystack.find(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + ViewSTD needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(TextL::npos, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.find(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -3487,7 +4299,7 @@ namespace const value_t* needle = STR("needle"); - std::u32string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); @@ -3506,7 +4318,7 @@ namespace position2 = haystack.find(needle, position2 + 1); CHECK_EQUAL(IText::npos, position2); - const value_t* pin = STR("pin"); + const value_t *pin = STR("pin"); position2 = haystack.find(pin); CHECK_EQUAL(IText::npos, position2); } @@ -3518,7 +4330,7 @@ namespace const value_t* needle = STR("needle"); - std::u32string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); @@ -3537,7 +4349,7 @@ namespace position2 = haystack.find(needle, position2 + 1, 3); CHECK_EQUAL(IText::npos, position2); - const value_t* pin = STR("pin"); + const value_t *pin = STR("pin"); position2 = haystack.find(pin, 0, 3); CHECK_EQUAL(IText::npos, position2); } @@ -3547,18 +4359,18 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_needle(STR("needle")); + TextSTD compare_needle(STR("needle")); TextBufferL buffer{0}; Text needle(STR("needle"), buffer.data(), buffer.size()); - std::u32string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; Text haystack(the_haystack, buffer2.data(), buffer2.size()); - size_t position1 = std::u32string::npos; - size_t position2 = etl::u32string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle, position2); @@ -3575,19 +4387,76 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_pointer) + TEST_FIXTURE(SetupFixture, test_rfind_etl_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_haystack(the_haystack); + TextSTD compare_needle(STR("needle")); + ViewETL needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewETL pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); + ViewSTD needle_view(needle); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } +#endif + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_pointer) + { + const value_t*the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); const value_t* needle = STR("needle"); - size_t position1 = std::u32string::npos; - size_t position2 = etl::u32string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(needle, position1); position2 = haystack.rfind(needle, position2); @@ -3606,16 +4475,16 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer_n) { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); + const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); const value_t* needle = STR("needle"); - size_t position1 = std::u32string::npos; + size_t position1 = TextSTD::npos; size_t position2 = Text::npos; @@ -3634,15 +4503,15 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_c_position) { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); + const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::u32string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); - size_t position1 = std::u32string::npos; - size_t position2 = etl::u32string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(STR('e'), position1); position2 = haystack.rfind(STR('e'), position2); @@ -3659,7 +4528,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3668,35 +4537,110 @@ namespace int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(TextL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(TextL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(TextL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(TextL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(TextL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_etl_view) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); + result = text.compare(ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); + result = text.compare(ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); + result = text.compare(ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); + result = text.compare(ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); + result = text.compare(ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_std_view) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); + result = text.compare(ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); + result = text.compare(ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); + result = text.compare(ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); + result = text.compare(ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); + result = text.compare(ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3705,35 +4649,109 @@ namespace int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, TextL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, TextL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, TextL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, TextL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, TextL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3742,35 +4760,109 @@ namespace int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, TextL(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, TextL(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3807,7 +4899,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3844,7 +4936,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3881,38 +4973,100 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(TextL(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(TextL(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(TextL(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(TextL(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); + position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); + position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3943,7 +5097,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3979,7 +5133,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4020,43 +5174,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(TextL(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(TextL(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(TextL(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(TextL(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(TextL(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4097,7 +5323,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4127,16 +5353,18 @@ namespace CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(STR("ZCXE"), 100, 4); position2 = text.find_last_of(STR("ZCXE"), 100, 4); CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" } //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4177,43 +5405,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(TextL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(TextL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(TextL(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(TextL(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(TextL(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4249,7 +5549,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4290,7 +5590,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4331,43 +5631,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(TextL(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(TextL(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4403,7 +5775,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4437,7 +5809,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4712,6 +6084,23 @@ namespace CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_after_clear) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.set_secure(); + text.assign(STR("ABCDEF")); + + Text::pointer pb = text.begin(); + Text::pointer pe = text.end(); + + text.clear(); + + // Check there no non-zero values in the remainder of the string. + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) { diff --git a/test/test_string_u8.cpp b/test/test_string_u8.cpp index 361ae40d..84020bbd 100644 --- a/test/test_string_u8.cpp +++ b/test/test_string_u8.cpp @@ -69,25 +69,25 @@ namespace { static const size_t SIZE = 11; - using Text = etl::u8string; - using IText = etl::iu8string; - using CompareText = std::u8string; - using value_t = Text::value_type; - using TextL = etl::u8string<52>; - using TextS = etl::u8string<4>; - using ViewETL = etl::u8string_view; + using Text = etl::u8string; + using IText = etl::iu8string; + using TextSTD = std::u8string; + using value_t = Text::value_type; + using TextL = etl::u8string<52>; + using TextS = etl::u8string<4>; + using ViewETL = etl::u8string_view; #if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::u8string_view; + using ViewSTD = std::u8string_view; #endif - CompareText initial_text; - CompareText less_text; - CompareText greater_text; - CompareText shorter_text; - CompareText different_text; - CompareText insert_text; - CompareText longer_text; - CompareText short_text; + TextSTD initial_text; + TextSTD less_text; + TextSTD greater_text; + TextSTD shorter_text; + TextSTD different_text; + TextSTD insert_text; + TextSTD longer_text; + TextSTD short_text; const value_t* pinitial_text = STR("Hello World"); @@ -150,7 +150,7 @@ namespace const size_t INITIAL_SIZE = 5; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text(INITIAL_SIZE, INITIAL_VALUE); + TextSTD compare_text(INITIAL_SIZE, INITIAL_VALUE); Text text(INITIAL_SIZE, INITIAL_VALUE); CHECK(text.size() == INITIAL_SIZE); @@ -178,7 +178,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); @@ -194,7 +194,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(longer_text.c_str()); @@ -210,7 +210,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); Text text(SIZE, STR('A')); @@ -226,7 +226,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); Text text(SIZE + 1, STR('A')); @@ -242,7 +242,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char) { - CompareText compare_text(initial_text.c_str(), initial_text.size() / 2); + TextSTD compare_text(initial_text.c_str(), initial_text.size() / 2); Text text(initial_text.c_str(), initial_text.size() / 2); @@ -258,7 +258,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) { - CompareText compare_text(initial_text.c_str(), initial_text.size()); + TextSTD compare_text(initial_text.c_str(), initial_text.size()); Text text(longer_text.c_str(), longer_text.size()); @@ -274,7 +274,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(compare_text.begin(), compare_text.end()); @@ -384,8 +384,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length) { - CompareText compare_text(initial_text.c_str()); - CompareText compare_text2(compare_text, 2, 4); + TextSTD compare_text(initial_text.c_str()); + TextSTD compare_text2(compare_text, 2, 4); Text text(initial_text.c_str()); Text text2(text, 2, 4); @@ -400,8 +400,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) { - CompareText compare_text(longer_text.c_str()); - CompareText compare_text2(compare_text, 2, 11); + TextSTD compare_text(longer_text.c_str()); + TextSTD compare_text2(compare_text, 2, 11); TextL textl(longer_text.c_str()); Text text2(textl, 2, 12); @@ -417,7 +417,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list) { - CompareText compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; Text text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; bool is_equal = Equal(compare_text, text); @@ -430,7 +430,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { - CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + TextSTD compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; Text text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), @@ -561,7 +561,7 @@ namespace text = STR("Hello World"); - bool is_equal = Equal(std::u8string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -575,7 +575,7 @@ namespace text = STR("Hello World There"); - bool is_equal = Equal(std::u8string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(text.is_truncated()); @@ -590,7 +590,7 @@ namespace itext = STR("Hello World"); - bool is_equal = Equal(std::u8string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!itext.is_truncated()); @@ -605,7 +605,7 @@ namespace itext = STR("Hello World There"); - bool is_equal = Equal(std::u8string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(itext.is_truncated()); @@ -619,7 +619,7 @@ namespace text = ViewETL(STR("Hello World")); - bool is_equal = Equal(std::u8string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -634,7 +634,7 @@ namespace text = ViewSTD(STR("Hello World")); - bool is_equal = Equal(std::u8string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -908,7 +908,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -924,7 +924,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -940,7 +940,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -958,7 +958,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -976,7 +976,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); CHECK(text.front() == compare_text.front()); @@ -988,7 +988,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); CHECK(text.front() == compare_text.front()); @@ -1000,7 +1000,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); CHECK(text.back() == compare_text.back()); @@ -1012,7 +1012,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); CHECK(text.back() == compare_text.back()); @@ -1024,7 +1024,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(compare_text.begin(), compare_text.end()); @@ -1041,7 +1041,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data_const) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); const Text text(compare_text.begin(), compare_text.end()); @@ -1058,10 +1058,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1077,11 +1077,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_etl_view) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); ViewETL view(input); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1098,11 +1098,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_std_view) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - ViewSTD view(input.data(), input.data_end()); + ViewSTD view(input.data(), input.size()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1119,10 +1119,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextL input(longer_text.c_str()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1138,7 +1138,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(initial_text.c_str()); @@ -1153,7 +1153,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(longer_text.c_str()); @@ -1168,7 +1168,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(initial_text.c_str(), initial_text.size()); @@ -1183,7 +1183,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) { - CompareText compare_text(longer_text.c_str()); + TextSTD compare_text(longer_text.c_str()); Text text; text.assign(longer_text.c_str(), longer_text.size()); @@ -1200,7 +1200,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; @@ -1272,7 +1272,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { - CompareText compare_text; + TextSTD compare_text; Text text; for (size_t i = 0UL; i < SIZE; ++i) @@ -1298,7 +1298,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_excess) { - CompareText compare_text; + TextSTD compare_text; Text text; for (size_t i = 0UL; i < SIZE; ++i) @@ -1329,7 +1329,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); compare_text.pop_back(); @@ -1353,7 +1353,7 @@ namespace for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; Text text; text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); @@ -1373,7 +1373,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(initial_text.begin(), initial_text.end()); const value_t INITIAL_VALUE = STR('A'); @@ -1418,7 +1418,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { - CompareText compare_text; + TextSTD compare_text; Text text; const size_t INITIAL_SIZE = 5; @@ -1444,7 +1444,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { - CompareText compare_text; + TextSTD compare_text; Text text; const size_t INSERT_SIZE = 4; @@ -1517,7 +1517,7 @@ namespace for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; Text text; text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); @@ -1540,7 +1540,7 @@ namespace const size_t INITIAL_SIZE = 5; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text; + TextSTD compare_text; Text text; size_t offset = 0; @@ -1598,7 +1598,7 @@ namespace for (size_t offset = 10; offset < length; ++offset) { - CompareText compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextSTD compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); TextL text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); text.insert(text.begin() + offset, text.begin() + 5, text.begin() + 10); @@ -1617,7 +1617,7 @@ namespace { for (size_t offset = 0; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1638,9 +1638,9 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewETL view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1660,9 +1660,9 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewSTD view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewSTD view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1682,7 +1682,7 @@ namespace { for (size_t offset = 0; offset <= initial_text.size(); ++offset) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(initial_text.begin(), initial_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1703,7 +1703,7 @@ namespace { for (size_t offset = 0; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(longer_text.begin(), longer_text.end()); insert.erase(insert.begin(), insert.end()); @@ -1724,7 +1724,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1770,7 +1770,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -1803,9 +1803,9 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_etl_view) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewETL view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1820,7 +1820,7 @@ namespace // Overflow. compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - view.assign(initial_text.data(), initial_text.data() + initial_text.size()); + view.assign(initial_text.data(), initial_text.size()); compare_text.append(initial_text); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -1837,9 +1837,9 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_std_view) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewSTD append(insert_text.data(), insert_text.data() + insert_text.size()); + ViewSTD append(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1854,7 +1854,7 @@ namespace // Overflow. compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.data() + initial_text.size()); + append = ViewSTD(initial_text.data(), initial_text.size()); compare_text.append(initial_text); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -1888,7 +1888,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_to_self) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Non-overflow. @@ -1919,7 +1919,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -1983,7 +1983,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_c_string) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Whole string. @@ -2015,7 +2015,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_n_c) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Non-overflow. @@ -2047,7 +2047,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_range) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -2080,10 +2080,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace"))); @@ -2097,7 +2097,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace"))); @@ -2111,7 +2111,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2125,7 +2125,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2139,7 +2139,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace"))); @@ -2153,7 +2153,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2167,7 +2167,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2182,10 +2182,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace"))); @@ -2199,7 +2199,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace"))); @@ -2213,7 +2213,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace with some text"))); @@ -2227,7 +2227,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); @@ -2241,7 +2241,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewETL(STR("Replace"))); @@ -2255,7 +2255,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace with some text"))); @@ -2269,7 +2269,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); @@ -2285,10 +2285,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace"))); @@ -2302,7 +2302,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace"))); @@ -2316,7 +2316,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace with some text"))); @@ -2330,7 +2330,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); @@ -2344,7 +2344,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewSTD(STR("Replace"))); @@ -2358,7 +2358,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace with some text"))); @@ -2372,7 +2372,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); @@ -2388,10 +2388,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace"))); @@ -2405,7 +2405,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2419,7 +2419,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace"))); @@ -2433,7 +2433,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2448,10 +2448,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); @@ -2465,7 +2465,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); @@ -2479,7 +2479,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); @@ -2493,7 +2493,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); @@ -2509,10 +2509,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); @@ -2526,7 +2526,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); @@ -2540,7 +2540,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); @@ -2554,7 +2554,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); @@ -2570,10 +2570,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")), 1, 5); @@ -2587,7 +2587,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2601,7 +2601,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2615,7 +2615,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2629,7 +2629,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")), 1, 5); @@ -2643,7 +2643,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2657,7 +2657,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2671,7 +2671,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2686,10 +2686,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); @@ -2703,7 +2703,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); @@ -2717,7 +2717,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); @@ -2731,7 +2731,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); @@ -2745,7 +2745,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); @@ -2759,7 +2759,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); @@ -2773,7 +2773,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); @@ -2787,7 +2787,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); @@ -2803,10 +2803,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); @@ -2820,7 +2820,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); @@ -2834,7 +2834,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); @@ -2848,7 +2848,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); @@ -2862,7 +2862,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); @@ -2876,7 +2876,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); @@ -2890,7 +2890,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); @@ -2904,7 +2904,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); @@ -2920,10 +2920,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")).c_str()); @@ -2937,7 +2937,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); @@ -2951,7 +2951,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); @@ -2965,7 +2965,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); @@ -2979,7 +2979,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")).c_str()); @@ -2993,7 +2993,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); @@ -3007,7 +3007,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); @@ -3021,7 +3021,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); @@ -3036,10 +3036,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str()); @@ -3053,7 +3053,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); @@ -3067,7 +3067,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str()); @@ -3081,7 +3081,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); @@ -3096,10 +3096,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")).c_str(), 5); @@ -3113,7 +3113,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); @@ -3127,7 +3127,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -3141,7 +3141,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); @@ -3155,7 +3155,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")).c_str(), 5); @@ -3169,7 +3169,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); @@ -3183,7 +3183,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -3197,7 +3197,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); @@ -3212,10 +3212,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str(), 5); @@ -3231,7 +3231,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -3247,7 +3247,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str(), 5); @@ -3263,7 +3263,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -3280,7 +3280,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(2, 4, 7, STR('A')); @@ -3297,7 +3297,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -3325,7 +3325,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -3353,7 +3353,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -3381,7 +3381,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -3396,7 +3396,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, 7, STR('A')); @@ -3456,11 +3456,11 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - CompareText replace(STR("Replace")); - CompareText replace_long(STR("Replace with some text")); + TextSTD replace(STR("Replace")); + TextSTD replace_long(STR("Replace with some text")); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -3518,10 +3518,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.begin() + 2); + TextSTD::iterator citr = compare_text.erase(compare_text.begin() + 2); Text::iterator ditr = text.erase(text.begin() + 2); CHECK(*citr == *ditr); @@ -3535,10 +3535,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2); + TextSTD::iterator citr = compare_text.erase(compare_text.cbegin() + 2); Text::iterator ditr = text.erase(text.cbegin() + 2); CHECK(*citr == *ditr); @@ -3552,10 +3552,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); + TextSTD::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); Text::iterator ditr = text.erase(text.cbegin() + 2, text.cbegin() + 4); CHECK(*citr == *ditr); @@ -3581,7 +3581,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.begin(), text.end(), compare_text.begin()); @@ -3594,7 +3594,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.cbegin(), text.cend(), compare_text.cbegin()); @@ -3607,7 +3607,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.rbegin(), text.rend(), compare_text.rbegin()); @@ -3620,7 +3620,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.crbegin(), text.crend(), compare_text.crbegin()); @@ -3807,7 +3807,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; @@ -3848,13 +3848,13 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; value_t buffer2[SIZE]; - size_t length1 = compare_text.copy(buffer1, CompareText::npos, 2); + size_t length1 = compare_text.copy(buffer1, TextSTD::npos, 2); buffer1[length1] = STR('\0'); size_t length2 = text.copy(buffer2, Text::npos, 2); @@ -3874,7 +3874,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_too_large) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; @@ -3902,11 +3902,11 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_needle(STR("needle")); - etl::u8string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); - std::u8string compare_haystack(the_haystack); - etl::u8string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -3920,11 +3920,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::u8string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::u8string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.find(pin); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -3932,12 +3932,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_needle(STR("needle")); - etl::u8string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); ViewETL needle_view(needle); - std::u8string compare_haystack(the_haystack); - etl::u8string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -3951,12 +3951,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(etl::u8string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::u8string<50> pin(STR("pin")); - ViewETL pin_view(pin); + ViewETL pin_view(STR("pin")); position2 = haystack.find(pin_view); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } #if ETL_USING_STL && ETL_USING_CPP17 @@ -3965,12 +3964,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_needle(STR("needle")); - std::u8string needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); ViewSTD needle_view(needle); - std::u8string compare_haystack(the_haystack); - etl::u8string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -3984,12 +3983,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(etl::u8string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - std::u8string pin(STR("pin")); - ViewSTD pin_view(pin); + ViewSTD pin_view(STR("pin")); position2 = haystack.find(pin_view); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } #endif @@ -4000,8 +3998,8 @@ namespace const value_t* needle = STR("needle"); - std::u8string compare_haystack(the_haystack); - etl::u8string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -4015,11 +4013,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); const value_t* pin = STR("pin"); position2 = haystack.find(pin); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4029,8 +4027,8 @@ namespace const value_t* needle = STR("needle"); - std::u8string compare_haystack(the_haystack); - etl::u8string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -4044,11 +4042,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1, 3); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); const value_t* pin = STR("pin"); position2 = haystack.find(pin, 0, 3); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4056,14 +4054,14 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_needle(STR("needle")); - etl::u8string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); - std::u8string compare_haystack(the_haystack); - etl::u8string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = std::u8string::npos; - size_t position2 = etl::u8string<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle, position2); @@ -4073,9 +4071,9 @@ namespace position2 = haystack.rfind(needle, haystack.size() - 10); CHECK_EQUAL(position1, position2); - etl::u8string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4083,45 +4081,15 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_needle(STR("needle")); - etl::u8string<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); ViewETL needle_view(needle); - std::u8string compare_haystack(the_haystack); - etl::u8string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = std::u8string::npos; - size_t position2 = etl::u8string<50>::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - etl::u8string<50> pin(STR("pin")); - ViewETL pin_view(pin); - position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iu8string::npos, position2); - } - -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - std::u8string compare_needle(STR("needle")); - std::u8string needle(STR("needle")); - ViewSTD needle_view(needle); - - std::u8string compare_haystack(the_haystack); - etl::u8string<50> haystack(the_haystack); - - size_t position1 = std::u8string::npos; - size_t position2 = etl::u8string<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle_view, position2); @@ -4131,10 +4099,38 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - std::u8string pin(STR("pin")); - ViewSTD pin_view(pin); + ViewETL pin_view(STR("pin")); position2 = haystack.rfind(pin_view); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); + ViewSTD needle_view(needle); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = std::u8string::npos; + size_t position2 = Text::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); } #endif @@ -4143,13 +4139,13 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_haystack(the_haystack); - etl::u8string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); const value_t* needle = STR("needle"); size_t position1 = std::u8string::npos; - size_t position2 = etl::u8string<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(needle, position1); position2 = haystack.rfind(needle, position2); @@ -4159,9 +4155,9 @@ namespace position2 = haystack.rfind(needle, haystack.size() - 10); CHECK_EQUAL(position1, position2); - etl::u8string<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4169,13 +4165,13 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_haystack(the_haystack); - etl::u8string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); const value_t* needle = STR("needle"); size_t position1 = std::u8string::npos; - size_t position2 = etl::u8string<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(needle, position1, 3); position2 = haystack.rfind(needle, position2, 3); @@ -4186,7 +4182,7 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.rfind(STR("pin"), 3); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4194,11 +4190,11 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_haystack(the_haystack); - etl::u8string<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = std::u8string::npos; - size_t position2 = etl::u8string<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(STR('e'), position1); position2 = haystack.rfind(STR('e'), position2); @@ -4209,16 +4205,16 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.rfind(STR('z')); - CHECK_EQUAL(etl::iu8string::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_substr) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText compare_result; + TextSTD compare_result; Text result; // Equal. @@ -4253,34 +4249,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(Text(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(Text(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(Text(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(Text(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(Text(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4288,34 +4284,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_etl_view) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(ViewETL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(ViewETL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(ViewETL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(ViewETL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(ViewETL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4324,34 +4320,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_std_view) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(ViewSTD(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(ViewSTD(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(ViewSTD(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(ViewSTD(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(ViewSTD(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4360,34 +4356,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, Text(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, Text(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, Text(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, Text(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, Text(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4395,34 +4391,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, ViewETL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4431,34 +4427,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4467,34 +4463,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, Text(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, Text(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4502,34 +4498,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4538,34 +4534,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4574,7 +4570,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; @@ -4609,7 +4605,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; @@ -4644,7 +4640,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; @@ -4679,26 +4675,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(Text(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(Text(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(Text(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(Text(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4708,26 +4704,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(ViewETL(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4738,26 +4734,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4768,7 +4764,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR("ZCXF")); @@ -4797,7 +4793,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR("ZCXF"), 0, 4); @@ -4831,7 +4827,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR('C')); @@ -4870,31 +4866,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(Text(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(Text(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(Text(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(Text(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(Text(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4904,31 +4900,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4939,31 +4935,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4974,7 +4970,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(STR("ZCXE")); @@ -5013,7 +5009,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(STR("AZCXE"), 0, 4); @@ -5050,7 +5046,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_last_of(STR('C')); @@ -5089,31 +5085,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(Text(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(Text(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(Text(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(Text(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(Text(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5123,31 +5119,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5158,31 +5154,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5193,7 +5189,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR("ZAXB")); @@ -5227,7 +5223,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR("ZAXB"), 0, 4); @@ -5266,7 +5262,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR('A')); @@ -5305,31 +5301,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(Text(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(Text(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(Text(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(Text(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(Text(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5339,31 +5335,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5374,31 +5370,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5409,7 +5405,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(STR("ZEXD")); @@ -5443,7 +5439,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(STR("ZEXD"), 0, 4); @@ -5475,7 +5471,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_last_not_of(STR('F')); diff --git a/test/test_string_u8_external_buffer.cpp b/test/test_string_u8_external_buffer.cpp index bc2caaaf..d0a02373 100644 --- a/test/test_string_u8_external_buffer.cpp +++ b/test/test_string_u8_external_buffer.cpp @@ -75,20 +75,25 @@ namespace using Text = etl::u8string_ext; using IText = etl::iu8string; using TextL = etl::u8string; - using CompareText = std::u8string; + using TextSTD = std::u8string; using value_t = Text::value_type; using TextBuffer = std::array; using TextBufferL = std::array; using TextBufferS = std::array; - CompareText initial_text; - CompareText less_text; - CompareText greater_text; - CompareText shorter_text; - CompareText different_text; - CompareText insert_text; - CompareText longer_text; - CompareText short_text; + using ViewETL = etl::u8string_view; +#if ETL_USING_STL && ETL_USING_CPP17 + using ViewSTD = std::u8string_view; +#endif + + TextSTD initial_text; + TextSTD less_text; + TextSTD greater_text; + TextSTD shorter_text; + TextSTD different_text; + TextSTD insert_text; + TextSTD longer_text; + TextSTD short_text; const value_t* pinitial_text = STR("Hello World"); @@ -203,9 +208,9 @@ namespace TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); - CHECK(text.begin() == text.end()); - CHECK(text.cbegin() == text.cend()); - CHECK(text.rbegin() == text.rend()); + CHECK(text.begin() == text.end()); + CHECK(text.cbegin() == text.cend()); + CHECK(text.rbegin() == text.rend()); CHECK(text.crbegin() == text.crend()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -215,11 +220,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_value) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const value_t INITIAL_VALUE = STR('A'); TextBuffer buffer{0}; - CompareText compare_text(INITIAL_SIZE, INITIAL_VALUE); + TextSTD compare_text(INITIAL_SIZE, INITIAL_VALUE); Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); CHECK(text.size() == INITIAL_SIZE); @@ -249,7 +254,7 @@ namespace TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) { TextBuffer buffer{0}; - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -265,7 +270,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(longer_text.c_str(), buffer.data(), buffer.size()); @@ -282,7 +287,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); TextBuffer buffer{0}; Text text(SIZE, STR('A'), buffer.data(), buffer.size()); @@ -299,7 +304,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); TextBuffer buffer{0}; Text text(SIZE + 1, STR('A'), buffer.data(), buffer.size()); @@ -316,7 +321,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char) { - CompareText compare_text(initial_text.c_str(), initial_text.size() / 2); + TextSTD compare_text(initial_text.c_str(), initial_text.size() / 2); TextBuffer buffer{0}; Text text(initial_text.c_str(), initial_text.size() / 2, buffer.data(), buffer.size()); @@ -333,7 +338,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) { - CompareText compare_text(initial_text.c_str(), initial_text.size()); + TextSTD compare_text(initial_text.c_str(), initial_text.size()); TextBuffer buffer{0}; Text text(longer_text.c_str(), longer_text.size(), buffer.data(), buffer.size()); @@ -350,7 +355,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); TextBuffer buffer{0}; Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -390,10 +395,9 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) + TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - etl::u8string_view view(initial_text.data(), initial_text.size()); - + ViewETL view(initial_text.data(), initial_text.size()); TextBuffer buffer{0}; Text text(view, buffer.data(), buffer.size()); @@ -403,6 +407,21 @@ namespace CHECK(!text.empty()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) + { + ViewSTD view(initial_text.data(), initial_text.size()); + TextBuffer buffer{0}; + Text text(view, buffer.data(), buffer.size()); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -466,8 +485,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length) { - CompareText compare_text(initial_text.c_str()); - CompareText compare_text2(compare_text, 2, 4); + TextSTD compare_text(initial_text.c_str()); + TextSTD compare_text2(compare_text, 2, 4); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -485,8 +504,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) { - CompareText compare_text(longer_text.c_str()); - CompareText compare_text2(compare_text, 2, 11); + TextSTD compare_text(longer_text.c_str()); + TextSTD compare_text2(compare_text, 2, 11); TextBufferL bufferl{0}; Text textl(longer_text.c_str(), bufferl.data(), bufferl.size()); @@ -505,7 +524,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list) { - CompareText compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; std::initializer_list il = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; TextBuffer buffer{0}; @@ -521,12 +540,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { - CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; std::initializer_list il = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), - STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; + STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), + STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; TextBuffer buffer{0}; Text text(il, buffer.data(), buffer.size()); @@ -674,7 +693,7 @@ namespace text = STR("Hello World"); - bool is_equal = Equal(std::u8string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -689,7 +708,7 @@ namespace text = STR("Hello World There"); - bool is_equal = Equal(std::u8string(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(text.is_truncated()); @@ -705,7 +724,7 @@ namespace itext = STR("Hello World"); - bool is_equal = Equal(std::u8string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!itext.is_truncated()); @@ -721,13 +740,45 @@ namespace itext = STR("Hello World There"); - bool is_equal = Equal(std::u8string(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(itext.is_truncated()); #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = ViewETL(STR("Hello World")); + + bool is_equal = Equal(TextSTD(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = ViewSTD(STR("Hello World")); + + bool is_equal = Equal(TextSTD(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -850,7 +901,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_uninitialized_resize_up) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const size_t NEW_SIZE = 8; const value_t INITIAL_VALUE = STR('A'); const value_t FILL_VALUE = STR('B'); @@ -894,7 +945,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_uninitialized_resize_down) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const size_t NEW_SIZE = 2; const value_t INITIAL_VALUE = STR('A'); const value_t FILL_VALUE = STR('B'); @@ -920,24 +971,6 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_fill) - { - TextBuffer buffer1{ 0 }; - TextBuffer buffer2{ 0 }; - Text text(11, STR('A'), buffer1.data(), buffer1.size()); - Text expected(11, STR('B'), buffer2.data(), buffer2.size()); - - text.fill(STR('B')); - - bool is_equal = Equal(expected, text); - CHECK(is_equal); - -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { @@ -1017,7 +1050,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1035,7 +1068,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1053,7 +1086,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1073,7 +1106,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1093,7 +1126,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1107,7 +1140,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1121,7 +1154,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1135,7 +1168,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1149,7 +1182,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -1167,7 +1200,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data_const) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -1185,12 +1218,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextBuffer buffer{0}; Text input(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer2{0}; Text text(buffer2.data(), buffer2.size()); @@ -1205,15 +1238,61 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_etl_view) + { + TextSTD compare_input(initial_text.c_str()); + TextBuffer buffer{0}; + Text input(initial_text.c_str(), buffer.data(), buffer.size()); + ViewETL view(input); + + TextSTD compare_text; + TextBuffer buffer2{0}; + Text text(buffer2.data(), buffer2.size()); + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_std_view) + { + TextSTD compare_input(initial_text.c_str()); + TextBuffer buffer{0}; + Text input(initial_text.c_str(), buffer.data(), buffer.size()); + ViewSTD view(input.data(), input.size()); + + TextSTD compare_text; + TextBuffer buffer2{0}; + Text text(buffer2.data(), buffer2.size()); + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextBufferL bufferl{0}; Text input(longer_text.c_str(), bufferl.data(), bufferl.size()); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1231,7 +1310,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1247,7 +1326,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1263,7 +1342,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1279,7 +1358,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) { - CompareText compare_text(longer_text.c_str()); + TextSTD compare_text(longer_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1297,7 +1376,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1373,7 +1452,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1401,7 +1480,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_excess) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1434,7 +1513,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1456,11 +1535,11 @@ namespace TEST_FIXTURE(SetupFixture, test_insert_position_value) { const size_t INITIAL_SIZE = 5; - const value_t INITIAL_VALUE = STR('A'); + const value_t INITIAL_VALUE = STR('A'); for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1482,7 +1561,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); TextBuffer buffer{0}; Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); @@ -1528,7 +1607,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1555,7 +1634,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1629,7 +1708,7 @@ namespace for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1653,7 +1732,7 @@ namespace const size_t INITIAL_SIZE = 5UL; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1712,7 +1791,7 @@ namespace for (size_t offset = 10UL; offset < length; ++offset) { - CompareText compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextSTD compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); TextBufferL bufferl{0}; Text text(bufferl.data(), bufferl.size()); text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); @@ -1731,18 +1810,14 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string) { - size_t s = short_text.size(); - (void)s; - - assert(s <= 5); - - for (size_t offset = s; offset <= short_text.size(); ++offset) + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - TextBuffer buffer2{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + TextBuffer buffer2{0}; Text insert(insert_text.begin(), insert_text.end(), buffer2.data(), buffer2.size()); text.insert(offset, insert); @@ -1758,23 +1833,64 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_2) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } } - //************************************************************************* +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } +#endif + + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { -#include "etl/private/diagnostic_array_bounds_push.h" for (size_t offset = 0UL; offset <= initial_text.size(); ++offset) { - CompareText compare_text(initial_text.cbegin(), initial_text.cend()); + TextSTD compare_text(initial_text.cbegin(), initial_text.cend()); - TextBuffer buffer{ 0 }; + TextBuffer buffer{0}; Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); - TextBuffer buffer2{ 0 }; + TextBuffer buffer2{0}; Text insert(insert_text.begin(), insert_text.end(), buffer2.data(), buffer2.size()); text.insert(offset, insert); @@ -1787,7 +1903,6 @@ namespace CHECK(text.is_truncated()); #endif } -#include "etl/private/diagnostic_pop.h" } //************************************************************************* @@ -1795,7 +1910,7 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer{0}; Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1821,7 +1936,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer{0}; Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1871,7 +1986,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1905,6 +2020,76 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_etl_view) + { + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + view.assign(initial_text.data(), initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(view); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_std_view) + { + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + ViewSTD append(insert_text.data(), insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(append); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append = ViewSTD(initial_text.data(), initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -1928,7 +2113,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_to_self) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1961,7 +2146,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1970,7 +2155,7 @@ namespace Text append(insert_text.c_str(), buffer2.data(), buffer2.size()); // Whole string. - compare_text.append(insert_text, 0, std::u8string::npos); + compare_text.append(insert_text, 0, TextSTD::npos); text.append(append, 0, Text::npos); bool is_equal = Equal(compare_text, text); @@ -2032,7 +2217,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_c_string) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2066,7 +2251,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_n_c) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2100,7 +2285,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_range) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2137,12 +2322,12 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace"))); @@ -2156,7 +2341,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace"))); @@ -2170,7 +2355,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2184,7 +2369,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2198,7 +2383,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace"))); @@ -2212,7 +2397,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2226,7 +2411,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2237,16 +2422,224 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + { + // Non-overflow short text, npos. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) + { + // Non-overflow short text, npos. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace"))); @@ -2260,7 +2653,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2274,7 +2667,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace"))); @@ -2288,7 +2681,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2299,16 +2692,140 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")), 1, 5); @@ -2322,7 +2839,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2336,7 +2853,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2350,7 +2867,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2364,7 +2881,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")), 1, 5); @@ -2378,7 +2895,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2392,7 +2909,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2406,7 +2923,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2417,16 +2934,252 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")).c_str()); @@ -2440,7 +3193,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); @@ -2454,7 +3207,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); @@ -2468,7 +3221,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); @@ -2482,7 +3235,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")).c_str()); @@ -2496,7 +3249,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); @@ -2510,7 +3263,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); @@ -2524,7 +3277,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); @@ -2539,12 +3292,12 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str()); @@ -2558,7 +3311,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); @@ -2572,7 +3325,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str()); @@ -2586,7 +3339,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); @@ -2601,12 +3354,12 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")).c_str(), 5); @@ -2620,7 +3373,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); @@ -2634,7 +3387,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -2648,7 +3401,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); @@ -2662,7 +3415,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")).c_str(), 5); @@ -2676,7 +3429,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); @@ -2690,7 +3443,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -2704,7 +3457,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); @@ -2719,12 +3472,12 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str(), 5); @@ -2740,7 +3493,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -2756,7 +3509,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace")).c_str(), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str(), 5); @@ -2772,7 +3525,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str(), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); @@ -2789,7 +3542,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2808,7 +3561,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -2836,7 +3589,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -2864,7 +3617,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -2892,7 +3645,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -2907,7 +3660,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2969,13 +3722,13 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - CompareText replace(STR("Replace")); - CompareText replace_long(STR("Replace with some text")); + TextSTD replace(STR("Replace")); + TextSTD replace_long(STR("Replace with some text")); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -3031,33 +3784,15 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_erase_single_iterator) + TEST_FIXTURE(SetupFixture, test_erase_single) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText::iterator citr = compare_text.erase(compare_text.begin() + 2); - Text::iterator ditr = text.erase(text.begin() + 2); - CHECK(*citr == *ditr); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) - { - CompareText compare_text(initial_text.c_str()); - TextBuffer buffer{0}; - Text text(initial_text.c_str(), buffer.data(), buffer.size()); - - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2); - Text::iterator ditr = text.erase(text.cbegin() + 2); - CHECK(*citr == *ditr); + compare_text.erase(compare_text.begin() + 2); + text.erase(text.begin() + 2); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3069,13 +3804,14 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); - Text::iterator ditr = text.erase(text.cbegin() + 2, text.cbegin() + 4); - CHECK(*citr == *ditr); + compare_text.erase(compare_text.begin() + 2, compare_text.begin() + 4); + + text.erase(text.begin() + 2, text.begin() + 4); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3100,7 +3836,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3115,7 +3851,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3130,7 +3866,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3145,7 +3881,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3211,7 +3947,7 @@ namespace const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); // String-String - CHECK((less < initial) == (less_text < initial_text)); + CHECK((less < initial) == (less_text < initial_text)); CHECK((initial < less) == (initial_text < less_text)); TextBuffer buffer3; @@ -3228,17 +3964,17 @@ namespace CHECK((initial < initial) == (initial_text < initial_text)); // String-Pointer Pointer-String - CHECK((less < pinitial_text) == (less_text < pinitial_text)); - CHECK((pinitial_text < less) == (pinitial_text < less_text)); + CHECK((less < pinitial_text) == (less_text < pinitial_text)); + CHECK((pinitial_text < less) == (pinitial_text < less_text)); - CHECK((greater < pinitial_text) == (greater_text < pinitial_text)); - CHECK((pinitial_text < greater) == (pinitial_text < greater_text)); + CHECK((greater < pinitial_text) == (greater_text < pinitial_text)); + CHECK((pinitial_text < greater) == (pinitial_text < greater_text)); - CHECK((shorter < pinitial_text) == (shorter_text < pinitial_text)); - CHECK((pinitial_text < shorter) == (pinitial_text < shorter_text)); + CHECK((shorter < pinitial_text) == (shorter_text < pinitial_text)); + CHECK((pinitial_text < shorter) == (pinitial_text < shorter_text)); - CHECK((initial < pinitial_text) == (initial_text < pinitial_text)); - CHECK((pinitial_text < initial) == (pinitial_text < initial_text)); + CHECK((initial < pinitial_text) == (initial_text < pinitial_text)); + CHECK((pinitial_text < initial) == (pinitial_text < initial_text)); } //************************************************************************* @@ -3251,8 +3987,8 @@ namespace const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); // String-String - CHECK((less <= initial) == (less_text <= initial_text)); - CHECK((initial <= less) == (initial_text <= less_text)); + CHECK((less <= initial) == (less_text <= initial_text)); + CHECK((initial <= less) == (initial_text <= less_text)); TextBuffer buffer3; const Text greater(greater_text.c_str(), buffer3.data(), buffer3.size()); @@ -3268,17 +4004,17 @@ namespace CHECK((initial <= initial) == (initial_text <= initial_text)); // String-Pointer Pointer-String - CHECK((less <= pinitial_text) == (less_text <= pinitial_text)); - CHECK((pinitial_text <= less) == (pinitial_text <= less_text)); + CHECK((less <= pinitial_text) == (less_text <= pinitial_text)); + CHECK((pinitial_text <= less) == (pinitial_text <= less_text)); - CHECK((greater <= pinitial_text) == (greater_text <= pinitial_text)); - CHECK((pinitial_text <= greater) == (pinitial_text <= greater_text)); + CHECK((greater <= pinitial_text) == (greater_text <= pinitial_text)); + CHECK((pinitial_text <= greater) == (pinitial_text <= greater_text)); - CHECK((shorter <= pinitial_text) == (shorter_text <= pinitial_text)); - CHECK((pinitial_text <= shorter) == (pinitial_text <= shorter_text)); + CHECK((shorter <= pinitial_text) == (shorter_text <= pinitial_text)); + CHECK((pinitial_text <= shorter) == (pinitial_text <= shorter_text)); - CHECK((initial <= pinitial_text) == (initial_text <= pinitial_text)); - CHECK((pinitial_text <= initial) == (pinitial_text <= initial_text)); + CHECK((initial <= pinitial_text) == (initial_text <= pinitial_text)); + CHECK((pinitial_text <= initial) == (pinitial_text <= initial_text)); } //************************************************************************* @@ -3308,17 +4044,17 @@ namespace CHECK((initial > initial) == (initial_text > initial_text)); // String-Pointer Pointer-String - CHECK((less > pinitial_text) == (less_text > pinitial_text)); - CHECK((pinitial_text > less) == (pinitial_text > less_text)); + CHECK((less > pinitial_text) == (less_text > pinitial_text)); + CHECK((pinitial_text > less) == (pinitial_text > less_text)); - CHECK((greater > pinitial_text) == (greater_text > pinitial_text)); - CHECK((pinitial_text > greater) == (pinitial_text > greater_text)); + CHECK((greater > pinitial_text) == (greater_text > pinitial_text)); + CHECK((pinitial_text > greater) == (pinitial_text > greater_text)); - CHECK((shorter > pinitial_text) == (shorter_text > pinitial_text)); - CHECK((pinitial_text > shorter) == (pinitial_text > shorter_text)); + CHECK((shorter > pinitial_text) == (shorter_text > pinitial_text)); + CHECK((pinitial_text > shorter) == (pinitial_text > shorter_text)); - CHECK((initial > pinitial_text) == (initial_text > pinitial_text)); - CHECK((pinitial_text > initial) == (pinitial_text > initial_text)); + CHECK((initial > pinitial_text) == (initial_text > pinitial_text)); + CHECK((pinitial_text > initial) == (pinitial_text > initial_text)); } //************************************************************************* @@ -3331,8 +4067,8 @@ namespace const Text initial(initial_text.begin(), initial_text.end(), buffer2.data(), buffer2.size()); // String-String - CHECK((less >= initial) == (less_text >= initial_text)); - CHECK((initial >= less) == (initial_text >= less_text)); + CHECK((less >= initial) == (less_text >= initial_text)); + CHECK((initial >= less) == (initial_text >= less_text)); TextBuffer buffer3; const Text greater(greater_text.begin(), greater_text.end(), buffer3.data(), buffer3.size()); @@ -3348,24 +4084,24 @@ namespace CHECK((initial >= initial) == (initial_text >= initial_text)); // String-Pointer Pointer-String - CHECK((less >= pinitial_text) == (less_text >= pinitial_text)); - CHECK((pinitial_text >= less) == (pinitial_text >= less_text)); + CHECK((less >= pinitial_text) == (less_text >= pinitial_text)); + CHECK((pinitial_text >= less) == (pinitial_text >= less_text)); - CHECK((greater >= pinitial_text) == (greater_text >= pinitial_text)); - CHECK((pinitial_text >= greater) == (pinitial_text >= greater_text)); + CHECK((greater >= pinitial_text) == (greater_text >= pinitial_text)); + CHECK((pinitial_text >= greater) == (pinitial_text >= greater_text)); - CHECK((shorter >= pinitial_text) == (shorter_text >= pinitial_text)); - CHECK((pinitial_text >= shorter) == (pinitial_text >= shorter_text)); + CHECK((shorter >= pinitial_text) == (shorter_text >= pinitial_text)); + CHECK((pinitial_text >= shorter) == (pinitial_text >= shorter_text)); - CHECK((initial >= pinitial_text) == (initial_text >= pinitial_text)); - CHECK((pinitial_text >= initial) == (pinitial_text >= initial_text)); + CHECK((initial >= pinitial_text) == (initial_text >= pinitial_text)); + CHECK((pinitial_text >= initial) == (pinitial_text >= initial_text)); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy) { - CompareText compare_text(initial_text.c_str()); - + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3384,8 +4120,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3408,7 +4144,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3416,7 +4152,7 @@ namespace value_t buffer1[SIZE]; value_t buffer2[SIZE]; - size_t length1 = compare_text.copy(buffer1, CompareText::npos, 2); + size_t length1 = compare_text.copy(buffer1, TextSTD::npos, 2); buffer1[length1] = STR('\0'); size_t length2 = text.copy(buffer2, Text::npos, 2); @@ -3428,15 +4164,15 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_too_large) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3456,8 +4192,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3466,12 +4202,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_needle(STR("needle")); + TextSTD compare_needle(STR("needle")); TextBuffer buffer{0}; Text needle(STR("needle"), buffer.data(), buffer.size()); - std::u8string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; Text haystack(the_haystack, buffer2.data(), buffer2.size()); @@ -3488,13 +4224,77 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::u8string<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::u8string<50> pin(STR("pin")); + Text pin(STR("pin"), buffer.data(), buffer.size()); position2 = haystack.find(pin); CHECK_EQUAL(IText::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + ViewETL needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(TextL::npos, position2); + + ViewETL pin_view(STR("pin")); + position2 = haystack.find(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + ViewSTD needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(TextL::npos, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.find(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -3502,7 +4302,7 @@ namespace const value_t* needle = STR("needle"); - std::u8string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); @@ -3521,7 +4321,7 @@ namespace position2 = haystack.find(needle, position2 + 1); CHECK_EQUAL(IText::npos, position2); - const value_t* pin = STR("pin"); + const value_t *pin = STR("pin"); position2 = haystack.find(pin); CHECK_EQUAL(IText::npos, position2); } @@ -3533,7 +4333,7 @@ namespace const value_t* needle = STR("needle"); - std::u8string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); @@ -3552,7 +4352,7 @@ namespace position2 = haystack.find(needle, position2 + 1, 3); CHECK_EQUAL(IText::npos, position2); - const value_t* pin = STR("pin"); + const value_t *pin = STR("pin"); position2 = haystack.find(pin, 0, 3); CHECK_EQUAL(IText::npos, position2); } @@ -3562,18 +4362,18 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_needle(STR("needle")); + TextSTD compare_needle(STR("needle")); TextBufferL buffer{0}; Text needle(STR("needle"), buffer.data(), buffer.size()); - std::u8string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; Text haystack(the_haystack, buffer2.data(), buffer2.size()); - size_t position1 = std::u8string::npos; - size_t position2 = etl::u8string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle, position2); @@ -3590,19 +4390,76 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_pointer) + TEST_FIXTURE(SetupFixture, test_rfind_etl_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_haystack(the_haystack); + TextSTD compare_needle(STR("needle")); + ViewETL needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewETL pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); + ViewSTD needle_view(needle); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } +#endif + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_pointer) + { + const value_t*the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); const value_t* needle = STR("needle"); - size_t position1 = std::u8string::npos; - size_t position2 = etl::u8string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(needle, position1); position2 = haystack.rfind(needle, position2); @@ -3621,16 +4478,16 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer_n) { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); + const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); const value_t* needle = STR("needle"); - size_t position1 = std::u8string::npos; + size_t position1 = TextSTD::npos; size_t position2 = Text::npos; @@ -3649,15 +4506,15 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_c_position) { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); + const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::u8string compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); - size_t position1 = std::u8string::npos; - size_t position2 = etl::u8string<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(STR('e'), position1); position2 = haystack.rfind(STR('e'), position2); @@ -3674,7 +4531,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3683,35 +4540,110 @@ namespace int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(TextL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(TextL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(TextL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(TextL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(TextL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_etl_view) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); + result = text.compare(ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); + result = text.compare(ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); + result = text.compare(ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); + result = text.compare(ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); + result = text.compare(ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_std_view) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); + result = text.compare(ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); + result = text.compare(ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); + result = text.compare(ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); + result = text.compare(ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); + result = text.compare(ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3720,35 +4652,109 @@ namespace int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, TextL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, TextL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, TextL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, TextL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, TextL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3757,35 +4763,109 @@ namespace int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, TextL(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, TextL(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3822,7 +4902,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3859,7 +4939,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3896,38 +4976,100 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(TextL(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(TextL(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(TextL(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(TextL(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); + position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); + position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3958,7 +5100,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3994,7 +5136,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4035,43 +5177,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(TextL(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(TextL(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(TextL(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(TextL(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(TextL(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4112,7 +5326,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4142,16 +5356,18 @@ namespace CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(STR("ZCXE"), 100, 4); position2 = text.find_last_of(STR("ZCXE"), 100, 4); CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" } //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4192,43 +5408,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(TextL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(TextL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(TextL(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(TextL(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(TextL(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4264,7 +5552,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4305,7 +5593,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4346,43 +5634,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(TextL(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(TextL(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4418,7 +5778,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4452,7 +5812,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); diff --git a/test/test_string_view.cpp b/test/test_string_view.cpp index bff4c211..27713f89 100644 --- a/test/test_string_view.cpp +++ b/test/test_string_view.cpp @@ -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"; @@ -166,7 +173,7 @@ namespace //************************************************************************* TEST(test_constructor_from_std_string_view) { - std::string_view stdview(etltext.begin(), etltext.end()); + std::string_view stdview(text.data(), text.size()); View view(stdview); @@ -182,7 +189,7 @@ namespace //************************************************************************* TEST(test_constructor_from_std_wstring_view) { - std::wstring_view stdview(wtext.begin(), wtext.end()); + std::wstring_view stdview(wtext.data(), wtext.size()); WView view(stdview); @@ -194,11 +201,27 @@ namespace } #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.begin(), u16text.end()); + std::u16string_view stdview(u16text.data(), u16text.size()); U16View view(stdview); @@ -214,7 +237,7 @@ namespace //************************************************************************* TEST(test_constructor_from_std_u32string_view) { - std::u32string_view stdview(u32text.begin(), u32text.end()); + std::u32string_view stdview(u32text.data(), u32text.size()); U32View view(stdview); diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 862565c0..b8f51dba 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -66,21 +66,21 @@ namespace { static const size_t SIZE = 11; - using Text = etl::wstring; - using IText = etl::iwstring; - using CompareText = std::wstring; - using value_t = Text::value_type; - using TextL = etl::wstring<52>; - using TextS = etl::wstring<4>; + using Text = etl::wstring; + using IText = etl::iwstring; + using TextSTD = std::wstring; + using value_t = Text::value_type; + using TextL = etl::wstring<52>; + using TextS = etl::wstring<4>; - CompareText initial_text; - CompareText less_text; - CompareText greater_text; - CompareText shorter_text; - CompareText different_text; - CompareText insert_text; - CompareText longer_text; - CompareText short_text; + TextSTD initial_text; + TextSTD less_text; + TextSTD greater_text; + TextSTD shorter_text; + TextSTD different_text; + TextSTD insert_text; + TextSTD longer_text; + TextSTD short_text; using ViewETL = etl::wstring_view; #if ETL_USING_STL && ETL_USING_CPP17 using ViewSTD = std::wstring_view; @@ -147,7 +147,7 @@ namespace const size_t INITIAL_SIZE = 5; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text(INITIAL_SIZE, INITIAL_VALUE); + TextSTD compare_text(INITIAL_SIZE, INITIAL_VALUE); Text text(INITIAL_SIZE, INITIAL_VALUE); CHECK(text.size() == INITIAL_SIZE); @@ -175,7 +175,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); @@ -191,7 +191,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(longer_text.c_str()); @@ -207,7 +207,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); Text text(SIZE, STR('A')); @@ -223,7 +223,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); Text text(SIZE + 1, STR('A')); @@ -239,7 +239,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char) { - CompareText compare_text(initial_text.c_str(), initial_text.size() / 2); + TextSTD compare_text(initial_text.c_str(), initial_text.size() / 2); Text text(initial_text.c_str(), initial_text.size() / 2); @@ -255,7 +255,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) { - CompareText compare_text(initial_text.c_str(), initial_text.size()); + TextSTD compare_text(initial_text.c_str(), initial_text.size()); Text text(longer_text.c_str(), longer_text.size()); @@ -271,7 +271,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(compare_text.begin(), compare_text.end()); @@ -381,8 +381,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length) { - CompareText compare_text(initial_text.c_str()); - CompareText compare_text2(compare_text, 2, 4); + TextSTD compare_text(initial_text.c_str()); + TextSTD compare_text2(compare_text, 2, 4); Text text(initial_text.c_str()); Text text2(text, 2, 4); @@ -397,8 +397,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) { - CompareText compare_text(longer_text.c_str()); - CompareText compare_text2(compare_text, 2, 11); + TextSTD compare_text(longer_text.c_str()); + TextSTD compare_text2(compare_text, 2, 11); TextL textl(longer_text.c_str()); Text text2(textl, 2, 12); @@ -414,7 +414,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list) { - CompareText compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; Text text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; bool is_equal = Equal(compare_text, text); @@ -427,7 +427,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { - CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + TextSTD compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; Text text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), @@ -558,7 +558,7 @@ namespace text = STR("Hello World"); - bool is_equal = Equal(std::wstring(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -572,7 +572,7 @@ namespace text = STR("Hello World There"); - bool is_equal = Equal(std::wstring(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(text.is_truncated()); @@ -587,7 +587,7 @@ namespace itext = STR("Hello World"); - bool is_equal = Equal(std::wstring(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!itext.is_truncated()); @@ -602,7 +602,7 @@ namespace itext = STR("Hello World There"); - bool is_equal = Equal(std::wstring(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(itext.is_truncated()); @@ -616,7 +616,7 @@ namespace text = ViewETL(STR("Hello World")); - bool is_equal = Equal(std::wstring(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -631,7 +631,7 @@ namespace text = ViewSTD(STR("Hello World")); - bool is_equal = Equal(std::wstring(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -905,7 +905,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -921,7 +921,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -937,7 +937,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -955,7 +955,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); for (size_t i = 0UL; i < text.size(); ++i) @@ -973,7 +973,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); CHECK(text.front() == compare_text.front()); @@ -985,7 +985,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); CHECK(text.front() == compare_text.front()); @@ -997,7 +997,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); CHECK(text.back() == compare_text.back()); @@ -1009,7 +1009,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); const Text text(initial_text.c_str()); CHECK(text.back() == compare_text.back()); @@ -1021,7 +1021,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(compare_text.begin(), compare_text.end()); @@ -1038,7 +1038,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data_const) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); const Text text(compare_text.begin(), compare_text.end()); @@ -1055,10 +1055,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1074,11 +1074,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_etl_view) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); ViewETL view(input); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1095,11 +1095,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_std_view) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - ViewSTD view(input.data(), input.data_end()); + ViewSTD view(input.data(), input.size()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1116,10 +1116,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextL input(longer_text.c_str()); - CompareText compare_text; + TextSTD compare_text; Text text; compare_text.assign(compare_input); @@ -1135,7 +1135,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(initial_text.c_str()); @@ -1150,7 +1150,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(longer_text.c_str()); @@ -1165,7 +1165,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; text.assign(initial_text.c_str(), initial_text.size()); @@ -1180,7 +1180,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) { - CompareText compare_text(longer_text.c_str()); + TextSTD compare_text(longer_text.c_str()); Text text; text.assign(longer_text.c_str(), longer_text.size()); @@ -1197,7 +1197,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text; @@ -1269,7 +1269,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { - CompareText compare_text; + TextSTD compare_text; Text text; for (size_t i = 0UL; i < SIZE; ++i) @@ -1295,7 +1295,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_excess) { - CompareText compare_text; + TextSTD compare_text; Text text; for (size_t i = 0UL; i < SIZE; ++i) @@ -1326,7 +1326,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); compare_text.pop_back(); @@ -1350,7 +1350,7 @@ namespace for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; Text text; text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); @@ -1370,7 +1370,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(initial_text.begin(), initial_text.end()); const value_t INITIAL_VALUE = STR('A'); @@ -1415,7 +1415,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { - CompareText compare_text; + TextSTD compare_text; Text text; const size_t INITIAL_SIZE = 5; @@ -1441,7 +1441,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { - CompareText compare_text; + TextSTD compare_text; Text text; const size_t INSERT_SIZE = 4; @@ -1514,7 +1514,7 @@ namespace for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; Text text; text.assign(initial_text.begin(), initial_text.begin() + INITIAL_SIZE); @@ -1537,7 +1537,7 @@ namespace const size_t INITIAL_SIZE = 5; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text; + TextSTD compare_text; Text text; size_t offset = 0; @@ -1595,7 +1595,7 @@ namespace for (size_t offset = 10; offset < length; ++offset) { - CompareText compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextSTD compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); TextL text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); text.insert(text.begin() + offset, text.begin() + 5, text.begin() + 10); @@ -1614,7 +1614,7 @@ namespace { for (size_t offset = 0; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1635,9 +1635,9 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewETL view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1657,9 +1657,9 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewSTD view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewSTD view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1679,7 +1679,7 @@ namespace { for (size_t offset = 0; offset <= initial_text.size(); ++offset) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); Text text(initial_text.begin(), initial_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1700,7 +1700,7 @@ namespace { for (size_t offset = 0; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(longer_text.begin(), longer_text.end()); insert.erase(insert.begin(), insert.end()); @@ -1721,7 +1721,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) { - CompareText compare_text(short_text.begin(), short_text.end()); + TextSTD compare_text(short_text.begin(), short_text.end()); Text text(short_text.begin(), short_text.end()); Text insert(insert_text.begin(), insert_text.end()); @@ -1767,7 +1767,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -1800,9 +1800,9 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_etl_view) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewETL view(insert_text.data(), insert_text.data() + insert_text.size()); + ViewETL view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1817,7 +1817,7 @@ namespace // Overflow. compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - view.assign(initial_text.data(), initial_text.data() + initial_text.size()); + view.assign(initial_text.data(), initial_text.size()); compare_text.append(initial_text); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -1834,9 +1834,9 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_std_view) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewSTD append(insert_text.data(), insert_text.data() + insert_text.size()); + ViewSTD append(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1851,7 +1851,7 @@ namespace // Overflow. compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.data() + initial_text.size()); + append = ViewSTD(initial_text.data(), initial_text.size()); compare_text.append(initial_text); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -1885,7 +1885,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_to_self) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Non-overflow. @@ -1916,7 +1916,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -1980,7 +1980,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_c_string) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Whole string. @@ -2012,7 +2012,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_n_c) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); // Non-overflow. @@ -2044,7 +2044,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_range) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); Text append(insert_text.c_str()); @@ -2077,10 +2077,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace"))); @@ -2094,7 +2094,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace"))); @@ -2108,7 +2108,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2122,7 +2122,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2136,7 +2136,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace"))); @@ -2150,7 +2150,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2164,7 +2164,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2179,10 +2179,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace"))); @@ -2196,7 +2196,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace"))); @@ -2210,7 +2210,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace with some text"))); @@ -2224,7 +2224,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); @@ -2238,7 +2238,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewETL(STR("Replace"))); @@ -2252,7 +2252,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewETL(STR("Replace with some text"))); @@ -2266,7 +2266,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); @@ -2282,10 +2282,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace"))); @@ -2299,7 +2299,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace"))); @@ -2313,7 +2313,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace with some text"))); @@ -2327,7 +2327,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); @@ -2341,7 +2341,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewSTD(STR("Replace"))); @@ -2355,7 +2355,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, ViewSTD(STR("Replace with some text"))); @@ -2369,7 +2369,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); @@ -2385,10 +2385,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace"))); @@ -2402,7 +2402,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2416,7 +2416,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace"))); @@ -2430,7 +2430,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2445,10 +2445,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); @@ -2462,7 +2462,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); @@ -2476,7 +2476,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); @@ -2490,7 +2490,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); @@ -2506,10 +2506,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); @@ -2523,7 +2523,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); @@ -2537,7 +2537,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); @@ -2551,7 +2551,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); @@ -2567,10 +2567,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")), 1, 5); @@ -2584,7 +2584,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2598,7 +2598,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2612,7 +2612,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2626,7 +2626,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")), 1, 5); @@ -2640,7 +2640,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2654,7 +2654,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2668,7 +2668,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2683,10 +2683,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); @@ -2700,7 +2700,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); @@ -2714,7 +2714,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); @@ -2728,7 +2728,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); @@ -2742,7 +2742,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); @@ -2756,7 +2756,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); @@ -2770,7 +2770,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); @@ -2784,7 +2784,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); @@ -2800,10 +2800,10 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); @@ -2817,7 +2817,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); @@ -2831,7 +2831,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); @@ -2845,7 +2845,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); @@ -2859,7 +2859,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); @@ -2873,7 +2873,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); @@ -2887,7 +2887,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); @@ -2901,7 +2901,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); @@ -2917,7 +2917,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(2, 4, STR("Replace")); @@ -2934,7 +2934,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, STR("Replace")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace")); @@ -2962,7 +2962,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text")); @@ -2990,7 +2990,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, STR("Replace")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace")); @@ -3018,7 +3018,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text")); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text")); @@ -3033,7 +3033,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace")); @@ -3093,7 +3093,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(2, 4, STR("Replace"), 5); @@ -3110,7 +3110,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, STR("Replace"), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace"), 5); @@ -3138,7 +3138,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text"), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text"), 15); @@ -3166,7 +3166,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, STR("Replace"), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace"), 5); @@ -3194,7 +3194,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, STR("Replace with some text"), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, STR("Replace with some text"), 15); @@ -3209,7 +3209,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace"), 5); @@ -3277,7 +3277,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(2, 4, 7, STR('A')); @@ -3294,7 +3294,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -3322,7 +3322,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -3350,7 +3350,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -3378,7 +3378,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -3393,7 +3393,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, 7, STR('A')); @@ -3453,11 +3453,11 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - CompareText replace(STR("Replace")); - CompareText replace_long(STR("Replace with some text")); + TextSTD replace(STR("Replace")); + TextSTD replace_long(STR("Replace with some text")); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -3515,10 +3515,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.begin() + 2); + TextSTD::iterator citr = compare_text.erase(compare_text.begin() + 2); Text::iterator ditr = text.erase(text.begin() + 2); CHECK(*citr == *ditr); @@ -3532,10 +3532,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2); + TextSTD::iterator citr = compare_text.erase(compare_text.cbegin() + 2); Text::iterator ditr = text.erase(text.cbegin() + 2); CHECK(*citr == *ditr); @@ -3549,10 +3549,10 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); + TextSTD::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); Text::iterator ditr = text.erase(text.cbegin() + 2, text.cbegin() + 4); CHECK(*citr == *ditr); @@ -3578,7 +3578,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.begin(), text.end(), compare_text.begin()); @@ -3591,7 +3591,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.cbegin(), text.cend(), compare_text.cbegin()); @@ -3604,7 +3604,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.rbegin(), text.rend(), compare_text.rbegin()); @@ -3617,7 +3617,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); bool is_equal = std::equal(text.crbegin(), text.crend(), compare_text.crbegin()); @@ -3804,7 +3804,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; @@ -3845,13 +3845,13 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; value_t buffer2[SIZE]; - size_t length1 = compare_text.copy(buffer1, CompareText::npos, 2); + size_t length1 = compare_text.copy(buffer1, TextSTD::npos, 2); buffer1[length1] = STR('\0'); size_t length2 = text.copy(buffer2, Text::npos, 2); @@ -3871,7 +3871,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_too_large) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); value_t buffer1[SIZE]; @@ -3899,11 +3899,11 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_needle(STR("needle")); - etl::wstring<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); - std::wstring compare_haystack(the_haystack); - etl::wstring<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -3917,11 +3917,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::wstring<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::wstring<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.find(pin); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -3929,12 +3929,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_needle(STR("needle")); - etl::wstring<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); ViewETL needle_view(needle); - std::wstring compare_haystack(the_haystack); - etl::wstring<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -3948,12 +3948,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(etl::wstring<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::wstring<50> pin(STR("pin")); - ViewETL pin_view(pin); + ViewETL pin_view(STR("pin")); position2 = haystack.find(pin_view); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } #if ETL_USING_STL && ETL_USING_CPP17 @@ -3962,12 +3961,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_needle(STR("needle")); - std::wstring needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); ViewSTD needle_view(needle); - std::wstring compare_haystack(the_haystack); - etl::wstring<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0UL; size_t position2 = 0UL; @@ -3981,12 +3980,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(etl::wstring<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - std::wstring pin(STR("pin")); - ViewSTD pin_view(pin); + ViewSTD pin_view(STR("pin")); position2 = haystack.find(pin_view); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } #endif @@ -3997,8 +3995,8 @@ namespace const value_t* needle = STR("needle"); - std::wstring compare_haystack(the_haystack); - etl::wstring<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -4012,11 +4010,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); const value_t* pin = STR("pin"); position2 = haystack.find(pin); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4026,8 +4024,8 @@ namespace const value_t* needle = STR("needle"); - std::wstring compare_haystack(the_haystack); - etl::wstring<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = 0; size_t position2 = 0; @@ -4041,11 +4039,11 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1, 3); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); const value_t* pin = STR("pin"); position2 = haystack.find(pin, 0, 3); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4053,14 +4051,14 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_needle(STR("needle")); - etl::wstring<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); - std::wstring compare_haystack(the_haystack); - etl::wstring<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = std::wstring::npos; - size_t position2 = etl::wstring<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle, position2); @@ -4070,9 +4068,9 @@ namespace position2 = haystack.rfind(needle, haystack.size() - 10); CHECK_EQUAL(position1, position2); - etl::wstring<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4080,45 +4078,15 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_needle(STR("needle")); - etl::wstring<50> needle(STR("needle")); + TextSTD compare_needle(STR("needle")); + Text needle(STR("needle")); ViewETL needle_view(needle); - std::wstring compare_haystack(the_haystack); - etl::wstring<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = std::wstring::npos; - size_t position2 = etl::wstring<50>::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - etl::wstring<50> pin(STR("pin")); - ViewETL pin_view(pin); - position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iwstring::npos, position2); - } - -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - std::wstring compare_needle(STR("needle")); - std::wstring needle(STR("needle")); - ViewSTD needle_view(needle); - - std::wstring compare_haystack(the_haystack); - etl::wstring<50> haystack(the_haystack); - - size_t position1 = std::wstring::npos; - size_t position2 = etl::wstring<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle_view, position2); @@ -4128,10 +4096,38 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - std::wstring pin(STR("pin")); - ViewSTD pin_view(pin); + ViewETL pin_view(STR("pin")); position2 = haystack.rfind(pin_view); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); + ViewSTD needle_view(needle); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = std::wstring::npos; + size_t position2 = Text::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); } #endif @@ -4140,13 +4136,13 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_haystack(the_haystack); - etl::wstring<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); const value_t* needle = STR("needle"); size_t position1 = std::wstring::npos; - size_t position2 = etl::wstring<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(needle, position1); position2 = haystack.rfind(needle, position2); @@ -4156,9 +4152,9 @@ namespace position2 = haystack.rfind(needle, haystack.size() - 10); CHECK_EQUAL(position1, position2); - etl::wstring<50> pin(STR("pin")); + Text pin(STR("pin")); position2 = haystack.rfind(pin); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4166,13 +4162,13 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_haystack(the_haystack); - etl::wstring<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); const value_t* needle = STR("needle"); size_t position1 = std::wstring::npos; - size_t position2 = etl::wstring<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(needle, position1, 3); position2 = haystack.rfind(needle, position2, 3); @@ -4183,7 +4179,7 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.rfind(STR("pin"), 3); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* @@ -4191,11 +4187,11 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_haystack(the_haystack); - etl::wstring<50> haystack(the_haystack); + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); size_t position1 = std::wstring::npos; - size_t position2 = etl::wstring<50>::npos; + size_t position2 = Text::npos; position1 = compare_haystack.rfind(STR('e'), position1); position2 = haystack.rfind(STR('e'), position2); @@ -4206,16 +4202,16 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.rfind(STR('z')); - CHECK_EQUAL(etl::iwstring::npos, position2); + CHECK_EQUAL(TextL::npos, position2); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_substr) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str()); - CompareText compare_result; + TextSTD compare_result; Text result; // Equal. @@ -4250,34 +4246,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(Text(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(Text(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(Text(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(Text(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(Text(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4285,34 +4281,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_etl_view) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(ViewETL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(ViewETL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(ViewETL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(ViewETL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(ViewETL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4321,34 +4317,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_std_view) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(ViewSTD(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(ViewSTD(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(ViewSTD(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(ViewSTD(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(ViewSTD(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4357,34 +4353,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, Text(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, Text(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, Text(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, Text(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, Text(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4392,34 +4388,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, ViewETL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4428,34 +4424,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } @@ -4464,34 +4460,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, Text(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, Text(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, Text(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4499,34 +4495,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4535,34 +4531,34 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } @@ -4571,7 +4567,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); int compare_result; @@ -4606,7 +4602,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; @@ -4641,7 +4637,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); int compare_result; @@ -4676,26 +4672,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(Text(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(Text(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(Text(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(Text(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4705,26 +4701,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(ViewETL(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4735,26 +4731,26 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); @@ -4765,7 +4761,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR("ZCXF")); @@ -4794,7 +4790,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR("ZCXF"), 0, 4); @@ -4828,7 +4824,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(STR('C')); @@ -4867,31 +4863,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(Text(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(Text(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(Text(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(Text(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(Text(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4901,31 +4897,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4936,31 +4932,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); @@ -4971,7 +4967,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(STR("ZCXE")); @@ -5010,7 +5006,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(STR("AZCXE"), 0, 4); @@ -5047,7 +5043,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_last_of(STR('C')); @@ -5086,31 +5082,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(Text(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(Text(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(Text(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(Text(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(Text(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5120,31 +5116,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5155,31 +5151,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); @@ -5190,7 +5186,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR("ZAXB")); @@ -5224,7 +5220,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR("ZAXB"), 0, 4); @@ -5263,7 +5259,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(STR('A')); @@ -5302,31 +5298,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(Text(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(Text(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(Text(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(Text(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(Text(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5336,31 +5332,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5371,31 +5367,31 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); @@ -5406,7 +5402,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(STR("ZEXD")); @@ -5440,7 +5436,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(STR("ZEXD"), 0, 4); @@ -5472,7 +5468,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_last_not_of(STR('F')); diff --git a/test/test_string_wchar_t_external_buffer.cpp b/test/test_string_wchar_t_external_buffer.cpp index a30dc63f..443b0b8a 100644 --- a/test/test_string_wchar_t_external_buffer.cpp +++ b/test/test_string_wchar_t_external_buffer.cpp @@ -69,24 +69,34 @@ namespace static constexpr size_t SIZE_L = 52; static constexpr size_t SIZE_S = 4; - using Text = etl::wstring_ext; - using IText = etl::iwstring; - using TextL = etl::wstring; - using CompareText = std::wstring; - using value_t = Text::value_type; + using Text = etl::wstring_ext; + using IText = etl::iwstring; + using TextL = etl::wstring; + using TextSTD = std::wstring; + using value_t = Text::value_type; + + using ViewETL = etl::wstring_view; +#if ETL_USING_STL && ETL_USING_CPP17 + using ViewSTD = std::wstring_view; +#endif using TextBuffer = std::array; using TextBufferL = std::array; using TextBufferS = std::array; - CompareText initial_text; - CompareText less_text; - CompareText greater_text; - CompareText shorter_text; - CompareText different_text; - CompareText insert_text; - CompareText longer_text; - CompareText short_text; + using ViewETL = etl::wstring_view; +#if ETL_USING_STL && ETL_USING_CPP17 + using ViewSTD = std::wstring_view; +#endif + + TextSTD initial_text; + TextSTD less_text; + TextSTD greater_text; + TextSTD shorter_text; + TextSTD different_text; + TextSTD insert_text; + TextSTD longer_text; + TextSTD short_text; const value_t* pinitial_text = STR("Hello World"); @@ -201,9 +211,9 @@ namespace TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); - CHECK(text.begin() == text.end()); - CHECK(text.cbegin() == text.cend()); - CHECK(text.rbegin() == text.rend()); + CHECK(text.begin() == text.end()); + CHECK(text.cbegin() == text.cend()); + CHECK(text.rbegin() == text.rend()); CHECK(text.crbegin() == text.crend()); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -213,11 +223,11 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_value) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const value_t INITIAL_VALUE = STR('A'); TextBuffer buffer{0}; - CompareText compare_text(INITIAL_SIZE, INITIAL_VALUE); + TextSTD compare_text(INITIAL_SIZE, INITIAL_VALUE); Text text(INITIAL_SIZE, INITIAL_VALUE, buffer.data(), buffer.size()); CHECK(text.size() == INITIAL_SIZE); @@ -247,7 +257,7 @@ namespace TEST_FIXTURE(SetupFixture, test_constructor_char_pointer) { TextBuffer buffer{0}; - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -263,7 +273,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(longer_text.c_str(), buffer.data(), buffer.size()); @@ -280,7 +290,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); TextBuffer buffer{0}; Text text(SIZE, STR('A'), buffer.data(), buffer.size()); @@ -297,7 +307,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_char_pointer_size_excess) { - CompareText compare_text(SIZE, STR('A')); + TextSTD compare_text(SIZE, STR('A')); TextBuffer buffer{0}; Text text(SIZE + 1, STR('A'), buffer.data(), buffer.size()); @@ -314,7 +324,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char) { - CompareText compare_text(initial_text.c_str(), initial_text.size() / 2); + TextSTD compare_text(initial_text.c_str(), initial_text.size() / 2); TextBuffer buffer{0}; Text text(initial_text.c_str(), initial_text.size() / 2, buffer.data(), buffer.size()); @@ -331,7 +341,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_size_char_excess) { - CompareText compare_text(initial_text.c_str(), initial_text.size()); + TextSTD compare_text(initial_text.c_str(), initial_text.size()); TextBuffer buffer{0}; Text text(longer_text.c_str(), longer_text.size(), buffer.data(), buffer.size()); @@ -348,7 +358,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_range) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); TextBuffer buffer{0}; Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -388,10 +398,9 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_string_view) + TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - etl::wstring_view view(initial_text.data(), initial_text.size()); - + ViewETL view(initial_text.data(), initial_text.size()); TextBuffer buffer{0}; Text text(view, buffer.data(), buffer.size()); @@ -401,6 +410,21 @@ namespace CHECK(!text.empty()); } +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) + { + ViewSTD view(initial_text.data(), initial_text.size()); + TextBuffer buffer{0}; + Text text(view, buffer.data(), buffer.size()); + + bool is_equal = Equal(initial_text, text); + CHECK(is_equal); + CHECK(text.size() == SIZE); + CHECK(!text.empty()); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -464,8 +488,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length) { - CompareText compare_text(initial_text.c_str()); - CompareText compare_text2(compare_text, 2, 4); + TextSTD compare_text(initial_text.c_str()); + TextSTD compare_text2(compare_text, 2, 4); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -483,8 +507,8 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_position_length_excess) { - CompareText compare_text(longer_text.c_str()); - CompareText compare_text2(compare_text, 2, 11); + TextSTD compare_text(longer_text.c_str()); + TextSTD compare_text2(compare_text, 2, 11); TextBufferL bufferl{0}; Text textl(longer_text.c_str(), bufferl.data(), bufferl.size()); @@ -503,7 +527,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list) { - CompareText compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; std::initializer_list il = { STR('H'), STR('e'), STR('l') , STR('l') , STR('o') }; TextBuffer buffer{0}; @@ -519,12 +543,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_construct_initializer_list_excess) { - CompareText compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; + TextSTD compare_text = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), + STR('W'), STR('o'), STR('r'), STR('l'), STR('d') }; std::initializer_list il = { STR('H'), STR('e'), STR('l'), STR('l'), STR('o'), STR(' '), - STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), - STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; + STR('W'), STR('o'), STR('r'), STR('l'), STR('d'), STR(' '), + STR('T'), STR('h'), STR('e'), STR('r'), STR('e') }; TextBuffer buffer{0}; Text text(il, buffer.data(), buffer.size()); @@ -672,7 +696,7 @@ namespace text = STR("Hello World"); - bool is_equal = Equal(std::wstring(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!text.is_truncated()); @@ -687,7 +711,7 @@ namespace text = STR("Hello World There"); - bool is_equal = Equal(std::wstring(STR("Hello World")), text); + bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(text.is_truncated()); @@ -703,7 +727,7 @@ namespace itext = STR("Hello World"); - bool is_equal = Equal(std::wstring(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(!itext.is_truncated()); @@ -719,13 +743,45 @@ namespace itext = STR("Hello World There"); - bool is_equal = Equal(std::wstring(STR("Hello World")), itext); + bool is_equal = Equal(TextSTD(STR("Hello World")), itext); CHECK(is_equal); #if ETL_HAS_STRING_TRUNCATION_CHECKS CHECK(itext.is_truncated()); #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = ViewETL(STR("Hello World")); + + bool is_equal = Equal(TextSTD(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + + text = ViewSTD(STR("Hello World")); + + bool is_equal = Equal(TextSTD(STR("Hello World")), text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -734,7 +790,7 @@ namespace TextBuffer buffer2{0}; const Text constText(initial_text.c_str(), buffer2.data(), buffer2.size()); - + CHECK_EQUAL(&text[0], text.begin()); CHECK_EQUAL(&constText[0], constText.begin()); } @@ -848,7 +904,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_uninitialized_resize_up) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const size_t NEW_SIZE = 8; const value_t INITIAL_VALUE = STR('A'); const value_t FILL_VALUE = STR('B'); @@ -892,7 +948,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_uninitialized_resize_down) { - const size_t INITIAL_SIZE = 5; + const size_t INITIAL_SIZE = 5UL; const size_t NEW_SIZE = 2; const value_t INITIAL_VALUE = STR('A'); const value_t FILL_VALUE = STR('B'); @@ -918,24 +974,6 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_fill) - { - TextBuffer buffer1{ 0 }; - TextBuffer buffer2{ 0 }; - Text text(11, STR('A'), buffer1.data(), buffer1.size()); - Text expected(11, STR('B'), buffer2.data(), buffer2.size()); - - text.fill(STR('B')); - - bool is_equal = Equal(expected, text); - CHECK(is_equal); - -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { @@ -1015,7 +1053,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1033,7 +1071,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_index_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1051,7 +1089,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1071,7 +1109,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_at_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1091,7 +1129,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1105,7 +1143,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_front_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1119,7 +1157,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1133,7 +1171,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_back_const) { - const CompareText compare_text(initial_text.c_str()); + const TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1147,7 +1185,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -1165,7 +1203,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_data_const) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; const Text text(compare_text.begin(), compare_text.end(), buffer.data(), buffer.size()); @@ -1183,12 +1221,12 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextBuffer buffer{0}; Text input(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer2{0}; Text text(buffer2.data(), buffer2.size()); @@ -1203,15 +1241,61 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_etl_view) + { + TextSTD compare_input(initial_text.c_str()); + TextBuffer buffer{0}; + Text input(initial_text.c_str(), buffer.data(), buffer.size()); + ViewETL view(input); + + TextSTD compare_text; + TextBuffer buffer2{0}; + Text text(buffer2.data(), buffer2.size()); + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_std_view) + { + TextSTD compare_input(initial_text.c_str()); + TextBuffer buffer{0}; + Text input(initial_text.c_str(), buffer.data(), buffer.size()); + ViewSTD view(input.data(), input.size()); + + TextSTD compare_text; + TextBuffer buffer2{0}; + Text text(buffer2.data(), buffer2.size()); + + compare_text.assign(compare_input); + text.assign(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { - CompareText compare_input(initial_text.c_str()); + TextSTD compare_input(initial_text.c_str()); TextBufferL bufferl{0}; Text input(longer_text.c_str(), bufferl.data(), bufferl.size()); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1229,7 +1313,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1245,7 +1329,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_excess) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1261,7 +1345,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1277,7 +1361,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_pointer_length_excess) { - CompareText compare_text(longer_text.c_str()); + TextSTD compare_text(longer_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1295,7 +1379,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1371,7 +1455,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1399,7 +1483,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_push_back_excess) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1432,7 +1516,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_pop_back) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -1454,11 +1538,11 @@ namespace TEST_FIXTURE(SetupFixture, test_insert_position_value) { const size_t INITIAL_SIZE = 5; - const value_t INITIAL_VALUE = STR('A'); + const value_t INITIAL_VALUE = STR('A'); for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1480,7 +1564,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) { - CompareText compare_text(initial_text.begin(), initial_text.end()); + TextSTD compare_text(initial_text.begin(), initial_text.end()); TextBuffer buffer{0}; Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); @@ -1526,7 +1610,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1553,7 +1637,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1627,7 +1711,7 @@ namespace for (size_t offset = 0UL; offset <= INITIAL_SIZE; ++offset) { - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1651,7 +1735,7 @@ namespace const size_t INITIAL_SIZE = 5UL; const value_t INITIAL_VALUE = STR('A'); - CompareText compare_text; + TextSTD compare_text; TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); @@ -1710,7 +1794,7 @@ namespace for (size_t offset = 10UL; offset < length; ++offset) { - CompareText compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + TextSTD compare_text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); TextBufferL bufferl{0}; Text text(bufferl.data(), bufferl.size()); text = STR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); @@ -1731,8 +1815,9 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer{0}; + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); TextBuffer buffer2{0}; @@ -1750,12 +1835,60 @@ namespace } } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) + { + for (size_t offset = 0UL; offset <= short_text.size(); ++offset) + { + TextSTD compare_text(short_text.cbegin(), short_text.cend()); + TextBuffer buffer; + buffer.fill(0); + Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + text.insert(offset, view); + compare_text.insert(offset, insert_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + } + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { for (size_t offset = 0UL; offset <= initial_text.size(); ++offset) { - CompareText compare_text(initial_text.cbegin(), initial_text.cend()); + TextSTD compare_text(initial_text.cbegin(), initial_text.cend()); TextBuffer buffer{0}; Text text(initial_text.begin(), initial_text.end(), buffer.data(), buffer.size()); @@ -1780,7 +1913,7 @@ namespace { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer{0}; Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1806,7 +1939,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_subpos_sunlen) { - CompareText compare_text(short_text.cbegin(), short_text.cend()); + TextSTD compare_text(short_text.cbegin(), short_text.cend()); TextBuffer buffer{0}; Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1856,7 +1989,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1890,6 +2023,76 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_etl_view) + { + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + ViewETL view(insert_text.data(), insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(view); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + view.assign(initial_text.data(), initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(view); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_append_std_view) + { + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + ViewSTD append(insert_text.data(), insert_text.size()); + + // Non-overflow. + compare_text.append(insert_text); + text.append(append); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + append = ViewSTD(initial_text.data(), initial_text.size()); + + compare_text.append(initial_text); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.append(append); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -1913,7 +2116,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_to_self) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1946,7 +2149,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_string_subpos_sublen) { - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -1955,7 +2158,7 @@ namespace Text append(insert_text.c_str(), buffer2.data(), buffer2.size()); // Whole string. - compare_text.append(insert_text, 0, std::wstring::npos); + compare_text.append(insert_text, 0, TextSTD::npos); text.append(append, 0, Text::npos); bool is_equal = Equal(compare_text, text); @@ -2017,7 +2220,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_c_string) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2051,7 +2254,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_n_c) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2085,7 +2288,7 @@ namespace TEST_FIXTURE(SetupFixture, test_append_range) { // Non-overflow. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2122,12 +2325,12 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_string) { // Non-overflow short text, npos. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace"))); @@ -2141,7 +2344,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace"))); + compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace"))); @@ -2155,7 +2358,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2169,7 +2372,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2183,7 +2386,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace"))); + compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace"))); @@ -2197,7 +2400,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 2, CompareText(STR("Replace with some text"))); + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 2, TextL(STR("Replace with some text"))); @@ -2211,7 +2414,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text"))); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text"))); @@ -2222,16 +2425,224 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + { + // Non-overflow short text, npos. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) + { + // Non-overflow short text, npos. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 2, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace"))); @@ -2245,7 +2656,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2259,7 +2670,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, CompareText(STR("Replace"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace"))); @@ -2273,7 +2684,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text"))); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text"))); @@ -2284,16 +2695,140 @@ namespace #endif } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace")), 1, 5); @@ -2307,7 +2842,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2321,7 +2856,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2335,7 +2870,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2349,7 +2884,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, CompareText(STR("Replace")), 1, 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 7, TextL(STR("Replace")), 1, 5); @@ -2363,7 +2898,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace")), 1, Text::npos); @@ -2377,7 +2912,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, CompareText(STR("Replace with some text")), 1, 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, 4, TextL(STR("Replace with some text")), 1, 15); @@ -2391,7 +2926,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, CompareText(STR("Replace with some text")), 1, CompareText::npos); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, TextL(STR("Replace with some text")), 1, Text::npos); @@ -2403,17 +2938,16 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) + TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); - + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, STR("Replace")); + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace")); + text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2425,9 +2959,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace")); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2439,9 +2973,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text")); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text")); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2453,9 +2987,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text")); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2467,9 +3001,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, STR("Replace")); + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, STR("Replace")); + text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2481,9 +3015,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace")); + text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2495,9 +3029,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text")); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text")); + text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2509,9 +3043,246 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text")); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text")); + text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + } +#endif + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) + { + // Non-overflow short text. + TextSTD compare_text(short_text.c_str()); + + TextBuffer buffer{0}; + Text text(short_text.c_str(), buffer.data(), buffer.size()); + + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextL(STR("Replace")).c_str()); + + bool is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow short text. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow short text, npos. + compare_text.assign(short_text.c_str()); + text.assign(short_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Non-overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 7, TextL(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Non-overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(!text.is_truncated()); +#endif + + // Overflow. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str()); + + is_equal = Equal(compare_text, text); + CHECK(is_equal); +#if ETL_HAS_STRING_TRUNCATION_CHECKS + CHECK(text.is_truncated()); +#endif + + // Overflow, npos. + compare_text.assign(initial_text.c_str()); + text.assign(initial_text.c_str()); + + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str()); + compare_text.resize(std::min(compare_text.size(), SIZE)); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2524,14 +3295,14 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace")); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace")); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str()); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2543,9 +3314,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, CompareText(STR("Replace with some text")).c_str()); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text")); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2557,9 +3328,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, STR("Replace")); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, STR("Replace")); + text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2571,9 +3342,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace with some text")); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str()); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text")); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str()); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2586,14 +3357,14 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(2, 4, STR("Replace"), 5); + compare_text.replace(2, 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace"), 5); + text.replace(2, 4, TextL(STR("Replace")).c_str(), 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2605,9 +3376,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace"), 5); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2619,9 +3390,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text"), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text"), 15); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2633,9 +3404,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text"), 15); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2647,9 +3418,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 7, STR("Replace"), 5); + compare_text.replace(2, 7, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, STR("Replace"), 5); + text.replace(2, 7, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2661,9 +3432,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace"), 5); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace"), 5); + text.replace(2, Text::npos, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2675,9 +3446,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, 4, STR("Replace with some text"), 15); + compare_text.replace(2, 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, STR("Replace with some text"), 15); + text.replace(2, 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2689,9 +3460,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, STR("Replace with some text"), 15); + compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, STR("Replace with some text"), 15); + text.replace(2, Text::npos, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2704,14 +3475,14 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_pointer_n) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace"), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace"), 5); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace")).c_str(), 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2725,9 +3496,9 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace with some text"), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text"), 15); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2741,9 +3512,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, STR("Replace"), 5); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace")).c_str(), 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, STR("Replace"), 5); + text.replace(text.begin() + 2, text.begin() + 9, TextL(STR("Replace")).c_str(), 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2757,9 +3528,9 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, STR("Replace with some text"), 15); + compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text")).c_str(), 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, STR("Replace with some text"), 15); + text.replace(text.begin() + 2, text.begin() + 4, TextL(STR("Replace with some text")).c_str(), 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2774,7 +3545,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_position_length_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2793,7 +3564,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -2821,7 +3592,7 @@ namespace compare_text.assign(short_text.c_str()); text.assign(short_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -2849,7 +3620,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 7, STR('A')); + compare_text.replace(2, TextSTD::npos, 7, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 7, STR('A')); @@ -2877,7 +3648,7 @@ namespace compare_text.assign(initial_text.c_str()); text.assign(initial_text.c_str()); - compare_text.replace(2, CompareText::npos, 15, STR('A')); + compare_text.replace(2, TextSTD::npos, 15, STR('A')); compare_text.resize(std::min(compare_text.size(), SIZE)); text.replace(2, Text::npos, 15, STR('A')); @@ -2892,7 +3663,7 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_n_c) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); @@ -2954,13 +3725,13 @@ namespace TEST_FIXTURE(SetupFixture, test_replace_first_last_first_last) { // Non-overflow short text. - CompareText compare_text(short_text.c_str()); + TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - CompareText replace(STR("Replace")); - CompareText replace_long(STR("Replace with some text")); + TextSTD replace(STR("Replace")); + TextSTD replace_long(STR("Replace with some text")); compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, replace.begin() + 1, replace.begin() + 5); compare_text.resize(std::min(compare_text.size(), SIZE)); @@ -3016,33 +3787,15 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_erase_single_iterator) + TEST_FIXTURE(SetupFixture, test_erase_single) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText::iterator citr = compare_text.erase(compare_text.begin() + 2); - Text::iterator ditr = text.erase(text.begin() + 2); - CHECK(*citr == *ditr); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_erase_single_const_iterator) - { - CompareText compare_text(initial_text.c_str()); - TextBuffer buffer{0}; - Text text(initial_text.c_str(), buffer.data(), buffer.size()); - - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2); - Text::iterator ditr = text.erase(text.cbegin() + 2); - CHECK(*citr == *ditr); + compare_text.erase(compare_text.begin() + 2); + text.erase(text.begin() + 2); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3054,13 +3807,14 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_erase_range) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); - CompareText::iterator citr = compare_text.erase(compare_text.cbegin() + 2, compare_text.cbegin() + 4); - Text::iterator ditr = text.erase(text.cbegin() + 2, text.cbegin() + 4); - CHECK(*citr == *ditr); + compare_text.erase(compare_text.begin() + 2, compare_text.begin() + 4); + + text.erase(text.begin() + 2, text.begin() + 4); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3085,7 +3839,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3100,7 +3854,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3115,7 +3869,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3130,7 +3884,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3196,7 +3950,7 @@ namespace const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); // String-String - CHECK((less < initial) == (less_text < initial_text)); + CHECK((less < initial) == (less_text < initial_text)); CHECK((initial < less) == (initial_text < less_text)); TextBuffer buffer3; @@ -3213,17 +3967,17 @@ namespace CHECK((initial < initial) == (initial_text < initial_text)); // String-Pointer Pointer-String - CHECK((less < pinitial_text) == (less_text < pinitial_text)); - CHECK((pinitial_text < less) == (pinitial_text < less_text)); + CHECK((less < pinitial_text) == (less_text < pinitial_text)); + CHECK((pinitial_text < less) == (pinitial_text < less_text)); - CHECK((greater < pinitial_text) == (greater_text < pinitial_text)); - CHECK((pinitial_text < greater) == (pinitial_text < greater_text)); + CHECK((greater < pinitial_text) == (greater_text < pinitial_text)); + CHECK((pinitial_text < greater) == (pinitial_text < greater_text)); - CHECK((shorter < pinitial_text) == (shorter_text < pinitial_text)); - CHECK((pinitial_text < shorter) == (pinitial_text < shorter_text)); + CHECK((shorter < pinitial_text) == (shorter_text < pinitial_text)); + CHECK((pinitial_text < shorter) == (pinitial_text < shorter_text)); - CHECK((initial < pinitial_text) == (initial_text < pinitial_text)); - CHECK((pinitial_text < initial) == (pinitial_text < initial_text)); + CHECK((initial < pinitial_text) == (initial_text < pinitial_text)); + CHECK((pinitial_text < initial) == (pinitial_text < initial_text)); } //************************************************************************* @@ -3236,8 +3990,8 @@ namespace const Text initial(initial_text.c_str(), buffer2.data(), buffer2.size()); // String-String - CHECK((less <= initial) == (less_text <= initial_text)); - CHECK((initial <= less) == (initial_text <= less_text)); + CHECK((less <= initial) == (less_text <= initial_text)); + CHECK((initial <= less) == (initial_text <= less_text)); TextBuffer buffer3; const Text greater(greater_text.c_str(), buffer3.data(), buffer3.size()); @@ -3253,17 +4007,17 @@ namespace CHECK((initial <= initial) == (initial_text <= initial_text)); // String-Pointer Pointer-String - CHECK((less <= pinitial_text) == (less_text <= pinitial_text)); - CHECK((pinitial_text <= less) == (pinitial_text <= less_text)); + CHECK((less <= pinitial_text) == (less_text <= pinitial_text)); + CHECK((pinitial_text <= less) == (pinitial_text <= less_text)); - CHECK((greater <= pinitial_text) == (greater_text <= pinitial_text)); - CHECK((pinitial_text <= greater) == (pinitial_text <= greater_text)); + CHECK((greater <= pinitial_text) == (greater_text <= pinitial_text)); + CHECK((pinitial_text <= greater) == (pinitial_text <= greater_text)); - CHECK((shorter <= pinitial_text) == (shorter_text <= pinitial_text)); - CHECK((pinitial_text <= shorter) == (pinitial_text <= shorter_text)); + CHECK((shorter <= pinitial_text) == (shorter_text <= pinitial_text)); + CHECK((pinitial_text <= shorter) == (pinitial_text <= shorter_text)); - CHECK((initial <= pinitial_text) == (initial_text <= pinitial_text)); - CHECK((pinitial_text <= initial) == (pinitial_text <= initial_text)); + CHECK((initial <= pinitial_text) == (initial_text <= pinitial_text)); + CHECK((pinitial_text <= initial) == (pinitial_text <= initial_text)); } //************************************************************************* @@ -3293,17 +4047,17 @@ namespace CHECK((initial > initial) == (initial_text > initial_text)); // String-Pointer Pointer-String - CHECK((less > pinitial_text) == (less_text > pinitial_text)); - CHECK((pinitial_text > less) == (pinitial_text > less_text)); + CHECK((less > pinitial_text) == (less_text > pinitial_text)); + CHECK((pinitial_text > less) == (pinitial_text > less_text)); - CHECK((greater > pinitial_text) == (greater_text > pinitial_text)); - CHECK((pinitial_text > greater) == (pinitial_text > greater_text)); + CHECK((greater > pinitial_text) == (greater_text > pinitial_text)); + CHECK((pinitial_text > greater) == (pinitial_text > greater_text)); - CHECK((shorter > pinitial_text) == (shorter_text > pinitial_text)); - CHECK((pinitial_text > shorter) == (pinitial_text > shorter_text)); + CHECK((shorter > pinitial_text) == (shorter_text > pinitial_text)); + CHECK((pinitial_text > shorter) == (pinitial_text > shorter_text)); - CHECK((initial > pinitial_text) == (initial_text > pinitial_text)); - CHECK((pinitial_text > initial) == (pinitial_text > initial_text)); + CHECK((initial > pinitial_text) == (initial_text > pinitial_text)); + CHECK((pinitial_text > initial) == (pinitial_text > initial_text)); } //************************************************************************* @@ -3316,8 +4070,8 @@ namespace const Text initial(initial_text.begin(), initial_text.end(), buffer2.data(), buffer2.size()); // String-String - CHECK((less >= initial) == (less_text >= initial_text)); - CHECK((initial >= less) == (initial_text >= less_text)); + CHECK((less >= initial) == (less_text >= initial_text)); + CHECK((initial >= less) == (initial_text >= less_text)); TextBuffer buffer3; const Text greater(greater_text.begin(), greater_text.end(), buffer3.data(), buffer3.size()); @@ -3333,24 +4087,24 @@ namespace CHECK((initial >= initial) == (initial_text >= initial_text)); // String-Pointer Pointer-String - CHECK((less >= pinitial_text) == (less_text >= pinitial_text)); - CHECK((pinitial_text >= less) == (pinitial_text >= less_text)); + CHECK((less >= pinitial_text) == (less_text >= pinitial_text)); + CHECK((pinitial_text >= less) == (pinitial_text >= less_text)); - CHECK((greater >= pinitial_text) == (greater_text >= pinitial_text)); - CHECK((pinitial_text >= greater) == (pinitial_text >= greater_text)); + CHECK((greater >= pinitial_text) == (greater_text >= pinitial_text)); + CHECK((pinitial_text >= greater) == (pinitial_text >= greater_text)); - CHECK((shorter >= pinitial_text) == (shorter_text >= pinitial_text)); - CHECK((pinitial_text >= shorter) == (pinitial_text >= shorter_text)); + CHECK((shorter >= pinitial_text) == (shorter_text >= pinitial_text)); + CHECK((pinitial_text >= shorter) == (pinitial_text >= shorter_text)); - CHECK((initial >= pinitial_text) == (initial_text >= pinitial_text)); - CHECK((pinitial_text >= initial) == (pinitial_text >= initial_text)); + CHECK((initial >= pinitial_text) == (initial_text >= pinitial_text)); + CHECK((pinitial_text >= initial) == (pinitial_text >= initial_text)); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy) { - CompareText compare_text(initial_text.c_str()); - + TextSTD compare_text(initial_text.c_str()); + TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3369,8 +4123,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3393,7 +4147,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_equals_npos) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3401,7 +4155,7 @@ namespace value_t buffer1[SIZE]; value_t buffer2[SIZE]; - size_t length1 = compare_text.copy(buffer1, CompareText::npos, 2); + size_t length1 = compare_text.copy(buffer1, TextSTD::npos, 2); buffer1[length1] = STR('\0'); size_t length2 = text.copy(buffer2, Text::npos, 2); @@ -3413,15 +4167,15 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_count_too_large) { - CompareText compare_text(initial_text.c_str()); + TextSTD compare_text(initial_text.c_str()); TextBuffer buffer{0}; Text text(initial_text.c_str(), buffer.data(), buffer.size()); @@ -3441,8 +4195,8 @@ namespace #endif bool is_equal = std::equal(buffer1, - buffer1 + length1, - buffer2); + buffer1 + length1, + buffer2); CHECK(is_equal); } @@ -3451,12 +4205,12 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_needle(STR("needle")); + TextSTD compare_needle(STR("needle")); TextBuffer buffer{0}; Text needle(STR("needle"), buffer.data(), buffer.size()); - std::wstring compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; Text haystack(the_haystack, buffer2.data(), buffer2.size()); @@ -3473,13 +4227,77 @@ namespace CHECK_EQUAL(position1, position2); position2 = haystack.find(needle, position2 + 1); - CHECK_EQUAL(etl::wstring<50>::npos, position2); + CHECK_EQUAL(Text::npos, position2); - etl::wstring<50> pin(STR("pin")); + Text pin(STR("pin"), buffer.data(), buffer.size()); position2 = haystack.find(pin); CHECK_EQUAL(IText::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_etl_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + ViewETL needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(TextL::npos, position2); + + ViewETL pin_view(STR("pin")); + position2 = haystack.find(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + ViewSTD needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextBufferL buffer2{0}; + Text haystack(the_haystack, buffer2.data(), buffer2.size()); + + size_t position1 = 0UL; + size_t position2 = 0UL; + + position1 = compare_haystack.find(compare_needle, position1); + position2 = haystack.find(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.find(compare_needle, position1 + 1); + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(position1, position2); + + position2 = haystack.find(needle_view, position2 + 1); + CHECK_EQUAL(TextL::npos, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.find(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -3487,7 +4305,7 @@ namespace const value_t* needle = STR("needle"); - std::wstring compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); @@ -3506,7 +4324,7 @@ namespace position2 = haystack.find(needle, position2 + 1); CHECK_EQUAL(IText::npos, position2); - const value_t* pin = STR("pin"); + const value_t *pin = STR("pin"); position2 = haystack.find(pin); CHECK_EQUAL(IText::npos, position2); } @@ -3518,7 +4336,7 @@ namespace const value_t* needle = STR("needle"); - std::wstring compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); @@ -3537,7 +4355,7 @@ namespace position2 = haystack.find(needle, position2 + 1, 3); CHECK_EQUAL(IText::npos, position2); - const value_t* pin = STR("pin"); + const value_t *pin = STR("pin"); position2 = haystack.find(pin, 0, 3); CHECK_EQUAL(IText::npos, position2); } @@ -3547,18 +4365,18 @@ namespace { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_needle(STR("needle")); + TextSTD compare_needle(STR("needle")); TextBufferL buffer{0}; Text needle(STR("needle"), buffer.data(), buffer.size()); - std::wstring compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; Text haystack(the_haystack, buffer2.data(), buffer2.size()); - size_t position1 = std::wstring::npos; - size_t position2 = etl::wstring<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(compare_needle, position1); position2 = haystack.rfind(needle, position2); @@ -3575,19 +4393,76 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_pointer) + TEST_FIXTURE(SetupFixture, test_rfind_etl_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_haystack(the_haystack); + TextSTD compare_needle(STR("needle")); + ViewETL needle_view(STR("needle")); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewETL pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_std_view) + { + const value_t* the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_needle(STR("needle")); + TextSTD needle(STR("needle")); + ViewSTD needle_view(needle); + + TextSTD compare_haystack(the_haystack); + TextL haystack(the_haystack); + + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; + + position1 = compare_haystack.rfind(compare_needle, position1); + position2 = haystack.rfind(needle_view, position2); + CHECK_EQUAL(position1, position2); + + position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); + position2 = haystack.rfind(needle_view, haystack.size() - 10); + CHECK_EQUAL(position1, position2); + + ViewSTD pin_view(STR("pin")); + position2 = haystack.rfind(pin_view); + CHECK_EQUAL(TextL::npos, position2); + } +#endif + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_rfind_pointer) + { + const value_t*the_haystack = STR("A haystack with a needle and another needle"); + + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); const value_t* needle = STR("needle"); - size_t position1 = std::wstring::npos; - size_t position2 = etl::wstring<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(needle, position1); position2 = haystack.rfind(needle, position2); @@ -3606,16 +4481,16 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer_n) { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); + const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); const value_t* needle = STR("needle"); - size_t position1 = std::wstring::npos; + size_t position1 = TextSTD::npos; size_t position2 = Text::npos; @@ -3634,15 +4509,15 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_c_position) { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); + const value_t*the_haystack = STR("A haystack with a needle and another needle"); - std::wstring compare_haystack(the_haystack); + TextSTD compare_haystack(the_haystack); TextBufferL buffer{0}; Text haystack(the_haystack, buffer.data(), buffer.size()); - size_t position1 = std::wstring::npos; - size_t position2 = etl::wstring<50>::npos; + size_t position1 = TextSTD::npos; + size_t position2 = TextL::npos; position1 = compare_haystack.rfind(STR('e'), position1); position2 = haystack.rfind(STR('e'), position2); @@ -3659,7 +4534,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3668,35 +4543,110 @@ namespace int result; // Equal. - compare_result = compare_text.compare(CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); result = text.compare(TextL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); result = text.compare(TextL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); result = text.compare(TextL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); result = text.compare(TextL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); result = text.compare(TextL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_etl_view) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); + result = text.compare(ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); + result = text.compare(ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); + result = text.compare(ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); + result = text.compare(ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); + result = text.compare(ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_std_view) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); + result = text.compare(ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); + result = text.compare(ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); + result = text.compare(ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); + result = text.compare(ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); + result = text.compare(ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3705,35 +4655,109 @@ namespace int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEF"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); result = text.compare(3, 6, TextL(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); result = text.compare(3, 6, TextL(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); result = text.compare(3, 6, TextL(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDE"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); result = text.compare(3, 6, TextL(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("ABCDEFG"))); + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); result = text.compare(3, 6, TextL(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); + result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); + result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3742,35 +4766,109 @@ namespace int result; // Equal. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEEbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEGbb")), 2, 6); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); result = text.compare(3, 6, TextL(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEbb")), 2, 5); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); result = text.compare(3, 6, TextL(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. - compare_result = compare_text.compare(3, 6, CompareText(STR("aaABCDEFGbb")), 2, 7); + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); result = text.compare(3, 6, TextL(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) + { + TextSTD compare_text(STR("xxxABCDEFyyy")); + TextBuffer buffer{0}; + Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); + + int compare_result; + int result; + + // Equal. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Less. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Greater. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); + CHECK(compares_agree(compare_result, result)); + + // Shorter. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); + CHECK(compares_agree(compare_result, result)); + + // Longer. + compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); + CHECK(compares_agree(compare_result, result)); + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3807,7 +4905,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3844,7 +4942,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_c_string_n) { - CompareText compare_text(STR("xxxABCDEFyyy")); + TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); @@ -3881,38 +4979,100 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_first_of(CompareText(STR("ZCXF"))); + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); size_t position2 = text.find_first_of(TextL(STR("ZCXF"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("WXYZ"))); + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); position2 = text.find_first_of(TextL(STR("WXYZ"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 3); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); position2 = text.find_first_of(TextL(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(CompareText(STR("ZCXF")), 100); + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); position2 = text.find_first_of(TextL(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); + position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); + size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); + position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); + position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3943,7 +5103,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -3979,7 +5139,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4020,43 +5180,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_last_of(CompareText(STR("ZCXE"))); + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); size_t position2 = text.find_last_of(TextL(STR("ZCXE"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("WXYZ")), 3); + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); position2 = text.find_last_of(TextL(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 5); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); position2 = text.find_last_of(TextL(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), compare_text.size()); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); position2 = text.find_last_of(TextL(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(CompareText(STR("ZCXE")), 100); + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); position2 = text.find_last_of(TextL(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); + size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); + position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); + position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4097,7 +5329,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4127,16 +5359,18 @@ namespace CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(STR("ZCXE"), 100, 4); position2 = text.find_last_of(STR("ZCXE"), 100, 4); CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" } //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4177,43 +5411,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_string_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); size_t position2 = text.find_first_not_of(TextL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB"))); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); position2 = text.find_first_not_of(TextL(STR("ZAXB"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 3); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); position2 = text.find_first_not_of(TextL(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), compare_text.size()); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); position2 = text.find_first_not_of(TextL(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(CompareText(STR("ZAXB")), 100); + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); position2 = text.find_first_not_of(TextL(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEF")); + TextBuffer buffer{0}; + Text text(STR("ABCDEF"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); + position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4249,7 +5555,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4290,7 +5596,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4331,43 +5637,115 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_string_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - size_t position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD"))); + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); size_t position2 = text.find_last_not_of(TextL(STR("ZEXD"))); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 3); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 5); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), compare_text.size()); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); position2 = text.find_last_not_of(TextL(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(CompareText(STR("ZEXD")), 100); + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); position2 = text.find_last_not_of(TextL(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } + +#if ETL_USING_STL && ETL_USING_CPP17 + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) + { + TextSTD compare_text(STR("ABCDEFABCDE")); + TextBuffer buffer{0}; + Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); + + size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); + + CHECK_EQUAL(position1, position2); + + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); + + CHECK_EQUAL(position1, position2); + +#include "etl/private/diagnostic_array_bounds_push.h" + position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); + position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); + + CHECK_EQUAL(position1, position2); +#include "etl/private/diagnostic_pop.h" + } +#endif + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4403,7 +5781,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position_n) { - CompareText compare_text(STR("ABCDEFABCDE")); + TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); @@ -4437,7 +5815,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_character_position) { - CompareText compare_text(STR("ABCDEF")); + TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); @@ -4712,6 +6090,23 @@ namespace CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_secure_after_clear) + { + TextBuffer buffer{0}; + Text text(buffer.data(), buffer.size()); + text.set_secure(); + text.assign(STR("ABCDEF")); + + Text::pointer pb = text.begin(); + Text::pointer pe = text.end(); + + text.clear(); + + // Check there no non-zero values in the remainder of the string. + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_secure_flag_after_copy) { From a3b40b667a8056c9d13b433f786e576800e8aa44 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 23 Nov 2024 10:47:41 +0000 Subject: [PATCH 06/18] Removed std::string_view interface Added contains member functions --- include/etl/basic_string.h | 343 +------ include/etl/string.h | 48 - include/etl/u16string.h | 48 - include/etl/u32string.h | 48 - include/etl/u8string.h | 12 - include/etl/wstring.h | 48 - test/test_string_char.cpp | 914 +++--------------- test/test_string_char_external_buffer.cpp | 933 +++--------------- test/test_string_u16.cpp | 910 +++--------------- test/test_string_u16_external_buffer.cpp | 933 +++--------------- test/test_string_u32.cpp | 910 +++--------------- test/test_string_u32_external_buffer.cpp | 933 +++--------------- test/test_string_u8.cpp | 910 +++--------------- test/test_string_u8_external_buffer.cpp | 933 +++--------------- test/test_string_wchar_t.cpp | 911 +++--------------- test/test_string_wchar_t_external_buffer.cpp | 938 +++---------------- 16 files changed, 1270 insertions(+), 8502 deletions(-) diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 344e7d3b..d228166f 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -52,10 +52,6 @@ SOFTWARE. #include #include -#if ETL_USING_STL && ETL_USING_CPP17 - #include -#endif - #include "private/minmax_push.h" //***************************************************************************** @@ -711,17 +707,6 @@ namespace etl assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //********************************************************************* - /// Assigns values to the string from a view. - //********************************************************************* - template - void assign(const std::basic_string_view& view) - { - assign(view.begin(), view.end()); - } -#endif - //********************************************************************* /// Assigns values to the string. /// Truncates if the string does not have enough free space. @@ -883,19 +868,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //********************************************************************* - /// Appends to the string. - ///\param view A std::string_view. - //********************************************************************* - template - ibasic_string& append(const std::basic_string_view& view) - { - insert(end(), view.begin(), view.end()); - return *this; - } -#endif - //********************************************************************* /// Inserts a value to the string. ///\param position The position to insert before. @@ -1138,20 +1110,6 @@ namespace etl 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 - iterator insert(const_iterator position, const std::basic_string_view& view) - { - return insert(position, view.begin(), view.end()); - } -#endif - //********************************************************************* /// Inserts a string at the specified position. ///\param position The position to insert before. @@ -1192,23 +1150,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //********************************************************************* - /// Inserts a string at the specified position. - ///\param position The position to insert before. - ///\param view The view to insert. - //********************************************************************* - template - etl::ibasic_string& insert(size_type position, const std::basic_string_view& view) - { - ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); - - insert(begin() + position, view.cbegin(), view.cend()); - - return *this; - } -#endif - //********************************************************************* /// Inserts a string at the specified position from subposition for sublength. ///\param position The position to insert before. @@ -1265,31 +1206,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //********************************************************************* - /// 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 - etl::ibasic_string& insert(size_type position, const std::basic_string_view& 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; - } -#endif - //********************************************************************* /// Inserts a string at the specified position from pointer. ///\param position The position to insert before. @@ -1461,19 +1377,6 @@ namespace etl return find_impl(view.begin(), view.end(), view.size(), pos); } -#if ETL_USING_STL && ETL_USING_CPP17 - //********************************************************************* - /// Find content within the string - ///\param view The content to find - ///\param pos The position to start searching from. - //********************************************************************* - template - size_type find(const std::basic_string_view& view, size_type pos = 0) const - { - return find_impl(view.begin(), view.end(), view.size(), pos); - } -#endif - //********************************************************************* /// Find content within the string ///\param s Pointer to the content to find @@ -1539,19 +1442,6 @@ namespace etl return rfind_impl(view.rbegin(), view.rend(), view.size(), pos); } -#if ETL_USING_STL && ETL_USING_CPP17 - //********************************************************************* - /// Find content within the string - ///\param view The content to find - ///\param pos The position to start searching from. - //********************************************************************* - template - size_type rfind(const std::basic_string_view& view, size_type pos = 0) const - { - return rfind_impl(view.rbegin(), view.rend(), view.size(), pos); - } -#endif - //********************************************************************* /// Find content within the string ///\param str The content to find @@ -1606,6 +1496,39 @@ namespace etl } } + //********************************************************************* + /// Checks that the string is within the string + //********************************************************************* + bool contains(const etl::ibasic_string& str) const + { + return find(str) != npos; + } + + //********************************************************************* + /// Checks that the view is within the string + //********************************************************************* + template + bool contains(const etl::basic_string_view& view) const + { + return find(view) != npos; + } + + //********************************************************************* + /// Checks that text is within the string + //********************************************************************* + bool contains(const_pointer s) const + { + return find(s) != npos; + } + + //********************************************************************* + /// Checks that character is within the string + //********************************************************************* + bool contains(value_type c) const + { + return find(c) != npos; + } + //********************************************************************* /// Replace 'length' characters from 'position' with 'str'. ///\param position The position to start from. @@ -1651,31 +1574,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 - ibasic_string& replace(size_type position, size_type length_, const std::basic_string_view& 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. @@ -1730,30 +1628,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 - ibasic_string& replace(const_iterator first, const_iterator last, const std::basic_string_view& 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'. //********************************************************************* @@ -1808,30 +1682,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 - ibasic_string& replace(size_type position, size_type length_, const std::basic_string_view& 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. //********************************************************************* @@ -1985,20 +1835,6 @@ namespace etl view.data() + view.size()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Compare with std::basic_string_view. - //************************************************************************* - template - int compare(const std::basic_string_view& view) const - { - return compare(p_buffer, - p_buffer + size(), - view.data(), - view.data() + view.size()); - } -#endif - //************************************************************************* /// Compare position / length with string. //************************************************************************* @@ -2027,20 +1863,6 @@ namespace etl view.data() + view.size()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Compare position / length with std::basic_string_view. - //************************************************************************* - template - int compare(size_type position, size_type length_, const std::basic_string_view& view) const - { - return compare(p_buffer + position, - p_buffer + position + length_, - view.data(), - view.data() + view.size()); - } -#endif - //************************************************************************* /// Compare position / length with string / subposition / sublength. //************************************************************************* @@ -2078,27 +1900,6 @@ namespace etl view.data() + subposition + sublength); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Compare position / length with std::basic_string_view. / subposition / sublength. - //************************************************************************* - template - int compare(size_type position, size_type length_, const std::basic_string_view& 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.data() + subposition, - view.data() + subposition + sublength); - } -#endif - //************************************************************************* /// Compare with C string //************************************************************************* @@ -2163,19 +1964,6 @@ namespace etl 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 - size_type find_first_of(const std::basic_string_view& 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 @@ -2253,19 +2041,6 @@ namespace etl 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 - size_type find_last_of(const std::basic_string_view& view, size_type position = npos) 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 @@ -2361,19 +2136,6 @@ namespace etl 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 - size_type find_first_not_of(const std::basic_string_view& 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 @@ -2458,19 +2220,6 @@ namespace etl 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 - size_type find_last_not_of(const std::basic_string_view& view, size_type position = npos) 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 @@ -2574,19 +2323,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Assignment operator. - //************************************************************************* - template - ibasic_string& operator = (const std::basic_string_view& view) - { - assign(view); - - return *this; - } -#endif - //************************************************************************* /// += operator. //************************************************************************* @@ -2608,19 +2344,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// += operator. - //************************************************************************* - template - ibasic_string& operator += (const std::basic_string_view& rhs) - { - append(rhs); - - return *this; - } -#endif - //************************************************************************* /// += operator. //************************************************************************* diff --git a/include/etl/string.h b/include/etl/string.h index 55bfa452..891815ad 100644 --- a/include/etl/string.h +++ b/include/etl/string.h @@ -186,18 +186,6 @@ namespace etl this->assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// From string_view. - ///\param view The string_view. - //************************************************************************* - explicit string(const std::string_view& view) - : istring(reinterpret_cast(&buffer), MAX_SIZE) - { - this->assign(view.begin(), view.end()); - } -#endif - //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -266,18 +254,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Assignment operator. - //************************************************************************* - string& operator = (const std::string_view& view) - { - this->assign(view); - - return *this; - } -#endif - //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* @@ -406,18 +382,6 @@ namespace etl this->assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// From string_view. - ///\param view The string_view. - //************************************************************************* - explicit string_ext(const std::string_view& view, value_type* buffer, size_type buffer_size) - : istring(buffer, buffer_size - 1U) - { - this->assign(view.begin(), view.end()); - } -#endif - //************************************************************************* /// Constructor, from an iterator range. ///\tparam TIterator The iterator type. @@ -488,18 +452,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Assignment operator. - //************************************************************************* - string_ext& operator = (const std::string_view& view) - { - this->assign(view); - - return *this; - } -#endif - //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/u16string.h b/include/etl/u16string.h index b18bc07d..69eb25bc 100644 --- a/include/etl/u16string.h +++ b/include/etl/u16string.h @@ -183,18 +183,6 @@ namespace etl this->assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// From string_view. - ///\param view The string_view. - //************************************************************************* - explicit u16string(const std::u16string_view& view) - : iu16string(reinterpret_cast(&buffer), MAX_SIZE) - { - this->assign(view.begin(), view.end()); - } -#endif - //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -249,18 +237,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Assignment operator. - //************************************************************************* - u16string& operator = (const std::u16string_view& view) - { - this->assign(view); - - return *this; - } -#endif - //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* @@ -409,18 +385,6 @@ namespace etl this->assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// From string_view. - ///\param view The string_view. - //************************************************************************* - explicit u16string_ext(const std::u16string_view& view, value_type* buffer, size_type buffer_size) - : iu16string(buffer, buffer_size - 1U) - { - this->assign(view.begin(), view.end()); - } -#endif - //************************************************************************* /// Assignment operator. //************************************************************************* @@ -467,18 +431,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Assignment operator. - //************************************************************************* - u16string_ext& operator = (const std::u16string_view& view) - { - this->assign(view); - - return *this; - } -#endif - //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/u32string.h b/include/etl/u32string.h index 068e9e3c..029748aa 100644 --- a/include/etl/u32string.h +++ b/include/etl/u32string.h @@ -183,18 +183,6 @@ namespace etl this->assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// From string_view. - ///\param view The string_view. - //************************************************************************* - explicit u32string(const std::u32string_view& view) - : iu32string(reinterpret_cast(&buffer), MAX_SIZE) - { - this->assign(view.begin(), view.end()); - } -#endif - //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -249,18 +237,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Assignment operator. - //************************************************************************* - u32string& operator = (const std::u32string_view& view) - { - this->assign(view); - - return *this; - } -#endif - //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* @@ -409,18 +385,6 @@ namespace etl this->assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// From string_view. - ///\param view The string_view. - //************************************************************************* - explicit u32string_ext(const std::u32string_view& view, value_type* buffer, size_type buffer_size) - : iu32string(buffer, buffer_size - 1U) - { - this->assign(view.begin(), view.end()); - } -#endif - //************************************************************************* /// Assignment operator. //************************************************************************* @@ -467,18 +431,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Assignment operator. - //************************************************************************* - u32string_ext& operator = (const std::u32string_view& view) - { - this->assign(view); - - return *this; - } -#endif - //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/u8string.h b/include/etl/u8string.h index 7cc1964f..009f541e 100644 --- a/include/etl/u8string.h +++ b/include/etl/u8string.h @@ -488,18 +488,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP20 - //************************************************************************* - /// Assignment operator. - //************************************************************************* - u8string_ext& operator = (const std::u8string_view& view) - { - this->assign(view); - - return *this; - } -#endif - //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/include/etl/wstring.h b/include/etl/wstring.h index 93964638..7107c7d8 100644 --- a/include/etl/wstring.h +++ b/include/etl/wstring.h @@ -183,18 +183,6 @@ namespace etl this->assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// From string_view. - ///\param view The string_view. - //************************************************************************* - explicit wstring(const std::wstring_view& view) - : iwstring(reinterpret_cast(&buffer), MAX_SIZE) - { - this->assign(view.begin(), view.end()); - } -#endif - //************************************************************************* /// Returns a sub-string. ///\param position The position of the first character. Default = 0. @@ -249,18 +237,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Assignment operator. - //************************************************************************* - wstring& operator = (const std::wstring_view& view) - { - this->assign(view); - - return *this; - } -#endif - //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* @@ -409,18 +385,6 @@ namespace etl this->assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// From string_view. - ///\param view The string_view. - //************************************************************************* - explicit wstring_ext(const std::wstring_view& view, value_type* buffer, size_type buffer_size) - : iwstring(buffer, buffer_size - 1U) - { - this->assign(view.begin(), view.end()); - } -#endif - //************************************************************************* /// Assignment operator. //************************************************************************* @@ -467,18 +431,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - /// Assignment operator. - //************************************************************************* - wstring_ext& operator = (const std::wstring_view& view) - { - this->assign(view); - - return *this; - } -#endif - //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index cb3de463..4da5716b 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -36,10 +36,6 @@ SOFTWARE. #include "etl/string_view.h" #include "etl/fnv_1.h" -#if ETL_USING_STL && ETL_USING_CPP17 - #include -#endif - #undef STR #define STR(x) x @@ -62,10 +58,7 @@ namespace using value_t = Text::value_type; using TextL = etl::string<52>; using TextS = etl::string<4>; - using ViewETL = etl::string_view; -#if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::string_view; -#endif + using View = etl::string_view; TextSTD initial_text; TextSTD less_text; @@ -299,7 +292,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - ViewETL view(initial_text.data(), initial_text.size()); + View view(initial_text.data(), initial_text.size()); Text text(view); bool is_equal = Equal(initial_text, text); @@ -308,20 +301,6 @@ namespace CHECK(!text.empty()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) - { - ViewSTD view(initial_text.data(), initial_text.size()); - Text text(view); - - bool is_equal = Equal(initial_text, text); - CHECK(is_equal); - CHECK(text.size() == SIZE); - CHECK(!text.empty()); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -599,11 +578,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + TEST_FIXTURE(SetupFixture, test_assignment_from_view) { Text text; - text = ViewETL(STR("Hello World")); + text = View(STR("Hello World")); bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); @@ -612,22 +591,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) - { - Text text; - - text = ViewSTD(STR("Hello World")); - - bool is_equal = Equal(TextSTD(STR("Hello World")), text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1062,11 +1025,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_etl_view) + TEST_FIXTURE(SetupFixture, test_assign_view) { TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - ViewETL view(input); + View view(input); TextSTD compare_text; Text text; @@ -1081,28 +1044,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_std_view) - { - TextSTD compare_input(initial_text.c_str()); - Text input(initial_text.c_str()); - ViewSTD view(input.data(), input.size()); - - TextSTD compare_text; - Text text; - - compare_text.assign(compare_input); - text.assign(view); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1621,13 +1562,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_view) { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1641,29 +1582,6 @@ namespace } } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) - { - for (size_t offset = 0UL; offset <= short_text.size(); ++offset) - { - TextSTD compare_text(short_text.cbegin(), short_text.cend()); - Text text(short_text.cbegin(), short_text.cend()); - ViewSTD view(insert_text.data(), insert_text.size()); - - text.insert(offset, view); - compare_text.insert(offset, insert_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -1788,11 +1706,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_etl_view) + TEST_FIXTURE(SetupFixture, test_append_view) { TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1820,41 +1738,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_std_view) - { - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - ViewSTD append(insert_text.data(), insert_text.size()); - - // Non-overflow. - compare_text.append(insert_text); - text.append(append); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.size()); - - compare_text.append(initial_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.append(append); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -2166,7 +2049,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view) { // Non-overflow short text, npos. TextSTD compare_text(short_text.c_str()); @@ -2174,7 +2057,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace"))); + text.replace(2, Text::npos, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2188,7 +2071,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace"))); + text.replace(2, 2, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2202,7 +2085,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2216,7 +2099,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2230,7 +2113,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace"))); + text.replace(2, 7, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2244,7 +2127,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2258,7 +2141,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2267,110 +2150,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) - { - // Non-overflow short text, npos. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2432,7 +2211,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_first_last_view) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2440,7 +2219,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2454,7 +2233,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2468,7 +2247,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 9, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2482,7 +2261,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2491,68 +2270,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2670,7 +2387,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view_subposition_sublength) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2678,7 +2395,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 4, View(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2692,7 +2409,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2706,7 +2423,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2720,7 +2437,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2734,7 +2451,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 7, View(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2748,7 +2465,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2762,7 +2479,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2776,7 +2493,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2785,124 +2502,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -3915,13 +3514,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_etl_view) + TEST_FIXTURE(SetupFixture, test_find_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); Text needle(STR("needle")); - ViewETL needle_view(needle); + View needle_view(needle); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -3940,44 +3539,11 @@ namespace position2 = haystack.find(needle_view, position2 + 1); CHECK_EQUAL(Text::npos, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.find(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = 0UL; - size_t position2 = 0UL; - - position1 = compare_haystack.find(compare_needle, position1); - position2 = haystack.find(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.find(compare_needle, position1 + 1); - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(position1, position2); - - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(Text::npos, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.find(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -4036,6 +3602,48 @@ namespace CHECK_EQUAL(TextL::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text needle(STR("needle")); + Text pin(STR("pin")); + Text excess(STR("A really gigantic pin or needle that's really really big")); + + CHECK_TRUE(haystack.contains(needle)); + CHECK_FALSE(haystack.contains(pin)); + CHECK_FALSE(haystack.contains(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(View(STR("needle")))); + CHECK_FALSE(haystack.contains(View(STR("pin")))); + CHECK_FALSE(haystack.contains(View(STR("A really gigantic pin or needle that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(STR("needle"))); + CHECK_FALSE(haystack.contains(STR("pin"))); + CHECK_FALSE(haystack.contains(STR("A really gigantic pin or needle that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(STR('l'))); + CHECK_FALSE(haystack.contains(STR('p'))); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { @@ -4064,13 +3672,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + TEST_FIXTURE(SetupFixture, test_rfind_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); Text needle(STR("needle")); - ViewETL needle_view(needle); + View needle_view(needle); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -4086,41 +3694,11 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.rfind(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = TextSTD::npos; - size_t position2 = Text::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle_view, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.rfind(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -4269,7 +3847,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_view) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); @@ -4279,67 +3857,30 @@ namespace // Equal. compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewETL(STR("ABCDEF"))); + result = text.compare(View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewETL(STR("ABCDEE"))); + result = text.compare(View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewETL(STR("ABCDEG"))); + result = text.compare(View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewETL(STR("ABCDE"))); + result = text.compare(View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewETL(STR("ABCDEFG"))); + result = text.compare(View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_std_view) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -4376,7 +3917,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view) { TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); @@ -4386,67 +3927,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + result = text.compare(3, 6, View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + result = text.compare(3, 6, View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + result = text.compare(3, 6, View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + result = text.compare(3, 6, View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + result = text.compare(3, 6, View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - Text text(STR("xxxABCDEFyyy")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -4483,7 +3987,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view_subposition_sublength) { TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); @@ -4493,67 +3997,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, View(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, View(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - Text text(STR("xxxABCDEFyyy")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -4689,65 +4156,34 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_of_view_position) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + size_t position2 = text.find_first_of(View(STR("ZCXF"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + position2 = text.find_first_of(View(STR("WXYZ"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + position2 = text.find_first_of(View(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + position2 = text.find_first_of(View(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -4885,75 +4321,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + size_t position2 = text.find_last_of(View(STR("ZCXE"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + position2 = text.find_last_of(View(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + position2 = text.find_last_of(View(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + position2 = text.find_last_of(View(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + position2 = text.find_last_of(View(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - Text text(STR("ABCDEFABCDE")); - - size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -5104,75 +4504,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_not_of_view_position) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + position2 = text.find_first_not_of(View(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + position2 = text.find_first_not_of(View(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + position2 = text.find_first_not_of(View(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -5320,75 +4684,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_not_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(View(STR("ZEXD"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + position2 = text.find_last_not_of(View(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + position2 = text.find_last_not_of(View(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + position2 = text.find_last_not_of(View(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + position2 = text.find_last_not_of(View(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - Text text(STR("ABCDEFABCDE")); - - size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_char_external_buffer.cpp b/test/test_string_char_external_buffer.cpp index e2704e81..b2998e63 100644 --- a/test/test_string_char_external_buffer.cpp +++ b/test/test_string_char_external_buffer.cpp @@ -64,10 +64,7 @@ namespace using TextBufferL = std::array; using TextBufferS = std::array; - using ViewETL = etl::string_view; -#if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::string_view; -#endif + using View = etl::string_view; TextSTD initial_text; TextSTD less_text; @@ -380,7 +377,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - ViewETL view(initial_text.data(), initial_text.size()); + View view(initial_text.data(), initial_text.size()); TextBuffer buffer{0}; Text text(view, buffer.data(), buffer.size()); @@ -390,21 +387,6 @@ namespace CHECK(!text.empty()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) - { - ViewSTD view(initial_text.data(), initial_text.size()); - TextBuffer buffer{0}; - Text text(view, buffer.data(), buffer.size()); - - bool is_equal = Equal(initial_text, text); - CHECK(is_equal); - CHECK(text.size() == SIZE); - CHECK(!text.empty()); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -731,12 +713,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + TEST_FIXTURE(SetupFixture, test_assignment_from_view) { TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); - text = ViewETL(STR("Hello World")); + text = View(STR("Hello World")); bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); @@ -745,23 +727,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) - { - TextBuffer buffer{0}; - Text text(buffer.data(), buffer.size()); - - text = ViewSTD(STR("Hello World")); - - bool is_equal = Equal(TextSTD(STR("Hello World")), text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1222,12 +1187,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_etl_view) + TEST_FIXTURE(SetupFixture, test_assign_view) { TextSTD compare_input(initial_text.c_str()); TextBuffer buffer{0}; Text input(initial_text.c_str(), buffer.data(), buffer.size()); - ViewETL view(input); + View view(input); TextSTD compare_text; TextBuffer buffer2{0}; @@ -1243,30 +1208,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_std_view) - { - TextSTD compare_input(initial_text.c_str()); - TextBuffer buffer{0}; - Text input(initial_text.c_str(), buffer.data(), buffer.size()); - ViewSTD view(input.data(), input.size()); - - TextSTD compare_text; - TextBuffer buffer2{0}; - Text text(buffer2.data(), buffer2.size()); - - compare_text.assign(compare_input); - text.assign(view); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1816,7 +1757,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_view) { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { @@ -1824,7 +1765,7 @@ namespace TextBuffer buffer; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1838,31 +1779,6 @@ namespace } } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) - { - for (size_t offset = 0UL; offset <= short_text.size(); ++offset) - { - TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; - buffer.fill(0); - Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); - - text.insert(offset, view); - compare_text.insert(offset, insert_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -2004,12 +1920,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_etl_view) + TEST_FIXTURE(SetupFixture, test_append_view) { TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -2037,42 +1953,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_std_view) - { - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - ViewSTD append(insert_text.data(), insert_text.size()); - - // Non-overflow. - compare_text.append(insert_text); - text.append(append); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.size()); - - compare_text.append(initial_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.append(append); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -2406,7 +2286,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view) { // Non-overflow short text, npos. TextSTD compare_text(short_text.c_str()); @@ -2415,7 +2295,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace"))); + text.replace(2, Text::npos, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2429,7 +2309,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace"))); + text.replace(2, 2, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2443,7 +2323,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2457,7 +2337,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2471,7 +2351,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace"))); + text.replace(2, 7, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2485,7 +2365,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2499,7 +2379,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2508,111 +2388,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) - { - // Non-overflow short text, npos. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2676,7 +2451,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_first_last_view) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2685,7 +2460,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2699,7 +2474,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2713,7 +2488,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 9, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2727,7 +2502,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2736,69 +2511,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2918,7 +2630,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view_subposition_sublength) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2927,7 +2639,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 4, View(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2941,7 +2653,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2955,7 +2667,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2969,7 +2681,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2983,7 +2695,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 7, View(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2997,7 +2709,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3011,7 +2723,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3025,7 +2737,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3034,125 +2746,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -4215,12 +3808,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_etl_view) + TEST_FIXTURE(SetupFixture, test_find_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); - ViewETL needle_view(STR("needle")); + View needle_view(STR("needle")); TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; @@ -4240,44 +3833,11 @@ namespace position2 = haystack.find(needle_view, position2 + 1); CHECK_EQUAL(TextL::npos, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.find(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - ViewSTD needle_view(STR("needle")); - - TextSTD compare_haystack(the_haystack); - TextBufferL buffer2{0}; - Text haystack(the_haystack, buffer2.data(), buffer2.size()); - - size_t position1 = 0UL; - size_t position2 = 0UL; - - position1 = compare_haystack.find(compare_needle, position1); - position2 = haystack.find(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.find(compare_needle, position1 + 1); - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(position1, position2); - - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(TextL::npos, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.find(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -4340,6 +3900,53 @@ namespace CHECK_EQUAL(IText::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text needle(STR("needle"), buffer2.data(), buffer2.size()); + Text pin(STR("pin"), buffer3.data(), buffer3.size()); + Text excess(STR("A really gigantic pin or needle that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.contains(needle)); + CHECK_FALSE(haystack.contains(pin)); + CHECK_FALSE(haystack.contains(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(View(STR("needle")))); + CHECK_FALSE(haystack.contains(View(STR("pin")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(STR("needle"))); + CHECK_FALSE(haystack.contains(STR("pin"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(STR('l'))); + CHECK_FALSE(haystack.contains(STR('p'))); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { @@ -4373,12 +3980,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + TEST_FIXTURE(SetupFixture, test_rfind_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); - ViewETL needle_view(STR("needle")); + View needle_view(STR("needle")); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -4394,41 +4001,11 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.rfind(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = TextSTD::npos; - size_t position2 = TextL::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle_view, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.rfind(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -4549,7 +4126,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_view) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; @@ -4560,69 +4137,30 @@ namespace // Equal. compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewETL(STR("ABCDEF"))); + result = text.compare(View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewETL(STR("ABCDEE"))); + result = text.compare(View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewETL(STR("ABCDEG"))); + result = text.compare(View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewETL(STR("ABCDE"))); + result = text.compare(View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewETL(STR("ABCDEFG"))); + result = text.compare(View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_std_view) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -4661,7 +4199,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view) { TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; @@ -4672,68 +4210,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + result = text.compare(3, 6, View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + result = text.compare(3, 6, View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + result = text.compare(3, 6, View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + result = text.compare(3, 6, View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + result = text.compare(3, 6, View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - TextBuffer buffer{0}; - Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -4772,7 +4272,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view_subposition_sublength) { TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; @@ -4783,68 +4283,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, View(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, View(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - TextBuffer buffer{0}; - Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -4988,67 +4450,35 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_of_view_position) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + size_t position2 = text.find_first_of(View(STR("ZCXF"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + position2 = text.find_first_of(View(STR("WXYZ"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + position2 = text.find_first_of(View(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + position2 = text.find_first_of(View(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -5194,77 +4624,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + size_t position2 = text.find_last_of(View(STR("ZCXE"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + position2 = text.find_last_of(View(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + position2 = text.find_last_of(View(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + position2 = text.find_last_of(View(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + position2 = text.find_last_of(View(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - TextBuffer buffer{0}; - Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -5425,77 +4818,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_not_of_view_position) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + position2 = text.find_first_not_of(View(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + position2 = text.find_first_not_of(View(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + position2 = text.find_first_not_of(View(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -5651,77 +5007,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_not_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(View(STR("ZEXD"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + position2 = text.find_last_not_of(View(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + position2 = text.find_last_not_of(View(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + position2 = text.find_last_not_of(View(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + position2 = text.find_last_not_of(View(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - TextBuffer buffer{0}; - Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index 98557a8e..a09f9a59 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -81,10 +81,7 @@ namespace TextSTD insert_text; TextSTD longer_text; TextSTD short_text; - using ViewETL = etl::u16string_view; -#if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::u16string_view; -#endif + using View = etl::u16string_view; const value_t* pinitial_text = STR("Hello World"); @@ -310,7 +307,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - ViewETL view(initial_text.data(), initial_text.size()); + View view(initial_text.data(), initial_text.size()); Text text(view); bool is_equal = Equal(initial_text, text); @@ -319,20 +316,6 @@ namespace CHECK(!text.empty()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) - { - ViewSTD view(initial_text.data(), initial_text.size()); - Text text(view); - - bool is_equal = Equal(initial_text, text); - CHECK(is_equal); - CHECK(text.size() == SIZE); - CHECK(!text.empty()); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -610,11 +593,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + TEST_FIXTURE(SetupFixture, test_assignment_from_view) { Text text; - text = ViewETL(STR("Hello World")); + text = View(STR("Hello World")); bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); @@ -623,22 +606,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) - { - Text text; - - text = ViewSTD(STR("Hello World")); - - bool is_equal = Equal(TextSTD(STR("Hello World")), text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1072,11 +1039,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_etl_view) + TEST_FIXTURE(SetupFixture, test_assign_view) { TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - ViewETL view(input); + View view(input); TextSTD compare_text; Text text; @@ -1091,28 +1058,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_std_view) - { - TextSTD compare_input(initial_text.c_str()); - Text input(initial_text.c_str()); - ViewSTD view(input.data(), input.size()); - - TextSTD compare_text; - Text text; - - compare_text.assign(compare_input); - text.assign(view); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1631,13 +1576,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_view) { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1651,29 +1596,6 @@ namespace } } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) - { - for (size_t offset = 0UL; offset <= short_text.size(); ++offset) - { - TextSTD compare_text(short_text.cbegin(), short_text.cend()); - Text text(short_text.cbegin(), short_text.cend()); - ViewSTD view(insert_text.data(), insert_text.size()); - - text.insert(offset, view); - compare_text.insert(offset, insert_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -1798,11 +1720,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_etl_view) + TEST_FIXTURE(SetupFixture, test_append_view) { TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1830,41 +1752,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_std_view) - { - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - ViewSTD append(insert_text.data(), insert_text.size()); - - // Non-overflow. - compare_text.append(insert_text); - text.append(append); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.size()); - - compare_text.append(initial_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.append(append); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -2176,7 +2063,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view) { // Non-overflow short text, npos. TextSTD compare_text(short_text.c_str()); @@ -2184,7 +2071,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace"))); + text.replace(2, Text::npos, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2198,7 +2085,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace"))); + text.replace(2, 2, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2212,7 +2099,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2226,7 +2113,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2240,7 +2127,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace"))); + text.replace(2, 7, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2254,7 +2141,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2268,7 +2155,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2277,110 +2164,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) - { - // Non-overflow short text, npos. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2442,7 +2225,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_first_last_view) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2450,7 +2233,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2464,7 +2247,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2478,7 +2261,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 9, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2492,7 +2275,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2501,68 +2284,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2680,7 +2401,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view_subposition_sublength) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2688,7 +2409,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 4, View(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2702,7 +2423,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2716,7 +2437,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2730,7 +2451,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2744,7 +2465,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 7, View(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2758,7 +2479,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2772,7 +2493,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2786,7 +2507,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2795,124 +2516,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -3925,13 +3528,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_etl_view) + TEST_FIXTURE(SetupFixture, test_find_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); Text needle(STR("needle")); - ViewETL needle_view(needle); + View needle_view(needle); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -3950,44 +3553,11 @@ namespace position2 = haystack.find(needle_view, position2 + 1); CHECK_EQUAL(Text::npos, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.find(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = 0UL; - size_t position2 = 0UL; - - position1 = compare_haystack.find(compare_needle, position1); - position2 = haystack.find(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.find(compare_needle, position1 + 1); - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(position1, position2); - - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(Text::npos, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.find(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -4046,6 +3616,48 @@ namespace CHECK_EQUAL(TextL::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text needle(STR("needle")); + Text pin(STR("pin")); + Text excess(STR("A really gigantic pin or needle that's really really big")); + + CHECK_TRUE(haystack.contains(needle)); + CHECK_FALSE(haystack.contains(pin)); + CHECK_FALSE(haystack.contains(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(View(STR("needle")))); + CHECK_FALSE(haystack.contains(View(STR("pin")))); + CHECK_FALSE(haystack.contains(View(STR("A really gigantic pin or needle that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(STR("needle"))); + CHECK_FALSE(haystack.contains(STR("pin"))); + CHECK_FALSE(haystack.contains(STR("A really gigantic pin or needle that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(STR('l'))); + CHECK_FALSE(haystack.contains(STR('p'))); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { @@ -4074,13 +3686,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + TEST_FIXTURE(SetupFixture, test_rfind_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); Text needle(STR("needle")); - ViewETL needle_view(needle); + View needle_view(needle); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -4096,41 +3708,11 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.rfind(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = TextSTD::npos; - size_t position2 = Text::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle_view, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.rfind(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -4279,7 +3861,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_view) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); @@ -4289,67 +3871,30 @@ namespace // Equal. compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewETL(STR("ABCDEF"))); + result = text.compare(View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewETL(STR("ABCDEE"))); + result = text.compare(View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewETL(STR("ABCDEG"))); + result = text.compare(View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewETL(STR("ABCDE"))); + result = text.compare(View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewETL(STR("ABCDEFG"))); + result = text.compare(View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_std_view) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -4386,7 +3931,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view) { TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); @@ -4396,67 +3941,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + result = text.compare(3, 6, View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + result = text.compare(3, 6, View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + result = text.compare(3, 6, View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + result = text.compare(3, 6, View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + result = text.compare(3, 6, View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - Text text(STR("xxxABCDEFyyy")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -4493,7 +4001,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view_subposition_sublength) { TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); @@ -4503,67 +4011,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, View(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, View(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - Text text(STR("xxxABCDEFyyy")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -4699,65 +4170,34 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_of_view_position) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + size_t position2 = text.find_first_of(View(STR("ZCXF"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + position2 = text.find_first_of(View(STR("WXYZ"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + position2 = text.find_first_of(View(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + position2 = text.find_first_of(View(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -4895,75 +4335,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + size_t position2 = text.find_last_of(View(STR("ZCXE"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + position2 = text.find_last_of(View(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + position2 = text.find_last_of(View(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + position2 = text.find_last_of(View(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + position2 = text.find_last_of(View(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - Text text(STR("ABCDEFABCDE")); - - size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -5114,75 +4518,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_not_of_view_position) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + position2 = text.find_first_not_of(View(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + position2 = text.find_first_not_of(View(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + position2 = text.find_first_not_of(View(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -5330,75 +4698,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_not_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(View(STR("ZEXD"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + position2 = text.find_last_not_of(View(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + position2 = text.find_last_not_of(View(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + position2 = text.find_last_not_of(View(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + position2 = text.find_last_not_of(View(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - Text text(STR("ABCDEFABCDE")); - - size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_u16_external_buffer.cpp b/test/test_string_u16_external_buffer.cpp index 867a799e..96fd23d5 100644 --- a/test/test_string_u16_external_buffer.cpp +++ b/test/test_string_u16_external_buffer.cpp @@ -78,10 +78,7 @@ namespace using TextBufferL = std::array; using TextBufferS = std::array; - using ViewETL = etl::u16string_view; -#if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::u16string_view; -#endif + using View = etl::u16string_view; TextSTD initial_text; TextSTD less_text; @@ -394,7 +391,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - ViewETL view(initial_text.data(), initial_text.size()); + View view(initial_text.data(), initial_text.size()); TextBuffer buffer{0}; Text text(view, buffer.data(), buffer.size()); @@ -404,21 +401,6 @@ namespace CHECK(!text.empty()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) - { - ViewSTD view(initial_text.data(), initial_text.size()); - TextBuffer buffer{0}; - Text text(view, buffer.data(), buffer.size()); - - bool is_equal = Equal(initial_text, text); - CHECK(is_equal); - CHECK(text.size() == SIZE); - CHECK(!text.empty()); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -745,12 +727,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + TEST_FIXTURE(SetupFixture, test_assignment_from_view) { TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); - text = ViewETL(STR("Hello World")); + text = View(STR("Hello World")); bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); @@ -759,23 +741,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) - { - TextBuffer buffer{0}; - Text text(buffer.data(), buffer.size()); - - text = ViewSTD(STR("Hello World")); - - bool is_equal = Equal(TextSTD(STR("Hello World")), text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1236,12 +1201,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_etl_view) + TEST_FIXTURE(SetupFixture, test_assign_view) { TextSTD compare_input(initial_text.c_str()); TextBuffer buffer{0}; Text input(initial_text.c_str(), buffer.data(), buffer.size()); - ViewETL view(input); + View view(input); TextSTD compare_text; TextBuffer buffer2{0}; @@ -1257,30 +1222,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_std_view) - { - TextSTD compare_input(initial_text.c_str()); - TextBuffer buffer{0}; - Text input(initial_text.c_str(), buffer.data(), buffer.size()); - ViewSTD view(input.data(), input.size()); - - TextSTD compare_text; - TextBuffer buffer2{0}; - Text text(buffer2.data(), buffer2.size()); - - compare_text.assign(compare_input); - text.assign(view); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1830,7 +1771,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_view) { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { @@ -1838,7 +1779,7 @@ namespace TextBuffer buffer; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1852,31 +1793,6 @@ namespace } } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) - { - for (size_t offset = 0UL; offset <= short_text.size(); ++offset) - { - TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; - buffer.fill(0); - Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); - - text.insert(offset, view); - compare_text.insert(offset, insert_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -2018,12 +1934,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_etl_view) + TEST_FIXTURE(SetupFixture, test_append_view) { TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -2051,42 +1967,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_std_view) - { - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - ViewSTD append(insert_text.data(), insert_text.size()); - - // Non-overflow. - compare_text.append(insert_text); - text.append(append); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.size()); - - compare_text.append(initial_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.append(append); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -2420,7 +2300,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view) { // Non-overflow short text, npos. TextSTD compare_text(short_text.c_str()); @@ -2429,7 +2309,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace"))); + text.replace(2, Text::npos, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2443,7 +2323,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace"))); + text.replace(2, 2, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2457,7 +2337,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2471,7 +2351,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2485,7 +2365,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace"))); + text.replace(2, 7, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2499,7 +2379,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2513,7 +2393,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2522,111 +2402,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) - { - // Non-overflow short text, npos. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2690,7 +2465,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_first_last_view) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2699,7 +2474,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2713,7 +2488,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2727,7 +2502,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 9, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2741,7 +2516,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2750,69 +2525,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2932,7 +2644,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view_subposition_sublength) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2941,7 +2653,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 4, View(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2955,7 +2667,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2969,7 +2681,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2983,7 +2695,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2997,7 +2709,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 7, View(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3011,7 +2723,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3025,7 +2737,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3039,7 +2751,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3048,125 +2760,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -4229,12 +3822,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_etl_view) + TEST_FIXTURE(SetupFixture, test_find_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); - ViewETL needle_view(STR("needle")); + View needle_view(STR("needle")); TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; @@ -4254,44 +3847,11 @@ namespace position2 = haystack.find(needle_view, position2 + 1); CHECK_EQUAL(TextL::npos, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.find(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - ViewSTD needle_view(STR("needle")); - - TextSTD compare_haystack(the_haystack); - TextBufferL buffer2{0}; - Text haystack(the_haystack, buffer2.data(), buffer2.size()); - - size_t position1 = 0UL; - size_t position2 = 0UL; - - position1 = compare_haystack.find(compare_needle, position1); - position2 = haystack.find(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.find(compare_needle, position1 + 1); - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(position1, position2); - - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(TextL::npos, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.find(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -4354,6 +3914,53 @@ namespace CHECK_EQUAL(IText::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text needle(STR("needle"), buffer2.data(), buffer2.size()); + Text pin(STR("pin"), buffer3.data(), buffer3.size()); + Text excess(STR("A really gigantic pin or needle that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.contains(needle)); + CHECK_FALSE(haystack.contains(pin)); + CHECK_FALSE(haystack.contains(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(View(STR("needle")))); + CHECK_FALSE(haystack.contains(View(STR("pin")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(STR("needle"))); + CHECK_FALSE(haystack.contains(STR("pin"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(STR('l'))); + CHECK_FALSE(haystack.contains(STR('p'))); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { @@ -4387,12 +3994,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + TEST_FIXTURE(SetupFixture, test_rfind_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); - ViewETL needle_view(STR("needle")); + View needle_view(STR("needle")); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -4408,41 +4015,11 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.rfind(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = TextSTD::npos; - size_t position2 = TextL::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle_view, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.rfind(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -4563,7 +4140,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_view) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; @@ -4574,69 +4151,30 @@ namespace // Equal. compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewETL(STR("ABCDEF"))); + result = text.compare(View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewETL(STR("ABCDEE"))); + result = text.compare(View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewETL(STR("ABCDEG"))); + result = text.compare(View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewETL(STR("ABCDE"))); + result = text.compare(View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewETL(STR("ABCDEFG"))); + result = text.compare(View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_std_view) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -4675,7 +4213,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view) { TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; @@ -4686,68 +4224,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + result = text.compare(3, 6, View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + result = text.compare(3, 6, View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + result = text.compare(3, 6, View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + result = text.compare(3, 6, View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + result = text.compare(3, 6, View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - TextBuffer buffer{0}; - Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -4786,7 +4286,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view_subposition_sublength) { TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; @@ -4797,68 +4297,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, View(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, View(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - TextBuffer buffer{0}; - Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -5002,67 +4464,35 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_of_view_position) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + size_t position2 = text.find_first_of(View(STR("ZCXF"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + position2 = text.find_first_of(View(STR("WXYZ"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + position2 = text.find_first_of(View(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + position2 = text.find_first_of(View(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -5208,77 +4638,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + size_t position2 = text.find_last_of(View(STR("ZCXE"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + position2 = text.find_last_of(View(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + position2 = text.find_last_of(View(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + position2 = text.find_last_of(View(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + position2 = text.find_last_of(View(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - TextBuffer buffer{0}; - Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -5439,77 +4832,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_not_of_view_position) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + position2 = text.find_first_not_of(View(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + position2 = text.find_first_not_of(View(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + position2 = text.find_first_not_of(View(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -5665,77 +5021,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_not_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(View(STR("ZEXD"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + position2 = text.find_last_not_of(View(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + position2 = text.find_last_not_of(View(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + position2 = text.find_last_not_of(View(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + position2 = text.find_last_not_of(View(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - TextBuffer buffer{0}; - Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index 2d9ef322..2b607b33 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -81,10 +81,7 @@ namespace TextSTD insert_text; TextSTD longer_text; TextSTD short_text; - using ViewETL = etl::u32string_view; -#if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::u32string_view; -#endif + using View = etl::u32string_view; const value_t* pinitial_text = STR("Hello World"); @@ -310,7 +307,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - ViewETL view(initial_text.data(), initial_text.size()); + View view(initial_text.data(), initial_text.size()); Text text(view); bool is_equal = Equal(initial_text, text); @@ -319,20 +316,6 @@ namespace CHECK(!text.empty()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) - { - ViewSTD view(initial_text.data(), initial_text.size()); - Text text(view); - - bool is_equal = Equal(initial_text, text); - CHECK(is_equal); - CHECK(text.size() == SIZE); - CHECK(!text.empty()); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -610,11 +593,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + TEST_FIXTURE(SetupFixture, test_assignment_from_view) { Text text; - text = ViewETL(STR("Hello World")); + text = View(STR("Hello World")); bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); @@ -623,22 +606,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) - { - Text text; - - text = ViewSTD(STR("Hello World")); - - bool is_equal = Equal(TextSTD(STR("Hello World")), text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1072,11 +1039,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_etl_view) + TEST_FIXTURE(SetupFixture, test_assign_view) { TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - ViewETL view(input); + View view(input); TextSTD compare_text; Text text; @@ -1091,28 +1058,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_std_view) - { - TextSTD compare_input(initial_text.c_str()); - Text input(initial_text.c_str()); - ViewSTD view(input.data(), input.size()); - - TextSTD compare_text; - Text text; - - compare_text.assign(compare_input); - text.assign(view); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1631,13 +1576,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_view) { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1651,29 +1596,6 @@ namespace } } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) - { - for (size_t offset = 0UL; offset <= short_text.size(); ++offset) - { - TextSTD compare_text(short_text.cbegin(), short_text.cend()); - Text text(short_text.cbegin(), short_text.cend()); - ViewSTD view(insert_text.data(), insert_text.size()); - - text.insert(offset, view); - compare_text.insert(offset, insert_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -1798,11 +1720,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_etl_view) + TEST_FIXTURE(SetupFixture, test_append_view) { TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1830,41 +1752,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_std_view) - { - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - ViewSTD append(insert_text.data(), insert_text.size()); - - // Non-overflow. - compare_text.append(insert_text); - text.append(append); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.size()); - - compare_text.append(initial_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.append(append); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -2176,7 +2063,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view) { // Non-overflow short text, npos. TextSTD compare_text(short_text.c_str()); @@ -2184,7 +2071,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace"))); + text.replace(2, Text::npos, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2198,7 +2085,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace"))); + text.replace(2, 2, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2212,7 +2099,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2226,7 +2113,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2240,7 +2127,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace"))); + text.replace(2, 7, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2254,7 +2141,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2268,7 +2155,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2277,110 +2164,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) - { - // Non-overflow short text, npos. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2442,7 +2225,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_first_last_view) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2450,7 +2233,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2464,7 +2247,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2478,7 +2261,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 9, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2492,7 +2275,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2501,68 +2284,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2680,7 +2401,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view_subposition_sublength) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2688,7 +2409,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 4, View(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2702,7 +2423,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2716,7 +2437,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2730,7 +2451,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2744,7 +2465,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 7, View(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2758,7 +2479,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2772,7 +2493,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2786,7 +2507,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2795,124 +2516,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -3925,13 +3528,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_etl_view) + TEST_FIXTURE(SetupFixture, test_find_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); Text needle(STR("needle")); - ViewETL needle_view(needle); + View needle_view(needle); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -3950,44 +3553,11 @@ namespace position2 = haystack.find(needle_view, position2 + 1); CHECK_EQUAL(Text::npos, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.find(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = 0UL; - size_t position2 = 0UL; - - position1 = compare_haystack.find(compare_needle, position1); - position2 = haystack.find(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.find(compare_needle, position1 + 1); - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(position1, position2); - - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(Text::npos, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.find(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -4046,6 +3616,48 @@ namespace CHECK_EQUAL(TextL::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text needle(STR("needle")); + Text pin(STR("pin")); + Text excess(STR("A really gigantic pin or needle that's really really big")); + + CHECK_TRUE(haystack.contains(needle)); + CHECK_FALSE(haystack.contains(pin)); + CHECK_FALSE(haystack.contains(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(View(STR("needle")))); + CHECK_FALSE(haystack.contains(View(STR("pin")))); + CHECK_FALSE(haystack.contains(View(STR("A really gigantic pin or needle that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(STR("needle"))); + CHECK_FALSE(haystack.contains(STR("pin"))); + CHECK_FALSE(haystack.contains(STR("A really gigantic pin or needle that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(STR('l'))); + CHECK_FALSE(haystack.contains(STR('p'))); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { @@ -4074,13 +3686,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + TEST_FIXTURE(SetupFixture, test_rfind_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); Text needle(STR("needle")); - ViewETL needle_view(needle); + View needle_view(needle); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -4096,41 +3708,11 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.rfind(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = std::u32string::npos; - size_t position2 = Text::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle_view, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.rfind(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -4279,7 +3861,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_view) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); @@ -4289,67 +3871,30 @@ namespace // Equal. compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewETL(STR("ABCDEF"))); + result = text.compare(View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewETL(STR("ABCDEE"))); + result = text.compare(View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewETL(STR("ABCDEG"))); + result = text.compare(View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewETL(STR("ABCDE"))); + result = text.compare(View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewETL(STR("ABCDEFG"))); + result = text.compare(View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_std_view) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -4386,7 +3931,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view) { TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); @@ -4396,67 +3941,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + result = text.compare(3, 6, View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + result = text.compare(3, 6, View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + result = text.compare(3, 6, View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + result = text.compare(3, 6, View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + result = text.compare(3, 6, View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - Text text(STR("xxxABCDEFyyy")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -4493,7 +4001,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view_subposition_sublength) { TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); @@ -4503,67 +4011,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, View(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, View(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - Text text(STR("xxxABCDEFyyy")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -4699,65 +4170,34 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_of_view_position) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + size_t position2 = text.find_first_of(View(STR("ZCXF"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + position2 = text.find_first_of(View(STR("WXYZ"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + position2 = text.find_first_of(View(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + position2 = text.find_first_of(View(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -4895,75 +4335,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + size_t position2 = text.find_last_of(View(STR("ZCXE"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + position2 = text.find_last_of(View(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + position2 = text.find_last_of(View(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + position2 = text.find_last_of(View(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + position2 = text.find_last_of(View(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - Text text(STR("ABCDEFABCDE")); - - size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -5114,75 +4518,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_not_of_view_position) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + position2 = text.find_first_not_of(View(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + position2 = text.find_first_not_of(View(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + position2 = text.find_first_not_of(View(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -5330,75 +4698,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_not_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(View(STR("ZEXD"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + position2 = text.find_last_not_of(View(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + position2 = text.find_last_not_of(View(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + position2 = text.find_last_not_of(View(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + position2 = text.find_last_not_of(View(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - Text text(STR("ABCDEFABCDE")); - - size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_u32_external_buffer.cpp b/test/test_string_u32_external_buffer.cpp index 2461206b..bdbaf7b2 100644 --- a/test/test_string_u32_external_buffer.cpp +++ b/test/test_string_u32_external_buffer.cpp @@ -78,10 +78,7 @@ namespace using TextBufferL = std::array; using TextBufferS = std::array; - using ViewETL = etl::u32string_view; -#if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::u32string_view; -#endif + using View = etl::u32string_view; TextSTD initial_text; TextSTD less_text; @@ -394,7 +391,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - ViewETL view(initial_text.data(), initial_text.size()); + View view(initial_text.data(), initial_text.size()); TextBuffer buffer{0}; Text text(view, buffer.data(), buffer.size()); @@ -404,21 +401,6 @@ namespace CHECK(!text.empty()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) - { - ViewSTD view(initial_text.data(), initial_text.size()); - TextBuffer buffer{0}; - Text text(view, buffer.data(), buffer.size()); - - bool is_equal = Equal(initial_text, text); - CHECK(is_equal); - CHECK(text.size() == SIZE); - CHECK(!text.empty()); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -745,12 +727,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + TEST_FIXTURE(SetupFixture, test_assignment_from_view) { TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); - text = ViewETL(STR("Hello World")); + text = View(STR("Hello World")); bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); @@ -759,23 +741,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) - { - TextBuffer buffer{0}; - Text text(buffer.data(), buffer.size()); - - text = ViewSTD(STR("Hello World")); - - bool is_equal = Equal(TextSTD(STR("Hello World")), text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1236,12 +1201,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_etl_view) + TEST_FIXTURE(SetupFixture, test_assign_view) { TextSTD compare_input(initial_text.c_str()); TextBuffer buffer{0}; Text input(initial_text.c_str(), buffer.data(), buffer.size()); - ViewETL view(input); + View view(input); TextSTD compare_text; TextBuffer buffer2{0}; @@ -1257,30 +1222,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_std_view) - { - TextSTD compare_input(initial_text.c_str()); - TextBuffer buffer{0}; - Text input(initial_text.c_str(), buffer.data(), buffer.size()); - ViewSTD view(input.data(), input.size()); - - TextSTD compare_text; - TextBuffer buffer2{0}; - Text text(buffer2.data(), buffer2.size()); - - compare_text.assign(compare_input); - text.assign(view); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1830,7 +1771,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_view) { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { @@ -1838,7 +1779,7 @@ namespace TextBuffer buffer; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1852,31 +1793,6 @@ namespace } } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) - { - for (size_t offset = 0UL; offset <= short_text.size(); ++offset) - { - TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; - buffer.fill(0); - Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); - - text.insert(offset, view); - compare_text.insert(offset, insert_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -2018,12 +1934,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_etl_view) + TEST_FIXTURE(SetupFixture, test_append_view) { TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -2051,42 +1967,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_std_view) - { - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - ViewSTD append(insert_text.data(), insert_text.size()); - - // Non-overflow. - compare_text.append(insert_text); - text.append(append); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.size()); - - compare_text.append(initial_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.append(append); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -2420,7 +2300,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view) { // Non-overflow short text, npos. TextSTD compare_text(short_text.c_str()); @@ -2429,7 +2309,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace"))); + text.replace(2, Text::npos, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2443,7 +2323,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace"))); + text.replace(2, 2, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2457,7 +2337,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2471,7 +2351,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2485,7 +2365,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace"))); + text.replace(2, 7, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2499,7 +2379,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2513,7 +2393,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2522,111 +2402,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) - { - // Non-overflow short text, npos. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2690,7 +2465,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_first_last_view) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2699,7 +2474,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2713,7 +2488,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2727,7 +2502,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 9, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2741,7 +2516,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2750,69 +2525,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2932,7 +2644,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view_subposition_sublength) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2941,7 +2653,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 4, View(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2955,7 +2667,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2969,7 +2681,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2983,7 +2695,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2997,7 +2709,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 7, View(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3011,7 +2723,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3025,7 +2737,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3039,7 +2751,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3048,125 +2760,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -4229,12 +3822,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_etl_view) + TEST_FIXTURE(SetupFixture, test_find_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); - ViewETL needle_view(STR("needle")); + View needle_view(STR("needle")); TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; @@ -4254,44 +3847,11 @@ namespace position2 = haystack.find(needle_view, position2 + 1); CHECK_EQUAL(TextL::npos, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.find(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - ViewSTD needle_view(STR("needle")); - - TextSTD compare_haystack(the_haystack); - TextBufferL buffer2{0}; - Text haystack(the_haystack, buffer2.data(), buffer2.size()); - - size_t position1 = 0UL; - size_t position2 = 0UL; - - position1 = compare_haystack.find(compare_needle, position1); - position2 = haystack.find(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.find(compare_needle, position1 + 1); - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(position1, position2); - - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(TextL::npos, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.find(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -4354,6 +3914,53 @@ namespace CHECK_EQUAL(IText::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text needle(STR("needle"), buffer2.data(), buffer2.size()); + Text pin(STR("pin"), buffer3.data(), buffer3.size()); + Text excess(STR("A really gigantic pin or needle that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.contains(needle)); + CHECK_FALSE(haystack.contains(pin)); + CHECK_FALSE(haystack.contains(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(View(STR("needle")))); + CHECK_FALSE(haystack.contains(View(STR("pin")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(STR("needle"))); + CHECK_FALSE(haystack.contains(STR("pin"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(STR('l'))); + CHECK_FALSE(haystack.contains(STR('p'))); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { @@ -4387,12 +3994,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + TEST_FIXTURE(SetupFixture, test_rfind_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); - ViewETL needle_view(STR("needle")); + View needle_view(STR("needle")); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -4408,41 +4015,11 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.rfind(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = TextSTD::npos; - size_t position2 = TextL::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle_view, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.rfind(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -4563,7 +4140,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_view) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; @@ -4574,69 +4151,30 @@ namespace // Equal. compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewETL(STR("ABCDEF"))); + result = text.compare(View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewETL(STR("ABCDEE"))); + result = text.compare(View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewETL(STR("ABCDEG"))); + result = text.compare(View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewETL(STR("ABCDE"))); + result = text.compare(View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewETL(STR("ABCDEFG"))); + result = text.compare(View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_std_view) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -4675,7 +4213,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view) { TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; @@ -4686,68 +4224,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + result = text.compare(3, 6, View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + result = text.compare(3, 6, View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + result = text.compare(3, 6, View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + result = text.compare(3, 6, View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + result = text.compare(3, 6, View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - TextBuffer buffer{0}; - Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -4786,7 +4286,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view_subposition_sublength) { TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; @@ -4797,68 +4297,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, View(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, View(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - TextBuffer buffer{0}; - Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -5002,67 +4464,35 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_of_view_position) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + size_t position2 = text.find_first_of(View(STR("ZCXF"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + position2 = text.find_first_of(View(STR("WXYZ"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + position2 = text.find_first_of(View(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + position2 = text.find_first_of(View(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -5208,77 +4638,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + size_t position2 = text.find_last_of(View(STR("ZCXE"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + position2 = text.find_last_of(View(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + position2 = text.find_last_of(View(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + position2 = text.find_last_of(View(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + position2 = text.find_last_of(View(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - TextBuffer buffer{0}; - Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -5439,77 +4832,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_not_of_view_position) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + position2 = text.find_first_not_of(View(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + position2 = text.find_first_not_of(View(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + position2 = text.find_first_not_of(View(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -5665,77 +5021,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_not_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(View(STR("ZEXD"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + position2 = text.find_last_not_of(View(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + position2 = text.find_last_not_of(View(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + position2 = text.find_last_not_of(View(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + position2 = text.find_last_not_of(View(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - TextBuffer buffer{0}; - Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_u8.cpp b/test/test_string_u8.cpp index 84020bbd..5ce38042 100644 --- a/test/test_string_u8.cpp +++ b/test/test_string_u8.cpp @@ -75,10 +75,7 @@ namespace using value_t = Text::value_type; using TextL = etl::u8string<52>; using TextS = etl::u8string<4>; - using ViewETL = etl::u8string_view; -#if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::u8string_view; -#endif + using View = etl::u8string_view; TextSTD initial_text; TextSTD less_text; @@ -313,7 +310,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - ViewETL view(initial_text.data(), initial_text.size()); + View view(initial_text.data(), initial_text.size()); Text text(view); bool is_equal = Equal(initial_text, text); @@ -322,20 +319,6 @@ namespace CHECK(!text.empty()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) - { - ViewSTD view(initial_text.data(), initial_text.size()); - Text text(view); - - bool is_equal = Equal(initial_text, text); - CHECK(is_equal); - CHECK(text.size() == SIZE); - CHECK(!text.empty()); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -613,11 +596,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + TEST_FIXTURE(SetupFixture, test_assignment_from_view) { Text text; - text = ViewETL(STR("Hello World")); + text = View(STR("Hello World")); bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); @@ -626,22 +609,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) - { - Text text; - - text = ViewSTD(STR("Hello World")); - - bool is_equal = Equal(TextSTD(STR("Hello World")), text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1075,11 +1042,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_etl_view) + TEST_FIXTURE(SetupFixture, test_assign_view) { TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - ViewETL view(input); + View view(input); TextSTD compare_text; Text text; @@ -1094,28 +1061,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_std_view) - { - TextSTD compare_input(initial_text.c_str()); - Text input(initial_text.c_str()); - ViewSTD view(input.data(), input.size()); - - TextSTD compare_text; - Text text; - - compare_text.assign(compare_input); - text.assign(view); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1634,13 +1579,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_view) { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1654,29 +1599,6 @@ namespace } } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) - { - for (size_t offset = 0UL; offset <= short_text.size(); ++offset) - { - TextSTD compare_text(short_text.cbegin(), short_text.cend()); - Text text(short_text.cbegin(), short_text.cend()); - ViewSTD view(insert_text.data(), insert_text.size()); - - text.insert(offset, view); - compare_text.insert(offset, insert_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -1801,11 +1723,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_etl_view) + TEST_FIXTURE(SetupFixture, test_append_view) { TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1833,41 +1755,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_std_view) - { - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - ViewSTD append(insert_text.data(), insert_text.size()); - - // Non-overflow. - compare_text.append(insert_text); - text.append(append); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.size()); - - compare_text.append(initial_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.append(append); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -2179,7 +2066,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view) { // Non-overflow short text, npos. TextSTD compare_text(short_text.c_str()); @@ -2187,7 +2074,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace"))); + text.replace(2, Text::npos, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2201,7 +2088,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace"))); + text.replace(2, 2, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2215,7 +2102,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2229,7 +2116,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2243,7 +2130,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace"))); + text.replace(2, 7, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2257,7 +2144,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2271,7 +2158,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2280,110 +2167,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) - { - // Non-overflow short text, npos. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2445,7 +2228,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_first_last_view) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2453,7 +2236,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2467,7 +2250,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2481,7 +2264,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 9, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2495,7 +2278,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2504,68 +2287,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2683,7 +2404,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view_subposition_sublength) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2691,7 +2412,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 4, View(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2705,7 +2426,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2719,7 +2440,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2733,7 +2454,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2747,7 +2468,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 7, View(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2761,7 +2482,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2775,7 +2496,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2789,7 +2510,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2798,124 +2519,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -3928,13 +3531,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_etl_view) + TEST_FIXTURE(SetupFixture, test_find_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); Text needle(STR("needle")); - ViewETL needle_view(needle); + View needle_view(needle); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -3953,44 +3556,11 @@ namespace position2 = haystack.find(needle_view, position2 + 1); CHECK_EQUAL(Text::npos, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.find(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = 0UL; - size_t position2 = 0UL; - - position1 = compare_haystack.find(compare_needle, position1); - position2 = haystack.find(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.find(compare_needle, position1 + 1); - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(position1, position2); - - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(Text::npos, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.find(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -4049,6 +3619,48 @@ namespace CHECK_EQUAL(TextL::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text needle(STR("needle")); + Text pin(STR("pin")); + Text excess(STR("A really gigantic pin or needle that's really really big")); + + CHECK_TRUE(haystack.contains(needle)); + CHECK_FALSE(haystack.contains(pin)); + CHECK_FALSE(haystack.contains(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(View(STR("needle")))); + CHECK_FALSE(haystack.contains(View(STR("pin")))); + CHECK_FALSE(haystack.contains(View(STR("A really gigantic pin or needle that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(STR("needle"))); + CHECK_FALSE(haystack.contains(STR("pin"))); + CHECK_FALSE(haystack.contains(STR("A really gigantic pin or needle that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(STR('l'))); + CHECK_FALSE(haystack.contains(STR('p'))); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { @@ -4077,13 +3689,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + TEST_FIXTURE(SetupFixture, test_rfind_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); Text needle(STR("needle")); - ViewETL needle_view(needle); + View needle_view(needle); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -4099,41 +3711,11 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.rfind(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = std::u8string::npos; - size_t position2 = Text::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle_view, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.rfind(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -4282,7 +3864,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_view) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); @@ -4292,67 +3874,30 @@ namespace // Equal. compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewETL(STR("ABCDEF"))); + result = text.compare(View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewETL(STR("ABCDEE"))); + result = text.compare(View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewETL(STR("ABCDEG"))); + result = text.compare(View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewETL(STR("ABCDE"))); + result = text.compare(View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewETL(STR("ABCDEFG"))); + result = text.compare(View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_std_view) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -4389,7 +3934,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view) { TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); @@ -4399,67 +3944,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + result = text.compare(3, 6, View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + result = text.compare(3, 6, View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + result = text.compare(3, 6, View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + result = text.compare(3, 6, View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + result = text.compare(3, 6, View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - Text text(STR("xxxABCDEFyyy")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -4496,7 +4004,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view_subposition_sublength) { TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); @@ -4506,67 +4014,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, View(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, View(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - Text text(STR("xxxABCDEFyyy")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -4702,65 +4173,34 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_of_view_position) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + size_t position2 = text.find_first_of(View(STR("ZCXF"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + position2 = text.find_first_of(View(STR("WXYZ"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + position2 = text.find_first_of(View(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + position2 = text.find_first_of(View(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -4898,75 +4338,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + size_t position2 = text.find_last_of(View(STR("ZCXE"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + position2 = text.find_last_of(View(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + position2 = text.find_last_of(View(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + position2 = text.find_last_of(View(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + position2 = text.find_last_of(View(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - Text text(STR("ABCDEFABCDE")); - - size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -5117,75 +4521,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_not_of_view_position) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + position2 = text.find_first_not_of(View(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + position2 = text.find_first_not_of(View(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + position2 = text.find_first_not_of(View(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -5333,75 +4701,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_not_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(View(STR("ZEXD"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + position2 = text.find_last_not_of(View(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + position2 = text.find_last_not_of(View(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + position2 = text.find_last_not_of(View(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + position2 = text.find_last_not_of(View(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - Text text(STR("ABCDEFABCDE")); - - size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_u8_external_buffer.cpp b/test/test_string_u8_external_buffer.cpp index d0a02373..085f7738 100644 --- a/test/test_string_u8_external_buffer.cpp +++ b/test/test_string_u8_external_buffer.cpp @@ -81,10 +81,7 @@ namespace using TextBufferL = std::array; using TextBufferS = std::array; - using ViewETL = etl::u8string_view; -#if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::u8string_view; -#endif + using View = etl::u8string_view; TextSTD initial_text; TextSTD less_text; @@ -397,7 +394,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - ViewETL view(initial_text.data(), initial_text.size()); + View view(initial_text.data(), initial_text.size()); TextBuffer buffer{0}; Text text(view, buffer.data(), buffer.size()); @@ -407,21 +404,6 @@ namespace CHECK(!text.empty()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) - { - ViewSTD view(initial_text.data(), initial_text.size()); - TextBuffer buffer{0}; - Text text(view, buffer.data(), buffer.size()); - - bool is_equal = Equal(initial_text, text); - CHECK(is_equal); - CHECK(text.size() == SIZE); - CHECK(!text.empty()); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -748,12 +730,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + TEST_FIXTURE(SetupFixture, test_assignment_from_view) { TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); - text = ViewETL(STR("Hello World")); + text = View(STR("Hello World")); bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); @@ -762,23 +744,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) - { - TextBuffer buffer{0}; - Text text(buffer.data(), buffer.size()); - - text = ViewSTD(STR("Hello World")); - - bool is_equal = Equal(TextSTD(STR("Hello World")), text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1239,12 +1204,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_etl_view) + TEST_FIXTURE(SetupFixture, test_assign_view) { TextSTD compare_input(initial_text.c_str()); TextBuffer buffer{0}; Text input(initial_text.c_str(), buffer.data(), buffer.size()); - ViewETL view(input); + View view(input); TextSTD compare_text; TextBuffer buffer2{0}; @@ -1260,30 +1225,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_std_view) - { - TextSTD compare_input(initial_text.c_str()); - TextBuffer buffer{0}; - Text input(initial_text.c_str(), buffer.data(), buffer.size()); - ViewSTD view(input.data(), input.size()); - - TextSTD compare_text; - TextBuffer buffer2{0}; - Text text(buffer2.data(), buffer2.size()); - - compare_text.assign(compare_input); - text.assign(view); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1833,7 +1774,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_view) { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { @@ -1841,7 +1782,7 @@ namespace TextBuffer buffer; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1855,31 +1796,6 @@ namespace } } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) - { - for (size_t offset = 0UL; offset <= short_text.size(); ++offset) - { - TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; - buffer.fill(0); - Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); - - text.insert(offset, view); - compare_text.insert(offset, insert_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -2021,12 +1937,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_etl_view) + TEST_FIXTURE(SetupFixture, test_append_view) { TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -2054,42 +1970,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_std_view) - { - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - ViewSTD append(insert_text.data(), insert_text.size()); - - // Non-overflow. - compare_text.append(insert_text); - text.append(append); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.size()); - - compare_text.append(initial_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.append(append); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -2423,7 +2303,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view) { // Non-overflow short text, npos. TextSTD compare_text(short_text.c_str()); @@ -2432,7 +2312,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace"))); + text.replace(2, Text::npos, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2446,7 +2326,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace"))); + text.replace(2, 2, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2460,7 +2340,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2474,7 +2354,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2488,7 +2368,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace"))); + text.replace(2, 7, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2502,7 +2382,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2516,7 +2396,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2525,111 +2405,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) - { - // Non-overflow short text, npos. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2693,7 +2468,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_first_last_view) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2702,7 +2477,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2716,7 +2491,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2730,7 +2505,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 9, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2744,7 +2519,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2753,69 +2528,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2935,7 +2647,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view_subposition_sublength) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2944,7 +2656,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 4, View(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2958,7 +2670,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2972,7 +2684,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2986,7 +2698,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3000,7 +2712,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 7, View(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3014,7 +2726,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3028,7 +2740,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3042,7 +2754,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3051,125 +2763,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -4232,12 +3825,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_etl_view) + TEST_FIXTURE(SetupFixture, test_find_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); - ViewETL needle_view(STR("needle")); + View needle_view(STR("needle")); TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; @@ -4257,44 +3850,11 @@ namespace position2 = haystack.find(needle_view, position2 + 1); CHECK_EQUAL(TextL::npos, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.find(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - ViewSTD needle_view(STR("needle")); - - TextSTD compare_haystack(the_haystack); - TextBufferL buffer2{0}; - Text haystack(the_haystack, buffer2.data(), buffer2.size()); - - size_t position1 = 0UL; - size_t position2 = 0UL; - - position1 = compare_haystack.find(compare_needle, position1); - position2 = haystack.find(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.find(compare_needle, position1 + 1); - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(position1, position2); - - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(TextL::npos, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.find(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -4326,6 +3886,53 @@ namespace CHECK_EQUAL(IText::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text needle(STR("needle"), buffer2.data(), buffer2.size()); + Text pin(STR("pin"), buffer3.data(), buffer3.size()); + Text excess(STR("A really gigantic pin or needle that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.contains(needle)); + CHECK_FALSE(haystack.contains(pin)); + CHECK_FALSE(haystack.contains(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(View(STR("needle")))); + CHECK_FALSE(haystack.contains(View(STR("pin")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(STR("needle"))); + CHECK_FALSE(haystack.contains(STR("pin"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(STR('l'))); + CHECK_FALSE(haystack.contains(STR('p'))); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_char_pointer_n) { @@ -4390,12 +3997,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + TEST_FIXTURE(SetupFixture, test_rfind_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); - ViewETL needle_view(STR("needle")); + View needle_view(STR("needle")); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -4411,41 +4018,11 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.rfind(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = TextSTD::npos; - size_t position2 = TextL::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle_view, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.rfind(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -4566,7 +4143,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_view) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; @@ -4577,69 +4154,30 @@ namespace // Equal. compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewETL(STR("ABCDEF"))); + result = text.compare(View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewETL(STR("ABCDEE"))); + result = text.compare(View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewETL(STR("ABCDEG"))); + result = text.compare(View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewETL(STR("ABCDE"))); + result = text.compare(View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewETL(STR("ABCDEFG"))); + result = text.compare(View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_std_view) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -4678,7 +4216,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view) { TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; @@ -4689,68 +4227,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + result = text.compare(3, 6, View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + result = text.compare(3, 6, View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + result = text.compare(3, 6, View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + result = text.compare(3, 6, View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + result = text.compare(3, 6, View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - TextBuffer buffer{0}; - Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -4789,7 +4289,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view_subposition_sublength) { TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; @@ -4800,68 +4300,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, View(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, View(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - TextBuffer buffer{0}; - Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -5005,67 +4467,35 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_of_view_position) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + size_t position2 = text.find_first_of(View(STR("ZCXF"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + position2 = text.find_first_of(View(STR("WXYZ"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + position2 = text.find_first_of(View(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + position2 = text.find_first_of(View(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -5211,77 +4641,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + size_t position2 = text.find_last_of(View(STR("ZCXE"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + position2 = text.find_last_of(View(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + position2 = text.find_last_of(View(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + position2 = text.find_last_of(View(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + position2 = text.find_last_of(View(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - TextBuffer buffer{0}; - Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -5442,77 +4835,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_not_of_view_position) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + position2 = text.find_first_not_of(View(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + position2 = text.find_first_not_of(View(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + position2 = text.find_first_not_of(View(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -5668,77 +5024,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_not_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(View(STR("ZEXD"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + position2 = text.find_last_not_of(View(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + position2 = text.find_last_not_of(View(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + position2 = text.find_last_not_of(View(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + position2 = text.find_last_not_of(View(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - TextBuffer buffer{0}; - Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index b8f51dba..1a8ed43b 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -81,10 +81,8 @@ namespace TextSTD insert_text; TextSTD longer_text; TextSTD short_text; - using ViewETL = etl::wstring_view; -#if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::wstring_view; -#endif + + using View = etl::wstring_view; const value_t* pinitial_text = STR("Hello World"); @@ -310,7 +308,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - ViewETL view(initial_text.data(), initial_text.size()); + View view(initial_text.data(), initial_text.size()); Text text(view); bool is_equal = Equal(initial_text, text); @@ -319,20 +317,6 @@ namespace CHECK(!text.empty()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) - { - ViewSTD view(initial_text.data(), initial_text.size()); - Text text(view); - - bool is_equal = Equal(initial_text, text); - CHECK(is_equal); - CHECK(text.size() == SIZE); - CHECK(!text.empty()); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -610,11 +594,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + TEST_FIXTURE(SetupFixture, test_assignment_from_view) { Text text; - text = ViewETL(STR("Hello World")); + text = View(STR("Hello World")); bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); @@ -623,22 +607,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) - { - Text text; - - text = ViewSTD(STR("Hello World")); - - bool is_equal = Equal(TextSTD(STR("Hello World")), text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1072,11 +1040,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_etl_view) + TEST_FIXTURE(SetupFixture, test_assign_view) { TextSTD compare_input(initial_text.c_str()); Text input(initial_text.c_str()); - ViewETL view(input); + View view(input); TextSTD compare_text; Text text; @@ -1091,28 +1059,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_std_view) - { - TextSTD compare_input(initial_text.c_str()); - Text input(initial_text.c_str()); - ViewSTD view(input.data(), input.size()); - - TextSTD compare_text; - Text text; - - compare_text.assign(compare_input); - text.assign(view); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1631,13 +1577,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_view) { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); Text text(short_text.cbegin(), short_text.cend()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1651,29 +1597,6 @@ namespace } } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) - { - for (size_t offset = 0UL; offset <= short_text.size(); ++offset) - { - TextSTD compare_text(short_text.cbegin(), short_text.cend()); - Text text(short_text.cbegin(), short_text.cend()); - ViewSTD view(insert_text.data(), insert_text.size()); - - text.insert(offset, view); - compare_text.insert(offset, insert_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -1798,11 +1721,11 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_etl_view) + TEST_FIXTURE(SetupFixture, test_append_view) { TextSTD compare_text(short_text.c_str()); Text text(short_text.c_str()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -1830,41 +1753,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_std_view) - { - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - ViewSTD append(insert_text.data(), insert_text.size()); - - // Non-overflow. - compare_text.append(insert_text); - text.append(append); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.size()); - - compare_text.append(initial_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.append(append); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -2176,7 +2064,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view) { // Non-overflow short text, npos. TextSTD compare_text(short_text.c_str()); @@ -2184,7 +2072,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace"))); + text.replace(2, Text::npos, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2198,7 +2086,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace"))); + text.replace(2, 2, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2212,7 +2100,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2226,7 +2114,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2240,7 +2128,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace"))); + text.replace(2, 7, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2254,7 +2142,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2268,7 +2156,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2277,110 +2165,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) - { - // Non-overflow short text, npos. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2442,7 +2226,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_first_last_view) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2450,7 +2234,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2464,7 +2248,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2478,7 +2262,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 9, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2492,7 +2276,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2501,68 +2285,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2680,7 +2402,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view_subposition_sublength) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2688,7 +2410,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 4, View(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2702,7 +2424,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2716,7 +2438,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2730,7 +2452,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2744,7 +2466,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 7, View(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2758,7 +2480,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2772,7 +2494,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2786,7 +2508,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2795,124 +2517,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - Text text(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -3925,13 +3529,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_etl_view) + TEST_FIXTURE(SetupFixture, test_find_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); Text needle(STR("needle")); - ViewETL needle_view(needle); + View needle_view(needle); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -3950,44 +3554,11 @@ namespace position2 = haystack.find(needle_view, position2 + 1); CHECK_EQUAL(Text::npos, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.find(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = 0UL; - size_t position2 = 0UL; - - position1 = compare_haystack.find(compare_needle, position1); - position2 = haystack.find(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.find(compare_needle, position1 + 1); - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(position1, position2); - - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(Text::npos, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.find(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -4046,6 +3617,48 @@ namespace CHECK_EQUAL(TextL::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text needle(STR("needle")); + Text pin(STR("pin")); + Text excess(STR("A really gigantic pin or needle that's really really big")); + + CHECK_TRUE(haystack.contains(needle)); + CHECK_FALSE(haystack.contains(pin)); + CHECK_FALSE(haystack.contains(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(View(STR("needle")))); + CHECK_FALSE(haystack.contains(View(STR("pin")))); + CHECK_FALSE(haystack.contains(View(STR("A really gigantic pin or needle that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(STR("needle"))); + CHECK_FALSE(haystack.contains(STR("pin"))); + CHECK_FALSE(haystack.contains(STR("A really gigantic pin or needle that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.contains(STR('l'))); + CHECK_FALSE(haystack.contains(STR('p'))); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { @@ -4074,13 +3687,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + TEST_FIXTURE(SetupFixture, test_rfind_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); Text needle(STR("needle")); - ViewETL needle_view(needle); + View needle_view(needle); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -4096,41 +3709,11 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.rfind(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = std::wstring::npos; - size_t position2 = Text::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle_view, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.rfind(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -4279,7 +3862,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_view) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); @@ -4289,67 +3872,30 @@ namespace // Equal. compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewETL(STR("ABCDEF"))); + result = text.compare(View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewETL(STR("ABCDEE"))); + result = text.compare(View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewETL(STR("ABCDEG"))); + result = text.compare(View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewETL(STR("ABCDE"))); + result = text.compare(View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewETL(STR("ABCDEFG"))); + result = text.compare(View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_std_view) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -4386,7 +3932,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view) { TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); @@ -4396,67 +3942,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + result = text.compare(3, 6, View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + result = text.compare(3, 6, View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + result = text.compare(3, 6, View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + result = text.compare(3, 6, View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + result = text.compare(3, 6, View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - Text text(STR("xxxABCDEFyyy")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -4493,7 +4002,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view_subposition_sublength) { TextSTD compare_text(STR("xxxABCDEFyyy")); Text text(STR("xxxABCDEFyyy")); @@ -4503,67 +4012,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, View(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, View(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - Text text(STR("xxxABCDEFyyy")); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -4699,65 +4171,34 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_of_view_position) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + size_t position2 = text.find_first_of(View(STR("ZCXF"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + position2 = text.find_first_of(View(STR("WXYZ"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + position2 = text.find_first_of(View(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + position2 = text.find_first_of(View(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -4895,75 +4336,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + size_t position2 = text.find_last_of(View(STR("ZCXE"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + position2 = text.find_last_of(View(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + position2 = text.find_last_of(View(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + position2 = text.find_last_of(View(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + position2 = text.find_last_of(View(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - Text text(STR("ABCDEFABCDE")); - - size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -5114,75 +4519,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_not_of_view_position) { TextSTD compare_text(STR("ABCDEF")); Text text(STR("ABCDEF")); size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + position2 = text.find_first_not_of(View(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + position2 = text.find_first_not_of(View(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + position2 = text.find_first_not_of(View(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - Text text(STR("ABCDEF")); - - size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -5330,75 +4699,39 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_not_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); Text text(STR("ABCDEFABCDE")); size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(View(STR("ZEXD"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + position2 = text.find_last_not_of(View(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + position2 = text.find_last_not_of(View(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + position2 = text.find_last_not_of(View(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + position2 = text.find_last_not_of(View(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - Text text(STR("ABCDEFABCDE")); - - size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { diff --git a/test/test_string_wchar_t_external_buffer.cpp b/test/test_string_wchar_t_external_buffer.cpp index 443b0b8a..5d277936 100644 --- a/test/test_string_wchar_t_external_buffer.cpp +++ b/test/test_string_wchar_t_external_buffer.cpp @@ -75,19 +75,13 @@ namespace using TextSTD = std::wstring; using value_t = Text::value_type; - using ViewETL = etl::wstring_view; -#if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::wstring_view; -#endif + using View = etl::wstring_view; using TextBuffer = std::array; using TextBufferL = std::array; using TextBufferS = std::array; - using ViewETL = etl::wstring_view; -#if ETL_USING_STL && ETL_USING_CPP17 - using ViewSTD = std::wstring_view; -#endif + using View = etl::wstring_view; TextSTD initial_text; TextSTD less_text; @@ -400,7 +394,7 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_constructor_from_etl_string_view) { - ViewETL view(initial_text.data(), initial_text.size()); + View view(initial_text.data(), initial_text.size()); TextBuffer buffer{0}; Text text(view, buffer.data(), buffer.size()); @@ -410,21 +404,6 @@ namespace CHECK(!text.empty()); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_constructor_from_std_string_view) - { - ViewSTD view(initial_text.data(), initial_text.size()); - TextBuffer buffer{0}; - Text text(view, buffer.data(), buffer.size()); - - bool is_equal = Equal(initial_text, text); - CHECK(is_equal); - CHECK(text.size() == SIZE); - CHECK(!text.empty()); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_copy_constructor) { @@ -751,12 +730,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_etl_view) + TEST_FIXTURE(SetupFixture, test_assignment_from_view) { TextBuffer buffer{0}; Text text(buffer.data(), buffer.size()); - text = ViewETL(STR("Hello World")); + text = View(STR("Hello World")); bool is_equal = Equal(TextSTD(STR("Hello World")), text); CHECK(is_equal); @@ -765,23 +744,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assignment_from_std_view) - { - TextBuffer buffer{0}; - Text text(buffer.data(), buffer.size()); - - text = ViewSTD(STR("Hello World")); - - bool is_equal = Equal(TextSTD(STR("Hello World")), text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_begin) { @@ -1242,12 +1204,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_etl_view) + TEST_FIXTURE(SetupFixture, test_assign_view) { TextSTD compare_input(initial_text.c_str()); TextBuffer buffer{0}; Text input(initial_text.c_str(), buffer.data(), buffer.size()); - ViewETL view(input); + View view(input); TextSTD compare_text; TextBuffer buffer2{0}; @@ -1263,30 +1225,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_assign_std_view) - { - TextSTD compare_input(initial_text.c_str()); - TextBuffer buffer{0}; - Text input(initial_text.c_str(), buffer.data(), buffer.size()); - ViewSTD view(input.data(), input.size()); - - TextSTD compare_text; - TextBuffer buffer2{0}; - Text text(buffer2.data(), buffer2.size()); - - compare_text.assign(compare_input); - text.assign(view); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_assign_string_excess) { @@ -1836,7 +1774,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_etl_view) + TEST_FIXTURE(SetupFixture, test_insert_size_t_position_view) { for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { @@ -1844,7 +1782,7 @@ namespace TextBuffer buffer; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); text.insert(offset, view); compare_text.insert(offset, insert_text); @@ -1858,31 +1796,6 @@ namespace } } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_insert_size_t_position_std_view) - { - for (size_t offset = 0UL; offset <= short_text.size(); ++offset) - { - TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; - buffer.fill(0); - Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); - - text.insert(offset, view); - compare_text.insert(offset, insert_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - } - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_insert_size_t_position_string_excess) { @@ -2024,12 +1937,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_etl_view) + TEST_FIXTURE(SetupFixture, test_append_view) { TextSTD compare_text(short_text.c_str()); TextBuffer buffer{0}; Text text(short_text.c_str(), buffer.data(), buffer.size()); - ViewETL view(insert_text.data(), insert_text.size()); + View view(insert_text.data(), insert_text.size()); // Non-overflow. compare_text.append(insert_text); @@ -2057,42 +1970,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_append_std_view) - { - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - ViewSTD append(insert_text.data(), insert_text.size()); - - // Non-overflow. - compare_text.append(insert_text); - text.append(append); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - append = ViewSTD(initial_text.data(), initial_text.size()); - - compare_text.append(initial_text); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.append(append); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_append_truncated_string) { @@ -2426,7 +2303,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view) { // Non-overflow short text, npos. TextSTD compare_text(short_text.c_str()); @@ -2435,7 +2312,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace"))); + text.replace(2, Text::npos, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2449,7 +2326,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace"))); + text.replace(2, 2, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2463,7 +2340,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2477,7 +2354,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2491,7 +2368,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace"))); + text.replace(2, 7, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2505,7 +2382,7 @@ namespace compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewETL(STR("Replace with some text"))); + text.replace(2, 2, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2519,7 +2396,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text"))); + text.replace(2, Text::npos, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2528,111 +2405,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view) - { - // Non-overflow short text, npos. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 2, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 2, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_first_last_string) { @@ -2696,7 +2468,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_etl_view) + TEST_FIXTURE(SetupFixture, test_replace_first_last_view) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2705,7 +2477,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace"))); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2719,7 +2491,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2733,7 +2505,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewETL(STR("Replace"))); + text.replace(text.begin() + 2, text.begin() + 9, View(STR("Replace"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2747,7 +2519,7 @@ namespace compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewETL(STR("Replace with some text"))); + text.replace(text.begin() + 2, text.begin() + 4, View(STR("Replace with some text"))); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2756,69 +2528,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_first_last_std_view) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace"))); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 9, TextSTD(STR("Replace"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 9, ViewSTD(STR("Replace"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(compare_text.begin() + 2, compare_text.begin() + 4, TextSTD(STR("Replace with some text"))); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(text.begin() + 2, text.begin() + 4, ViewSTD(STR("Replace with some text"))); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_string_subposition_sublength) { @@ -2938,7 +2647,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_replace_position_length_view_subposition_sublength) { // Non-overflow short text. TextSTD compare_text(short_text.c_str()); @@ -2947,7 +2656,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 4, View(STR("Replace")), 1, 5); bool is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2961,7 +2670,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2975,7 +2684,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -2989,7 +2698,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3003,7 +2712,7 @@ namespace compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewETL(STR("Replace")), 1, 5); + text.replace(2, 7, View(STR("Replace")), 1, 5); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3017,7 +2726,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3031,7 +2740,7 @@ namespace compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewETL(STR("Replace with some text")), 1, 15); + text.replace(2, 4, View(STR("Replace with some text")), 1, 15); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3045,7 +2754,7 @@ namespace compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewETL(STR("Replace with some text")), 1, Text::npos); + text.replace(2, Text::npos, View(STR("Replace with some text")), 1, Text::npos); is_equal = Equal(compare_text, text); CHECK(is_equal); @@ -3054,125 +2763,6 @@ namespace #endif } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_replace_position_length_std_view_subposition_sublength) - { - // Non-overflow short text. - TextSTD compare_text(short_text.c_str()); - TextBuffer buffer{0}; - Text text(short_text.c_str(), buffer.data(), buffer.size()); - - compare_text.replace(2, 4, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace")), 1, 5); - - bool is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow short text. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow short text, npos. - compare_text.assign(short_text.c_str()); - text.assign(short_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Non-overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 7, TextSTD(STR("Replace")), 1, 5); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 7, ViewSTD(STR("Replace")), 1, 5); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Non-overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(!text.is_truncated()); -#endif - - // Overflow. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, 4, TextSTD(STR("Replace with some text")), 1, 15); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, 4, ViewSTD(STR("Replace with some text")), 1, 15); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - - // Overflow, npos. - compare_text.assign(initial_text.c_str()); - text.assign(initial_text.c_str()); - - compare_text.replace(2, TextSTD::npos, TextSTD(STR("Replace with some text")), 1, TextSTD::npos); - compare_text.resize(std::min(compare_text.size(), SIZE)); - text.replace(2, Text::npos, ViewSTD(STR("Replace with some text")), 1, Text::npos); - - is_equal = Equal(compare_text, text); - CHECK(is_equal); -#if ETL_HAS_STRING_TRUNCATION_CHECKS - CHECK(text.is_truncated()); -#endif - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_replace_position_length_pointer) { @@ -4235,12 +3825,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_etl_view) + TEST_FIXTURE(SetupFixture, test_find_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); - ViewETL needle_view(STR("needle")); + View needle_view(STR("needle")); TextSTD compare_haystack(the_haystack); TextBufferL buffer2{0}; @@ -4260,44 +3850,11 @@ namespace position2 = haystack.find(needle_view, position2 + 1); CHECK_EQUAL(TextL::npos, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.find(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - ViewSTD needle_view(STR("needle")); - - TextSTD compare_haystack(the_haystack); - TextBufferL buffer2{0}; - Text haystack(the_haystack, buffer2.data(), buffer2.size()); - - size_t position1 = 0UL; - size_t position2 = 0UL; - - position1 = compare_haystack.find(compare_needle, position1); - position2 = haystack.find(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.find(compare_needle, position1 + 1); - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(position1, position2); - - position2 = haystack.find(needle_view, position2 + 1); - CHECK_EQUAL(TextL::npos, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.find(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_pointer) { @@ -4360,6 +3917,53 @@ namespace CHECK_EQUAL(IText::npos, position2); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text needle(STR("needle"), buffer2.data(), buffer2.size()); + Text pin(STR("pin"), buffer3.data(), buffer3.size()); + Text excess(STR("A really gigantic pin or needle that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.contains(needle)); + CHECK_FALSE(haystack.contains(pin)); + CHECK_FALSE(haystack.contains(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(View(STR("needle")))); + CHECK_FALSE(haystack.contains(View(STR("pin")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(STR("needle"))); + CHECK_FALSE(haystack.contains(STR("pin"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_contains_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.contains(STR('l'))); + CHECK_FALSE(haystack.contains(STR('p'))); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { @@ -4393,12 +3997,12 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_etl_view) + TEST_FIXTURE(SetupFixture, test_rfind_view) { const value_t* the_haystack = STR("A haystack with a needle and another needle"); TextSTD compare_needle(STR("needle")); - ViewETL needle_view(STR("needle")); + View needle_view(STR("needle")); TextSTD compare_haystack(the_haystack); TextL haystack(the_haystack); @@ -4414,41 +4018,11 @@ namespace position2 = haystack.rfind(needle_view, haystack.size() - 10); CHECK_EQUAL(position1, position2); - ViewETL pin_view(STR("pin")); + View pin_view(STR("pin")); position2 = haystack.rfind(pin_view); CHECK_EQUAL(TextL::npos, position2); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_rfind_std_view) - { - const value_t* the_haystack = STR("A haystack with a needle and another needle"); - - TextSTD compare_needle(STR("needle")); - TextSTD needle(STR("needle")); - ViewSTD needle_view(needle); - - TextSTD compare_haystack(the_haystack); - TextL haystack(the_haystack); - - size_t position1 = TextSTD::npos; - size_t position2 = TextL::npos; - - position1 = compare_haystack.rfind(compare_needle, position1); - position2 = haystack.rfind(needle_view, position2); - CHECK_EQUAL(position1, position2); - - position1 = compare_haystack.rfind(compare_needle, compare_haystack.size() - 10); - position2 = haystack.rfind(needle_view, haystack.size() - 10); - CHECK_EQUAL(position1, position2); - - ViewSTD pin_view(STR("pin")); - position2 = haystack.rfind(pin_view); - CHECK_EQUAL(TextL::npos, position2); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_pointer) { @@ -4569,7 +4143,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_view) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; @@ -4580,69 +4154,30 @@ namespace // Equal. compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewETL(STR("ABCDEF"))); + result = text.compare(View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewETL(STR("ABCDEE"))); + result = text.compare(View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewETL(STR("ABCDEG"))); + result = text.compare(View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewETL(STR("ABCDE"))); + result = text.compare(View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewETL(STR("ABCDEFG"))); + result = text.compare(View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_std_view) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(TextSTD(STR("ABCDEF"))); - result = text.compare(ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(TextSTD(STR("ABCDEE"))); - result = text.compare(ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(TextSTD(STR("ABCDEG"))); - result = text.compare(ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(TextSTD(STR("ABCDE"))); - result = text.compare(ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(TextSTD(STR("ABCDEFG"))); - result = text.compare(ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string) { @@ -4681,7 +4216,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view) { TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; @@ -4692,68 +4227,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEF"))); + result = text.compare(3, 6, View(STR("ABCDEF"))); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEE"))); + result = text.compare(3, 6, View(STR("ABCDEE"))); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEG"))); + result = text.compare(3, 6, View(STR("ABCDEG"))); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewETL(STR("ABCDE"))); + result = text.compare(3, 6, View(STR("ABCDE"))); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewETL(STR("ABCDEFG"))); + result = text.compare(3, 6, View(STR("ABCDEFG"))); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - TextBuffer buffer{0}; - Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEF"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEF"))); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEE"))); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEG"))); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDE"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDE"))); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("ABCDEFG"))); - result = text.compare(3, 6, ViewSTD(STR("ABCDEFG"))); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_position_length_string_subposition_sublength) { @@ -4792,7 +4289,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_etl_view_subposition_sublength) + TEST_FIXTURE(SetupFixture, test_compare_position_length_view_subposition_sublength) { TextSTD compare_text(STR("xxxABCDEFyyy")); TextBuffer buffer{0}; @@ -4803,68 +4300,30 @@ namespace // Equal. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEFbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Less. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEEbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEEbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Greater. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewETL(STR("aaABCDEGbb")), 2, 6); + result = text.compare(3, 6, View(STR("aaABCDEGbb")), 2, 6); CHECK(compares_agree(compare_result, result)); // Shorter. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewETL(STR("aaABCDEbb")), 2, 5); + result = text.compare(3, 6, View(STR("aaABCDEbb")), 2, 5); CHECK(compares_agree(compare_result, result)); // Longer. compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewETL(STR("aaABCDEFGbb")), 2, 7); + result = text.compare(3, 6, View(STR("aaABCDEFGbb")), 2, 7); CHECK(compares_agree(compare_result, result)); } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_compare_position_length_std_view_subposition_sublength) - { - TextSTD compare_text(STR("xxxABCDEFyyy")); - TextBuffer buffer{0}; - Text text(STR("xxxABCDEFyyy"), buffer.data(), buffer.size()); - - int compare_result; - int result; - - // Equal. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Less. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEEbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEEbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Greater. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEGbb")), 2, 6); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEGbb")), 2, 6); - CHECK(compares_agree(compare_result, result)); - - // Shorter. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEbb")), 2, 5); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEbb")), 2, 5); - CHECK(compares_agree(compare_result, result)); - - // Longer. - compare_result = compare_text.compare(3, 6, TextSTD(STR("aaABCDEFGbb")), 2, 7); - result = text.compare(3, 6, ViewSTD(STR("aaABCDEFGbb")), 2, 7); - CHECK(compares_agree(compare_result, result)); - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_compare_c_string) { @@ -5008,67 +4467,35 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_of_view_position) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewETL(STR("ZCXF"))); + size_t position2 = text.find_first_of(View(STR("ZCXF"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewETL(STR("WXYZ"))); + position2 = text.find_first_of(View(STR("WXYZ"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 3); + position2 = text.find_first_of(View(STR("ZCXF")), 3); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewETL(STR("ZCXF")), 100); + position2 = text.find_first_of(View(STR("ZCXF")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_first_of(TextSTD(STR("ZCXF"))); - size_t position2 = text.find_first_of(ViewSTD(STR("ZCXF"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("WXYZ"))); - position2 = text.find_first_of(ViewSTD(STR("WXYZ"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 3); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 3); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_of(TextSTD(STR("ZCXF")), 100); - position2 = text.find_first_of(ViewSTD(STR("ZCXF")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_of_pointer_position) { @@ -5214,77 +4641,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewETL(STR("ZCXE"))); + size_t position2 = text.find_last_of(View(STR("ZCXE"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewETL(STR("WXYZ")), 3); + position2 = text.find_last_of(View(STR("WXYZ")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 5); + position2 = text.find_last_of(View(STR("ZCXE")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), text.size()); + position2 = text.find_last_of(View(STR("ZCXE")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewETL(STR("ZCXE")), 100); + position2 = text.find_last_of(View(STR("ZCXE")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - TextBuffer buffer{0}; - Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_last_of(TextSTD(STR("ZCXE"))); - size_t position2 = text.find_last_of(ViewSTD(STR("ZCXE"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("WXYZ")), 3); - position2 = text.find_last_of(ViewSTD(STR("WXYZ")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 5); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), compare_text.size()); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_of(TextSTD(STR("ZCXE")), 100); - position2 = text.find_last_of(ViewSTD(STR("ZCXE")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_of_pointer_position) { @@ -5445,77 +4835,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_first_not_of_view_position) { TextSTD compare_text(STR("ABCDEF")); TextBuffer buffer{0}; Text text(STR("ABCDEF"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + size_t position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB"))); + position2 = text.find_first_not_of(View(STR("ZAXB"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 3); + position2 = text.find_first_not_of(View(STR("ZAXB")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), text.size()); + position2 = text.find_first_not_of(View(STR("ZAXB")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewETL(STR("ZAXB")), 100); + position2 = text.find_first_not_of(View(STR("ZAXB")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_first_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEF")); - TextBuffer buffer{0}; - Text text(STR("ABCDEF"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - size_t position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB"))); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 3); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), compare_text.size()); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_first_not_of(TextSTD(STR("ZAXB")), 100); - position2 = text.find_first_not_of(ViewSTD(STR("ZAXB")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_first_not_of_pointer_position) { @@ -5671,77 +5024,40 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_etl_view_position) + TEST_FIXTURE(SetupFixture, test_find_last_not_of_view_position) { TextSTD compare_text(STR("ABCDEFABCDE")); TextBuffer buffer{0}; Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewETL(STR("ZEXD"))); + size_t position2 = text.find_last_not_of(View(STR("ZEXD"))); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 3); + position2 = text.find_last_not_of(View(STR("ZEXD")), 3); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 5); + position2 = text.find_last_not_of(View(STR("ZEXD")), 5); CHECK_EQUAL(position1, position2); position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), text.size()); + position2 = text.find_last_not_of(View(STR("ZEXD")), text.size()); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_array_bounds_push.h" position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewETL(STR("ZEXD")), 100); + position2 = text.find_last_not_of(View(STR("ZEXD")), 100); CHECK_EQUAL(position1, position2); #include "etl/private/diagnostic_pop.h" } -#if ETL_USING_STL && ETL_USING_CPP17 - //************************************************************************* - TEST_FIXTURE(SetupFixture, test_find_last_not_of_std_view_position) - { - TextSTD compare_text(STR("ABCDEFABCDE")); - TextBuffer buffer{0}; - Text text(STR("ABCDEFABCDE"), buffer.data(), buffer.size()); - - size_t position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD"))); - size_t position2 = text.find_last_not_of(ViewSTD(STR("ZEXD"))); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 3); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 3); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 5); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 5); - - CHECK_EQUAL(position1, position2); - - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), compare_text.size()); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), text.size()); - - CHECK_EQUAL(position1, position2); - -#include "etl/private/diagnostic_array_bounds_push.h" - position1 = compare_text.find_last_not_of(TextSTD(STR("ZEXD")), 100); - position2 = text.find_last_not_of(ViewSTD(STR("ZEXD")), 100); - - CHECK_EQUAL(position1, position2); -#include "etl/private/diagnostic_pop.h" - } -#endif - //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_last_not_of_pointer_position) { From d5cd9567cd4f5fa35ef5fc2e4882c76ecaa8f4a6 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 23 Nov 2024 12:33:36 +0000 Subject: [PATCH 07/18] Added starts_with and ends_with to basic_string --- include/etl/basic_string.h | 93 ++++++++++++++++++- test/test_string_char.cpp | 84 +++++++++++++++++ test/test_string_char_external_buffer.cpp | 98 ++++++++++++++++++++ test/test_string_u16.cpp | 84 +++++++++++++++++ test/test_string_u16_external_buffer.cpp | 98 ++++++++++++++++++++ test/test_string_u32.cpp | 84 +++++++++++++++++ test/test_string_u32_external_buffer.cpp | 98 ++++++++++++++++++++ test/test_string_u8.cpp | 84 +++++++++++++++++ test/test_string_u8_external_buffer.cpp | 98 ++++++++++++++++++++ test/test_string_wchar_t.cpp | 84 +++++++++++++++++ test/test_string_wchar_t_external_buffer.cpp | 98 ++++++++++++++++++++ 11 files changed, 999 insertions(+), 4 deletions(-) diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index d228166f..5cc37f10 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -1497,7 +1497,7 @@ namespace etl } //********************************************************************* - /// Checks that the string is within the string + /// Checks that the string is within this string //********************************************************************* bool contains(const etl::ibasic_string& str) const { @@ -1505,7 +1505,7 @@ namespace etl } //********************************************************************* - /// Checks that the view is within the string + /// Checks that the view is within this string //********************************************************************* template bool contains(const etl::basic_string_view& view) const @@ -1514,7 +1514,7 @@ namespace etl } //********************************************************************* - /// Checks that text is within the string + /// Checks that text is within this string //********************************************************************* bool contains(const_pointer s) const { @@ -1522,13 +1522,98 @@ namespace etl } //********************************************************************* - /// Checks that character is within the string + /// 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 ibasic_string& str) const + { + return compare(0, str.size(), str) == 0; + } + + //********************************************************************* + /// Checks that the view is the start of this string + //********************************************************************* + template + bool starts_with(const basic_string_view& 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 ibasic_string& 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 + bool ends_with(const basic_string_view& 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. diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 4da5716b..5c1e0c99 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -3644,6 +3644,90 @@ namespace CHECK_FALSE(haystack.contains(STR('p'))); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text start(STR("A haystack")); + Text not_start(STR("a needle")); + Text excess(STR("Really gigantic text that's really really big")); + + CHECK_TRUE(haystack.starts_with(start)); + CHECK_FALSE(haystack.starts_with(not_start)); + CHECK_FALSE(haystack.starts_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(View(STR("A haystack")))); + CHECK_FALSE(haystack.starts_with(View(STR("a needle")))); + CHECK_FALSE(haystack.starts_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(STR("A haystack"))); + CHECK_FALSE(haystack.starts_with(STR("a needle"))); + CHECK_FALSE(haystack.starts_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(haystack[0])); + CHECK_FALSE(haystack.starts_with(haystack[1])); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text end(STR("else")); + Text not_end(STR("needle")); + Text excess(STR("Really gigantic text that's really really big")); + + CHECK_TRUE(haystack.ends_with(end)); + CHECK_FALSE(haystack.ends_with(not_end)); + CHECK_FALSE(haystack.ends_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(View(STR("else")))); + CHECK_FALSE(haystack.ends_with(View(STR("needle")))); + CHECK_FALSE(haystack.ends_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(STR("else"))); + CHECK_FALSE(haystack.ends_with(STR("needle"))); + CHECK_FALSE(haystack.ends_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(haystack[haystack.size() - 1])); + CHECK_FALSE(haystack.ends_with(haystack[haystack.size() - 2])); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { diff --git a/test/test_string_char_external_buffer.cpp b/test/test_string_char_external_buffer.cpp index b2998e63..4ef70851 100644 --- a/test/test_string_char_external_buffer.cpp +++ b/test/test_string_char_external_buffer.cpp @@ -3947,6 +3947,104 @@ namespace CHECK_FALSE(haystack.contains(STR('p'))); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text start(STR("A haystack"), buffer2.data(), buffer2.size()); + Text not_start(STR("a needle"), buffer3.data(), buffer3.size()); + Text excess(STR("Really gigantic text that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.starts_with(start)); + CHECK_FALSE(haystack.starts_with(not_start)); + CHECK_FALSE(haystack.starts_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(View(STR("A haystack")))); + CHECK_FALSE(haystack.starts_with(View(STR("a needle")))); + CHECK_FALSE(haystack.starts_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(STR("A haystack"))); + CHECK_FALSE(haystack.starts_with(STR("a needle"))); + CHECK_FALSE(haystack.starts_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(haystack[0])); + CHECK_FALSE(haystack.starts_with(haystack[1])); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text end(STR("else"), buffer2.data(), buffer2.size()); + Text not_end(STR("needle"), buffer3.data(), buffer3.size()); + Text excess(STR("Really gigantic text that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.ends_with(end)); + CHECK_FALSE(haystack.ends_with(not_end)); + CHECK_FALSE(haystack.ends_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(View(STR("else")))); + CHECK_FALSE(haystack.ends_with(View(STR("needle")))); + CHECK_FALSE(haystack.ends_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(STR("else"))); + CHECK_FALSE(haystack.ends_with(STR("needle"))); + CHECK_FALSE(haystack.ends_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(haystack[haystack.size() - 1])); + CHECK_FALSE(haystack.ends_with(haystack[haystack.size() - 2])); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index a09f9a59..f7565b01 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -3658,6 +3658,90 @@ namespace CHECK_FALSE(haystack.contains(STR('p'))); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text start(STR("A haystack")); + Text not_start(STR("a needle")); + Text excess(STR("Really gigantic text that's really really big")); + + CHECK_TRUE(haystack.starts_with(start)); + CHECK_FALSE(haystack.starts_with(not_start)); + CHECK_FALSE(haystack.starts_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(View(STR("A haystack")))); + CHECK_FALSE(haystack.starts_with(View(STR("a needle")))); + CHECK_FALSE(haystack.starts_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(STR("A haystack"))); + CHECK_FALSE(haystack.starts_with(STR("a needle"))); + CHECK_FALSE(haystack.starts_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(haystack[0])); + CHECK_FALSE(haystack.starts_with(haystack[1])); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text end(STR("else")); + Text not_end(STR("needle")); + Text excess(STR("Really gigantic text that's really really big")); + + CHECK_TRUE(haystack.ends_with(end)); + CHECK_FALSE(haystack.ends_with(not_end)); + CHECK_FALSE(haystack.ends_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(View(STR("else")))); + CHECK_FALSE(haystack.ends_with(View(STR("needle")))); + CHECK_FALSE(haystack.ends_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(STR("else"))); + CHECK_FALSE(haystack.ends_with(STR("needle"))); + CHECK_FALSE(haystack.ends_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(haystack[haystack.size() - 1])); + CHECK_FALSE(haystack.ends_with(haystack[haystack.size() - 2])); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { diff --git a/test/test_string_u16_external_buffer.cpp b/test/test_string_u16_external_buffer.cpp index 96fd23d5..b15a4772 100644 --- a/test/test_string_u16_external_buffer.cpp +++ b/test/test_string_u16_external_buffer.cpp @@ -3961,6 +3961,104 @@ namespace CHECK_FALSE(haystack.contains(STR('p'))); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text start(STR("A haystack"), buffer2.data(), buffer2.size()); + Text not_start(STR("a needle"), buffer3.data(), buffer3.size()); + Text excess(STR("Really gigantic text that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.starts_with(start)); + CHECK_FALSE(haystack.starts_with(not_start)); + CHECK_FALSE(haystack.starts_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(View(STR("A haystack")))); + CHECK_FALSE(haystack.starts_with(View(STR("a needle")))); + CHECK_FALSE(haystack.starts_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(STR("A haystack"))); + CHECK_FALSE(haystack.starts_with(STR("a needle"))); + CHECK_FALSE(haystack.starts_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(haystack[0])); + CHECK_FALSE(haystack.starts_with(haystack[1])); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text end(STR("else"), buffer2.data(), buffer2.size()); + Text not_end(STR("needle"), buffer3.data(), buffer3.size()); + Text excess(STR("Really gigantic text that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.ends_with(end)); + CHECK_FALSE(haystack.ends_with(not_end)); + CHECK_FALSE(haystack.ends_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(View(STR("else")))); + CHECK_FALSE(haystack.ends_with(View(STR("needle")))); + CHECK_FALSE(haystack.ends_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(STR("else"))); + CHECK_FALSE(haystack.ends_with(STR("needle"))); + CHECK_FALSE(haystack.ends_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(haystack[haystack.size() - 1])); + CHECK_FALSE(haystack.ends_with(haystack[haystack.size() - 2])); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index 2b607b33..b27fcaff 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -3658,6 +3658,90 @@ namespace CHECK_FALSE(haystack.contains(STR('p'))); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text start(STR("A haystack")); + Text not_start(STR("a needle")); + Text excess(STR("Really gigantic text that's really really big")); + + CHECK_TRUE(haystack.starts_with(start)); + CHECK_FALSE(haystack.starts_with(not_start)); + CHECK_FALSE(haystack.starts_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(View(STR("A haystack")))); + CHECK_FALSE(haystack.starts_with(View(STR("a needle")))); + CHECK_FALSE(haystack.starts_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(STR("A haystack"))); + CHECK_FALSE(haystack.starts_with(STR("a needle"))); + CHECK_FALSE(haystack.starts_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(haystack[0])); + CHECK_FALSE(haystack.starts_with(haystack[1])); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text end(STR("else")); + Text not_end(STR("needle")); + Text excess(STR("Really gigantic text that's really really big")); + + CHECK_TRUE(haystack.ends_with(end)); + CHECK_FALSE(haystack.ends_with(not_end)); + CHECK_FALSE(haystack.ends_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(View(STR("else")))); + CHECK_FALSE(haystack.ends_with(View(STR("needle")))); + CHECK_FALSE(haystack.ends_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(STR("else"))); + CHECK_FALSE(haystack.ends_with(STR("needle"))); + CHECK_FALSE(haystack.ends_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(haystack[haystack.size() - 1])); + CHECK_FALSE(haystack.ends_with(haystack[haystack.size() - 2])); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { diff --git a/test/test_string_u32_external_buffer.cpp b/test/test_string_u32_external_buffer.cpp index bdbaf7b2..11858685 100644 --- a/test/test_string_u32_external_buffer.cpp +++ b/test/test_string_u32_external_buffer.cpp @@ -3961,6 +3961,104 @@ namespace CHECK_FALSE(haystack.contains(STR('p'))); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text start(STR("A haystack"), buffer2.data(), buffer2.size()); + Text not_start(STR("a needle"), buffer3.data(), buffer3.size()); + Text excess(STR("Really gigantic text that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.starts_with(start)); + CHECK_FALSE(haystack.starts_with(not_start)); + CHECK_FALSE(haystack.starts_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(View(STR("A haystack")))); + CHECK_FALSE(haystack.starts_with(View(STR("a needle")))); + CHECK_FALSE(haystack.starts_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(STR("A haystack"))); + CHECK_FALSE(haystack.starts_with(STR("a needle"))); + CHECK_FALSE(haystack.starts_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(haystack[0])); + CHECK_FALSE(haystack.starts_with(haystack[1])); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text end(STR("else"), buffer2.data(), buffer2.size()); + Text not_end(STR("needle"), buffer3.data(), buffer3.size()); + Text excess(STR("Really gigantic text that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.ends_with(end)); + CHECK_FALSE(haystack.ends_with(not_end)); + CHECK_FALSE(haystack.ends_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(View(STR("else")))); + CHECK_FALSE(haystack.ends_with(View(STR("needle")))); + CHECK_FALSE(haystack.ends_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(STR("else"))); + CHECK_FALSE(haystack.ends_with(STR("needle"))); + CHECK_FALSE(haystack.ends_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(haystack[haystack.size() - 1])); + CHECK_FALSE(haystack.ends_with(haystack[haystack.size() - 2])); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { diff --git a/test/test_string_u8.cpp b/test/test_string_u8.cpp index 5ce38042..d8d9c6a3 100644 --- a/test/test_string_u8.cpp +++ b/test/test_string_u8.cpp @@ -3661,6 +3661,90 @@ namespace CHECK_FALSE(haystack.contains(STR('p'))); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text start(STR("A haystack")); + Text not_start(STR("a needle")); + Text excess(STR("Really gigantic text that's really really big")); + + CHECK_TRUE(haystack.starts_with(start)); + CHECK_FALSE(haystack.starts_with(not_start)); + CHECK_FALSE(haystack.starts_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(View(STR("A haystack")))); + CHECK_FALSE(haystack.starts_with(View(STR("a needle")))); + CHECK_FALSE(haystack.starts_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(STR("A haystack"))); + CHECK_FALSE(haystack.starts_with(STR("a needle"))); + CHECK_FALSE(haystack.starts_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(haystack[0])); + CHECK_FALSE(haystack.starts_with(haystack[1])); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text end(STR("else")); + Text not_end(STR("needle")); + Text excess(STR("Really gigantic text that's really really big")); + + CHECK_TRUE(haystack.ends_with(end)); + CHECK_FALSE(haystack.ends_with(not_end)); + CHECK_FALSE(haystack.ends_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(View(STR("else")))); + CHECK_FALSE(haystack.ends_with(View(STR("needle")))); + CHECK_FALSE(haystack.ends_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(STR("else"))); + CHECK_FALSE(haystack.ends_with(STR("needle"))); + CHECK_FALSE(haystack.ends_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(haystack[haystack.size() - 1])); + CHECK_FALSE(haystack.ends_with(haystack[haystack.size() - 2])); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { diff --git a/test/test_string_u8_external_buffer.cpp b/test/test_string_u8_external_buffer.cpp index 085f7738..e7613008 100644 --- a/test/test_string_u8_external_buffer.cpp +++ b/test/test_string_u8_external_buffer.cpp @@ -3933,6 +3933,104 @@ namespace CHECK_FALSE(haystack.contains(STR('p'))); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text start(STR("A haystack"), buffer2.data(), buffer2.size()); + Text not_start(STR("a needle"), buffer3.data(), buffer3.size()); + Text excess(STR("Really gigantic text that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.starts_with(start)); + CHECK_FALSE(haystack.starts_with(not_start)); + CHECK_FALSE(haystack.starts_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(View(STR("A haystack")))); + CHECK_FALSE(haystack.starts_with(View(STR("a needle")))); + CHECK_FALSE(haystack.starts_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(STR("A haystack"))); + CHECK_FALSE(haystack.starts_with(STR("a needle"))); + CHECK_FALSE(haystack.starts_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(haystack[0])); + CHECK_FALSE(haystack.starts_with(haystack[1])); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text end(STR("else"), buffer2.data(), buffer2.size()); + Text not_end(STR("needle"), buffer3.data(), buffer3.size()); + Text excess(STR("Really gigantic text that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.ends_with(end)); + CHECK_FALSE(haystack.ends_with(not_end)); + CHECK_FALSE(haystack.ends_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(View(STR("else")))); + CHECK_FALSE(haystack.ends_with(View(STR("needle")))); + CHECK_FALSE(haystack.ends_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(STR("else"))); + CHECK_FALSE(haystack.ends_with(STR("needle"))); + CHECK_FALSE(haystack.ends_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(haystack[haystack.size() - 1])); + CHECK_FALSE(haystack.ends_with(haystack[haystack.size() - 2])); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_find_char_pointer_n) { diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 1a8ed43b..8b3ae997 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -3659,6 +3659,90 @@ namespace CHECK_FALSE(haystack.contains(STR('p'))); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text start(STR("A haystack")); + Text not_start(STR("a needle")); + Text excess(STR("Really gigantic text that's really really big")); + + CHECK_TRUE(haystack.starts_with(start)); + CHECK_FALSE(haystack.starts_with(not_start)); + CHECK_FALSE(haystack.starts_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(View(STR("A haystack")))); + CHECK_FALSE(haystack.starts_with(View(STR("a needle")))); + CHECK_FALSE(haystack.starts_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(STR("A haystack"))); + CHECK_FALSE(haystack.starts_with(STR("a needle"))); + CHECK_FALSE(haystack.starts_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.starts_with(haystack[0])); + CHECK_FALSE(haystack.starts_with(haystack[1])); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_string) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + Text end(STR("else")); + Text not_end(STR("needle")); + Text excess(STR("Really gigantic text that's really really big")); + + CHECK_TRUE(haystack.ends_with(end)); + CHECK_FALSE(haystack.ends_with(not_end)); + CHECK_FALSE(haystack.ends_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_view) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(View(STR("else")))); + CHECK_FALSE(haystack.ends_with(View(STR("needle")))); + CHECK_FALSE(haystack.ends_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_pointer) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(STR("else"))); + CHECK_FALSE(haystack.ends_with(STR("needle"))); + CHECK_FALSE(haystack.ends_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_char) + { + TextL haystack(STR("A haystack with a needle and nothing else")); + + CHECK_TRUE(haystack.ends_with(haystack[haystack.size() - 1])); + CHECK_FALSE(haystack.ends_with(haystack[haystack.size() - 2])); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { diff --git a/test/test_string_wchar_t_external_buffer.cpp b/test/test_string_wchar_t_external_buffer.cpp index 5d277936..7ce900d0 100644 --- a/test/test_string_wchar_t_external_buffer.cpp +++ b/test/test_string_wchar_t_external_buffer.cpp @@ -3964,6 +3964,104 @@ namespace CHECK_FALSE(haystack.contains(STR('p'))); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text start(STR("A haystack"), buffer2.data(), buffer2.size()); + Text not_start(STR("a needle"), buffer3.data(), buffer3.size()); + Text excess(STR("Really gigantic text that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.starts_with(start)); + CHECK_FALSE(haystack.starts_with(not_start)); + CHECK_FALSE(haystack.starts_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(View(STR("A haystack")))); + CHECK_FALSE(haystack.starts_with(View(STR("a needle")))); + CHECK_FALSE(haystack.starts_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(STR("A haystack"))); + CHECK_FALSE(haystack.starts_with(STR("a needle"))); + CHECK_FALSE(haystack.starts_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_starts_with_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.starts_with(haystack[0])); + CHECK_FALSE(haystack.starts_with(haystack[1])); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_string) + { + TextBufferL buffer1{0}; + TextBuffer buffer2{0}; + TextBuffer buffer3{0}; + TextBuffer buffer4{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + Text end(STR("else"), buffer2.data(), buffer2.size()); + Text not_end(STR("needle"), buffer3.data(), buffer3.size()); + Text excess(STR("Really gigantic text that's really really big"), buffer4.data(), buffer4.size()); + + CHECK_TRUE(haystack.ends_with(end)); + CHECK_FALSE(haystack.ends_with(not_end)); + CHECK_FALSE(haystack.ends_with(excess)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_view) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(View(STR("else")))); + CHECK_FALSE(haystack.ends_with(View(STR("needle")))); + CHECK_FALSE(haystack.ends_with(View(STR("Really gigantic text that's really really big")))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_pointer) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(STR("else"))); + CHECK_FALSE(haystack.ends_with(STR("needle"))); + CHECK_FALSE(haystack.ends_with(STR("Really gigantic text that's really really big"))); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_ends_with_char) + { + TextBufferL buffer1{0}; + Text haystack(STR("A haystack with a needle and nothing else"), buffer1.data(), buffer1.size()); + + CHECK_TRUE(haystack.ends_with(haystack[haystack.size() - 1])); + CHECK_FALSE(haystack.ends_with(haystack[haystack.size() - 2])); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_rfind_string) { From 75f7292447dfa80a4499c779d888310b1a5570ef Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 24 Nov 2024 08:53:51 +0000 Subject: [PATCH 08/18] Made construction from std::basic_string_view explicit --- include/etl/string_view.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/etl/string_view.h b/include/etl/string_view.h index 3558d2ef..48c6c75d 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -172,7 +172,7 @@ namespace etl /// Constructor from std::basic string_view //************************************************************************* template - ETL_CONSTEXPR basic_string_view(const std::basic_string_view& other) ETL_NOEXCEPT + explicit ETL_CONSTEXPR basic_string_view(const std::basic_string_view& other) ETL_NOEXCEPT : mbegin(other.data()) , mend(other.data() + other.size()) { From 89123357a60a1d8a986679073e93e559d27266ad Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 24 Nov 2024 08:55:22 +0000 Subject: [PATCH 09/18] Removed remaining std::u8string_view functions --- include/etl/u8string.h | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/include/etl/u8string.h b/include/etl/u8string.h index 009f541e..7510c4f6 100644 --- a/include/etl/u8string.h +++ b/include/etl/u8string.h @@ -186,18 +186,6 @@ namespace etl this->assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP20 - //************************************************************************* - /// From string_view. - ///\param view The string_view. - //************************************************************************* - explicit u8string(const std::u8string_view& view) - : iu8string(reinterpret_cast(&buffer), MAX_SIZE) - { - this->assign(view.begin(), view.end()); - } -#endif - //************************************************************************* /// Returns a sub-u8string. ///\param position The position of the first character. Default = 0. @@ -266,18 +254,6 @@ namespace etl return *this; } -#if ETL_USING_STL && ETL_USING_CPP20 - //************************************************************************* - /// Assignment operator. - //************************************************************************* - u8string& operator = (const std::u8string_view& view) - { - this->assign(view); - - return *this; - } -#endif - //************************************************************************* /// Fix the internal pointers after a low level memory copy. //************************************************************************* @@ -430,18 +406,6 @@ namespace etl this->assign(view.begin(), view.end()); } -#if ETL_USING_STL && ETL_USING_CPP20 - //************************************************************************* - /// From string_view. - ///\param view The string_view. - //************************************************************************* - explicit u8string_ext(const std::u8string_view& view, value_type* buffer, size_type buffer_size) - : iu8string(buffer, buffer_size - 1U) - { - this->assign(view.begin(), view.end()); - } -#endif - //************************************************************************* /// Assignment operator. //************************************************************************* From f566076f42aea4b4e145c03d4fbcbc2ec653057d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 24 Nov 2024 09:01:33 +0000 Subject: [PATCH 10/18] Added member function resize_and_overwrite --- include/etl/basic_string.h | 24 ++++++-- test/test_string_char.cpp | 64 ++++++++++++++++++- test/test_string_char_external_buffer.cpp | 65 +++++++++++++++++++- test/test_string_u16.cpp | 58 +++++++++++++++++ test/test_string_u16_external_buffer.cpp | 39 +++++++++++- test/test_string_u32.cpp | 58 +++++++++++++++++ test/test_string_u32_external_buffer.cpp | 39 +++++++++++- test/test_string_u8.cpp | 58 +++++++++++++++++ test/test_string_u8_external_buffer.cpp | 65 +++++++++++++++++++- test/test_string_wchar_t.cpp | 58 +++++++++++++++++ test/test_string_wchar_t_external_buffer.cpp | 39 +++++++++++- 11 files changed, 550 insertions(+), 17 deletions(-) diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 5cc37f10..9146d523 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -496,6 +496,22 @@ namespace etl cleanup(); } + //********************************************************************* + /// Resizes the string and overwrites to data using the operation. + //********************************************************************* + template + 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. @@ -1532,7 +1548,7 @@ namespace etl //********************************************************************* /// Checks that the string is the start of this string //********************************************************************* - bool starts_with(const ibasic_string& str) const + bool starts_with(const etl::ibasic_string& str) const { return compare(0, str.size(), str) == 0; } @@ -1541,7 +1557,7 @@ namespace etl /// Checks that the view is the start of this string //********************************************************************* template - bool starts_with(const basic_string_view& view) const + bool starts_with(const etl::basic_string_view& view) const { return compare(0, view.size(), view) == 0; } @@ -1567,7 +1583,7 @@ namespace etl //********************************************************************* /// Checks that the string is the end of this string //********************************************************************* - bool ends_with(const ibasic_string& str) const + bool ends_with(const etl::ibasic_string& str) const { if (str.size() > size()) { @@ -1581,7 +1597,7 @@ namespace etl /// Checks that the view is the end of this string //********************************************************************* template - bool ends_with(const basic_string_view& view) const + bool ends_with(const etl::basic_string_view& view) const { if (view.size() > size()) { diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 5c1e0c99..7c118ff8 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -725,7 +725,7 @@ namespace bool is_equal = Equal(compare_text, text); CHECK(is_equal); - CHECK_EQUAL(text.size(), NEW_SIZE); + CHECK_EQUAL(NEW_SIZE, text.size()); } //************************************************************************* @@ -738,7 +738,7 @@ namespace text.uninitialized_resize(NEW_SIZE); - CHECK_EQUAL(text.size(), SIZE); + CHECK_EQUAL(SIZE, text.size()); } //************************************************************************* @@ -766,7 +766,65 @@ namespace bool is_equal = Equal(compare_text, text); CHECK(is_equal); - CHECK_EQUAL(text.size(), NEW_SIZE); + CHECK_EQUAL(NEW_SIZE, text.size()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 8UL; + + Text text(initial_text.c_str(), INITIAL_SIZE); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) noexcept + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H234567")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_down) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 3UL; + + Text text(initial_text.c_str(), INITIAL_SIZE); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H2")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up_excess) + { + Text text(initial_text.c_str(), initial_text.size()); + + CHECK_THROW(text.resize_and_overwrite(text.capacity() + 1, [](Text::pointer /*p*/, size_t n) { return n; }), etl::string_out_of_bounds); } //************************************************************************* diff --git a/test/test_string_char_external_buffer.cpp b/test/test_string_char_external_buffer.cpp index 4ef70851..3eb26da5 100644 --- a/test/test_string_char_external_buffer.cpp +++ b/test/test_string_char_external_buffer.cpp @@ -919,6 +919,67 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 8UL; + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), INITIAL_SIZE, buffer.data(), buffer.size()); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) noexcept + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H234567")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_down) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 3UL; + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), INITIAL_SIZE, buffer.data(), buffer.size()); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H2")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up_excess) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), initial_text.size(), buffer.data(), buffer.size()); + + CHECK_THROW(text.resize_and_overwrite(text.capacity() + 1, [](Text::pointer /*p*/, size_t n) { return n; }), etl::string_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { @@ -1737,7 +1798,7 @@ namespace for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; + TextBuffer buffer{0}; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1762,7 +1823,7 @@ namespace for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; + TextBuffer buffer{0}; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); View view(insert_text.data(), insert_text.size()); diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index f7565b01..37465e2a 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -783,6 +783,64 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 8UL; + + Text text(initial_text.c_str(), INITIAL_SIZE); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) noexcept + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H234567")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_down) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 3UL; + + Text text(initial_text.c_str(), INITIAL_SIZE); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) noexcept + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H2")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up_excess) + { + Text text(initial_text.c_str(), initial_text.size()); + + CHECK_THROW(text.resize_and_overwrite(text.capacity() + 1, [](Text::pointer /*p*/, size_t n) { return n; }), etl::string_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_fill) { diff --git a/test/test_string_u16_external_buffer.cpp b/test/test_string_u16_external_buffer.cpp index b15a4772..c94fdad0 100644 --- a/test/test_string_u16_external_buffer.cpp +++ b/test/test_string_u16_external_buffer.cpp @@ -933,6 +933,41 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_down) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 3UL; + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), INITIAL_SIZE, buffer.data(), buffer.size()); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H2")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up_excess) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), initial_text.size(), buffer.data(), buffer.size()); + + CHECK_THROW(text.resize_and_overwrite(text.capacity() + 1, [](Text::pointer /*p*/, size_t n) { return n; }), etl::string_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { @@ -1751,7 +1786,7 @@ namespace for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; + TextBuffer buffer{0}; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1776,7 +1811,7 @@ namespace for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; + TextBuffer buffer{0}; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); View view(insert_text.data(), insert_text.size()); diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index b27fcaff..b72ef01e 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -783,6 +783,64 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 8UL; + + Text text(initial_text.c_str(), INITIAL_SIZE); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) noexcept + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H234567")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_down) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 3UL; + + Text text(initial_text.c_str(), INITIAL_SIZE); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) noexcept + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H2")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up_excess) + { + Text text(initial_text.c_str(), initial_text.size()); + + CHECK_THROW(text.resize_and_overwrite(text.capacity() + 1, [](Text::pointer /*p*/, size_t n) { return n; }), etl::string_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_fill) { diff --git a/test/test_string_u32_external_buffer.cpp b/test/test_string_u32_external_buffer.cpp index 11858685..f5e25510 100644 --- a/test/test_string_u32_external_buffer.cpp +++ b/test/test_string_u32_external_buffer.cpp @@ -933,6 +933,41 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_down) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 3UL; + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), INITIAL_SIZE, buffer.data(), buffer.size()); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H2")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up_excess) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), initial_text.size(), buffer.data(), buffer.size()); + + CHECK_THROW(text.resize_and_overwrite(text.capacity() + 1, [](Text::pointer /*p*/, size_t n) { return n; }), etl::string_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { @@ -1751,7 +1786,7 @@ namespace for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; + TextBuffer buffer{0}; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1776,7 +1811,7 @@ namespace for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; + TextBuffer buffer{0}; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); View view(insert_text.data(), insert_text.size()); diff --git a/test/test_string_u8.cpp b/test/test_string_u8.cpp index d8d9c6a3..e3d5c1fa 100644 --- a/test/test_string_u8.cpp +++ b/test/test_string_u8.cpp @@ -786,6 +786,64 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 8UL; + + Text text(initial_text.c_str(), INITIAL_SIZE); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) noexcept + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H234567")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_down) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 3UL; + + Text text(initial_text.c_str(), INITIAL_SIZE); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) noexcept + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H2")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up_excess) + { + Text text(initial_text.c_str(), initial_text.size()); + + CHECK_THROW(text.resize_and_overwrite(text.capacity() + 1, [](Text::pointer /*p*/, size_t n) { return n; }), etl::string_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_fill) { diff --git a/test/test_string_u8_external_buffer.cpp b/test/test_string_u8_external_buffer.cpp index e7613008..5f64fb37 100644 --- a/test/test_string_u8_external_buffer.cpp +++ b/test/test_string_u8_external_buffer.cpp @@ -936,6 +936,67 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 8UL; + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), INITIAL_SIZE, buffer.data(), buffer.size()); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) noexcept + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H234567")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_down) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 3UL; + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), INITIAL_SIZE, buffer.data(), buffer.size()); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H2")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up_excess) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), initial_text.size(), buffer.data(), buffer.size()); + + CHECK_THROW(text.resize_and_overwrite(text.capacity() + 1, [](Text::pointer /*p*/, size_t n) { return n; }), etl::string_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { @@ -1754,7 +1815,7 @@ namespace for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; + TextBuffer buffer{0}; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1779,7 +1840,7 @@ namespace for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; + TextBuffer buffer{0}; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); View view(insert_text.data(), insert_text.size()); diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 8b3ae997..81b2d8bb 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -784,6 +784,64 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 8UL; + + Text text(initial_text.c_str(), INITIAL_SIZE); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) noexcept + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H234567")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_down) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 3UL; + + Text text(initial_text.c_str(), INITIAL_SIZE); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) noexcept + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H2")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up_excess) + { + Text text(initial_text.c_str(), initial_text.size()); + + CHECK_THROW(text.resize_and_overwrite(text.capacity() + 1, [](Text::pointer /*p*/, size_t n) { return n; }), etl::string_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_fill) { diff --git a/test/test_string_wchar_t_external_buffer.cpp b/test/test_string_wchar_t_external_buffer.cpp index 7ce900d0..886c7b70 100644 --- a/test/test_string_wchar_t_external_buffer.cpp +++ b/test/test_string_wchar_t_external_buffer.cpp @@ -936,6 +936,41 @@ namespace CHECK_EQUAL(text.size(), NEW_SIZE); } + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_down) + { + const size_t INITIAL_SIZE = 5UL; + const size_t NEW_SIZE = 3UL; + + TextBuffer buffer{0}; + Text text(initial_text.c_str(), INITIAL_SIZE, buffer.data(), buffer.size()); + + // Overwrite from index 1 to one less than the new size and set to that size. + text.resize_and_overwrite(NEW_SIZE, [](Text::pointer p, size_t n) + { + size_t i = 1; + while (i < (n - 1)) + { + p[i] = '1' + Text::value_type(i); + ++i; + } + + return i; + }); + + CHECK_EQUAL(NEW_SIZE - 1, text.size()); + CHECK_TRUE(Equal(TextSTD(STR("H2")), text)); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_resize_and_overwrite_up_excess) + { + TextBuffer buffer{0}; + Text text(initial_text.c_str(), initial_text.size(), buffer.data(), buffer.size()); + + CHECK_THROW(text.resize_and_overwrite(text.capacity() + 1, [](Text::pointer /*p*/, size_t n) { return n; }), etl::string_out_of_bounds); + } + //************************************************************************* TEST_FIXTURE(SetupFixture, test_empty_full) { @@ -1754,7 +1789,7 @@ namespace for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; + TextBuffer buffer{0}; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); @@ -1779,7 +1814,7 @@ namespace for (size_t offset = 0UL; offset <= short_text.size(); ++offset) { TextSTD compare_text(short_text.cbegin(), short_text.cend()); - TextBuffer buffer; + TextBuffer buffer{0}; buffer.fill(0); Text text(short_text.begin(), short_text.end(), buffer.data(), buffer.size()); View view(insert_text.data(), insert_text.size()); From 705b6b1baebc75c00da6b5351d9e3744070a7445 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 24 Nov 2024 15:01:38 +0000 Subject: [PATCH 11/18] Added contains member function to string_view --- include/etl/string_view.h | 25 +++++++++++++++++++++++++ test/test_string_view.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/include/etl/string_view.h b/include/etl/string_view.h index 48c6c75d..af261924 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -763,6 +763,31 @@ namespace etl return find_last_not_of(etl::basic_string_view(text), position); } + //********************************************************************* + /// Checks that the view is within this string + //********************************************************************* + template + bool contains(const etl::basic_string_view& 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. //************************************************************************* diff --git a/test/test_string_view.cpp b/test/test_string_view.cpp index 27713f89..bc9404e6 100644 --- a/test/test_string_view.cpp +++ b/test/test_string_view.cpp @@ -822,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) { From fe47f91a8df78edd7742d29f606cfa77ea8229fe Mon Sep 17 00:00:00 2001 From: David Hebbeker Date: Sun, 24 Nov 2024 16:09:57 +0100 Subject: [PATCH 12/18] Added basic guidelines for contributing code (#976) * Update README.md * Apply instructions for pull requests from Slack to new CONTRIBUTING guideline file. I copied the [message in Slack](https://etlcpp.slack.com/archives/C7SJ45VFB/p1729596737002559) from @jwellbelove into a new file for [contributing guidelines](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/setting-guidelines-for-repository-contributors). This way a starting point for potential contributors is delivered next to the source code. * Added hint for the starting point for contributing commits. I derived this rule from https://github.com/ETLCPP/etl/issues/802#issuecomment-2323530862 --------- Co-authored-by: John Wellbelove --- CONTRIBUTING.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..56ce976d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,10 @@ +# How to contribute + +If your are considering creating a pull request, please observe the following: + +- If you are adding or modifying a feature, add *new* unit tests that test that feature. +- If you are fixing a bug, add a unit test that *fails* before the bug fix is implemented. +- Do not initiate a pull request until all of the units tests pass. +- Branches should be based on the branch `master`. + +There is a project file for VS2022 for C++14, 17, 20, and bash scripts that run the tests for C++11, 14, 17, 20 under Linux with GCC and Clang. From 27c20931102cd63d7a1962f89ccd0c17644dbe1d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 24 Nov 2024 15:33:21 +0000 Subject: [PATCH 13/18] Added CONTRIBUTING.md to the VS2022 project files. --- test/vs2022/etl.vcxproj | 1 + test/vs2022/etl.vcxproj.filters | 3 +++ 2 files changed, 4 insertions(+) diff --git a/test/vs2022/etl.vcxproj b/test/vs2022/etl.vcxproj index 7506cfa1..daac6aea 100644 --- a/test/vs2022/etl.vcxproj +++ b/test/vs2022/etl.vcxproj @@ -9031,6 +9031,7 @@ + diff --git a/test/vs2022/etl.vcxproj.filters b/test/vs2022/etl.vcxproj.filters index 2da095b9..8344c20b 100644 --- a/test/vs2022/etl.vcxproj.filters +++ b/test/vs2022/etl.vcxproj.filters @@ -3541,6 +3541,9 @@ Tests\Scripts + + Resource Files + From 962264e0b1072b52760bcecc1c41b7292b6e966f Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 27 Nov 2024 16:35:09 +0000 Subject: [PATCH 14/18] Changed case for script header --- test/run-tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/run-tests.sh b/test/run-tests.sh index cb5a9d12..4b45ba3b 100644 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -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 #****************************************************************************** From 2b0690928f199be316e44274843e876bd24c53c2 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 27 Nov 2024 16:36:00 +0000 Subject: [PATCH 15/18] Fixed possible null dereference for etl::multi_span operator -> --- include/etl/multi_span.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/etl/multi_span.h b/include/etl/multi_span.h index 8e974ee3..4d93df42 100644 --- a/include/etl/multi_span.h +++ b/include/etl/multi_span.h @@ -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; } //************************************************************************* From ec3d20695b3eb6bf26c902200b71c9abfd34a2e8 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 27 Nov 2024 16:36:35 +0000 Subject: [PATCH 16/18] Fixed shadowing warnings --- include/etl/basic_string.h | 88 +++++++++++++++++++------------------- include/etl/string_view.h | 7 ++- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 9146d523..f590c948 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -717,8 +717,8 @@ namespace etl //********************************************************************* /// Assigns values to the string from a view. //********************************************************************* - template - void assign(const etl::basic_string_view& view) + template + void assign(const etl::basic_string_view& view) { assign(view.begin(), view.end()); } @@ -877,8 +877,8 @@ namespace etl /// Appends to the string. ///\param view An etl::string_view. //********************************************************************* - template - ibasic_string& append(const etl::basic_string_view& view) + template + ibasic_string& append(const etl::basic_string_view& view) { insert(end(), view.begin(), view.end()); return *this; @@ -1120,8 +1120,8 @@ namespace etl ///\param position The position to insert before. ///\param view The view element to add. //********************************************************************* - template - iterator insert(const_iterator position, const etl::basic_string_view& view) + template + iterator insert(const_iterator position, const etl::basic_string_view& view) { return insert(position, view.begin(), view.end()); } @@ -1156,8 +1156,8 @@ namespace etl ///\param position The position to insert before. ///\param view The view to insert. //********************************************************************* - template - etl::ibasic_string& insert(size_type position, const etl::basic_string_view& view) + template + etl::ibasic_string& insert(size_type position, const etl::basic_string_view& view) { ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); @@ -1206,8 +1206,8 @@ namespace etl ///\param subposition The subposition to start from. ///\param sublength The number of characters to insert. //********************************************************************* - template - etl::ibasic_string& insert(size_type position, const etl::basic_string_view& view, size_type subposition, size_type sublength) + template + etl::ibasic_string& insert(size_type position, const etl::basic_string_view& 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)); @@ -1387,8 +1387,8 @@ namespace etl ///\param view The content to find ///\param pos The position to start searching from. //********************************************************************* - template - size_type find(const etl::basic_string_view& view, size_type pos = 0) const + template + size_type find(const etl::basic_string_view& view, size_type pos = 0) const { return find_impl(view.begin(), view.end(), view.size(), pos); } @@ -1452,8 +1452,8 @@ namespace etl ///\param view The content to find ///\param pos The position to start searching from. //********************************************************************* - template - size_type rfind(const etl::basic_string_view& view, size_type pos = 0) const + template + size_type rfind(const etl::basic_string_view& view, size_type pos = 0) const { return rfind_impl(view.rbegin(), view.rend(), view.size(), pos); } @@ -1523,8 +1523,8 @@ namespace etl //********************************************************************* /// Checks that the view is within this string //********************************************************************* - template - bool contains(const etl::basic_string_view& view) const + template + bool contains(const etl::basic_string_view& view) const { return find(view) != npos; } @@ -1556,8 +1556,8 @@ namespace etl //********************************************************************* /// Checks that the view is the start of this string //********************************************************************* - template - bool starts_with(const etl::basic_string_view& view) const + template + bool starts_with(const etl::basic_string_view& view) const { return compare(0, view.size(), view) == 0; } @@ -1596,8 +1596,8 @@ namespace etl //********************************************************************* /// Checks that the view is the end of this string //********************************************************************* - template - bool ends_with(const etl::basic_string_view& view) const + template + bool ends_with(const etl::basic_string_view& view) const { if (view.size() > size()) { @@ -1658,8 +1658,8 @@ namespace etl ///\param length The number of characters to replace. ///\param view The string to replace it with. //********************************************************************* - template - ibasic_string& replace(size_type position, size_type length_, const etl::basic_string_view& view) + template + ibasic_string& replace(size_type position, size_type length_, const etl::basic_string_view& view) { ETL_ASSERT(position <= size(), ETL_ERROR(string_out_of_bounds)); @@ -1713,8 +1713,8 @@ namespace etl ///\param last The one after the position to end at. ///\param view The string view to replace it with. //********************************************************************* - template - ibasic_string& replace(const_iterator first, const_iterator last, const etl::basic_string_view& view) + template + ibasic_string& replace(const_iterator first, const_iterator last, const etl::basic_string_view& view) { // Quick hack, as iterators are pointers. iterator first_ = to_iterator(first); @@ -1764,8 +1764,8 @@ namespace etl //********************************************************************* /// Replace characters from 'position' of 'length' with 'view' from 'subposition' of 'sublength'. //********************************************************************* - template - ibasic_string& replace(size_type position, size_type length_, const etl::basic_string_view& view, size_type subposition, size_type sublength) + template + ibasic_string& replace(size_type position, size_type length_, const etl::basic_string_view& 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)); @@ -1927,8 +1927,8 @@ namespace etl //************************************************************************* /// Compare with etl::basic_string_view. //************************************************************************* - template - int compare(const etl::basic_string_view& view) const + template + int compare(const etl::basic_string_view& view) const { return compare(p_buffer, p_buffer + size(), @@ -1955,8 +1955,8 @@ namespace etl //************************************************************************* /// Compare position / length with etl::basic_string_view. //************************************************************************* - template - int compare(size_type position, size_type length_, const etl::basic_string_view& view) const + template + int compare(size_type position, size_type length_, const etl::basic_string_view& view) const { return compare(p_buffer + position, p_buffer + position + length_, @@ -1985,8 +1985,8 @@ namespace etl //************************************************************************* /// Compare position / length with etl::basic_string_view. / subposition / sublength. //************************************************************************* - template - int compare(size_type position, size_type length_, const etl::basic_string_view& view, size_type subposition, size_type sublength) const + template + int compare(size_type position, size_type length_, const etl::basic_string_view& 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)); @@ -2059,8 +2059,8 @@ namespace etl ///\param view The content to find ///\param pos The position to start searching from. //********************************************************************* - template - size_type find_first_of(const etl::basic_string_view& view, size_type position = 0) const + template + size_type find_first_of(const etl::basic_string_view& view, size_type position = 0) const { return find_first_of(view.data(), position, view.size()); } @@ -2136,8 +2136,8 @@ namespace etl ///\param view The content to find ///\param pos The position to start searching from. //********************************************************************* - template - size_type find_last_of(const etl::basic_string_view& view, size_type position = npos) const + template + size_type find_last_of(const etl::basic_string_view& view, size_type position = npos) const { return find_last_of(view.data(), position, view.size()); } @@ -2231,8 +2231,8 @@ namespace etl ///\param view The content to find ///\param pos The position to start searching from. //********************************************************************* - template - size_type find_first_not_of(const etl::basic_string_view& view, size_type position = 0) const + template + size_type find_first_not_of(const etl::basic_string_view& view, size_type position = 0) const { return find_first_not_of(view.data(), position, view.size()); } @@ -2315,8 +2315,8 @@ namespace etl ///\param view The content to find ///\param pos The position to start searching from. //********************************************************************* - template - size_type find_last_not_of(const etl::basic_string_view& view, size_type position = npos) const + template + size_type find_last_not_of(const etl::basic_string_view& view, size_type position = npos) const { return find_last_not_of(view.data(), position, view.size()); } @@ -2416,8 +2416,8 @@ namespace etl //************************************************************************* /// Assignment operator. //************************************************************************* - template - ibasic_string& operator = (const etl::basic_string_view& view) + template + ibasic_string& operator = (const etl::basic_string_view& view) { assign(view); @@ -2437,8 +2437,8 @@ namespace etl //************************************************************************* /// += operator. //************************************************************************* - template - ibasic_string& operator += (const etl::basic_string_view& rhs) + template + ibasic_string& operator += (const etl::basic_string_view& rhs) { append(rhs); diff --git a/include/etl/string_view.h b/include/etl/string_view.h index af261924..7b60d839 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -100,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; @@ -766,7 +766,6 @@ namespace etl //********************************************************************* /// Checks that the view is within this string //********************************************************************* - template bool contains(const etl::basic_string_view& view) const { return find(view) != npos; From 9cd2d463ac3473caf055873bddb7a73a138f9a54 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 29 Nov 2024 18:53:44 +0000 Subject: [PATCH 17/18] Removed using directive in derived message router classes. --- .gitignore | 3 + .../QueuedMessageRouter.cpp | 2 - .../QueuedMessageRouter.sln | 0 .../QueuedMessageRouter.vcxproj | 8 +- test/test_message_router.cpp | 93 +++++++++++++++++++ 5 files changed, 100 insertions(+), 6 deletions(-) rename examples/QueuedMessageRouter/{vs2019 => vs2022}/QueuedMessageRouter.sln (100%) rename examples/QueuedMessageRouter/{vs2019 => vs2022}/QueuedMessageRouter.vcxproj (97%) diff --git a/.gitignore b/.gitignore index 8f313ddb..6ca19e11 100644 --- a/.gitignore +++ b/.gitignore @@ -388,3 +388,6 @@ support/time remaining test.xlsx test/vs2022/Debug MSVC C++20 - Force C++03 test/vs2022/Release MSVC C++20 - No STL - Optimised -O2 - Sanitiser test/test_file_list.txt +examples/QueuedMessageRouter/vs2022/.vs/QueuedMessageRouter/CopilotIndices +examples/QueuedMessageRouter/vs2022/.vs/QueuedMessageRouter/FileContentIndex +examples/QueuedMessageRouter/vs2022/.vs/QueuedMessageRouter/v17 diff --git a/examples/QueuedMessageRouter/QueuedMessageRouter.cpp b/examples/QueuedMessageRouter/QueuedMessageRouter.cpp index d4f78f77..f4348e5e 100644 --- a/examples/QueuedMessageRouter/QueuedMessageRouter.cpp +++ b/examples/QueuedMessageRouter/QueuedMessageRouter.cpp @@ -52,8 +52,6 @@ public: typedef etl::message_router Base_t; - using Base_t::receive; - //*************************************************************************** Router() : message_router(1) diff --git a/examples/QueuedMessageRouter/vs2019/QueuedMessageRouter.sln b/examples/QueuedMessageRouter/vs2022/QueuedMessageRouter.sln similarity index 100% rename from examples/QueuedMessageRouter/vs2019/QueuedMessageRouter.sln rename to examples/QueuedMessageRouter/vs2022/QueuedMessageRouter.sln diff --git a/examples/QueuedMessageRouter/vs2019/QueuedMessageRouter.vcxproj b/examples/QueuedMessageRouter/vs2022/QueuedMessageRouter.vcxproj similarity index 97% rename from examples/QueuedMessageRouter/vs2019/QueuedMessageRouter.vcxproj rename to examples/QueuedMessageRouter/vs2022/QueuedMessageRouter.vcxproj index 65dad150..eaacbe96 100644 --- a/examples/QueuedMessageRouter/vs2019/QueuedMessageRouter.vcxproj +++ b/examples/QueuedMessageRouter/vs2022/QueuedMessageRouter.vcxproj @@ -29,26 +29,26 @@ Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode diff --git a/test/test_message_router.cpp b/test/test_message_router.cpp index b5936d62..a4e600fd 100644 --- a/test/test_message_router.cpp +++ b/test/test_message_router.cpp @@ -253,6 +253,77 @@ namespace int sender_id; }; + //*************************************************************************** + // Router that handles messages 1, 2, 3. + // 'receive' is overridden. + //*************************************************************************** + class Router3 : public etl::message_router + { + public: + + using base = etl::message_router; + + Router3() + : message_router(ROUTER3) + , message1_received(false) + , message2_received(false) + , message3_received(false) + , unknown_message_received(false) + { + } + + void receive(const etl::imessage& msg) override + { + switch (msg.get_message_id()) + { + case MESSAGE1: + { + message1_received = true; + break; + } + + case MESSAGE2: + { + message2_received = true; + break; + } + + case MESSAGE3: + { + message3_received = true; + break; + } + + default: + { + unknown_message_received = true; + break; + } + } + } + + void on_receive(const Message1& msg) + { + } + + void on_receive(const Message2& msg) + { + } + + void on_receive(const Message3& msg) + { + } + + void on_receive_unknown(const etl::imessage&) + { + } + + bool message1_received; + bool message2_received; + bool message3_received; + bool unknown_message_received; + }; + etl::imessage_router* p_router; SUITE(test_message_router) @@ -641,5 +712,27 @@ namespace CHECK_EQUAL(0, r1.message4_count); CHECK_EQUAL(0, r1.message_unknown_count); } + + //************************************************************************* + TEST(message_router_with_overloaded_receive) + { + Router3 router; + etl::imessage_router& irouter = router; + + Message1 message1(router); + Message2 message2(router); + Message3 message3(router); + + router.receive(message1); + CHECK_TRUE(router.message1_received); + + router.receive(message2); + CHECK_TRUE(router.message2_received); + + router.receive(message3); + CHECK_TRUE(router.message3_received); + + CHECK_FALSE(router.unknown_message_received); + } }; } From d53ff4ff053917d53af15a481415657185d39709 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 29 Nov 2024 18:53:44 +0000 Subject: [PATCH 18/18] Removed using directive in derived message router classes. --- test/test_message_router.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_message_router.cpp b/test/test_message_router.cpp index a4e600fd..938a0854 100644 --- a/test/test_message_router.cpp +++ b/test/test_message_router.cpp @@ -717,7 +717,6 @@ namespace TEST(message_router_with_overloaded_receive) { Router3 router; - etl::imessage_router& irouter = router; Message1 message1(router); Message2 message2(router);