diff --git a/array.h b/array.h index 7a4aa238..6d62c4cf 100644 --- a/array.h +++ b/array.h @@ -83,7 +83,7 @@ namespace etl { private: - typedef typename parameter_type::value || is_pointer::value>::type parameter_t; + typedef typename parameter_type::type parameter_t; public: diff --git a/bitset.h b/bitset.h index 9713e895..fe6c29ba 100644 --- a/bitset.h +++ b/bitset.h @@ -213,11 +213,22 @@ namespace etl /// Set the bit at the position. //************************************************************************* bitset& set(size_t position, bool value = true) - { + { if (position < N) { - size_t index = position / BITS_PER_ELEMENT; - element_type bit = element_type(1) << position % BITS_PER_ELEMENT; + size_t index; + element_type bit; + + if (ARRAY_SIZE == 1) + { + index = 0; + bit = element_type(1) << position; + } + else + { + index = position / BITS_PER_ELEMENT; + bit = element_type(1) << position % BITS_PER_ELEMENT; + } if (value) { @@ -248,8 +259,19 @@ namespace etl { if (position < N) { - size_t index = position / BITS_PER_ELEMENT; - element_type bit = element_type(1) << position % BITS_PER_ELEMENT; + size_t index; + element_type bit; + + if (ARRAY_SIZE == 1) + { + index = 0; + bit = element_type(1) << position; + } + else + { + index = position / BITS_PER_ELEMENT; + bit = element_type(1) << position % BITS_PER_ELEMENT; + } data[index] &= ~bit; } @@ -279,8 +301,20 @@ namespace etl { if (position < N) { - size_t index = position / BITS_PER_ELEMENT; - element_type bit = element_type(1) << position % BITS_PER_ELEMENT; + size_t index; + element_type bit; + + if (ARRAY_SIZE == 1) + { + index = 0; + bit = element_type(1) << position; + } + else + { + index = position / BITS_PER_ELEMENT; + bit = element_type(1) << position % BITS_PER_ELEMENT; + } + data[index] ^= bit; } @@ -311,19 +345,21 @@ namespace etl { if (position < N) { + size_t index; + element_type bit; + if (ARRAY_SIZE == 1) { - element_type bit = element_type(1) << position % BITS_PER_ELEMENT; - - return (data[0] & bit) != 0; + index = 0; + bit = element_type(1) << position; } else { - size_t index = position / BITS_PER_ELEMENT; - element_type bit = element_type(1) << position % BITS_PER_ELEMENT; - - return (data[index] & bit) != 0; + index = position / BITS_PER_ELEMENT; + bit = element_type(1) << position % BITS_PER_ELEMENT; } + + return (data[index] & bit) != 0; } else { diff --git a/cyclic_value.h b/cyclic_value.h index 94302e54..90be5006 100644 --- a/cyclic_value.h +++ b/cyclic_value.h @@ -42,47 +42,15 @@ SOFTWARE. namespace etl { -#ifdef ETL_USE_EXCEPTIONS - //*************************************************************************** - ///\ingroup cyclic_value - /// The base class for cyclic_value exceptions. - //*************************************************************************** - class cyclic_value_exception : public exception - { - public: - - cyclic_value_exception(const char* what) - : exception(what) - { - } - }; - - //*************************************************************************** - ///\ingroup cyclic_value - /// The illegal range exception. - //*************************************************************************** - class cyclic_value_illegal_range : public cyclic_value_exception - { - public: - - cyclic_value_illegal_range() - : cyclic_value_exception("cyclic_value illegal range") - { - } - }; -#endif - //*************************************************************************** /// Provides a value that cycles between two limits. /// Supports incrementing and decrementing. ///\tparam T The type of the variable. ///\tparam FIRST The first value of the range. ///\tparam LAST The last value of the range. - ///\tparam STEP The amount to increment or decrement. Default = 1. - ///\note LAST - FIRST + 1 must be a multiple of STEP. ///\ingroup cyclic_value //*************************************************************************** - template + template class cyclic_value { public: @@ -95,10 +63,8 @@ namespace etl cyclic_value() : value(FIRST), first_value(FIRST), - last_value(LAST), - step_value(STEP) + last_value(LAST) { - STATIC_ASSERT(((LAST - FIRST + 1) % STEP) == 0, "LAST - FIRST + 1 is not a multiple of STEP"); } //************************************************************************* @@ -110,45 +76,21 @@ namespace etl cyclic_value(const T& first_, const T& last_) : value(first_), first_value(first_), - last_value(last_), - step_value(STEP) + last_value(last_) { } - //************************************************************************* - /// Constructor. - /// Sets the value to the first of the range. - ///\param first The first value in the range. - ///\param last The last value in the range. - //************************************************************************* - cyclic_value(const T& first_, const T& last_, const T& step_) - : value(first_), - first_value(first_), - last_value(last_), - step_value(step_) - { - } - //************************************************************************* /// Sets the range. /// Sets the value to the first of the range. ///\param first The first value in the range. ///\param last The last value in the range. - ///\param step The step value. Default = 1. - //************************************************************************* - void set(const T& first_, const T& last_, const T& step_ = 1) + //************************************************************************* + void set(const T& first_, const T& last_) { first_value = first_; last_value = last_; - step_value = step_; value = first_; - -#if ETL_USE_EXCEPTIONS - if (((last_value - first_value + 1) % step_value) != 0) - { - throw cyclic_value_illegal_range(); - } -#endif } //************************************************************************* @@ -218,7 +160,7 @@ namespace etl } else { - value += step_value; + ++value; } return *this; @@ -247,7 +189,7 @@ namespace etl } else { - value -= step_value; + --value; } return *this; @@ -281,28 +223,11 @@ namespace etl return last_value; } - //************************************************************************* - /// Gets the last value. - //************************************************************************* - const T& step() const - { - return step_value; - } - - //************************************************************************* - /// Gets the number of steps in a cycle. - //************************************************************************* - size_t number_of_steps() const - { - return (last_value - first_value + 1) / step_value; - } - private: T value; ///< The current value. T first_value; ///< The first value in the range. T last_value; ///< The last value in the range. - T step_value; ///< The value to step. }; } diff --git a/ideque.h b/ideque.h index 66389348..e464e153 100644 --- a/ideque.h +++ b/ideque.h @@ -59,7 +59,7 @@ namespace etl protected: - typedef typename parameter_type::value || is_pointer::value>::type parameter_t; + typedef typename parameter_type::type parameter_t; //************************************************************************* /// Test for an iterator. diff --git a/iqueue.h b/iqueue.h index 8ffe35ee..826f46de 100644 --- a/iqueue.h +++ b/iqueue.h @@ -54,68 +54,19 @@ namespace etl { public: - typedef queue_base::size_type size_type; ///< The type used for determining the size of the queue. typedef T value_type; ///< The type stored in the queue. typedef T& reference; ///< A reference to the type used in the queue. typedef const T& const_reference; ///< A const reference to the type used in the queue. typedef T* pointer; ///< A pointer to the type used in the queue. typedef const T* const_pointer; ///< A const pointer to the type used in the qu + typedef queue_base::size_type size_type; ///< The type used for determining the size of the queue. private: - typedef typename parameter_type::value || is_pointer::value>::type parameter_t; + typedef typename parameter_type::type parameter_t; public: - //************************************************************************* - /// Adds an item to the queue. - /// If ETL_USE_EXCEPTIONS is defined, throws an etl::queue_full is the queue is already full, - /// otherwise does nothing if full. - ///\param item The item to push to the queue. - //************************************************************************* - void push(parameter_t item) - { - if (!full()) - { - buffer[in] = item; - in = (in == (MAX_SIZE - 1)) ? 0 : in + 1; - ++current_size; - } -#ifdef ETL_USE_EXCEPTIONS - else - { - throw queue_full(); - } -#endif - } - - //************************************************************************* - /// Allows a possibly more efficient 'push' by moving to the next input item - /// and returning a reference to it. - /// This may eliminate a copy by allowing direct construction in-place.
- /// If ETL_USE_EXCEPTIONS is defined, throws an etl::queue_full is the queue is already full, - /// otherwise does nothing if full. - /// \return A reference to the position to 'push' to. - //************************************************************************* - reference push() - { - const size_type next = in; - - if (!full()) - { - in = (in == (MAX_SIZE - 1)) ? 0 : in + 1; - ++current_size; - } -#ifdef ETL_USE_EXCEPTIONS - else - { - throw queue_full(); - } -#endif - - return buffer[next]; - } - //************************************************************************* /// Gets a reference to the item at the front of the queue.
/// If ETL_USE_EXCEPTIONS is defined, throws an etl::queue_empty if the queue is empty.
@@ -188,6 +139,55 @@ namespace etl return buffer[in == 0 ? MAX_SIZE - 1 : in - 1]; } + //************************************************************************* + /// Adds an item to the queue. + /// If ETL_USE_EXCEPTIONS is defined, throws an etl::queue_full is the queue is already full, + /// otherwise does nothing if full. + ///\param item The item to push to the queue. + //************************************************************************* + void push(parameter_t item) + { + if (!full()) + { + buffer[in] = item; + in = (in == (MAX_SIZE - 1)) ? 0 : in + 1; + ++current_size; + } +#ifdef ETL_USE_EXCEPTIONS + else + { + throw queue_full(); + } +#endif + } + + //************************************************************************* + /// Allows a possibly more efficient 'push' by moving to the next input item + /// and returning a reference to it. + /// This may eliminate a copy by allowing direct construction in-place.
+ /// If ETL_USE_EXCEPTIONS is defined, throws an etl::queue_full is the queue is already full, + /// otherwise does nothing if full. + /// \return A reference to the position to 'push' to. + //************************************************************************* + reference push() + { + const size_type next = in; + + if (!full()) + { + in = (in == (MAX_SIZE - 1)) ? 0 : in + 1; + ++current_size; + } +#ifdef ETL_USE_EXCEPTIONS + else + { + throw queue_full(); + } +#endif + + return buffer[next]; + } + protected: //************************************************************************* diff --git a/istack.h b/istack.h index 03d2dc2e..9520b293 100644 --- a/istack.h +++ b/istack.h @@ -54,19 +54,37 @@ namespace etl { public: - typedef stack_base::size_type size_type; ///< The type used for determining the size of the stack. typedef T value_type; ///< The type stored in the stack. typedef T& reference; ///< A reference to the type used in the stack. typedef const T& const_reference; ///< A const reference to the type used in the stack. typedef T* pointer; ///< A pointer to the type used in the stack. typedef const T* const_pointer; ///< A const pointer to the type used in the stack. + typedef stack_base::size_type size_type; ///< The type used for determining the size of the stack. private: - typedef typename parameter_type::value || is_pointer::value>::type parameter_t; + typedef typename parameter_type::type parameter_t; public: + //************************************************************************* + /// Gets a reference to the item at the top of the stack.
+ /// If ETL_USE_EXCEPTIONS is defined, throws an etl::stack_empty if the stack is empty.
+ /// If ETL_USE_EXCEPTIONS is not defined and the stack is empty, the return value is undefined. + /// \return A reference to the item at the top of the stack. + //************************************************************************* + reference top() + { +#ifdef ETL_USE_EXCEPTIONS + if (empty()) + { + throw stack_empty(); + } +#endif + + return buffer[top_index]; + } + //************************************************************************* /// Adds an item to the stack. /// If ETL_USE_EXCEPTIONS is defined, throws an etl::stack_full is the stack is already full, @@ -112,24 +130,6 @@ namespace etl return buffer[top_index]; } - //************************************************************************* - /// Gets a reference to the item at the top of the stack.
- /// If ETL_USE_EXCEPTIONS is defined, throws an etl::stack_empty if the stack is empty.
- /// If ETL_USE_EXCEPTIONS is not defined and the stack is empty, the return value is undefined. - /// \return A reference to the item at the top of the stack. - //************************************************************************* - reference top() - { -#ifdef ETL_USE_EXCEPTIONS - if (empty()) - { - throw stack_empty(); - } -#endif - - return buffer[top_index]; - } - //************************************************************************* /// Gets a const reference to the item at the top of the stack.
/// If ETL_USE_EXCEPTIONS is defined, throws an etl::stack_empty if the stack is empty.
diff --git a/ivector.h b/ivector.h index 3a7ae1f7..be9ce379 100644 --- a/ivector.h +++ b/ivector.h @@ -51,24 +51,43 @@ namespace etl { public: + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef T* pointer; + typedef const T* const_pointer; typedef T* iterator; typedef const T* const_iterator; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; typedef size_t size_type; - typedef T value_type; typedef typename std::iterator_traits::difference_type difference_type; protected: - typedef typename parameter_type::value || is_pointer::value>::type parameter_t; + typedef typename parameter_type::type parameter_t; public: + // Use the base class void push_back(). + using vector_base::push_back; + + //********************************************************************* + /// Assignment operator. + /// The source vector can be larger than the destination, but + /// only the elements that will fit in the destination will be copied. + ///\param other The other vector. + //********************************************************************* + ivector& operator = (ivector& other) + { + const size_t length = std::min(MAX_SIZE, other.size()); + + std::copy(other.begin(), other.begin() + length, p_buffer); + current_size = length; + + return *this; + } + //********************************************************************* /// Returns an iterator to the beginning of the vector. ///\return An iterator to the beginning of the vector. @@ -87,6 +106,24 @@ namespace etl return &p_buffer[0]; } + //********************************************************************* + /// Returns an iterator to the end of the vector. + ///\return An iterator to the end of the vector. + //********************************************************************* + iterator end() + { + return &p_buffer[current_size]; + } + + //********************************************************************* + /// Returns a const_iterator to the end of the vector. + ///\return A const iterator to the end of the vector. + //********************************************************************* + const_iterator end() const + { + return &p_buffer[current_size]; + } + //********************************************************************* /// Returns a const_iterator to the beginning of the vector. ///\return A const iterator to the beginning of the vector. @@ -96,6 +133,15 @@ namespace etl return &p_buffer[0]; } + //********************************************************************* + /// Returns a const_iterator to the end of the vector. + ///\return A const iterator to the end of the vector. + //********************************************************************* + const_iterator cend() const + { + return &p_buffer[current_size]; + } + //********************************************************************* /// Returns an reverse iterator to the reverse beginning of the vector. ///\return Iterator to the reverse beginning of the vector. @@ -114,6 +160,24 @@ namespace etl return const_reverse_iterator(end()); } + //********************************************************************* + /// Returns a reverse iterator to the end + 1 of the vector. + ///\return Reverse iterator to the end + 1 of the vector. + //********************************************************************* + reverse_iterator rend() + { + return reverse_iterator(begin()); + } + + //********************************************************************* + /// Returns a const reverse iterator to the end + 1 of the vector. + ///\return Const reverse iterator to the end + 1 of the vector. + //********************************************************************* + const_reverse_iterator rend() const + { + return const_reverse_iterator(begin()); + } + //********************************************************************* /// Returns a const reverse iterator to the reverse beginning of the vector. ///\return Const reverse iterator to the reverse beginning of the vector. @@ -123,51 +187,6 @@ namespace etl return const_reverse_iterator(cend()); } - //********************************************************************* - /// Returns an iterator to the end of the vector. - ///\return An iterator to the end of the vector. - //********************************************************************* - iterator end() - { - return &p_buffer[current_size]; - } - - //********************************************************************* - /// Returns a const_iterator to the end of the vector. - ///\return A const iterator to the end of the vector. - //********************************************************************* - const_iterator end() const - { - return &p_buffer[current_size]; - } - - //********************************************************************* - /// Returns a const_iterator to the end of the vector. - ///\return A const iterator to the end of the vector. - //********************************************************************* - const_iterator cend() const - { - return &p_buffer[current_size]; - } - - //********************************************************************* - /// Returns a reverse iterator to the end + 1 of the vector. - ///\return Reverse iterator to the end + 1 of the vector. - //********************************************************************* - reverse_iterator rend() - { - return reverse_iterator(begin()); - } - - //********************************************************************* - /// Returns a const reverse iterator to the end + 1 of the vector. - ///\return Const reverse iterator to the end + 1 of the vector. - //********************************************************************* - const_reverse_iterator rend() const - { - return const_reverse_iterator(begin()); - } - //********************************************************************* /// Returns a const reverse iterator to the end + 1 of the vector. ///\return Const reverse iterator to the end + 1 of the vector. @@ -177,24 +196,6 @@ namespace etl return const_reverse_iterator(cbegin()); } - //********************************************************************* - /// Returns a pointer to the beginning of the vector data. - ///\return A pointer to the beginning of the vector data. - //********************************************************************* - pointer data() - { - return p_buffer; - } - - //********************************************************************* - /// Returns a const pointer to the beginning of the vector data. - ///\return A const pointer to the beginning of the vector data. - //********************************************************************* - const_pointer data() const - { - return p_buffer; - } - //********************************************************************* /// Resizes the vector. /// If ETL_USE_EXCEPTIONS is defined and the new size is larger than the @@ -220,12 +221,113 @@ namespace etl } //********************************************************************* - /// Clears the vector. - /// Does not call the destructor for any elements. + /// Returns a reference to the value at index 'i' + ///\param i The index. + ///\return A reference to the value at index 'i' //********************************************************************* - void clear() + reference operator [](size_t i) { - current_size = 0; + return p_buffer[i]; + } + + //********************************************************************* + /// Returns a const reference to the value at index 'i' + ///\param i The index. + ///\return A const reference to the value at index 'i' + //********************************************************************* + const_reference operator [](size_t i) const + { + return p_buffer[i]; + } + + //********************************************************************* + /// Returns a reference to the value at index 'i' + /// If ETL_USE_EXCEPTIONS is defined, throws a std::range_error if the index is out of range. + ///\param i The index. + ///\return A reference to the value at index 'i' + //********************************************************************* + reference at(size_t i) + { +#ifdef ETL_USE_EXCEPTIONS + if (i >= current_size) + { + throw vector_out_of_bounds(); + } +#endif + + return p_buffer[i]; + } + + //********************************************************************* + /// Returns a const reference to the value at index 'i' + /// If ETL_USE_EXCEPTIONS is defined, throws a std::range_error if the index is out of range. + ///\param i The index. + ///\return A const reference to the value at index 'i' + //********************************************************************* + const_reference at(size_t i) const + { +#ifdef ETL_USE_EXCEPTIONS + if (i >= current_size) + { + throw vector_out_of_bounds(); + } +#endif + + return p_buffer[i]; + } + + //********************************************************************* + /// Returns a reference to the first element. + ///\return A reference to the first element. + //********************************************************************* + reference front() + { + return p_buffer[0]; + } + + //********************************************************************* + /// Returns a const reference to the first element. + ///\return A const reference to the first element. + //********************************************************************* + const_reference front() const + { + return p_buffer[0]; + } + + //********************************************************************* + /// Returns a reference to the last element. + ///\return A reference to the last element. + //********************************************************************* + reference back() + { + return p_buffer[current_size - 1]; + } + + //********************************************************************* + /// Returns a const reference to the last element. + ///\return A const reference to the last element. + //********************************************************************* + const_reference back() const + { + return p_buffer[current_size - 1]; + } + + //********************************************************************* + /// Returns a pointer to the beginning of the vector data. + ///\return A pointer to the beginning of the vector data. + //********************************************************************* + pointer data() + { + return p_buffer; + } + + //********************************************************************* + /// Returns a const pointer to the beginning of the vector data. + ///\return A const pointer to the beginning of the vector data. + //********************************************************************* + const_pointer data() const + { + return p_buffer; } //********************************************************************* @@ -281,6 +383,25 @@ namespace etl } } + //********************************************************************* + /// Inserts a value at the end of the vector. + /// If ETL_USE_EXCEPTIONS is defined, throws vector_full if the vector is already full. + ///\param value The value to add. + //********************************************************************* + void push_back(parameter_t value) + { + if (current_size == MAX_SIZE) + { +#ifdef ETL_USE_EXCEPTIONS + throw vector_full(); +#endif + } + else + { + p_buffer[current_size++] = value; + } + } + //********************************************************************* /// Inserts a value to the vector. /// If ETL_USE_EXCEPTIONS is defined, throws vector_full if the vector is already full. @@ -362,55 +483,6 @@ namespace etl } } - //********************************************************************* - /// Inserts a value at the end of the vector. - /// If ETL_USE_EXCEPTIONS is defined, throws vector_full if the vector is already full. - ///\param value The value to add. - //********************************************************************* - void push_back(parameter_t value) - { - if (current_size == MAX_SIZE) - { -#ifdef ETL_USE_EXCEPTIONS - throw vector_full(); -#endif - } - else - { - p_buffer[current_size++] = value; - } - } - - //********************************************************************* - /// Increases the size of the vector by one, but does not initialise the new element. - /// If ETL_USE_EXCEPTIONS is defined, throws vector_full if the vector is already full. - //********************************************************************* - void push_back() - { - if (current_size == MAX_SIZE) - { -#ifdef ETL_USE_EXCEPTIONS - throw vector_full(); -#endif - } - else - { - ++current_size; - } - } - - //********************************************************************* - /// Removes an element from the end of the vector. - /// Does nothing if the vector is empty. - //********************************************************************* - void pop_back() - { - if (current_size > 0) - { - --current_size; - } - } - //********************************************************************* /// Erases an element. ///\param iElement Iterator to the element. @@ -418,10 +490,10 @@ namespace etl //********************************************************************* iterator erase(iterator iElement) { - std::copy(iElement + 1, end(), iElement); - --current_size; + std::copy(iElement + 1, end(), iElement); + --current_size; - return iElement; + return iElement; } //********************************************************************* @@ -434,118 +506,19 @@ namespace etl //********************************************************************* iterator erase(iterator first, iterator last) { - std::copy(last, end(), first); - current_size -= std::distance(first, last); + std::copy(last, end(), first); + current_size -= std::distance(first, last); - return first; + return first; } //********************************************************************* - /// Returns a reference to the first element. - ///\return A reference to the first element. + /// Clears the vector. + /// Does not call the destructor for any elements. //********************************************************************* - reference front() + void clear() { - return p_buffer[0]; - } - - //********************************************************************* - /// Returns a const reference to the first element. - ///\return A const reference to the first element. - //********************************************************************* - const_reference front() const - { - return p_buffer[0]; - } - - //********************************************************************* - /// Returns a reference to the last element. - ///\return A reference to the last element. - //********************************************************************* - reference back() - { - return p_buffer[current_size - 1]; - } - - //********************************************************************* - /// Returns a const reference to the last element. - ///\return A const reference to the last element. - //********************************************************************* - const_reference back() const - { - return p_buffer[current_size - 1]; - } - - //********************************************************************* - /// Returns a reference to the value at index 'i' - /// If ETL_USE_EXCEPTIONS is defined, throws a std::range_error if the index is out of range. - ///\param i The index. - ///\return A reference to the value at index 'i' - //********************************************************************* - reference at(size_t i) - { -#ifdef ETL_USE_EXCEPTIONS - if (i >= current_size) - { - throw vector_out_of_bounds(); - } -#endif - - return p_buffer[i]; - } - - //********************************************************************* - /// Returns a const reference to the value at index 'i' - /// If ETL_USE_EXCEPTIONS is defined, throws a std::range_error if the index is out of range. - ///\param i The index. - ///\return A const reference to the value at index 'i' - //********************************************************************* - const_reference at(size_t i) const - { -#ifdef ETL_USE_EXCEPTIONS - if (i >= current_size) - { - throw vector_out_of_bounds(); - } -#endif - - return p_buffer[i]; - } - - //********************************************************************* - /// Returns a reference to the value at index 'i' - ///\param i The index. - ///\return A reference to the value at index 'i' - //********************************************************************* - reference operator [](size_t i) - { - return p_buffer[i]; - } - - //********************************************************************* - /// Returns a const reference to the value at index 'i' - ///\param i The index. - ///\return A const reference to the value at index 'i' - //********************************************************************* - const_reference operator [](size_t i) const - { - return p_buffer[i]; - } - - //********************************************************************* - /// Assignment operator. - /// The source vector can be larger than the destination, but - /// only the elements that will fit in the destination will be copied. - ///\param other The other vector. - //********************************************************************* - ivector& operator = (ivector& other) - { - const size_t length = std::min(MAX_SIZE, other.size()); - - std::copy(other.begin(), other.begin() + length, p_buffer); - current_size = length; - - return *this; + current_size = 0; } protected: diff --git a/queue_base.h b/queue_base.h index 6e9c27fb..923b20b6 100644 --- a/queue_base.h +++ b/queue_base.h @@ -117,16 +117,6 @@ namespace etl return MAX_SIZE; } - //************************************************************************* - /// Clears the queue to the empty state. - //************************************************************************* - void clear() - { - in = 0; - out = 0; - current_size = 0; - } - //************************************************************************* /// Checks to see if the queue is empty. /// \return true if the queue is empty, otherwise false @@ -145,6 +135,16 @@ namespace etl return current_size == MAX_SIZE; } + //************************************************************************* + /// Clears the queue to the empty state. + //************************************************************************* + void clear() + { + in = 0; + out = 0; + current_size = 0; + } + //************************************************************************* /// Removes the oldest item from the back of the queue. /// Does nothing if the queue is already empty. diff --git a/stack_base.h b/stack_base.h index 35cce0f8..3673180e 100644 --- a/stack_base.h +++ b/stack_base.h @@ -94,6 +94,24 @@ namespace etl typedef size_t size_type; ///< The type used for determining the size of stack. + //************************************************************************* + /// Checks to see if the stack is empty. + /// \return true if the stack is empty, otherwise false + //************************************************************************* + bool empty() const + { + return current_size == 0; + } + + //************************************************************************* + /// Checks to see if the stack is full. + /// \return true if the stack is full, otherwise false + //************************************************************************* + bool full() const + { + return current_size == MAX_SIZE; + } + //************************************************************************* /// Returns the current number of items top the stack. //************************************************************************* @@ -127,24 +145,6 @@ namespace etl current_size = 0; } - //************************************************************************* - /// Checks to see if the stack is empty. - /// \return true if the stack is empty, otherwise false - //************************************************************************* - bool empty() const - { - return current_size == 0; - } - - //************************************************************************* - /// Checks to see if the stack is full. - /// \return true if the stack is full, otherwise false - //************************************************************************* - bool full() const - { - return current_size == MAX_SIZE; - } - //************************************************************************* /// Removes the oldest item from the top of the stack. /// Does nothing if the stack is already empty. diff --git a/test/codelite/.codelite/ETL.session b/test/codelite/.codelite/ETL.session index f2fbe454..ffc85218 100644 --- a/test/codelite/.codelite/ETL.session +++ b/test/codelite/.codelite/ETL.session @@ -5,7 +5,7 @@ - + @@ -97,7 +97,7 @@ - + diff --git a/test/codelite/.codelite/ETL.tags b/test/codelite/.codelite/ETL.tags index 2e555da8..7c741bda 100644 Binary files a/test/codelite/.codelite/ETL.tags and b/test/codelite/.codelite/ETL.tags differ diff --git a/test/codelite/.codelite/refactoring.db b/test/codelite/.codelite/refactoring.db index 6b58b555..adc154c9 100644 Binary files a/test/codelite/.codelite/refactoring.db and b/test/codelite/.codelite/refactoring.db differ diff --git a/test/codelite/ETL.mk b/test/codelite/ETL.mk index cc16b82c..d2674618 100644 --- a/test/codelite/ETL.mk +++ b/test/codelite/ETL.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=John -Date :=11/19/14 +Date :=11/21/14 CodeLitePath :="C:\Program Files (x86)\CodeLite" LinkerName :=C:/MinGW/bin/g++.exe SharedObjectLinkerName :=C:/MinGW/bin/g++.exe -shared -fPIC @@ -65,9 +65,9 @@ CodeLiteDir:=C:\Program Files (x86)\CodeLite UNIT_TEST_PP_SRC_DIR:=C:\UnitTest++-1.3 Objects0=$(IntermediateDirectory)/UnitTest++_AssertException.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_Checks.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_CompositeTestReporter.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_CurrentTest.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_DeferredTestReporter.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_DeferredTestResult.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_MemoryOutStream.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_ReportAssert.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_Test.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_TestDetails.cpp$(ObjectSuffix) \ $(IntermediateDirectory)/UnitTest++_TestList.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_TestReporter.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_TestReporterStdout.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_TestResults.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_TestRunner.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_TimeConstraint.cpp$(ObjectSuffix) $(IntermediateDirectory)/UnitTest++_XmlTestReporter.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_main.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_array.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_container.cpp$(ObjectSuffix) \ - $(IntermediateDirectory)/test_test_crc.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_cyclic_value.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_deque.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_enum_type.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_exception.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_function.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_largest.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_list.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_math.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_numeric.cpp$(ObjectSuffix) \ - $(IntermediateDirectory)/test_test_observer.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_queue.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_stack.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_type_traits.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_vector.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_visitor.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_bitset.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_forward_list.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_integral_limits.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_variant.cpp$(ObjectSuffix) \ - $(IntermediateDirectory)/test_test_smallest.cpp$(ObjectSuffix) + $(IntermediateDirectory)/test_test_crc.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_cyclic_value.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_deque.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_enum_type.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_exception.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_function.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_largest.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_list.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_numeric.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_observer.cpp$(ObjectSuffix) \ + $(IntermediateDirectory)/test_test_queue.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_stack.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_type_traits.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_vector.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_visitor.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_bitset.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_forward_list.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_integral_limits.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_variant.cpp$(ObjectSuffix) $(IntermediateDirectory)/test_test_smallest.cpp$(ObjectSuffix) \ + $(IntermediateDirectory)/test_test_maths.cpp$(ObjectSuffix) Objects1=$(IntermediateDirectory)/etl_crc8_ccitt.cpp$(ObjectSuffix) $(IntermediateDirectory)/etl_crc16.cpp$(ObjectSuffix) $(IntermediateDirectory)/etl_crc16_ccitt.cpp$(ObjectSuffix) $(IntermediateDirectory)/etl_crc32.cpp$(ObjectSuffix) $(IntermediateDirectory)/etl_crc64_ecma.cpp$(ObjectSuffix) $(IntermediateDirectory)/etl_crc16_kermit.cpp$(ObjectSuffix) $(IntermediateDirectory)/Win32_TimeHelpers.cpp$(ObjectSuffix) @@ -326,14 +326,6 @@ $(IntermediateDirectory)/test_test_list.cpp$(DependSuffix): ../test_list.cpp $(IntermediateDirectory)/test_test_list.cpp$(PreprocessSuffix): ../test_list.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/test_test_list.cpp$(PreprocessSuffix) "../test_list.cpp" -$(IntermediateDirectory)/test_test_math.cpp$(ObjectSuffix): ../test_math.cpp $(IntermediateDirectory)/test_test_math.cpp$(DependSuffix) - $(CXX) $(IncludePCH) $(SourceSwitch) "U:/Users/John/Documents/Programming/GitHub/etl/test/test_math.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/test_test_math.cpp$(ObjectSuffix) $(IncludePath) -$(IntermediateDirectory)/test_test_math.cpp$(DependSuffix): ../test_math.cpp - @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/test_test_math.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/test_test_math.cpp$(DependSuffix) -MM "../test_math.cpp" - -$(IntermediateDirectory)/test_test_math.cpp$(PreprocessSuffix): ../test_math.cpp - @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/test_test_math.cpp$(PreprocessSuffix) "../test_math.cpp" - $(IntermediateDirectory)/test_test_numeric.cpp$(ObjectSuffix): ../test_numeric.cpp $(IntermediateDirectory)/test_test_numeric.cpp$(DependSuffix) $(CXX) $(IncludePCH) $(SourceSwitch) "U:/Users/John/Documents/Programming/GitHub/etl/test/test_numeric.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/test_test_numeric.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/test_test_numeric.cpp$(DependSuffix): ../test_numeric.cpp @@ -430,6 +422,14 @@ $(IntermediateDirectory)/test_test_smallest.cpp$(DependSuffix): ../test_smallest $(IntermediateDirectory)/test_test_smallest.cpp$(PreprocessSuffix): ../test_smallest.cpp @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/test_test_smallest.cpp$(PreprocessSuffix) "../test_smallest.cpp" +$(IntermediateDirectory)/test_test_maths.cpp$(ObjectSuffix): ../test_maths.cpp $(IntermediateDirectory)/test_test_maths.cpp$(DependSuffix) + $(CXX) $(IncludePCH) $(SourceSwitch) "U:/Users/John/Documents/Programming/GitHub/etl/test/test_maths.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/test_test_maths.cpp$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/test_test_maths.cpp$(DependSuffix): ../test_maths.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/test_test_maths.cpp$(ObjectSuffix) -MF$(IntermediateDirectory)/test_test_maths.cpp$(DependSuffix) -MM "../test_maths.cpp" + +$(IntermediateDirectory)/test_test_maths.cpp$(PreprocessSuffix): ../test_maths.cpp + @$(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/test_test_maths.cpp$(PreprocessSuffix) "../test_maths.cpp" + $(IntermediateDirectory)/etl_crc8_ccitt.cpp$(ObjectSuffix): ../../crc8_ccitt.cpp $(IntermediateDirectory)/etl_crc8_ccitt.cpp$(DependSuffix) $(CXX) $(IncludePCH) $(SourceSwitch) "U:/Users/John/Documents/Programming/GitHub/etl/crc8_ccitt.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/etl_crc8_ccitt.cpp$(ObjectSuffix) $(IncludePath) $(IntermediateDirectory)/etl_crc8_ccitt.cpp$(DependSuffix): ../../crc8_ccitt.cpp diff --git a/test/codelite/ETL.project b/test/codelite/ETL.project index 65ba895d..36f732e2 100644 --- a/test/codelite/ETL.project +++ b/test/codelite/ETL.project @@ -85,7 +85,6 @@ - @@ -98,6 +97,7 @@ + diff --git a/test/codelite/ETL.txt b/test/codelite/ETL.txt index 43771b65..b35d0a2b 100644 --- a/test/codelite/ETL.txt +++ b/test/codelite/ETL.txt @@ -1,2 +1,2 @@ -./Debug/UnitTest++_AssertException.cpp.o ./Debug/UnitTest++_Checks.cpp.o ./Debug/UnitTest++_CompositeTestReporter.cpp.o ./Debug/UnitTest++_CurrentTest.cpp.o ./Debug/UnitTest++_DeferredTestReporter.cpp.o ./Debug/UnitTest++_DeferredTestResult.cpp.o ./Debug/UnitTest++_MemoryOutStream.cpp.o ./Debug/UnitTest++_ReportAssert.cpp.o ./Debug/UnitTest++_Test.cpp.o ./Debug/UnitTest++_TestDetails.cpp.o ./Debug/UnitTest++_TestList.cpp.o ./Debug/UnitTest++_TestReporter.cpp.o ./Debug/UnitTest++_TestReporterStdout.cpp.o ./Debug/UnitTest++_TestResults.cpp.o ./Debug/UnitTest++_TestRunner.cpp.o ./Debug/UnitTest++_TimeConstraint.cpp.o ./Debug/UnitTest++_XmlTestReporter.cpp.o ./Debug/test_main.cpp.o ./Debug/test_test_array.cpp.o ./Debug/test_test_container.cpp.o ./Debug/test_test_crc.cpp.o ./Debug/test_test_cyclic_value.cpp.o ./Debug/test_test_deque.cpp.o ./Debug/test_test_enum_type.cpp.o ./Debug/test_test_exception.cpp.o ./Debug/test_test_function.cpp.o ./Debug/test_test_largest.cpp.o ./Debug/test_test_list.cpp.o ./Debug/test_test_math.cpp.o ./Debug/test_test_numeric.cpp.o ./Debug/test_test_observer.cpp.o ./Debug/test_test_queue.cpp.o ./Debug/test_test_stack.cpp.o ./Debug/test_test_type_traits.cpp.o ./Debug/test_test_vector.cpp.o ./Debug/test_test_visitor.cpp.o ./Debug/test_test_bitset.cpp.o ./Debug/test_test_forward_list.cpp.o ./Debug/test_test_integral_limits.cpp.o ./Debug/test_test_variant.cpp.o ./Debug/test_test_smallest.cpp.o +./Debug/UnitTest++_AssertException.cpp.o ./Debug/UnitTest++_Checks.cpp.o ./Debug/UnitTest++_CompositeTestReporter.cpp.o ./Debug/UnitTest++_CurrentTest.cpp.o ./Debug/UnitTest++_DeferredTestReporter.cpp.o ./Debug/UnitTest++_DeferredTestResult.cpp.o ./Debug/UnitTest++_MemoryOutStream.cpp.o ./Debug/UnitTest++_ReportAssert.cpp.o ./Debug/UnitTest++_Test.cpp.o ./Debug/UnitTest++_TestDetails.cpp.o ./Debug/UnitTest++_TestList.cpp.o ./Debug/UnitTest++_TestReporter.cpp.o ./Debug/UnitTest++_TestReporterStdout.cpp.o ./Debug/UnitTest++_TestResults.cpp.o ./Debug/UnitTest++_TestRunner.cpp.o ./Debug/UnitTest++_TimeConstraint.cpp.o ./Debug/UnitTest++_XmlTestReporter.cpp.o ./Debug/test_main.cpp.o ./Debug/test_test_array.cpp.o ./Debug/test_test_container.cpp.o ./Debug/test_test_crc.cpp.o ./Debug/test_test_cyclic_value.cpp.o ./Debug/test_test_deque.cpp.o ./Debug/test_test_enum_type.cpp.o ./Debug/test_test_exception.cpp.o ./Debug/test_test_function.cpp.o ./Debug/test_test_largest.cpp.o ./Debug/test_test_list.cpp.o ./Debug/test_test_numeric.cpp.o ./Debug/test_test_observer.cpp.o ./Debug/test_test_queue.cpp.o ./Debug/test_test_stack.cpp.o ./Debug/test_test_type_traits.cpp.o ./Debug/test_test_vector.cpp.o ./Debug/test_test_visitor.cpp.o ./Debug/test_test_bitset.cpp.o ./Debug/test_test_forward_list.cpp.o ./Debug/test_test_integral_limits.cpp.o ./Debug/test_test_variant.cpp.o ./Debug/test_test_smallest.cpp.o ./Debug/test_test_maths.cpp.o ./Debug/etl_crc8_ccitt.cpp.o ./Debug/etl_crc16.cpp.o ./Debug/etl_crc16_ccitt.cpp.o ./Debug/etl_crc32.cpp.o ./Debug/etl_crc64_ecma.cpp.o ./Debug/etl_crc16_kermit.cpp.o ./Debug/Win32_TimeHelpers.cpp.o diff --git a/test/test_bitset.cpp b/test/test_bitset.cpp index d7d7c403..d1c3d10b 100644 --- a/test/test_bitset.cpp +++ b/test/test_bitset.cpp @@ -39,7 +39,7 @@ SOFTWARE. namespace { - SUITE(TestBitset) + SUITE(test_bitset) { //************************************************************************* TEST(test_constructor) diff --git a/test/test_container.cpp b/test/test_container.cpp index e7691e83..4acdd17f 100644 --- a/test/test_container.cpp +++ b/test/test_container.cpp @@ -32,7 +32,7 @@ SOFTWARE. namespace { - SUITE(ContainerTest) + SUITE(test_container) { //************************************************************************* TEST(test_stl_style_container) diff --git a/test/test_crc.cpp b/test/test_crc.cpp index abb16a14..8919eda8 100644 --- a/test/test_crc.cpp +++ b/test/test_crc.cpp @@ -41,7 +41,7 @@ SOFTWARE. namespace { - SUITE(TestCRC) + SUITE(test_crc) { //************************************************************************* TEST(test_crc8_ccitt_constructor) diff --git a/test/test_cyclic_value.cpp b/test/test_cyclic_value.cpp index da876880..347226b5 100644 --- a/test/test_cyclic_value.cpp +++ b/test/test_cyclic_value.cpp @@ -32,10 +32,10 @@ SOFTWARE. namespace { - SUITE(TestCyclicValue) + SUITE(test_cyclic_value) { //************************************************************************* - TEST(CompileTimeInitialisation) + TEST(test_compile_time_initialisation) { etl::cyclic_value value; @@ -45,9 +45,9 @@ namespace } //************************************************************************* - TEST(RunTimeInitialisation) + TEST(test_run_time_initialisation) { - etl::cyclic_value value(2, 7, 1); + etl::cyclic_value value(2, 7); CHECK_EQUAL(2, value); CHECK_EQUAL(2, value.first()); @@ -55,7 +55,7 @@ namespace } //************************************************************************* - TEST(set) + TEST(test_set) { etl::cyclic_value value; @@ -67,7 +67,7 @@ namespace } //************************************************************************* - TEST(ToFirst) + TEST(test_to_first) { etl::cyclic_value value; @@ -79,7 +79,7 @@ namespace } //************************************************************************* - TEST(ToLast) + TEST(test_to_last) { etl::cyclic_value value; @@ -90,7 +90,7 @@ namespace } //************************************************************************* - TEST(Increment) + TEST(test_increment) { etl::cyclic_value value; @@ -104,7 +104,7 @@ namespace } //************************************************************************* - TEST(Decrement) + TEST(test_decrement) { etl::cyclic_value value; @@ -119,7 +119,7 @@ namespace } //************************************************************************* - TEST(IncrementWrap) + TEST(test_increment_wrap) { etl::cyclic_value value; @@ -135,7 +135,7 @@ namespace } //************************************************************************* - TEST(DecrementWrap) + TEST(test_decrement_wrap) { etl::cyclic_value value; @@ -151,21 +151,9 @@ namespace } //************************************************************************* - TEST(NumberOfSteps) + TEST(test_advance_positive) { - etl::cyclic_value value; - - value.set(2, 7, 1); - CHECK_EQUAL(7 - 2 + 1, value.number_of_steps()); - - value.set(2, 7, 2); - CHECK_EQUAL((7 - 2 + 1) / 2, value.number_of_steps()); - } - - //************************************************************************* - TEST(AdvancePositive) - { - etl::cyclic_value value; + etl::cyclic_value value; value.advance(2); @@ -173,22 +161,14 @@ namespace } //************************************************************************* - TEST(AdvanceNegative) + TEST(test_advance_negative) { - etl::cyclic_value value; + etl::cyclic_value value; value.to_last(); value.advance(-2); CHECK_EQUAL(5, value); } - - //************************************************************************* - TEST(TestException) - { - etl::cyclic_value value; - - CHECK_THROW(value.set(2, 7, 4), etl::cyclic_value_illegal_range); - } }; } diff --git a/test/test_enum_type.cpp b/test/test_enum_type.cpp index ecbcdbe7..9424d60f 100644 --- a/test/test_enum_type.cpp +++ b/test/test_enum_type.cpp @@ -48,7 +48,7 @@ struct enum_test namespace { - SUITE(TestEnumType) + SUITE(test_enum_type) { //************************************************************************* TEST(Values) @@ -60,7 +60,7 @@ namespace } //************************************************************************* - TEST(Strings) + TEST(test_c_str) { enum_test value; @@ -83,7 +83,7 @@ namespace } //************************************************************************* - TEST(Assignment) + TEST(test_assignment) { enum_test value1 = enum_test::ZERO; enum_test value2 = enum_test::ONE; @@ -94,7 +94,7 @@ namespace } //************************************************************************* - TEST(GetValue) + TEST(test_get_value) { enum_test actual = enum_test::THREE; enum_test::value_type expected = enum_test::THREE; @@ -103,7 +103,7 @@ namespace } //************************************************************************* - TEST(GetEnum) + TEST(test_get_enum) { enum_test actual = enum_test::THREE; enum_test::enum_type expected = enum_test::THREE; diff --git a/test/test_exception.cpp b/test/test_exception.cpp index d6361e7f..c6568f30 100644 --- a/test/test_exception.cpp +++ b/test/test_exception.cpp @@ -31,10 +31,10 @@ SOFTWARE. namespace { - SUITE(TestException) + SUITE(test_exception) { //************************************************************************* - TEST(Constructor) + TEST(test_constructor) { etl::exception e("An exception"); @@ -42,7 +42,7 @@ namespace } //************************************************************************* - TEST(Exception) + TEST(test_exception) { etl::exception e("An exception"); diff --git a/test/test_forward_list.cpp b/test/test_forward_list.cpp index 0864eb17..e3852a37 100644 --- a/test/test_forward_list.cpp +++ b/test/test_forward_list.cpp @@ -36,7 +36,7 @@ SOFTWARE. namespace { - SUITE(TestForwardList) + SUITE(test_forward_list) { const size_t SIZE = 10; @@ -65,7 +65,7 @@ namespace }; //************************************************************************* - TEST_FIXTURE(SetupFixture, DefaultConstructor) + TEST_FIXTURE(SetupFixture, test_default_constructor) { Data data; @@ -74,7 +74,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorSize) + TEST_FIXTURE(SetupFixture, test_constructor_size) { const size_t INITIAL_SIZE = 4; Data data(INITIAL_SIZE); @@ -83,13 +83,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorSizeExcess) + TEST_FIXTURE(SetupFixture, test_constructor_size_excess) { CHECK_THROW(Data data(SIZE + 1), etl::forward_list_full); } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorSizeValue) + TEST_FIXTURE(SetupFixture, test_constructor_size_value) { const size_t INITIAL_SIZE = 4; const int INITIAL_VALUE = 1; @@ -107,7 +107,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorRange) + TEST_FIXTURE(SetupFixture, test_constructor_range) { Data data(sorted_data.begin(), sorted_data.end()); @@ -115,7 +115,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, CopyConstructor) + TEST_FIXTURE(SetupFixture, test_copy_constructor) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -125,7 +125,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Iterator) + TEST_FIXTURE(SetupFixture, test_iterator) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(compare_data.begin(), compare_data.end()); @@ -136,7 +136,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstIterator) + TEST_FIXTURE(SetupFixture, test_const_iterator) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(compare_data.begin(), compare_data.end()); @@ -147,7 +147,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ResizeUpValue) + TEST_FIXTURE(SetupFixture, test_resize_up_value) { const size_t INITIAL_SIZE = 4; const size_t NEW_SIZE = 8; @@ -165,7 +165,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ResizeExcess) + TEST_FIXTURE(SetupFixture, test_resize_excess) { const size_t INITIAL_SIZE = 4; Data data(INITIAL_SIZE); @@ -174,7 +174,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Clear) + TEST_FIXTURE(SetupFixture, test_clear) { Data data(sorted_data.begin(), sorted_data.end()); data.clear(); @@ -183,7 +183,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, AssignRange) + TEST_FIXTURE(SetupFixture, test_assign_range) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data; @@ -198,7 +198,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, AssignSizeValue) + TEST_FIXTURE(SetupFixture, test_assign_size_value) { const size_t INITIAL_SIZE = 4; const int VALUE = 1; @@ -216,7 +216,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, AssignSizeValueExcess) + TEST_FIXTURE(SetupFixture, test_assign_size_value_excess) { const int VALUE = 1; @@ -226,7 +226,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, InsertAfterPositionValue) + TEST_FIXTURE(SetupFixture, test_insert_after_position_value) { const size_t INITIAL_SIZE = 4; const int VALUE = 1; @@ -267,7 +267,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, InsertAfterRange) + TEST_FIXTURE(SetupFixture, test_insert_after_range) { std::vector test1 = { 1, 2, 3, 4, 5 }; std::vector test2 = { 6, 7, 8, 9, 10 }; @@ -300,7 +300,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushFront) + TEST_FIXTURE(SetupFixture, test_push_front) { CompareData compare_data; Data data; @@ -325,7 +325,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushFrontExcess) + TEST_FIXTURE(SetupFixture, test_push_front_excess) { Data data; @@ -344,7 +344,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushFrontPopFront) + TEST_FIXTURE(SetupFixture, test_push_front_pop_front) { Data data; @@ -358,7 +358,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, EraseAfterSingle) + TEST_FIXTURE(SetupFixture, test_erase_after_single) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -404,7 +404,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, EraseAfterRange) + TEST_FIXTURE(SetupFixture, test_erase_after_range) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -431,7 +431,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, EraseAfterAll) + TEST_FIXTURE(SetupFixture, test_erase_after_all) { Data data(sorted_data.begin(), sorted_data.end()); @@ -441,7 +441,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Front) + TEST_FIXTURE(SetupFixture, test_front) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -450,7 +450,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Assignment) + TEST_FIXTURE(SetupFixture, test_assignment) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -466,7 +466,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Unique) + TEST_FIXTURE(SetupFixture, test_unique) { CompareData compare_data(non_unique_data.begin(), non_unique_data.end()); Data data(non_unique_data.begin(), non_unique_data.end()); @@ -480,7 +480,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Remove) + TEST_FIXTURE(SetupFixture, test_remove) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -494,7 +494,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, RemoveIf) + TEST_FIXTURE(SetupFixture, test_remove_if) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -508,7 +508,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Reverse) + TEST_FIXTURE(SetupFixture, test_reverse) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -522,7 +522,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Sort) + TEST_FIXTURE(SetupFixture, test_sort) { CompareData compare_data(unsorted_data.begin(), unsorted_data.end()); Data data(unsorted_data.begin(), unsorted_data.end()); @@ -536,7 +536,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Swap) + TEST_FIXTURE(SetupFixture, test_swap) { Data first(unsorted_data.begin(), unsorted_data.end()); Data second(small_data.begin(), small_data.end()); diff --git a/test/test_function.cpp b/test/test_function.cpp index 25fd6b1c..8edcace8 100644 --- a/test/test_function.cpp +++ b/test/test_function.cpp @@ -30,8 +30,8 @@ SOFTWARE. //***************************************************************************** const int VALUE = 1; -bool functionCalled = false; -bool parameterCorrect = false; +bool function_called = false; +bool parameter_correct = false; //***************************************************************************** // Test data structure. @@ -44,7 +44,7 @@ struct Data //***************************************************************************** // Call the function taking no parameters. //***************************************************************************** -void Call(etl::ifunction& function) +void call(etl::ifunction& function) { function(); } @@ -52,7 +52,7 @@ void Call(etl::ifunction& function) //***************************************************************************** // Call the function taking an int parameter. //***************************************************************************** -void Call(etl::ifunction& function) +void call(etl::ifunction& function) { function(VALUE); } @@ -60,7 +60,7 @@ void Call(etl::ifunction& function) //***************************************************************************** // Call the function taking a Data parameter. //***************************************************************************** -void Call(etl::ifunction& function) +void call(etl::ifunction& function) { Data data; data.d = VALUE; @@ -70,27 +70,27 @@ void Call(etl::ifunction& function) //***************************************************************************** // The free function taking no parameters. //***************************************************************************** -void FreeVoid() +void free_void() { - functionCalled = true; + function_called = true; } //***************************************************************************** // The free function taking an int parameter. //***************************************************************************** -void FreeInt(int i) +void free_int(int i) { - functionCalled = true; - parameterCorrect = (i == VALUE); + function_called = true; + parameter_correct = (i == VALUE); } //***************************************************************************** // The free function taking a Data reference parameter. //***************************************************************************** -void FreeReference(const Data& data) +void free_reference(const Data& data) { - functionCalled = true; - parameterCorrect = (data.d == VALUE); + function_called = true; + parameter_correct = (data.d == VALUE); } //***************************************************************************** @@ -100,21 +100,21 @@ class Test { public: - void MemberVoid() + void member_void() { - functionCalled = true; + function_called = true; } - void MemberInt(int i) + void member_int(int i) { - functionCalled = true; - parameterCorrect = (i == VALUE); + function_called = true; + parameter_correct = (i == VALUE); } - void MemberReference(const Data& data) + void member_reference(const Data& data) { - functionCalled = true; - parameterCorrect = (data.d == VALUE); + function_called = true; + parameter_correct = (data.d == VALUE); } }; @@ -125,80 +125,80 @@ struct SetupFixture { SetupFixture() { - functionCalled = false; - parameterCorrect = false; + function_called = false; + parameter_correct = false; } }; namespace { - SUITE(TestFunction) + SUITE(test_function) { //************************************************************************* - TEST_FIXTURE(SetupFixture, TestFreeVoid) + TEST_FIXTURE(SetupFixture, test_free_void) { - etl::function function(FreeVoid); + etl::function function(free_void); - Call(function); + call(function); - CHECK(functionCalled); + CHECK(function_called); } //************************************************************************* - TEST_FIXTURE(SetupFixture, TestFreeInt) + TEST_FIXTURE(SetupFixture, test_free_int) { - etl::function function(FreeInt); + etl::function function(free_int); - Call(function); + call(function); - CHECK(functionCalled); - CHECK(parameterCorrect); + CHECK(function_called); + CHECK(parameter_correct); } //************************************************************************* - TEST_FIXTURE(SetupFixture, TestFreeReference) + TEST_FIXTURE(SetupFixture, test_free_reference) { - etl::function function(FreeReference); + etl::function function(free_reference); - Call(function); + call(function); - CHECK(functionCalled); - CHECK(parameterCorrect); + CHECK(function_called); + CHECK(parameter_correct); } //************************************************************************* - TEST_FIXTURE(SetupFixture, TestMemberVoid) + TEST_FIXTURE(SetupFixture, test_member_void) { Test test; - etl::function function(test, &Test::MemberVoid); + etl::function function(test, &Test::member_void); - Call(function); + call(function); - CHECK(functionCalled); + CHECK(function_called); } //************************************************************************* - TEST_FIXTURE(SetupFixture, TestMemberInt) + TEST_FIXTURE(SetupFixture, test_member_int) { Test test; - etl::function function(test, &Test::MemberInt); + etl::function function(test, &Test::member_int); - Call(function); + call(function); - CHECK(functionCalled); - CHECK(parameterCorrect); + CHECK(function_called); + CHECK(parameter_correct); } //************************************************************************* - TEST_FIXTURE(SetupFixture, TestMemberReference) + TEST_FIXTURE(SetupFixture, test_member_reference) { Test test; - etl::function function(test, &Test::MemberReference); + etl::function function(test, &Test::member_reference); - Call(function); + call(function); - CHECK(functionCalled); - CHECK(parameterCorrect); + CHECK(function_called); + CHECK(parameter_correct); } }; } \ No newline at end of file diff --git a/test/test_integral_limits.cpp b/test/test_integral_limits.cpp index f7fa3339..4c106d5f 100644 --- a/test/test_integral_limits.cpp +++ b/test/test_integral_limits.cpp @@ -37,10 +37,10 @@ SOFTWARE. namespace { - SUITE(TestIntegralLimits) + SUITE(test_integral_limits) { //************************************************************************* - TEST(MinTest) + TEST(test_min) { CHECK_EQUAL(std::numeric_limits::min(), (char)etl::integral_limits::min); CHECK_EQUAL(std::numeric_limits::min(), (signed char)etl::integral_limits::min); @@ -56,7 +56,7 @@ namespace } //************************************************************************* - TEST(MaxTest) + TEST(test_max) { CHECK_EQUAL(std::numeric_limits::max(), (char)etl::integral_limits::max); CHECK_EQUAL(std::numeric_limits::max(), (signed char)etl::integral_limits::max); @@ -72,7 +72,7 @@ namespace } //************************************************************************* - TEST(BitsTest) + TEST(test_bits) { CHECK_EQUAL(std::numeric_limits::type>::digits, (int)etl::integral_limits::bits); CHECK_EQUAL(std::numeric_limits::type>::digits, (int)etl::integral_limits::bits); @@ -88,7 +88,7 @@ namespace } //************************************************************************* - TEST(IsSignedTest) + TEST(test_is_signed) { CHECK_EQUAL(std::numeric_limits::is_signed, (bool)etl::integral_limits::is_signed); CHECK_EQUAL(std::numeric_limits::is_signed, (bool)etl::integral_limits::is_signed); diff --git a/test/test_largest.cpp b/test/test_largest.cpp index c07a1bdb..54c4584f 100644 --- a/test/test_largest.cpp +++ b/test/test_largest.cpp @@ -32,7 +32,7 @@ SOFTWARE. namespace { - SUITE(TestLargest) + SUITE(test_largest) { //************************************************************************* TEST(test_pod_type) diff --git a/test/test_list.cpp b/test/test_list.cpp index 5a75eb3d..e57f2c96 100644 --- a/test/test_list.cpp +++ b/test/test_list.cpp @@ -36,7 +36,7 @@ SOFTWARE. namespace { - SUITE(TestList) + SUITE(test_list) { const size_t SIZE = 10; @@ -65,7 +65,7 @@ namespace }; //************************************************************************* - TEST_FIXTURE(SetupFixture, DefaultConstructor) + TEST_FIXTURE(SetupFixture, test_default_constructor) { Data data; @@ -75,7 +75,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorSize) + TEST_FIXTURE(SetupFixture, test_constructor_size) { const size_t INITIAL_SIZE = 4; Data data(INITIAL_SIZE); @@ -85,13 +85,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorSizeExcess) + TEST_FIXTURE(SetupFixture, test_constructor_size_excess) { CHECK_THROW(Data data(SIZE + 1), etl::list_full); } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorSizeValue) + TEST_FIXTURE(SetupFixture, test_constructor_size_value) { const size_t INITIAL_SIZE = 4; const int INITIAL_VALUE = 1; @@ -110,7 +110,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorRange) + TEST_FIXTURE(SetupFixture, test_constructor_size_value_excess) + { + CHECK_THROW(Data data(SIZE + 1, 1), etl::list_full); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_constructor_range) { Data data(sorted_data.begin(), sorted_data.end()); @@ -119,7 +125,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, CopyConstructor) + TEST_FIXTURE(SetupFixture, test_copy_constructor) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -139,7 +145,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Iterator) + TEST_FIXTURE(SetupFixture, test_iterator) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(compare_data.begin(), compare_data.end()); @@ -150,7 +156,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstIterator) + TEST_FIXTURE(SetupFixture, test_const_iterator) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(compare_data.begin(), compare_data.end()); @@ -161,7 +167,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ReverseIterator) + TEST_FIXTURE(SetupFixture, test_reverse_iterator) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(compare_data.begin(), compare_data.end()); @@ -172,7 +178,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstReverseIterator) + TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(compare_data.begin(), compare_data.end()); @@ -183,7 +189,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ResizeUp) + TEST_FIXTURE(SetupFixture, test_resize_up) { const size_t INITIAL_SIZE = 4; const size_t NEW_SIZE = 8; @@ -195,7 +201,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ResizeUpValue) + TEST_FIXTURE(SetupFixture, test_resize_up_value) { const size_t INITIAL_SIZE = 4; const size_t NEW_SIZE = 8; @@ -213,7 +219,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ResizeExcess) + TEST_FIXTURE(SetupFixture, test_resize_excess) { const size_t INITIAL_SIZE = 4; Data data(INITIAL_SIZE); @@ -222,7 +228,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ResizeDown) + TEST_FIXTURE(SetupFixture, test_resize_down) { const size_t INITIAL_SIZE = 4; const size_t NEW_SIZE = 2; @@ -234,7 +240,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Clear) + TEST_FIXTURE(SetupFixture, test_clear) { Data data(sorted_data.begin(), sorted_data.end()); data.clear(); @@ -243,7 +249,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, AssignRange) + TEST_FIXTURE(SetupFixture, test_assign_range) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data; @@ -260,7 +266,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, AssignSizeValue) + TEST_FIXTURE(SetupFixture, test_assign_size_value) { const size_t INITIAL_SIZE = 4; const int VALUE = 1; @@ -280,7 +286,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, AssignSizeValueExcess) + TEST_FIXTURE(SetupFixture, test_assign_size_value_excess) { const int VALUE = 1; @@ -290,7 +296,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, InsertPositionValue) + TEST_FIXTURE(SetupFixture, test_insert_position_value) { const size_t INITIAL_SIZE = 4; const int VALUE = 1; @@ -341,7 +347,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, InsertRange) + TEST_FIXTURE(SetupFixture, test_insert_range) { std::vector test1 = { 1, 2, 3, 4, 5 }; std::vector test2 = { 6, 7, 8, 9, 10 }; @@ -384,7 +390,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushFront) + TEST_FIXTURE(SetupFixture, test_push_front) { CompareData compare_data; Data data; @@ -409,7 +415,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushFrontExcess) + TEST_FIXTURE(SetupFixture, test_push_front_excess) { Data data; @@ -428,7 +434,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushFrontPopFront) + TEST_FIXTURE(SetupFixture, test_push_front_pop_front) { Data data; @@ -442,7 +448,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushFrontPopBack) + TEST_FIXTURE(SetupFixture, test_push_front_pop_back) { Data data; @@ -456,7 +462,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushBackPopFront) + TEST_FIXTURE(SetupFixture, test_push_back_pop_front) { Data data; @@ -470,7 +476,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushBackPopBack) + TEST_FIXTURE(SetupFixture, test_push_back_pop_back) { Data data; @@ -484,7 +490,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushBack) + TEST_FIXTURE(SetupFixture, test_push_back) { CompareData compare_data; Data data; @@ -509,7 +515,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushBackExcess) + TEST_FIXTURE(SetupFixture, test_push_back_excess) { Data data; @@ -528,7 +534,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, PopBack) + TEST_FIXTURE(SetupFixture, test_pop_back) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -545,7 +551,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, EraseSingle) + TEST_FIXTURE(SetupFixture, test_erase_single) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -591,7 +597,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, EraseRange) + TEST_FIXTURE(SetupFixture, test_erase_range) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -618,7 +624,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, EraseAll) + TEST_FIXTURE(SetupFixture, test_erase_all) { Data data(sorted_data.begin(), sorted_data.end()); @@ -633,7 +639,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Front) + TEST_FIXTURE(SetupFixture, test_front) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -642,7 +648,16 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Back) + TEST_FIXTURE(SetupFixture, test_front_const) + { + const CompareData compare_data(sorted_data.begin(), sorted_data.end()); + const Data data(sorted_data.begin(), sorted_data.end()); + + CHECK_EQUAL(compare_data.front(), data.front()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_back) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -651,7 +666,16 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Assignment) + TEST_FIXTURE(SetupFixture, test_back_const) + { + const CompareData compare_data(sorted_data.begin(), sorted_data.end()); + const Data data(sorted_data.begin(), sorted_data.end()); + + CHECK_EQUAL(compare_data.back(), data.back()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assignment) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -667,7 +691,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Unique) + TEST_FIXTURE(SetupFixture, test_unique) { CompareData compare_data(non_unique_data.begin(), non_unique_data.end()); Data data(non_unique_data.begin(), non_unique_data.end()); @@ -681,7 +705,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Remove) + TEST_FIXTURE(SetupFixture, test_remove) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -695,7 +719,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, RemoveIf) + TEST_FIXTURE(SetupFixture, test_remove_if) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -709,7 +733,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Reverse) + TEST_FIXTURE(SetupFixture, test_reverse) { CompareData compare_data(sorted_data.begin(), sorted_data.end()); Data data(sorted_data.begin(), sorted_data.end()); @@ -723,7 +747,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Sort) + TEST_FIXTURE(SetupFixture, test_sort) { CompareData compare_data(unsorted_data.begin(), unsorted_data.end()); Data data(unsorted_data.begin(), unsorted_data.end()); @@ -737,7 +761,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Swap) + TEST_FIXTURE(SetupFixture, test_swap) { Data first(unsorted_data.begin(), unsorted_data.end()); Data second(small_data.begin(), small_data.end()); diff --git a/test/test_numeric.cpp b/test/test_numeric.cpp index 843f0da1..164e1c0f 100644 --- a/test/test_numeric.cpp +++ b/test/test_numeric.cpp @@ -33,10 +33,10 @@ SOFTWARE. namespace { - SUITE(TestNumeric) + SUITE(test_numeric) { //************************************************************************* - TEST(IOTA) + TEST(test_iota) { int data1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int data2[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; diff --git a/test/test_observer.cpp b/test/test_observer.cpp index f44cbea9..7be27afa 100644 --- a/test/test_observer.cpp +++ b/test/test_observer.cpp @@ -196,10 +196,10 @@ public: namespace { - SUITE(TestObserver) + SUITE(test_observer) { //************************************************************************* - TEST(Test2Observables2Observers3Notifications) + TEST(test_2_observables_2_observers_3_notifications) { // The observable objects. Observable1 observable1; @@ -282,7 +282,7 @@ namespace } //************************************************************************* - TEST(Test8Notifications) + TEST(test_8_notifications) { typedef etl::observer, Notification<2>, Notification<3>, Notification<4>, Notification<5>, Notification<6>, Notification<7>, Notification<8>> Observer; @@ -295,7 +295,7 @@ namespace } //************************************************************************* - TEST(Test7Notifications) + TEST(test_7_notifications) { typedef etl::observer, Notification<2>, Notification<3>, Notification<4>, Notification<5>, Notification<6>, Notification<7>> Observer; @@ -308,7 +308,7 @@ namespace } //************************************************************************* - TEST(Test6Notifications) + TEST(test_6_notifications) { typedef etl::observer, Notification<2>, Notification<3>, Notification<4>, Notification<5>, Notification<6>> Observer; @@ -321,7 +321,7 @@ namespace } //************************************************************************* - TEST(Test5Notifications) + TEST(test_5_notifications) { typedef etl::observer, Notification<2>, Notification<3>, Notification<4>, Notification<5>> Observer; @@ -334,7 +334,7 @@ namespace } //************************************************************************* - TEST(Test4Notifications) + TEST(test_4_notifications) { typedef etl::observer, Notification<2>, Notification<3>, Notification<4>> Observer; @@ -347,7 +347,7 @@ namespace } //************************************************************************* - TEST(Test3Notifications) + TEST(test_3_notifications) { typedef etl::observer, Notification<2>, Notification<3>> Observer; @@ -360,7 +360,7 @@ namespace } //************************************************************************* - TEST(Test2Notifications) + TEST(test_2_notifications) { typedef etl::observer, Notification<2>> Observer; @@ -373,7 +373,7 @@ namespace } //************************************************************************* - TEST(Test1Notification) + TEST(test_1_notification) { typedef etl::observer> Observer; @@ -386,7 +386,7 @@ namespace } //************************************************************************* - TEST(TestObserverList) + TEST(test_observer_list) { class Observer : public etl::observer { diff --git a/test/test_queue.cpp b/test/test_queue.cpp index 87412064..fd888421 100644 --- a/test/test_queue.cpp +++ b/test/test_queue.cpp @@ -32,10 +32,10 @@ SOFTWARE. namespace { - SUITE(TestQueue) + SUITE(test_queue) { //************************************************************************* - TEST(Size) + TEST(test_size) { etl::queue queue; @@ -47,7 +47,7 @@ namespace } //************************************************************************* - TEST(Capacity) + TEST(test_capacity) { etl::queue queue; @@ -55,7 +55,7 @@ namespace } //************************************************************************* - TEST(Clear) + TEST(test_clear) { etl::queue queue; @@ -66,7 +66,7 @@ namespace } //************************************************************************* - TEST(Empty) + TEST(test_empty) { etl::queue queue; @@ -78,7 +78,7 @@ namespace } //************************************************************************* - TEST(Full) + TEST(test_full) { etl::queue queue; @@ -93,65 +93,7 @@ namespace } //************************************************************************* - TEST(Push) - { - etl::queue queue; - - queue.push(1); - CHECK_EQUAL(1, queue.size()); - - queue.push(2); - CHECK_EQUAL(2, queue.size()); - - CHECK_EQUAL(1, queue.front()); - - queue.pop(); - CHECK_EQUAL(2, queue.front()); - } - - //************************************************************************* - TEST(PushVoid) - { - etl::queue queue; - - queue.push() = 1; - CHECK_EQUAL(1, queue.size()); - - queue.push() = 2; - CHECK_EQUAL(2, queue.size()); - - CHECK_EQUAL(1, queue.front()); - - queue.pop(); - CHECK_EQUAL(2, queue.front()); - } - - //************************************************************************* - TEST(PushExcess) - { - etl::queue queue; - - for (size_t i = 0; i < queue.capacity(); ++i) - { - queue.push(1); - } - - CHECK_THROW(queue.push(1), etl::queue_full); - } - - //************************************************************************* - TEST(Pop) - { - etl::queue queue; - - queue.push(1); - queue.push(2); - queue.pop(); - CHECK_EQUAL(1, queue.size()); - } - - //************************************************************************* - TEST(Front) + TEST(test_front) { etl::queue queue; @@ -169,7 +111,7 @@ namespace } //************************************************************************* - TEST(FrontConst) + TEST(test_front_const) { etl::queue queue; const etl::queue& constQueue = queue; @@ -188,7 +130,7 @@ namespace } //************************************************************************* - TEST(FrontException) + TEST(test_front_exception) { etl::queue queue; @@ -196,7 +138,7 @@ namespace } //************************************************************************* - TEST(Back) + TEST(test_back) { etl::queue queue; @@ -211,7 +153,7 @@ namespace } //************************************************************************* - TEST(BackConst) + TEST(test_back_const) { etl::queue queue; const etl::queue& constQueue = queue; @@ -220,14 +162,14 @@ namespace CHECK_EQUAL(1, constQueue.back()); queue.push(2); - CHECK_EQUAL(2, constQueue.back()); - + CHECK_EQUAL(2, constQueue.back()); + queue.push(3); CHECK_EQUAL(3, constQueue.back()); } //************************************************************************* - TEST(BackException) + TEST(test_back_exception) { etl::queue queue; @@ -235,7 +177,54 @@ namespace } //************************************************************************* - TEST(CheckMultiplePush) + TEST(test_push) + { + etl::queue queue; + + queue.push(1); + CHECK_EQUAL(1, queue.size()); + + queue.push(2); + CHECK_EQUAL(2, queue.size()); + + CHECK_EQUAL(1, queue.front()); + + queue.pop(); + CHECK_EQUAL(2, queue.front()); + } + + //************************************************************************* + TEST(test_push_void) + { + etl::queue queue; + + queue.push() = 1; + CHECK_EQUAL(1, queue.size()); + + queue.push() = 2; + CHECK_EQUAL(2, queue.size()); + + CHECK_EQUAL(1, queue.front()); + + queue.pop(); + CHECK_EQUAL(2, queue.front()); + } + + //************************************************************************* + TEST(test_push_excess) + { + etl::queue queue; + + for (size_t i = 0; i < queue.capacity(); ++i) + { + queue.push(1); + } + + CHECK_THROW(queue.push(1), etl::queue_full); + } + + //************************************************************************* + TEST(test_multiple_push) { etl::queue queue; @@ -268,7 +257,7 @@ namespace } //************************************************************************* - TEST(CheckMultiplePushVoid) + TEST(test_multiple_push_void) { etl::queue queue; @@ -301,7 +290,18 @@ namespace } //************************************************************************* - TEST(Swap) + TEST(test_pop) + { + etl::queue queue; + + queue.push(1); + queue.push(2); + queue.pop(); + CHECK_EQUAL(1, queue.size()); + } + + //************************************************************************* + TEST(test_swap) { std::queue compare1; std::queue compare2; diff --git a/test/test_stack.cpp b/test/test_stack.cpp index cff96230..2079ba60 100644 --- a/test/test_stack.cpp +++ b/test/test_stack.cpp @@ -32,41 +32,10 @@ SOFTWARE. namespace { - SUITE(TestStack) + SUITE(test_stack) { //************************************************************************* - TEST(Size) - { - etl::stack stack; - - stack.push(1); - stack.push(2); - stack.push(3); - - CHECK_EQUAL(3, stack.size()); - } - - //************************************************************************* - TEST(Capacity) - { - etl::stack stack; - - CHECK_EQUAL(4, stack.capacity()); - } - - //************************************************************************* - TEST(Clear) - { - etl::stack stack; - - stack.push(1); - stack.push(2); - stack.clear(); - CHECK_EQUAL(0, stack.size()); - } - - //************************************************************************* - TEST(Empty) + TEST(test_empty) { etl::stack stack; @@ -78,7 +47,7 @@ namespace } //************************************************************************* - TEST(Full) + TEST(test_full) { etl::stack stack; @@ -93,7 +62,38 @@ namespace } //************************************************************************* - TEST(Push) + TEST(test_size) + { + etl::stack stack; + + stack.push(1); + stack.push(2); + stack.push(3); + + CHECK_EQUAL(3, stack.size()); + } + + //************************************************************************* + TEST(test_capacity) + { + etl::stack stack; + + CHECK_EQUAL(4, stack.capacity()); + } + + //************************************************************************* + TEST(test_clear) + { + etl::stack stack; + + stack.push(1); + stack.push(2); + stack.clear(); + CHECK_EQUAL(0, stack.size()); + } + + //************************************************************************* + TEST(test_push) { etl::stack stack; @@ -110,7 +110,7 @@ namespace } //************************************************************************* - TEST(PushVoid) + TEST(test_push_void) { etl::stack stack; @@ -127,7 +127,7 @@ namespace } //************************************************************************* - TEST(PushExcess) + TEST(test_push_excess) { etl::stack stack; @@ -140,7 +140,7 @@ namespace } //************************************************************************* - TEST(Pop) + TEST(test_pop) { etl::stack stack; @@ -151,7 +151,7 @@ namespace } //************************************************************************* - TEST(Top) + TEST(test_top) { etl::stack stack; @@ -169,7 +169,7 @@ namespace } //************************************************************************* - TEST(TopConst) + TEST(test_top_const) { etl::stack stack; const etl::stack& constQueue = stack; @@ -188,7 +188,7 @@ namespace } //************************************************************************* - TEST(TopException) + TEST(test_top_exception) { etl::stack stack; @@ -196,7 +196,7 @@ namespace } //************************************************************************* - TEST(CheckMultiplePush) + TEST(test_multiple_push) { etl::stack stack; @@ -229,7 +229,7 @@ namespace } //************************************************************************* - TEST(CheckMultiplePushVoid) + TEST(test_multiple_push_void) { etl::stack stack; @@ -262,7 +262,7 @@ namespace } //************************************************************************* - TEST(Swap) + TEST(test_swap) { std::stack compare1; std::stack compare2; diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index 58ff6b4b..65ce7b08 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -26,13 +26,13 @@ SOFTWARE. #include -#if (__GNUC__) +#if (COMPILER_GCC) #define __GXX_EXPERIMENTAL_CXX0X__ #endif #include -#if (__GNUC__) +#if (COMPILER_GCC) namespace std { template @@ -52,10 +52,10 @@ struct Test namespace { - SUITE(TestTypeTraits) + SUITE(test_type_traits) { //************************************************************************* - TEST(is_integral) + TEST(test_is_integral) { CHECK(etl::is_integral::value == std::is_integral::value); CHECK(etl::is_integral::value == std::is_integral::value); @@ -85,7 +85,7 @@ namespace } //************************************************************************* - TEST(is_signed) + TEST(test_is_signed) { CHECK(etl::is_signed::value == std::is_signed::value); CHECK(etl::is_signed::value == std::is_signed::value); @@ -115,7 +115,7 @@ namespace } //************************************************************************* - TEST(is_unsigned) + TEST(test_is_unsigned) { CHECK(etl::is_unsigned::value == std::is_unsigned::value); CHECK(etl::is_unsigned::value == std::is_unsigned::value); @@ -146,7 +146,7 @@ namespace } //************************************************************************* - TEST(is_floating_point) + TEST(test_is_floating_point) { CHECK(etl::is_floating_point::value == std::is_floating_point::value); CHECK(etl::is_floating_point::value == std::is_floating_point::value); @@ -176,7 +176,7 @@ namespace } //************************************************************************* - TEST(is_pointer) + TEST(test_is_pointer) { CHECK(etl::is_pointer::value == std::is_pointer::value); CHECK(etl::is_pointer::value == std::is_pointer::value); @@ -186,7 +186,7 @@ namespace } //************************************************************************* - TEST(is_reference) + TEST(test_is_reference) { CHECK(etl::is_reference::value == std::is_reference::value); CHECK(etl::is_reference::value == std::is_reference::value); @@ -196,21 +196,21 @@ namespace } //************************************************************************* - TEST(is_same) + TEST(test_is_same) { CHECK((etl::is_same::value == std::is_same::value)); CHECK((etl::is_same::value == std::is_same::value)); } //************************************************************************* - TEST(is_array) + TEST(test_is_array) { CHECK(etl::is_array::value == std::is_array::value); CHECK(etl::is_array::value == std::is_array::value); } //************************************************************************* - TEST(remove_pointer) + TEST(test_remove_pointer) { CHECK((std::is_same::type, std::remove_pointer::type>::value)); CHECK((std::is_same::type, std::remove_pointer::type>::value)); @@ -220,7 +220,7 @@ namespace } //************************************************************************* - TEST(add_pointer) + TEST(test_add_pointer) { CHECK((std::is_same::type, std::add_pointer::type>::value)); CHECK((std::is_same::type, std::add_pointer::type>::value)); @@ -230,7 +230,7 @@ namespace } //************************************************************************* - TEST(remove_reference) + TEST(test_remove_reference) { CHECK((std::is_same::type, std::remove_reference::type>::value)); CHECK((std::is_same::type, std::remove_reference::type>::value)); @@ -240,7 +240,7 @@ namespace } //************************************************************************* - TEST(add_reference) + TEST(test_add_reference) { CHECK((std::is_same::type, std::add_lvalue_reference::type>::value)); CHECK((std::is_same::type, std::add_reference::type>::value)); @@ -251,7 +251,7 @@ namespace } //************************************************************************* - TEST(remove_const) + TEST(test_remove_const) { CHECK((std::is_same::type, std::remove_const::type>::value)); CHECK((std::is_same::type, std::remove_const::type>::value)); @@ -259,7 +259,7 @@ namespace } //************************************************************************* - TEST(add_const) + TEST(test_add_const) { CHECK((std::is_same::type, std::add_const::type>::value)); CHECK((std::is_same::type, std::add_const::type>::value)); @@ -267,7 +267,7 @@ namespace } //************************************************************************* - TEST(is_const) + TEST(test_is_const) { CHECK(etl::is_const::value == std::is_const::value); CHECK(etl::is_const::value == std::is_const::value); @@ -275,7 +275,7 @@ namespace } //************************************************************************* - TEST(is_volatile) + TEST(test_is_volatile) { CHECK(etl::is_volatile::value == std::is_volatile::value); CHECK(etl::is_volatile::value == std::is_volatile::value); @@ -283,7 +283,7 @@ namespace } //************************************************************************* - TEST(remove_volatile) + TEST(test_remove_volatile) { CHECK((std::is_same::type, std::remove_volatile::type>::value)); CHECK((std::is_same::type, std::remove_volatile::type>::value)); @@ -291,7 +291,7 @@ namespace } //************************************************************************* - TEST(add_volatile) + TEST(test_add_volatile) { CHECK((std::is_same::type, std::add_volatile::type>::value)); CHECK((std::is_same::type, std::add_volatile::type>::value)); @@ -299,7 +299,7 @@ namespace } //************************************************************************* - TEST(remove_cv) + TEST(test_remove_cv) { CHECK((std::is_same::type, std::remove_cv::type>::value)); CHECK((std::is_same::type, std::remove_cv::type>::value)); @@ -308,7 +308,7 @@ namespace } //************************************************************************* - TEST(add_cv) + TEST(test_add_cv) { typedef etl::add_cv::type t1; @@ -324,7 +324,7 @@ namespace } //************************************************************************* - TEST(is_arithmetic) + TEST(test_is_arithmetic) { CHECK(etl::is_arithmetic::value == std::is_arithmetic::value); CHECK(etl::is_arithmetic::value == std::is_arithmetic::value); @@ -354,7 +354,7 @@ namespace } //************************************************************************* - TEST(is_fundamental) + TEST(test_is_fundamental) { CHECK(etl::is_fundamental::value == std::is_fundamental::value); CHECK(etl::is_fundamental::value == std::is_fundamental::value); @@ -385,14 +385,45 @@ namespace } //************************************************************************* - TEST(is_void) + TEST(test_is_compound) + { + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + CHECK(etl::is_compound::value == std::is_compound::value); + } + + //************************************************************************* + TEST(test_is_void) { CHECK(etl::is_void::value == std::is_void::value); CHECK(etl::is_void::value == std::is_void::value); } //************************************************************************* - TEST(make_signed) + TEST(test_make_signed) { CHECK((std::is_same::type, std::make_signed::type>::value)); CHECK((std::is_same::type, std::make_signed::type>::value)); @@ -417,7 +448,7 @@ namespace } //************************************************************************* - TEST(make_unsigned) + TEST(test_make_unsigned) { CHECK((std::is_same::type, std::make_unsigned::type>::value)); CHECK((std::is_same::type, std::make_unsigned::type>::value)); @@ -442,7 +473,7 @@ namespace } //************************************************************************* - TEST(extent) + TEST(test_extent) { CHECK((std::is_same::type, std::extent::type>::value)); CHECK((std::is_same::type, std::extent::type>::value)); @@ -450,7 +481,7 @@ namespace } //************************************************************************* - TEST(remove_extent) + TEST(test_remove_extent) { CHECK((std::is_same::type, std::remove_extent::type>::value)); CHECK((std::is_same::type, std::remove_extent::type>::value)); @@ -458,7 +489,7 @@ namespace } //************************************************************************* - TEST(remove_all_extents) + TEST(test_remove_all_extents) { CHECK((std::is_same::type, std::remove_all_extents::type>::value)); CHECK((std::is_same::type, std::remove_all_extents::type>::value)); @@ -466,7 +497,7 @@ namespace } //************************************************************************* - TEST(rank) + TEST(test_rank) { CHECK(etl::rank::value == std::rank::value); CHECK(etl::rank::value == std::rank::value); @@ -474,7 +505,7 @@ namespace } //************************************************************************* - TEST(alignment_of) + TEST(test_alignment_of) { struct Test { diff --git a/test/test_variant.cpp b/test/test_variant.cpp index eada05ba..d81b2c79 100644 --- a/test/test_variant.cpp +++ b/test/test_variant.cpp @@ -82,9 +82,9 @@ test_variant_max_types variant_max; namespace { - SUITE(test_alignment) + SUITE(test_variant) { - TEST(test_lignment) + TEST(test_alignment) { typedef etl::variant test_variant_a; typedef etl::variant test_variant_b; @@ -104,7 +104,7 @@ namespace } //************************************************************************* - TEST(text_constructor_value) + TEST(test_constructor_value) { // Char. char c = 'a'; diff --git a/test/test_vector.cpp b/test/test_vector.cpp index 5b1217ee..ec48bc92 100644 --- a/test/test_vector.cpp +++ b/test/test_vector.cpp @@ -34,18 +34,18 @@ SOFTWARE. namespace { - SUITE(TestVector) + SUITE(test_vector) { static const size_t SIZE = 10; typedef etl::vector Data; - typedef std::vector TestData; + typedef std::vector Compare_Data; - TestData initial_data; - TestData less_data; - TestData greater_data; - TestData shorter_data; - TestData different_data; + Compare_Data initial_data; + Compare_Data less_data; + Compare_Data greater_data; + Compare_Data shorter_data; + Compare_Data different_data; //************************************************************************* struct SetupFixture @@ -65,7 +65,7 @@ namespace }; //************************************************************************* - TEST_FIXTURE(SetupFixture, DefaultConstructor) + TEST_FIXTURE(SetupFixture, test_default_constructor) { Data data; @@ -76,7 +76,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorSize) + TEST_FIXTURE(SetupFixture, test_constructor_size) { const size_t INITIAL_SIZE = 5; Data data(INITIAL_SIZE); @@ -86,13 +86,13 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorSizeValue) + TEST_FIXTURE(SetupFixture, test_constructor_size_value) { const size_t INITIAL_SIZE = 5; const int INITIAL_VALUE = 1; - std::array testData; - testData.fill(INITIAL_VALUE); + std::array compare_data; + compare_data.fill(INITIAL_VALUE); Data data(INITIAL_SIZE, INITIAL_VALUE); @@ -101,114 +101,65 @@ namespace bool isEqual = std::equal(data.begin(), data.end(), - testData.begin()); + compare_data.begin()); CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorSizeExcess) + TEST_FIXTURE(SetupFixture, test_constructor_size_excess) { CHECK_THROW(Data data(SIZE + 1), etl::vector_full); } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstructorRange) + TEST_FIXTURE(SetupFixture, test_constructor_range) { - TestData testData(initial_data.begin(), initial_data.end()); + Compare_Data compare_data(initial_data.begin(), initial_data.end()); - Data data(testData.begin(), testData.end()); + Data data(compare_data.begin(), compare_data.end()); CHECK(data.size() == SIZE); CHECK(!data.empty()); } //************************************************************************* - TEST_FIXTURE(SetupFixture, Iterator) + TEST_FIXTURE(SetupFixture, test_assignment) { - TestData testData(initial_data.begin(), initial_data.end()); + Data data(initial_data.begin(), initial_data.end()); + Data otherData; - Data data(testData.begin(), testData.end()); + otherData = data; bool isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + otherData.begin()); CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstIterator) + TEST_FIXTURE(SetupFixture, test_begin) { - TestData testData(initial_data.begin(), initial_data.end()); + Data data(10); + const Data constData(10); - Data data(testData.begin(), testData.end()); - - bool isEqual = std::equal(data.cbegin(), - data.cend(), - testData.cbegin()); - - CHECK(isEqual); + CHECK_EQUAL(data.begin(), std::begin(data)); + CHECK_EQUAL(constData.begin(), std::begin(constData)); } //************************************************************************* - TEST_FIXTURE(SetupFixture, ReverseIterator) + TEST_FIXTURE(SetupFixture, test_end) { - TestData testData(initial_data.begin(), initial_data.end()); + Data data(10); + const Data constData(10); - Data data(testData.begin(), testData.end()); - - bool isEqual = std::equal(data.rbegin(), - data.rend(), - testData.rbegin()); - - CHECK(isEqual); + CHECK_EQUAL(data.end(), std::end(data)); + CHECK_EQUAL(constData.end(), std::end(constData)); } //************************************************************************* - TEST_FIXTURE(SetupFixture, ConstReverseIterator) - { - TestData testData(initial_data.begin(), initial_data.end()); - - Data data(testData.begin(), testData.end()); - - bool isEqual = std::equal(data.crbegin(), - data.crend(), - testData.crbegin()); - - CHECK(isEqual); - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, DataPointer) - { - TestData testData(initial_data.begin(), initial_data.end()); - - Data data(testData.begin(), testData.end()); - - bool isEqual = std::equal(data.data(), - data.data() + data.size(), - testData.begin()); - - CHECK(isEqual); - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, DataConstPointer) - { - TestData testData(initial_data.begin(), initial_data.end()); - - const Data data(testData.begin(), testData.end()); - - bool isEqual = std::equal(data.data(), - data.data() + data.size(), - testData.begin()); - - CHECK(isEqual); - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, ResizeUp) + TEST_FIXTURE(SetupFixture, test_resize_up) { const size_t INITIAL_SIZE = 5; const size_t NEW_SIZE = 8; @@ -220,7 +171,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ResizeUpValue) + TEST_FIXTURE(SetupFixture, test_resize_up_value) { const size_t INITIAL_SIZE = 5; const size_t NEW_SIZE = 8; @@ -229,16 +180,16 @@ namespace Data data(INITIAL_SIZE, INITIAL_VALUE); data.resize(NEW_SIZE, INITIAL_VALUE); - std::array testData; - testData.fill(INITIAL_VALUE); + std::array compare_data; + compare_data.fill(INITIAL_VALUE); - bool isEqual = std::equal(data.begin(), data.end(), testData.begin()); + bool isEqual = std::equal(data.begin(), data.end(), compare_data.begin()); CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, ResizeExcess) + TEST_FIXTURE(SetupFixture, test_resize_excess) { const size_t INITIAL_SIZE = 5; const size_t NEW_SIZE = SIZE + 1; @@ -249,7 +200,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, ResizeDown) + TEST_FIXTURE(SetupFixture, test_resize_down) { const size_t INITIAL_SIZE = 5; const size_t NEW_SIZE = 2; @@ -261,135 +212,304 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, Indexing) + TEST_FIXTURE(SetupFixture, test_empty) { - TestData testData(initial_data.begin(), initial_data.end()); + Data data; + data.resize(data.max_size()); - Data data(testData.begin(), testData.end()); - - for (size_t i = 0; i < data.size(); ++i) - { - CHECK_EQUAL(data[i], testData[i]); - } + CHECK(data.full()); + CHECK(!data.empty()); } //************************************************************************* - TEST_FIXTURE(SetupFixture, IndexingConst) + TEST_FIXTURE(SetupFixture, test_full) { - const TestData testData(initial_data.begin(), initial_data.end()); - - const Data data(testData.begin(), testData.end()); - - for (size_t i = 0; i < data.size(); ++i) - { - CHECK_EQUAL(data[i], testData[i]); - } - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, Clear) - { - TestData testData(initial_data.begin(), initial_data.end()); - - Data data(testData.begin(), testData.end()); - data.clear(); - - CHECK_EQUAL(data.size(), size_t(0)); - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, AssignRange) - { - TestData testData(initial_data.begin(), initial_data.end()); - Data data; - data.assign(testData.begin(), testData.end()); + CHECK(!data.full()); + CHECK(data.empty()); + } - bool isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_index) + { + Compare_Data compare_data(initial_data.begin(), initial_data.end()); + + Data data(compare_data.begin(), compare_data.end()); + + for (size_t i = 0; i < data.size(); ++i) + { + CHECK_EQUAL(data[i], compare_data[i]); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_index_const) + { + const Compare_Data compare_data(initial_data.begin(), initial_data.end()); + + const Data data(compare_data.begin(), compare_data.end()); + + for (size_t i = 0; i < data.size(); ++i) + { + CHECK_EQUAL(data[i], compare_data[i]); + } + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_at) + { + Compare_Data compare_data(initial_data.begin(), initial_data.end()); + Data data(initial_data.begin(), initial_data.end()); + + + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_at_const) + { + const Compare_Data compare_data(initial_data.begin(), initial_data.end()); + const Data data(initial_data.begin(), initial_data.end()); + + for (size_t i = 0; i < data.size(); ++i) + { + CHECK_EQUAL(data.at(i), compare_data.at(i)); + } + + CHECK_THROW(data.at(data.size()), etl::vector_out_of_bounds); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_front) + { + Compare_Data compare_data(initial_data.begin(), initial_data.end()); + Data data(initial_data.begin(), initial_data.end()); + + CHECK(data.front() == compare_data.front()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_front_const) + { + const Compare_Data compare_data(initial_data.begin(), initial_data.end()); + const Data data(initial_data.begin(), initial_data.end()); + + CHECK(data.front() == compare_data.front()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_back) + { + Compare_Data compare_data(initial_data.begin(), initial_data.end()); + Data data(initial_data.begin(), initial_data.end()); + + CHECK(data.back() == compare_data.back()); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_back_const) + { + const Compare_Data compare_data(initial_data.begin(), initial_data.end()); + const Data data(initial_data.begin(), initial_data.end()); + + CHECK(data.back() == compare_data.back()); + } + + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_data) + { + Compare_Data compare_data(initial_data.begin(), initial_data.end()); + + Data data(compare_data.begin(), compare_data.end()); + + bool isEqual = std::equal(data.data(), + data.data() + data.size(), + compare_data.begin()); CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, AssignSizeValue) + TEST_FIXTURE(SetupFixture, test_data_const) + { + Compare_Data compare_data(initial_data.begin(), initial_data.end()); + + const Data data(compare_data.begin(), compare_data.end()); + + bool isEqual = std::equal(data.data(), + data.data() + data.size(), + compare_data.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_range) + { + Compare_Data compare_data(initial_data.begin(), initial_data.end()); + + Data data; + + data.assign(compare_data.begin(), compare_data.end()); + + bool isEqual = std::equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_assign_size_value) { const size_t INITIAL_SIZE = 5; const int INITIAL_VALUE = 1; - std::array testData; - testData.fill(INITIAL_VALUE); + std::array compare_data; + compare_data.fill(INITIAL_VALUE); Data data; data.assign(INITIAL_SIZE, INITIAL_VALUE); bool isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, AssignSizeValueExcess) + TEST_FIXTURE(SetupFixture, test_assign_size_value_excess) { const size_t INITIAL_SIZE = SIZE; const size_t EXCESS_SIZE = SIZE + 1; const int INITIAL_VALUE = 1; - std::array testData; - testData.fill(INITIAL_VALUE); + std::array compare_data; + compare_data.fill(INITIAL_VALUE); Data data; - + CHECK_THROW(data.assign(EXCESS_SIZE, INITIAL_VALUE), etl::vector_full); } //************************************************************************* - TEST_FIXTURE(SetupFixture, InsertPositionValue) + TEST_FIXTURE(SetupFixture, test_push_back) + { + Compare_Data compare_data; + Data data; + + for (size_t i = 0; i < SIZE; ++i) + { + compare_data.push_back(i); + } + + for (size_t i = 0; i < SIZE; ++i) + { + data.push_back(i); + } + + bool isEqual = std::equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_push_back_null) + { + Compare_Data compare_data; + Data data; + + compare_data.push_back(1); + + data.push_back(); + data[0] = 1; + + bool isEqual = std::equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_push_back_excess) + { + Data data; + + for (size_t i = 0; i < SIZE; ++i) + { + data.push_back(i); + } + + CHECK_THROW(data.push_back(SIZE), etl::vector_full); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_pop_back) + { + Compare_Data compare_data(initial_data.begin(), initial_data.end()); + Data data(initial_data.begin(), initial_data.end()); + + compare_data.pop_back(); + compare_data.pop_back(); + + data.pop_back(); + data.pop_back(); + + bool isEqual = std::equal(data.begin(), + data.end(), + compare_data.begin()); + + CHECK(isEqual); + } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_insert_position_value) { const size_t INITIAL_SIZE = 5; const int INITIAL_VALUE = 1; - TestData testData(INITIAL_SIZE, INITIAL_VALUE); + Compare_Data compare_data(INITIAL_SIZE, INITIAL_VALUE); Data data(INITIAL_SIZE, INITIAL_VALUE); size_t offset = 2; data.insert(data.begin() + offset, INITIAL_VALUE); - testData.insert(testData.begin() + offset, INITIAL_VALUE); + compare_data.insert(compare_data.begin() + offset, INITIAL_VALUE); bool isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); offset = 0; data.insert(data.begin() + offset, INITIAL_VALUE); - testData.insert(testData.begin() + offset, INITIAL_VALUE); + compare_data.insert(compare_data.begin() + offset, INITIAL_VALUE); isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); offset = data.size(); data.insert(data.begin() + offset, INITIAL_VALUE); - testData.insert(testData.begin() + offset, INITIAL_VALUE); + compare_data.insert(compare_data.begin() + offset, INITIAL_VALUE); isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, InsertPositionValueExcess) + TEST_FIXTURE(SetupFixture, test_insert_position_value_excess) { const size_t INITIAL_SIZE = SIZE; const int INITIAL_VALUE = 1; @@ -410,56 +530,56 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, InsertPositionNValue) + TEST_FIXTURE(SetupFixture, test_insert_position_n_value) { const size_t INITIAL_SIZE = 5; - const size_t INSERT_SIZE = 3; - const int INITIAL_VALUE = 1; + const size_t INSERT_SIZE = 3; + const int INITIAL_VALUE = 1; - TestData testData; + Compare_Data compare_data; Data data; size_t offset = 2; data.assign(INITIAL_SIZE, INITIAL_VALUE); - testData.assign(INITIAL_SIZE, INITIAL_VALUE); + compare_data.assign(INITIAL_SIZE, INITIAL_VALUE); data.insert(data.begin() + offset, INSERT_SIZE, INITIAL_VALUE); - testData.insert(testData.begin() + offset, INSERT_SIZE, INITIAL_VALUE); + compare_data.insert(compare_data.begin() + offset, INSERT_SIZE, INITIAL_VALUE); bool isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); offset = 0; data.assign(INITIAL_SIZE, INITIAL_VALUE); - testData.assign(INITIAL_SIZE, INITIAL_VALUE); + compare_data.assign(INITIAL_SIZE, INITIAL_VALUE); data.insert(data.begin() + offset, INSERT_SIZE, INITIAL_VALUE); - testData.insert(testData.begin() + offset, INSERT_SIZE, INITIAL_VALUE); + compare_data.insert(compare_data.begin() + offset, INSERT_SIZE, INITIAL_VALUE); isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); data.assign(INITIAL_SIZE, INITIAL_VALUE); - testData.assign(INITIAL_SIZE, INITIAL_VALUE); + compare_data.assign(INITIAL_SIZE, INITIAL_VALUE); offset = data.size(); data.insert(data.begin() + offset, INSERT_SIZE, INITIAL_VALUE); - testData.insert(testData.begin() + offset, INSERT_SIZE, INITIAL_VALUE); + compare_data.insert(compare_data.begin() + offset, INSERT_SIZE, INITIAL_VALUE); isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, InsertPositionNValueExcess) + TEST_FIXTURE(SetupFixture, test_insert_position_n_value_excess) { const size_t INITIAL_SIZE = SIZE; const size_t INSERT_SIZE = 4; @@ -472,7 +592,7 @@ namespace CHECK_THROW(data.insert(data.begin() + offset, INSERT_SIZE, INITIAL_VALUE), etl::vector_full); offset = 0; - + CHECK_THROW(data.insert(data.begin() + offset, INSERT_SIZE, INITIAL_VALUE), etl::vector_full); offset = data.size(); @@ -481,62 +601,62 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, InsertPositionRange) + TEST_FIXTURE(SetupFixture, test_insert_position_range) { const size_t INITIAL_SIZE = 5; const int INITIAL_VALUE = 1; - TestData testData; + Compare_Data compare_data; Data data; size_t offset = 2; data.assign(INITIAL_SIZE, INITIAL_VALUE); - testData.assign(INITIAL_SIZE, INITIAL_VALUE); + compare_data.assign(INITIAL_SIZE, INITIAL_VALUE); data.insert(data.begin() + offset, initial_data.begin(), initial_data.begin() + 3); - testData.insert(testData.begin() + offset, initial_data.begin(), initial_data.begin() + 3); + compare_data.insert(compare_data.begin() + offset, initial_data.begin(), initial_data.begin() + 3); bool isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); offset = 0; data.assign(INITIAL_SIZE, INITIAL_VALUE); - testData.assign(INITIAL_SIZE, INITIAL_VALUE); + compare_data.assign(INITIAL_SIZE, INITIAL_VALUE); data.insert(data.begin() + offset, initial_data.begin(), initial_data.begin() + 3); - testData.insert(testData.begin() + offset, initial_data.begin(), initial_data.begin() + 3); + compare_data.insert(compare_data.begin() + offset, initial_data.begin(), initial_data.begin() + 3); isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); data.assign(INITIAL_SIZE, INITIAL_VALUE); - testData.assign(INITIAL_SIZE, INITIAL_VALUE); + compare_data.assign(INITIAL_SIZE, INITIAL_VALUE); offset = data.size(); data.insert(data.begin() + offset, initial_data.begin(), initial_data.begin() + 3); - testData.insert(testData.begin() + offset, initial_data.begin(), initial_data.begin() + 3); + compare_data.insert(compare_data.begin() + offset, initial_data.begin(), initial_data.begin() + 3); isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, InsertPositionRangeExcess) + TEST_FIXTURE(SetupFixture, test_insert_position_range_excess) { const size_t INITIAL_SIZE = 5; const int INITIAL_VALUE = 1; Data data(INITIAL_SIZE, INITIAL_VALUE); - size_t offset = 2; + size_t offset = 2; CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full); @@ -549,222 +669,110 @@ namespace CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full); } - //************************************************************************* - TEST_FIXTURE(SetupFixture, PushBack) - { - TestData testData; - Data data; - - for (size_t i = 0; i < SIZE; ++i) - { - testData.push_back(i); - } - - for (size_t i = 0; i < SIZE; ++i) - { - data.push_back(i); - } - - bool isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); - - CHECK(isEqual); - } //************************************************************************* - TEST_FIXTURE(SetupFixture, PushBackNull) + TEST_FIXTURE(SetupFixture, test_erase_single) { - TestData testData; - Data data; - - testData.push_back(1); - - data.push_back(); - data[0] = 1; - - bool isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); - - CHECK(isEqual); - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, PushBackExcess) - { - Data data; - - for (size_t i = 0; i < SIZE; ++i) - { - data.push_back(i); - } - - CHECK_THROW(data.push_back(SIZE), etl::vector_full); - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, PopBack) - { - TestData testData(initial_data.begin(), initial_data.end()); + Compare_Data compare_data(initial_data.begin(), initial_data.end()); Data data(initial_data.begin(), initial_data.end()); - testData.pop_back(); - testData.pop_back(); - - data.pop_back(); - data.pop_back(); - - bool isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); - - CHECK(isEqual); - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, EraseSingle) - { - TestData testData(initial_data.begin(), initial_data.end()); - Data data(initial_data.begin(), initial_data.end()); - - testData.erase(testData.begin() + 2); + compare_data.erase(compare_data.begin() + 2); data.erase(data.begin() + 2); bool isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, EraseRange) + TEST_FIXTURE(SetupFixture, test_erase_range) { - TestData testData(initial_data.begin(), initial_data.end()); + Compare_Data compare_data(initial_data.begin(), initial_data.end()); Data data(initial_data.begin(), initial_data.end()); - testData.erase(testData.begin() + 2, testData.begin() + 4); + compare_data.erase(compare_data.begin() + 2, compare_data.begin() + 4); data.erase(data.begin() + 2, data.begin() + 4); bool isEqual = std::equal(data.begin(), - data.end(), - testData.begin()); + data.end(), + compare_data.begin()); CHECK(isEqual); } - + //************************************************************************* - TEST_FIXTURE(SetupFixture, Front) + TEST_FIXTURE(SetupFixture, test_clear) { - TestData testData(initial_data.begin(), initial_data.end()); - Data data(initial_data.begin(), initial_data.end()); + Compare_Data compare_data(initial_data.begin(), initial_data.end()); - CHECK(data.front()== testData.front()); + Data data(compare_data.begin(), compare_data.end()); + data.clear(); + + CHECK_EQUAL(data.size(), size_t(0)); } //************************************************************************* - TEST_FIXTURE(SetupFixture, Back) + TEST_FIXTURE(SetupFixture, test_iterator) { - TestData testData(initial_data.begin(), initial_data.end()); - Data data(initial_data.begin(), initial_data.end()); + Compare_Data compare_data(initial_data.begin(), initial_data.end()); - CHECK(data.back() == testData.back()); - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, Assignment) - { - Data data(initial_data.begin(), initial_data.end()); - Data otherData; - - otherData = data; + Data data(compare_data.begin(), compare_data.end()); bool isEqual = std::equal(data.begin(), data.end(), - otherData.begin()); + compare_data.begin()); CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, At) + TEST_FIXTURE(SetupFixture, test_const_iterator) { - TestData testData(initial_data.begin(), initial_data.end()); - Data data(initial_data.begin(), initial_data.end()); + Compare_Data compare_data(initial_data.begin(), initial_data.end()); + Data data(compare_data.begin(), compare_data.end()); + bool isEqual = std::equal(data.cbegin(), + data.cend(), + compare_data.cbegin()); + + CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, AtConst) + TEST_FIXTURE(SetupFixture, test_reverse_iterator) { - const TestData testData(initial_data.begin(), initial_data.end()); - const Data data(initial_data.begin(), initial_data.end()); + Compare_Data compare_data(initial_data.begin(), initial_data.end()); - for (size_t i = 0; i < data.size(); ++i) - { - CHECK_EQUAL(data.at(i), testData.at(i)); - } + Data data(compare_data.begin(), compare_data.end()); - CHECK_THROW(data.at(data.size()), etl::vector_out_of_bounds); + bool isEqual = std::equal(data.rbegin(), + data.rend(), + compare_data.rbegin()); + + CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, Full) + TEST_FIXTURE(SetupFixture, test_const_reverse_iterator) { - Data data; - data.resize(data.max_size()); + Compare_Data compare_data(initial_data.begin(), initial_data.end()); - CHECK(data.full()); - CHECK(!data.empty()); + Data data(compare_data.begin(), compare_data.end()); + + bool isEqual = std::equal(data.crbegin(), + data.crend(), + compare_data.crbegin()); + + CHECK(isEqual); } //************************************************************************* - TEST_FIXTURE(SetupFixture, Begin) - { - Data data(10); - const Data constData(10); - - CHECK_EQUAL(data.begin(), std::begin(data)); - CHECK_EQUAL(constData.begin(), std::begin(constData)); - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, End) - { - Data data(10); - const Data constData(10); - - CHECK_EQUAL(data.end(), std::end(data)); - CHECK_EQUAL(constData.end(), std::end(constData)); - } - - //************************************************************************* - TEST(Swap) - { - std::vector first = { 1, 2, 3, 4, 5, 6 }; - std::vector second = { 6, 5, 4 }; - - Data data1(first.begin(), first.end()); - Data data2(second.begin(), second.end()); - - swap(data1, data2); - - CHECK_EQUAL(second.size(), data1.size()); - CHECK_EQUAL(first.size(), data2.size()); - - CHECK_EQUAL(std::distance(second.begin(), second.end()), std::distance(data1.begin(), data1.end())); - CHECK_EQUAL(std::distance(first.begin(), first.end()), std::distance(data2.begin(), data2.end())); - - CHECK(std::equal(second.begin(), second.end(), data1.begin())); - CHECK(std::equal(first.begin(), first.end(), data2.begin())); - } - - //************************************************************************* - TEST_FIXTURE(SetupFixture, Equal) + TEST_FIXTURE(SetupFixture, test_equal) { const Data initial1(initial_data.begin(), initial_data.end()); const Data initial2(initial_data.begin(), initial_data.end()); @@ -781,7 +789,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, NotEqual) + TEST_FIXTURE(SetupFixture, test_not_equal) { const Data initial1(initial_data.begin(), initial_data.end()); const Data initial2(initial_data.begin(), initial_data.end()); @@ -798,7 +806,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, LessThan) + TEST_FIXTURE(SetupFixture, test_less_than) { const Data less(less_data.begin(), less_data.end()); const Data initial(initial_data.begin(), initial_data.end()); @@ -816,7 +824,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, LessThanEqual) + TEST_FIXTURE(SetupFixture, test_less_than_or_equal) { const Data less(less_data.begin(), less_data.end()); const Data initial(initial_data.begin(), initial_data.end()); @@ -837,7 +845,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, GreaterThan) + TEST_FIXTURE(SetupFixture, test_greater_than) { const Data less(less_data.begin(), less_data.end()); const Data initial(initial_data.begin(), initial_data.end()); @@ -855,7 +863,7 @@ namespace } //************************************************************************* - TEST_FIXTURE(SetupFixture, GreaterThanEqual) + TEST_FIXTURE(SetupFixture, test_greater_than_or_equal) { const Data less(less_data.begin(), less_data.end()); const Data initial(initial_data.begin(), initial_data.end()); @@ -874,5 +882,26 @@ namespace const Data initial2(initial_data.begin(), initial_data.end()); CHECK((initial >= initial2) == (initial_data >= initial_data)); } + + //************************************************************************* + TEST(test_swap) + { + std::vector first = { 1, 2, 3, 4, 5, 6 }; + std::vector second = { 6, 5, 4 }; + + Data data1(first.begin(), first.end()); + Data data2(second.begin(), second.end()); + + swap(data1, data2); + + CHECK_EQUAL(second.size(), data1.size()); + CHECK_EQUAL(first.size(), data2.size()); + + CHECK_EQUAL(std::distance(second.begin(), second.end()), std::distance(data1.begin(), data1.end())); + CHECK_EQUAL(std::distance(first.begin(), first.end()), std::distance(data2.begin(), data2.end())); + + CHECK(std::equal(second.begin(), second.end(), data1.begin())); + CHECK(std::equal(first.begin(), first.end(), data2.begin())); + } }; } diff --git a/test/test_visitor.cpp b/test/test_visitor.cpp index 14a70fb5..8c7a78ad 100644 --- a/test/test_visitor.cpp +++ b/test/test_visitor.cpp @@ -181,10 +181,10 @@ public: namespace { - SUITE(TestVisitor) + SUITE(test_visitor) { //************************************************************************* - TEST(TestTwoVisitorsThreeVisitables) + TEST(test_two_visitors_three_visitables) { DrawVisitor draw_visitor; LogVisitor log_visitor; @@ -231,7 +231,7 @@ namespace } //************************************************************************* - TEST(Test1Visitor) + TEST(test_1_visitor) { class AShape; class ShapeVisitor1 : public etl::visitor @@ -251,7 +251,7 @@ namespace } //************************************************************************* - TEST(Test2Visitor) + TEST(test_2_visitor) { class AShape; class ShapeVisitor1 : public etl::visitor @@ -277,7 +277,7 @@ namespace } //************************************************************************* - TEST(Test3Visitor) + TEST(test_3_visitor) { class AShape; class ShapeVisitor1 : public etl::visitor @@ -309,7 +309,7 @@ namespace } //************************************************************************* - TEST(Test4Visitor) + TEST(test_4_visitor) { class AShape; class ShapeVisitor1 : public etl::visitor @@ -347,7 +347,7 @@ namespace } //************************************************************************* - TEST(Test1Visitable) + TEST(test_1_visitable) { class ShapeVisitor : public etl::visitor > { @@ -361,7 +361,7 @@ namespace } //************************************************************************* - TEST(Test2Visitables) + TEST(test_2_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor> > { @@ -376,7 +376,7 @@ namespace } //************************************************************************* - TEST(Test3Visitables) + TEST(test_3_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor> > { @@ -392,7 +392,7 @@ namespace } //************************************************************************* - TEST(Test4Visitables) + TEST(test_4_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor> > { @@ -409,7 +409,7 @@ namespace } //************************************************************************* - TEST(Test5Visitables) + TEST(test_5_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor> > @@ -428,7 +428,7 @@ namespace } //************************************************************************* - TEST(Test6Visitables) + TEST(test_6_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor>, Shape<6, ShapeVisitor> > @@ -448,7 +448,7 @@ namespace } //************************************************************************* - TEST(Test7Visitables) + TEST(test_7_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor>, Shape<6, ShapeVisitor>, Shape<7, ShapeVisitor> > @@ -469,7 +469,7 @@ namespace } //************************************************************************* - TEST(Test8Visitables) + TEST(test_8_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor>, Shape<6, ShapeVisitor>, Shape<7, ShapeVisitor>, Shape<8, ShapeVisitor> > @@ -491,7 +491,7 @@ namespace } //************************************************************************* - TEST(Test9Visitables) + TEST(test_9_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor>, Shape<6, ShapeVisitor>, Shape<7, ShapeVisitor>, Shape<8, ShapeVisitor>, @@ -515,7 +515,7 @@ namespace } //************************************************************************* - TEST(Test10Visitables) + TEST(test_10_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor>, Shape<6, ShapeVisitor>, Shape<7, ShapeVisitor>, Shape<8, ShapeVisitor>, @@ -541,7 +541,7 @@ namespace //************************************************************************* - TEST(Test11Visitables) + TEST(test_11_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor>, Shape<6, ShapeVisitor>, Shape<7, ShapeVisitor>, Shape<8, ShapeVisitor>, @@ -567,7 +567,7 @@ namespace } //************************************************************************* - TEST(Test12Visitables) + TEST(test_12_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor>, Shape<6, ShapeVisitor>, Shape<7, ShapeVisitor>, Shape<8, ShapeVisitor>, @@ -594,7 +594,7 @@ namespace } //************************************************************************* - TEST(Test13Visitables) + TEST(test_13_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor>, Shape<6, ShapeVisitor>, Shape<7, ShapeVisitor>, Shape<8, ShapeVisitor>, @@ -623,7 +623,7 @@ namespace } //************************************************************************* - TEST(Test14Visitables) + TEST(test_14_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor>, Shape<6, ShapeVisitor>, Shape<7, ShapeVisitor>, Shape<8, ShapeVisitor>, @@ -653,7 +653,7 @@ namespace } //************************************************************************* - TEST(Test15Visitables) + TEST(test_15_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor>, Shape<6, ShapeVisitor>, Shape<7, ShapeVisitor>, Shape<8, ShapeVisitor>, @@ -684,7 +684,7 @@ namespace } //************************************************************************* - TEST(Test16Visitables) + TEST(test_16_visitable) { class ShapeVisitor : public etl::visitor , Shape<2, ShapeVisitor>, Shape<3, ShapeVisitor>, Shape<4, ShapeVisitor>, Shape<5, ShapeVisitor>, Shape<6, ShapeVisitor>, Shape<7, ShapeVisitor>, Shape<8, ShapeVisitor>, diff --git a/test/vs2013/etl.vcxproj b/test/vs2013/etl.vcxproj index 8d50f43f..e0d7c65b 100644 --- a/test/vs2013/etl.vcxproj +++ b/test/vs2013/etl.vcxproj @@ -146,6 +146,7 @@ + @@ -202,7 +203,7 @@ - + diff --git a/test/vs2013/etl.vcxproj.filters b/test/vs2013/etl.vcxproj.filters index 0901bbc2..4b349c1a 100644 --- a/test/vs2013/etl.vcxproj.filters +++ b/test/vs2013/etl.vcxproj.filters @@ -267,6 +267,9 @@ ETL\Utilities + + ETL\Utilities + @@ -338,9 +341,6 @@ Source Files - - Source Files - Source Files @@ -413,6 +413,9 @@ Source Files + + Source Files + diff --git a/type_traits.h b/type_traits.h index fe00488c..50010fb5 100644 --- a/type_traits.h +++ b/type_traits.h @@ -79,9 +79,9 @@ namespace etl /// is_const ///\ingroup type_traits - template struct is_const : false_type { }; - template struct is_const : true_type { }; - template struct is_const : true_type { }; + template struct is_const : false_type {}; + template struct is_const : true_type {}; + template struct is_const : true_type {}; /// remove_const ///\ingroup type_traits @@ -95,9 +95,9 @@ namespace etl /// is_volatile ///\ingroup type_traits - template struct is_volatile : false_type { }; - template struct is_volatile : true_type { }; - template struct is_volatile : true_type { }; + template struct is_volatile : false_type {}; + template struct is_volatile : true_type {}; + template struct is_volatile : true_type {}; /// remove_volatile ///\ingroup type_traits @@ -125,78 +125,78 @@ namespace etl /// is_integral ///\ingroup type_traits - template struct is_integral : false_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template <> struct is_integral : true_type { }; - template struct is_integral : is_integral { }; - template struct is_integral : is_integral { }; - template struct is_integral : is_integral { }; + template struct is_integral : false_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template <> struct is_integral : true_type {}; + template struct is_integral : is_integral {}; + template struct is_integral : is_integral {}; + template struct is_integral : is_integral {}; /// is_signed ///\ingroup type_traits - template struct is_signed : false_type { }; - template <> struct is_signed : true_type { }; + template struct is_signed : false_type {}; + template <> struct is_signed : true_type {}; #ifdef PLATFORM_LINUX - template <> struct is_signed : true_type { }; + template <> struct is_signed : true_type {}; #endif - template <> struct is_signed : true_type { }; - template <> struct is_signed : true_type { }; - template <> struct is_signed : true_type { }; - template <> struct is_signed : true_type { }; - template <> struct is_signed : true_type { }; + template <> struct is_signed : true_type {}; + template <> struct is_signed : true_type {}; + template <> struct is_signed : true_type {}; + template <> struct is_signed : true_type {}; + template <> struct is_signed : true_type {}; template <> struct is_signed : true_type{}; template <> struct is_signed : true_type{}; template <> struct is_signed : true_type{}; - template struct is_signed : is_signed { }; - template struct is_signed : is_signed { }; - template struct is_signed : is_signed { }; + template struct is_signed : is_signed {}; + template struct is_signed : is_signed {}; + template struct is_signed : is_signed {}; /// is_unsigned ///\ingroup type_traits - template struct is_unsigned : false_type { }; - template <> struct is_unsigned : true_type { }; - template <> struct is_unsigned : true_type { }; + template struct is_unsigned : false_type {}; + template <> struct is_unsigned : true_type {}; + template <> struct is_unsigned : true_type {}; #ifndef PLATFORM_LINUX - template <> struct is_unsigned : true_type { }; + template <> struct is_unsigned : true_type {}; #endif - template <> struct is_unsigned : true_type { }; - template <> struct is_unsigned : true_type { }; - template <> struct is_unsigned : true_type { }; - template <> struct is_unsigned : true_type { }; - template struct is_unsigned : is_unsigned { }; - template struct is_unsigned : is_unsigned { }; - template struct is_unsigned : is_unsigned { }; + template <> struct is_unsigned : true_type {}; + template <> struct is_unsigned : true_type {}; + template <> struct is_unsigned : true_type {}; + template <> struct is_unsigned : true_type {}; + template struct is_unsigned : is_unsigned {}; + template struct is_unsigned : is_unsigned {}; + template struct is_unsigned : is_unsigned {}; /// is_floating_point ///\ingroup type_traits - template struct is_floating_point : false_type { }; - template <> struct is_floating_point : true_type { }; - template <> struct is_floating_point : true_type { }; - template <> struct is_floating_point : true_type { }; - template struct is_floating_point : is_floating_point { }; - template struct is_floating_point : is_floating_point { }; - template struct is_floating_point : is_floating_point { }; + template struct is_floating_point : false_type {}; + template <> struct is_floating_point : true_type {}; + template <> struct is_floating_point : true_type {}; + template <> struct is_floating_point : true_type {}; + template struct is_floating_point : is_floating_point {}; + template struct is_floating_point : is_floating_point {}; + template struct is_floating_point : is_floating_point {}; /// is_same ///\ingroup type_traits - template struct is_same : public false_type { }; - template struct is_same : public true_type { }; + template struct is_same : public false_type {}; + template struct is_same : public true_type {}; /// is_void ///\ingroup type_traits - template struct is_void : false_type { }; - template<> struct is_void : true_type { }; + template struct is_void : false_type {}; + template<> struct is_void : true_type {}; /// is_arithmetic ///\ingroup type_traits @@ -209,6 +209,10 @@ namespace etl is_same::type>::value> {}; + /// is_compound + ///\ingroup type_traits + template struct is_compound : std::integral_constant::value> {}; + /// is_array ///\ingroup type_traits template struct is_array : false_type {}; @@ -217,8 +221,8 @@ namespace etl /// is_pointer ///\ingroup type_traits - template struct is_pointer : false_type { }; - template struct is_pointer : true_type { }; + template struct is_pointer : false_type {}; + template struct is_pointer : true_type {}; /// is_reference ///\ingroup type_traits @@ -237,9 +241,9 @@ namespace etl template <> struct make_signed { typedef int type; }; template <> struct make_signed { typedef long type; }; template <> struct make_signed { typedef long long type; }; - template struct make_signed : add_const::type> { }; - template struct make_signed : add_volatile::type> { }; - template struct make_signed : add_const::type>::type> { }; + template struct make_signed : add_const::type> {}; + template struct make_signed : add_volatile::type> {}; + template struct make_signed : add_const::type>::type> {}; /// make_unsigned ///\ingroup type_traits @@ -253,13 +257,13 @@ namespace etl template <> struct make_unsigned { typedef unsigned int type; }; template <> struct make_unsigned { typedef unsigned long type; }; template <> struct make_unsigned { typedef unsigned long long type; }; - template struct make_unsigned : add_const::type> { }; - template struct make_unsigned : add_volatile::type> { }; - template struct make_unsigned : add_const::type>::type> { }; + template struct make_unsigned : add_const::type> {}; + template struct make_unsigned : add_volatile::type> {}; + template struct make_unsigned : add_const::type>::type> {}; /// enable_if ///\ingroup type_traits - template struct enable_if { }; + template struct enable_if {}; template struct enable_if { typedef T type; }; /// conditional