From 778351a49ed22ec08e9e9985a2347dd0511ce48d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 20 Jan 2025 13:50:36 +0000 Subject: [PATCH] Removed constexpr from unaligned_type --- include/etl/unaligned_type.h | 568 ++--------- test/test_unaligned_type_constexpr.cpp | 1240 ++++++++++++------------ 2 files changed, 711 insertions(+), 1097 deletions(-) diff --git a/include/etl/unaligned_type.h b/include/etl/unaligned_type.h index 3fcaf40e0..8910f864d 100644 --- a/include/etl/unaligned_type.h +++ b/include/etl/unaligned_type.h @@ -41,6 +41,7 @@ SOFTWARE. #include "iterator.h" #include "algorithm.h" #include "bit.h" +#include "binary.h" #include "array.h" #include "exception.h" #include "file_error_numbers.h" @@ -100,14 +101,14 @@ namespace etl //************************************************************************* /// Default constructor //************************************************************************* - ETL_CONSTEXPR14 unaligned_type_common() + unaligned_type_common() { } //************************************************************************* /// Size of the storage. //************************************************************************* - ETL_CONSTEXPR14 size_t size() const + size_t size() const { return Size_; } @@ -123,7 +124,7 @@ namespace etl //************************************************************************* /// Const pointer to the beginning of the storage. //************************************************************************* - ETL_CONSTEXPR14 const_pointer data() const + const_pointer data() const { return get_storage(); } @@ -139,7 +140,7 @@ namespace etl //************************************************************************* /// Const iterator to the beginning of the storage. //************************************************************************* - ETL_CONSTEXPR14 const_iterator begin() const + const_iterator begin() const { return const_iterator(get_storage()); } @@ -147,7 +148,7 @@ namespace etl //************************************************************************* /// Const iterator to the beginning of the storage. //************************************************************************* - ETL_CONSTEXPR14 const_iterator cbegin() const + const_iterator cbegin() const { return const_iterator(get_storage()); } @@ -163,7 +164,7 @@ namespace etl //************************************************************************* /// Const reverse iterator to the beginning of the storage. //************************************************************************* - ETL_CONSTEXPR14 const_reverse_iterator rbegin() const + const_reverse_iterator rbegin() const { return const_reverse_iterator(get_storage() + Size_); } @@ -171,7 +172,7 @@ namespace etl //************************************************************************* /// Const reverse iterator to the beginning of the storage. //************************************************************************* - ETL_CONSTEXPR14 const_reverse_iterator crbegin() const + const_reverse_iterator crbegin() const { return const_reverse_iterator(get_storage() + Size_); } @@ -187,7 +188,7 @@ namespace etl //************************************************************************* /// Const iterator to the end of the storage. //************************************************************************* - ETL_CONSTEXPR14 const_iterator end() const + const_iterator end() const { return const_iterator(get_storage() + Size_); } @@ -195,7 +196,7 @@ namespace etl //************************************************************************* /// Const iterator to the end of the storage. //************************************************************************* - ETL_CONSTEXPR14 const_iterator cend() const + const_iterator cend() const { return const_iterator(get_storage() + Size_); } @@ -211,7 +212,7 @@ namespace etl //************************************************************************* /// Const reverse iterator to the end of the storage. //************************************************************************* - ETL_CONSTEXPR14 const_reverse_iterator rend() const + const_reverse_iterator rend() const { return const_reverse_iterator(get_storage()); } @@ -219,7 +220,7 @@ namespace etl //************************************************************************* /// Const reverse iterator to the end of the storage. //************************************************************************* - ETL_CONSTEXPR14 const_reverse_iterator crend() const + const_reverse_iterator crend() const { return const_reverse_iterator(get_storage()); } @@ -235,7 +236,7 @@ namespace etl //************************************************************************* /// Const index operator. //************************************************************************* - ETL_CONSTEXPR14 const storage_type& operator[](int i) const + const storage_type& operator[](int i) const { return get_storage()[i]; } @@ -253,7 +254,7 @@ namespace etl //************************************************************************* /// Get a const pointer to the storage. //************************************************************************* - ETL_CONSTEXPR14 const_pointer get_storage() const + const_pointer get_storage() const { return static_cast(this)->storage; } @@ -274,25 +275,11 @@ namespace etl protected: //******************************* - ETL_CONSTEXPR14 unaligned_type_storage() + unaligned_type_storage() : storage() { } - //******************************* - ETL_CONSTEXPR14 unaligned_type_storage(const unaligned_type_storage& other) - { - etl::copy_n(other.storage, Size_, storage); - } - - //******************************* - ETL_CONSTEXPR14 unaligned_type_storage& operator =(const unaligned_type_storage& other) - { - etl::copy_n(other.storage, Size_, storage); - - return *this; - } - unsigned char storage[Size_]; }; ETL_END_PACKED @@ -311,19 +298,19 @@ namespace etl protected: //******************************* - ETL_CONSTEXPR14 unaligned_type_storage_ext(unsigned char* storage_) + unaligned_type_storage_ext(unsigned char* storage_) : storage(storage_) { } //******************************* - ETL_CONSTEXPR14 unaligned_type_storage_ext(const unaligned_type_storage_ext& other) + unaligned_type_storage_ext(const unaligned_type_storage_ext& other) : storage(other.storage) { } //******************************* - ETL_CONSTEXPR14 unaligned_type_storage_ext& operator =(const unaligned_type_storage_ext& other) + unaligned_type_storage_ext& operator =(const unaligned_type_storage_ext& other) { storage = other.storage; @@ -336,510 +323,119 @@ namespace etl //************************************************************************* /// Unaligned copy //************************************************************************* - template + template class unaligned_copy; //************************************************************************* /// Unaligned copy - /// Size == 1 - //************************************************************************* - template - ETL_PACKED_CLASS(unaligned_copy)::value>::type> - { - public: - - typedef typename private_unaligned_type::unaligned_type_storage::storage_type storage_type; - typedef typename private_unaligned_type::unaligned_type_storage::pointer pointer; - typedef typename private_unaligned_type::unaligned_type_storage::const_pointer const_pointer; - - //******************************* - static ETL_CONSTEXPR14 void copy_value_to_store(T value, pointer store) - { - store[0] = static_cast(value); - } - - //******************************* - static ETL_CONSTEXPR14 void copy_store_to_value(const_pointer store, T& value) - { - value = static_cast(store[0]); - } - - //******************************* - static ETL_CONSTEXPR14 void copy_store_to_store(const_pointer src, int /*endian_src*/, unsigned char* dst) - { - dst[0] = src[0]; - } - }; ETL_END_PACKED - - //************************************************************************* - /// Unaligned copy - /// Size == 2 - //************************************************************************* - template - ETL_PACKED_CLASS(unaligned_copy)::value>::type> - { - public: - - typedef typename private_unaligned_type::unaligned_type_storage::storage_type storage_type; - typedef typename private_unaligned_type::unaligned_type_storage::pointer pointer; - typedef typename private_unaligned_type::unaligned_type_storage::const_pointer const_pointer; - - //******************************* - static ETL_CONSTEXPR14 void copy_value_to_store(T value, pointer store) - { -#if ETL_HAS_CONSTEXPR_ENDIANESS - if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) -#else - if (Endian == etl::endianness::value()) -#endif - { - store[0] = static_cast(value); - store[1] = static_cast(value >> (1U * CHAR_BIT)); - } - else - { - store[1] = static_cast(value); - store[0] = static_cast(value >> (1U * CHAR_BIT)); - } - } - - //******************************* - static ETL_CONSTEXPR14 void copy_store_to_value(const_pointer store, T& value) - { -#if ETL_HAS_CONSTEXPR_ENDIANESS - if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) -#else - if (Endian == etl::endianness::value()) -#endif - { - value = static_cast(static_cast(store[0])); - value |= static_cast(static_cast(store[1])) << (1U * CHAR_BIT); - } - else - { - value = static_cast(static_cast(store[1])); - value |= static_cast(static_cast(store[0])) << (1U * CHAR_BIT); - } - } - - //******************************* - static ETL_CONSTEXPR14 void copy_store_to_store(const_pointer src, int endian_src, unsigned char* dst) - { - if (Endian == endian_src) - { - dst[0] = src[0]; - dst[1] = src[1]; - } - else - { - dst[0] = src[1]; - dst[1] = src[0]; - } - } - }; ETL_END_PACKED - - //************************************************************************* - /// Unaligned copy - /// Size == 4 - /// Integrals - //************************************************************************* - template - ETL_PACKED_CLASS(unaligned_copy)::value>::type> - { - public: - - typedef typename private_unaligned_type::unaligned_type_storage::storage_type storage_type; - typedef typename private_unaligned_type::unaligned_type_storage::pointer pointer; - typedef typename private_unaligned_type::unaligned_type_storage::const_pointer const_pointer; - - static ETL_CONSTEXPR14 void copy_value_to_store(T value, pointer store) - { -#if ETL_HAS_CONSTEXPR_ENDIANESS - if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) -#else - if (Endian == etl::endianness::value()) -#endif - { - store[0] = static_cast(value); - store[1] = static_cast(value >> (1U * CHAR_BIT)); - store[2] = static_cast(value >> (2U * CHAR_BIT)); - store[3] = static_cast(value >> (3U * CHAR_BIT)); - } - else - { - store[3] = static_cast(value); - store[2] = static_cast(value >> (1U * CHAR_BIT)); - store[1] = static_cast(value >> (2U * CHAR_BIT)); - store[0] = static_cast(value >> (3U * CHAR_BIT)); - } - } - - //******************************* - static ETL_CONSTEXPR14 void copy_store_to_value(const_pointer store, T& value) - { -#if ETL_HAS_CONSTEXPR_ENDIANESS - if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) -#else - if (Endian == etl::endianness::value()) -#endif - { - value = static_cast(static_cast(store[0])); - value |= static_cast(static_cast(store[1])) << (1U * CHAR_BIT); - value |= static_cast(static_cast(store[2])) << (2U * CHAR_BIT); - value |= static_cast(static_cast(store[3])) << (3U * CHAR_BIT); - } - else - { - value = static_cast(static_cast(store[3])); - value |= static_cast(static_cast(store[2])) << (1U * CHAR_BIT); - value |= static_cast(static_cast(store[1])) << (2U * CHAR_BIT); - value |= static_cast(static_cast(store[0])) << (3U * CHAR_BIT); - } - } - - //******************************* - static ETL_CONSTEXPR14 void copy_store_to_store(const_pointer src, int endian_src, unsigned char* dst) - { - if (Endian == endian_src) - { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; - } - else - { - dst[0] = src[3]; - dst[1] = src[2]; - dst[2] = src[1]; - dst[3] = src[0]; - } - } - }; ETL_END_PACKED - - //************************************************************************* - /// Unaligned copy - /// Size == 4 - /// Floating point - //************************************************************************* - template - ETL_PACKED_CLASS(unaligned_copy)::value>::type> - { - public: - - typedef typename private_unaligned_type::unaligned_type_storage::storage_type storage_type; - typedef typename private_unaligned_type::unaligned_type_storage::pointer pointer; - typedef typename private_unaligned_type::unaligned_type_storage::const_pointer const_pointer; - - static void copy_value_to_store(T value, pointer store) - { - memcpy(store, &value, 4U); - - if (Endian != etl::endianness::value()) - { - etl::reverse(store, store + 4U); - } - } - - //******************************* - static void copy_store_to_value(const_pointer store, T& value) - { - unsigned char temp[4U]; - memcpy(temp, store, 4U); - - if (Endian != etl::endianness::value()) - { - etl::reverse(temp, temp + 4U); - } - - memcpy(&value, temp, 4U); - } - - //******************************* - static void copy_store_to_store(const_pointer src, int endian_src, unsigned char* dst) - { - memcpy(dst, src, 4U); - - if (Endian != endian_src) - { - etl::reverse(dst, dst + 4U); - } - } - }; ETL_END_PACKED - - //************************************************************************* - /// Unaligned copy - /// Size == 8 - /// Integrals + /// For integrals. //************************************************************************* - template - ETL_PACKED_CLASS(unaligned_copy)::value>::type> + template + ETL_PACKED_CLASS(unaligned_copy) { public: - typedef typename private_unaligned_type::unaligned_type_storage::storage_type storage_type; - typedef typename private_unaligned_type::unaligned_type_storage::pointer pointer; - typedef typename private_unaligned_type::unaligned_type_storage::const_pointer const_pointer; - - static ETL_CONSTEXPR14 void copy_value_to_store(T value, pointer store) - { -#if ETL_HAS_CONSTEXPR_ENDIANESS - if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) -#else - if (Endian == etl::endianness::value()) -#endif - { - store[0] = static_cast(value); - store[1] = static_cast(value >> (1U * CHAR_BIT)); - store[2] = static_cast(value >> (2U * CHAR_BIT)); - store[3] = static_cast(value >> (3U * CHAR_BIT)); - store[4] = static_cast(value >> (4U * CHAR_BIT)); - store[5] = static_cast(value >> (5U * CHAR_BIT)); - store[6] = static_cast(value >> (6U * CHAR_BIT)); - store[7] = static_cast(value >> (7U * CHAR_BIT)); - } - else - { - store[7] = static_cast(value); - store[6] = static_cast(value >> (1U * CHAR_BIT)); - store[5] = static_cast(value >> (2U * CHAR_BIT)); - store[4] = static_cast(value >> (3U * CHAR_BIT)); - store[3] = static_cast(value >> (4U * CHAR_BIT)); - store[2] = static_cast(value >> (5U * CHAR_BIT)); - store[1] = static_cast(value >> (6U * CHAR_BIT)); - store[0] = static_cast(value >> (7U * CHAR_BIT)); - } - } + typedef typename private_unaligned_type::unaligned_type_storage::storage_type storage_type; + typedef typename private_unaligned_type::unaligned_type_storage::pointer pointer; + typedef typename private_unaligned_type::unaligned_type_storage::const_pointer const_pointer; //******************************* - static ETL_CONSTEXPR14 void copy_store_to_value(const_pointer store, T& value) + template + static void copy_value_to_store(const T& value, pointer store) { -#if ETL_HAS_CONSTEXPR_ENDIANESS - if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) -#else - if (Endian == etl::endianness::value()) -#endif - { - value = static_cast(static_cast(store[0])); - value |= static_cast(static_cast(store[1])) << (1U * CHAR_BIT); - value |= static_cast(static_cast(store[2])) << (2U * CHAR_BIT); - value |= static_cast(static_cast(store[3])) << (3U * CHAR_BIT); - value |= static_cast(static_cast(store[4])) << (4U * CHAR_BIT); - value |= static_cast(static_cast(store[5])) << (5U * CHAR_BIT); - value |= static_cast(static_cast(store[6])) << (6U * CHAR_BIT); - value |= static_cast(static_cast(store[7])) << (7U * CHAR_BIT); - } - else - { - value = static_cast(static_cast(store[7])); - value |= static_cast(static_cast(store[6])) << (1U * CHAR_BIT); - value |= static_cast(static_cast(store[5])) << (2U * CHAR_BIT); - value |= static_cast(static_cast(store[4])) << (3U * CHAR_BIT); - value |= static_cast(static_cast(store[3])) << (4U * CHAR_BIT); - value |= static_cast(static_cast(store[2])) << (5U * CHAR_BIT); - value |= static_cast(static_cast(store[1])) << (6U * CHAR_BIT); - value |= static_cast(static_cast(store[0])) << (7U * CHAR_BIT); - } - } - - //******************************* - static ETL_CONSTEXPR14 void copy_store_to_store(const_pointer src, int endian_src, unsigned char* dst) - { - if (Endian == endian_src) - { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; - dst[4] = src[4]; - dst[5] = src[5]; - dst[6] = src[6]; - dst[7] = src[7]; - } - else - { - dst[0] = src[7]; - dst[1] = src[6]; - dst[2] = src[5]; - dst[3] = src[4]; - dst[4] = src[3]; - dst[5] = src[2]; - dst[6] = src[1]; - dst[7] = src[0]; - } - } - }; ETL_END_PACKED - - //************************************************************************* - /// Unaligned copy - /// Size == 8 - /// Floating point - //************************************************************************* - template - ETL_PACKED_CLASS(unaligned_copy)::value>::type> - { - public: - - typedef typename private_unaligned_type::unaligned_type_storage::storage_type storage_type; - typedef typename private_unaligned_type::unaligned_type_storage::pointer pointer; - typedef typename private_unaligned_type::unaligned_type_storage::const_pointer const_pointer; - - static void copy_value_to_store(T value, pointer store) - { - memcpy(store, &value, 8U); + memcpy(store, &value, Size_); #if ETL_HAS_CONSTEXPR_ENDIANESS - if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) + if ETL_IF_CONSTEXPR(Endian_ == etl::endianness::value()) #else - if (Endian == etl::endianness::value()) + if (Endian_ != etl::endianness::value()) #endif { - etl::reverse(store, store + 8U); + etl::reverse(store, store + Size_); } } //******************************* + template static void copy_store_to_value(const_pointer store, T& value) { - unsigned char temp[8U]; - memcpy(temp, store, 8U); + memcpy(&value, store, Size_); #if ETL_HAS_CONSTEXPR_ENDIANESS if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) #else - if (Endian == etl::endianness::value()) + if (Endian_ != etl::endianness::value()) #endif { - etl::reverse(temp, temp + 8U); + value = etl::reverse_bytes(value); } - - memcpy(&value, temp, 8U); } //******************************* - static ETL_CONSTEXPR14 void copy_store_to_store(const_pointer src, int endian_src, unsigned char* dst) + static void copy_store_to_store(const_pointer src, int endian_src, pointer dst) { - memcpy(dst, src, 8U); + memcpy(dst, src, Size_); - if (Endian != endian_src) + if (Endian_ != endian_src) { - etl::reverse(dst, dst + 8U); + etl::reverse(dst, dst + Size_); } } }; ETL_END_PACKED //************************************************************************* /// Unaligned copy - /// Size == 12 - /// Floating point + /// For floating point. //************************************************************************* - template - ETL_PACKED_CLASS(unaligned_copy)::value>::type> + template + ETL_PACKED_CLASS(unaligned_copy) { public: - typedef typename private_unaligned_type::unaligned_type_storage::storage_type storage_type; - typedef typename private_unaligned_type::unaligned_type_storage::pointer pointer; - typedef typename private_unaligned_type::unaligned_type_storage::const_pointer const_pointer; - - static void copy_value_to_store(T value, pointer store) - { - memcpy(store, &value, 12U); - -#if ETL_HAS_CONSTEXPR_ENDIANESS - if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) -#else - if (Endian == etl::endianness::value()) -#endif - { - etl::reverse(store, store + 12U); - } - } + typedef typename private_unaligned_type::unaligned_type_storage::storage_type storage_type; + typedef typename private_unaligned_type::unaligned_type_storage::pointer pointer; + typedef typename private_unaligned_type::unaligned_type_storage::const_pointer const_pointer; //******************************* - static void copy_store_to_value(const_pointer store, T& value) + template + static void copy_value_to_store(const T& value, pointer store) { - unsigned char temp[12U]; - memcpy(temp, store, 12U); + memcpy(store, &value, Size_); #if ETL_HAS_CONSTEXPR_ENDIANESS - if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) + if ETL_IF_CONSTEXPR(Endian_ == etl::endianness::value()) #else - if (Endian == etl::endianness::value()) + if (Endian_ != etl::endianness::value()) #endif { - etl::reverse(temp, temp + 12U); - } - - memcpy(&value, temp, 12U); - } - - //******************************* - static ETL_CONSTEXPR14 void copy_store_to_store(const_pointer src, int endian_src, unsigned char* dst) - { - memcpy(dst, src, 12U); - - if (Endian != endian_src) - { - etl::reverse(dst, dst + 12U); - } - } - }; ETL_END_PACKED - - //************************************************************************* - /// Unaligned copy - /// Size == 16 - /// Floating point - //************************************************************************* - template - ETL_PACKED_CLASS(unaligned_copy)::value>::type> - { - public: - - typedef typename private_unaligned_type::unaligned_type_storage::storage_type storage_type; - typedef typename private_unaligned_type::unaligned_type_storage::pointer pointer; - typedef typename private_unaligned_type::unaligned_type_storage::const_pointer const_pointer; - - static void copy_value_to_store(T value, pointer store) - { - memcpy(store, &value, 16U); - -#if ETL_HAS_CONSTEXPR_ENDIANESS - if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) -#else - if (Endian == etl::endianness::value()) -#endif - { - etl::reverse(store, store + 16U); + etl::reverse(store, store + Size_); } } //******************************* + template static void copy_store_to_value(const_pointer store, T& value) { - unsigned char temp[16U]; - memcpy(temp, store, 16U); + memcpy(&value, store, Size_); #if ETL_HAS_CONSTEXPR_ENDIANESS - if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) + if ETL_IF_CONSTEXPR(Endian == etl::endianness::value()) #else - if (Endian == etl::endianness::value()) + if (Endian_ != etl::endianness::value()) #endif - { - etl::reverse(temp, temp + 16U); - } - - memcpy(&value, temp, 16U); + { + etl::reverse(reinterpret_cast(&value), reinterpret_cast(&value) + Size_); + } } //******************************* - static ETL_CONSTEXPR14 void copy_store_to_store(const_pointer src, int endian_src, unsigned char* dst) + static void copy_store_to_store(const_pointer src, int endian_src, pointer dst) { - memcpy(dst, src, 16U); + memcpy(dst, src, Size_); - if (Endian != endian_src) + if (Endian_ != endian_src) { - etl::reverse(dst, dst + 16U); + etl::reverse(dst, dst + Size_); } } }; ETL_END_PACKED @@ -853,7 +449,7 @@ namespace etl //************************************************************************* template ETL_PACKED_CLASS(unaligned_type) : public private_unaligned_type::unaligned_type_storage - , public private_unaligned_type::unaligned_copy + , public private_unaligned_type::unaligned_copy::value ? false : true> { public: @@ -875,14 +471,14 @@ namespace etl //************************************************************************* /// Default constructor //************************************************************************* - ETL_CONSTEXPR14 unaligned_type() + unaligned_type() { } //************************************************************************* /// Construct from a value. //************************************************************************* - ETL_CONSTEXPR14 unaligned_type(T value) + unaligned_type(T value) { this->copy_value_to_store(value, this->storage); } @@ -890,7 +486,7 @@ namespace etl //************************************************************************* /// Construct from an address. //************************************************************************* - ETL_CONSTEXPR14 unaligned_type(const void* address) + unaligned_type(const void* address) { etl::copy_n(reinterpret_cast(address), sizeof(T), this->storage); } @@ -898,18 +494,26 @@ namespace etl //************************************************************************* /// Construct from an address and buffer size. //************************************************************************* - ETL_CONSTEXPR14 unaligned_type(const void* address, size_t buffer_size) + unaligned_type(const void* address, size_t buffer_size) { ETL_ASSERT(sizeof(T) <= buffer_size, ETL_ERROR(etl::unaligned_type_buffer_size)); etl::copy_n(reinterpret_cast(address), sizeof(T), this->storage); } + //************************************************************************* + /// Copy constructor + //************************************************************************* + unaligned_type(const unaligned_type& other) + { + this->copy_store_to_store(other.data(), Endian, this->storage); + } + //************************************************************************* /// Copy constructor //************************************************************************* template - ETL_CONSTEXPR14 unaligned_type(const unaligned_type& other) + unaligned_type(const unaligned_type& other) { this->copy_store_to_store(other.data(), Endian_Other, this->storage); } @@ -917,18 +521,28 @@ namespace etl //************************************************************************* /// Assignment operator //************************************************************************* - ETL_CONSTEXPR14 unaligned_type& operator =(T value) + unaligned_type& operator =(T value) { this->copy_value_to_store(value, this->storage); return *this; } + //************************************************************************* + /// Assignment operator. + //************************************************************************* + unaligned_type& operator =(const unaligned_type& other) + { + this->copy_store_to_store(other.data(), Endian_, this->storage); + + return *this; + } + //************************************************************************* /// Assignment operator from other endianness. //************************************************************************* template - ETL_CONSTEXPR14 unaligned_type& operator =(const unaligned_type& other) + unaligned_type& operator =(const unaligned_type& other) { this->copy_store_to_store(other.data(), Endian_Other, this->storage); @@ -938,7 +552,7 @@ namespace etl //************************************************************************* /// Conversion operator //************************************************************************* - ETL_CONSTEXPR14 operator T() const + operator T() const { T value = T(); @@ -950,7 +564,7 @@ namespace etl //************************************************************************* /// Get the value. //************************************************************************* - ETL_CONSTEXPR14 T value() const + T value() const { T value = T(); @@ -975,7 +589,7 @@ namespace etl //************************************************************************* template ETL_PACKED_CLASS(unaligned_type_ext) : public private_unaligned_type::unaligned_type_storage_ext - , public private_unaligned_type::unaligned_copy + , public private_unaligned_type::unaligned_copy::value ? false : true> { public: diff --git a/test/test_unaligned_type_constexpr.cpp b/test/test_unaligned_type_constexpr.cpp index 27c1f401e..d125cdddf 100644 --- a/test/test_unaligned_type_constexpr.cpp +++ b/test/test_unaligned_type_constexpr.cpp @@ -26,625 +26,625 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include "unit_test_framework.h" - -#include "etl/unaligned_type.h" -#include "etl/integral_limits.h" - -#if ETL_USING_CPP14 - -#include "etl/private/diagnostic_useless_cast_push.h" - -namespace -{ - SUITE(test_unaligned_type_constexpr) - { - //************************************************************************* - TEST(test_construction) - { - constexpr etl::le_uint32_t le_v1(0x01234567); - constexpr etl::be_uint32_t be_v1(0x01234567); - - CHECK_EQUAL(int(0x01234567), int(le_v1)); - CHECK_EQUAL(int(0x01234567), int(be_v1)); - } - - ////************************************************************************* - //TEST(test_copy_construction) - //{ - // constexpr etl::le_uint32_t le_v1(0x01234567); - // constexpr etl::be_uint32_t be_v1(0x01234567); - // constexpr etl::le_uint32_t le_v2(le_v1); // Copy construct le from le. - // constexpr etl::be_uint32_t be_v2(be_v1); // Copy construct be from be. - // constexpr etl::le_uint32_t le_v3(be_v1); // Copy construct le from be. - // constexpr etl::be_uint32_t be_v3(le_v1); // Copy construct be from le. - - // CHECK_EQUAL(int(0x01234567), int(le_v2)); - // CHECK_EQUAL(int(0x01234567), int(be_v2)); - // CHECK_EQUAL(int(0x01234567), int(le_v3)); - // CHECK_EQUAL(int(0x01234567), int(be_v3)); - //} - - ////************************************************************************* - //TEST(test_le_equality) - //{ - // constexpr bool check_char1 = etl::le_char_t(0x01) == etl::le_char_t(0x01); - // constexpr bool check_char2 = (char)(0x01) == etl::le_char_t(0x01); - // constexpr bool check_char3 = etl::le_char_t(0x01) == (char)(0x01); - - // CHECK_EQUAL(true, check_char1); - // CHECK(check_char2); - // CHECK(check_char3); - - // constexpr bool check_schar1 = etl::le_schar_t(0x01) == etl::le_schar_t(0x01); - // constexpr bool check_schar2 = (signed char)(0x01) == etl::le_schar_t(0x01); - // constexpr bool check_schar3 = etl::le_schar_t(0x01) == (signed char)(0x01); - // - // CHECK(check_schar1); - // CHECK(check_schar2); - // CHECK(check_schar3); - - // constexpr bool check_uchar1 = etl::le_uchar_t(0x01) == etl::le_uchar_t(0x01); - // constexpr bool check_uchar2 = (unsigned char)(0x01) == etl::le_uchar_t(0x01); - // constexpr bool check_uchar3 = etl::le_uchar_t(0x01) == (unsigned char)(0x01); - - // CHECK(check_uchar1); - // CHECK(check_uchar2); - // CHECK(check_uchar3); - - // constexpr bool check_short1 = (short)(0x0123) == etl::le_short_t(0x0123); - // constexpr bool check_short2 = etl::le_short_t(0x0123) == (short)(0x0123); - // constexpr bool check_short3 = (short)(0x0123) == etl::le_short_t(0x0123); - // - // CHECK(check_short1); - // CHECK(check_short2); - // CHECK(check_short3); - - // constexpr bool check_ushort1 = (unsigned short)(0x0123) == etl::le_ushort_t(0x0123); - // constexpr bool check_ushort2 = etl::le_ushort_t(0x0123) == (unsigned short)(0x0123); - // constexpr bool check_ushort3 = (unsigned short)(0x0123) == etl::le_ushort_t(0x0123); - - // CHECK(check_ushort1); - // CHECK(check_ushort2); - // CHECK(check_ushort3); - - // constexpr bool check_int1 = (int)(0x01234567) == etl::le_int_t(0x01234567); - // constexpr bool check_int2 = etl::le_int_t(0x01234567) == (int)(0x01234567); - // constexpr bool check_int3 = (int)(0x01234567) == etl::le_int_t(0x01234567); - - // CHECK(check_int1); - // CHECK(check_int2); - // CHECK(check_int3); - - // constexpr bool check_uint1 = (unsigned int)(0x01234567) == etl::le_uint_t(0x01234567); - // constexpr bool check_uint2 = etl::le_uint_t(0x01234567) == (unsigned int)(0x01234567); - // constexpr bool check_uint3 = (unsigned int)(0x01234567) == etl::le_uint_t(0x01234567); - - // CHECK(check_uint1); - // CHECK(check_uint2); - // CHECK(check_uint3); - - // if (sizeof(long) == 4U) - // { - // constexpr bool check_long1 = (long)(0x01234567) == etl::le_long_t(0x01234567); - // constexpr bool check_long2 = etl::le_long_t(0x01234567) == (long)(0x01234567); - // constexpr bool check_long3 = (long)(0x01234567) == etl::le_long_t(0x01234567); - // - // CHECK(check_long1); - // CHECK(check_long2); - // CHECK(check_long3); - - // constexpr bool check_ulong1 = (unsigned long)(0x01234567) == etl::le_ulong_t(0x01234567); - // constexpr bool check_ulong2 = etl::le_ulong_t(0x01234567) == (unsigned long)(0x01234567); - // constexpr bool check_ulong3 = (unsigned long)(0x01234567) == etl::le_ulong_t(0x01234567); - - // CHECK(check_ulong1); - // CHECK(check_ulong2); - // CHECK(check_ulong3); - // } - - // if (sizeof(long long) == 8U) - // { - // constexpr bool check_long_long1 = (long long)(0x0123456789ABCDEF) == etl::le_long_long_t(0x0123456789ABCDEF); - // constexpr bool check_long_long2 = etl::le_long_long_t(0x0123456789ABCDEF) == (long long)(0x0123456789ABCDEF); - // constexpr bool check_long_long3 = (long long)(0x0123456789ABCDEF) == etl::le_long_long_t(0x0123456789ABCDEF); - - // CHECK(check_long_long1); - // CHECK(check_long_long2); - // CHECK(check_long_long3); - - // constexpr bool check_ulong_long1 = (unsigned long long)(0x0123456789ABCDEF) == etl::le_ulong_long_t(0x0123456789ABCDEF); - // constexpr bool check_ulong_long2 = etl::le_ulong_long_t(0x0123456789ABCDEF) == (unsigned long long)(0x0123456789ABCDEF); - // constexpr bool check_ulong_long3 = (unsigned long long)(0x0123456789ABCDEF) == etl::le_ulong_long_t(0x0123456789ABCDEF); - - // CHECK(check_ulong_long1); - // CHECK(check_ulong_long2); - // CHECK(check_ulong_long3); - // } - //} - - ////************************************************************************* - //TEST(test_le_inequality) - //{ - // constexpr bool check_char1 = etl::le_char_t(0x01) != etl::le_char_t(0x02); - // constexpr bool check_char2 = (char)(0x01) != etl::le_char_t(0x02); - // constexpr bool check_char3 = etl::le_char_t(0x01) != (char)(0x02); - - // CHECK(check_char1); - // CHECK(check_char2); - // CHECK(check_char3); - - // constexpr bool check_schar1 = etl::le_schar_t(0x01) != etl::le_schar_t(0x02); - // constexpr bool check_schar2 = (signed char)(0x01) != etl::le_schar_t(0x02); - // constexpr bool check_schar3 = etl::le_schar_t(0x01) != (signed char)(0x02); - - // CHECK(check_schar1); - // CHECK(check_schar2); - // CHECK(check_schar3); - - // constexpr bool check_uchar1 = etl::le_uchar_t(0x01) != etl::le_uchar_t(0x02); - // constexpr bool check_uchar2 = (unsigned char)(0x01) != etl::le_uchar_t(0x02); - // constexpr bool check_uchar3 = etl::le_uchar_t(0x01) != (unsigned char)(0x02); - - // CHECK(check_uchar1); - // CHECK(check_uchar2); - // CHECK(check_uchar3); - - // constexpr bool check_short1 = (short)(0x0123) != etl::le_short_t(0x0124); - // constexpr bool check_short2 = etl::le_short_t(0x0123) != (short)(0x0124); - // constexpr bool check_short3 = (short)(0x0123) != etl::le_short_t(0x0124); - - // CHECK(check_short1); - // CHECK(check_short2); - // CHECK(check_short3); - - // constexpr bool check_ushort1 = (unsigned short)(0x0123) != etl::le_ushort_t(0x0124); - // constexpr bool check_ushort2 = etl::le_ushort_t(0x0123) != (unsigned short)(0x0124); - // constexpr bool check_ushort3 = (unsigned short)(0x0123) != etl::le_ushort_t(0x0124); - - // CHECK(check_ushort1); - // CHECK(check_ushort2); - // CHECK(check_ushort3); - - // constexpr bool check_int1 = (int)(0x01234567) != etl::le_int_t(0x01244567); - // constexpr bool check_int2 = etl::le_int_t(0x01234567) != (int)(0x01244567); - // constexpr bool check_int3 = (int)(0x01234567) != etl::le_int_t(0x01244567); - - // CHECK(check_int1); - // CHECK(check_int2); - // CHECK(check_int3); - - // constexpr bool check_uint1 = (unsigned int)(0x01234567) != etl::le_uint_t(0x01244567); - // constexpr bool check_uint2 = etl::le_uint_t(0x01234567) != (unsigned int)(0x01244567); - // constexpr bool check_uint3 = (unsigned int)(0x01234567) != etl::le_uint_t(0x01244567); - - // CHECK(check_uint1); - // CHECK(check_uint2); - // CHECK(check_uint3); - - // if (sizeof(long) == 4U) - // { - // constexpr bool check_long1 = (long)(0x01234567) != etl::le_long_t(0x01244567); - // constexpr bool check_long2 = etl::le_long_t(0x01234567) != (long)(0x01244567); - // constexpr bool check_long3 = (long)(0x01234567) != etl::le_long_t(0x01244567); - - // CHECK(check_long1); - // CHECK(check_long2); - // CHECK(check_long3); - - // constexpr bool check_ulong1 = (unsigned long)(0x01234567) != etl::le_ulong_t(0x01244567); - // constexpr bool check_ulong2 = etl::le_ulong_t(0x01234567) != (unsigned long)(0x01244567); - // constexpr bool check_ulong3 = (unsigned long)(0x01234567) != etl::le_ulong_t(0x01244567); - - // CHECK(check_ulong1); - // CHECK(check_ulong2); - // CHECK(check_ulong3); - // } - - // if (sizeof(long long) == 8U) - // { - // constexpr bool check_long_long1 = (long long)(0x0123456789ABCDEF) != etl::le_long_long_t(0x0123457789ABCDEF); - // constexpr bool check_long_long2 = etl::le_long_long_t(0x0123456789ABCDEF) != (long long)(0x0123457789ABCDEF); - // constexpr bool check_long_long3 = (long long)(0x0123456789ABCDEF) != etl::le_long_long_t(0x0123457789ABCDEF); - - // CHECK(check_long_long1); - // CHECK(check_long_long2); - // CHECK(check_long_long3); - - // constexpr bool check_ulong_long1 = (unsigned long long)(0x0123456789ABCDEF) != etl::le_ulong_long_t(0x0123457789ABCDEF); - // constexpr bool check_ulong_long2 = etl::le_ulong_long_t(0x0123456789ABCDEF) != (unsigned long long)(0x0123457789ABCDEF); - // constexpr bool check_ulong_long3 = (unsigned long long)(0x0123456789ABCDEF) != etl::le_ulong_long_t(0x0123457789ABCDEF); - - // CHECK(check_ulong_long1); - // CHECK(check_ulong_long2); - // CHECK(check_ulong_long3); - // } - //} - - ////************************************************************************* - //TEST(test_be_equality) - //{ - // constexpr bool check_char1 = etl::be_char_t(0x01) == etl::be_char_t(0x01); - // constexpr bool check_char2 = (char)(0x01) == etl::be_char_t(0x01); - // constexpr bool check_char3 = etl::be_char_t(0x01) == (char)(0x01); - - // CHECK(check_char1); - // CHECK(check_char2); - // CHECK(check_char3); - - // constexpr bool check_schar1 = etl::be_schar_t(0x01) == etl::be_schar_t(0x01); - // constexpr bool check_schar2 = (signed char)(0x01) == etl::be_schar_t(0x01); - // constexpr bool check_schar3 = etl::be_schar_t(0x01) == (signed char)(0x01); - - // CHECK(check_schar1); - // CHECK(check_schar2); - // CHECK(check_schar3); - - // constexpr bool check_uchar1 = etl::be_uchar_t(0x01) == etl::be_uchar_t(0x01); - // constexpr bool check_uchar2 = (unsigned char)(0x01) == etl::be_uchar_t(0x01); - // constexpr bool check_uchar3 = etl::be_uchar_t(0x01) == (unsigned char)(0x01); - - // CHECK(check_uchar1); - // CHECK(check_uchar2); - // CHECK(check_uchar3); - - // constexpr bool check_short1 = (short)(0x0123) == etl::be_short_t(0x0123); - // constexpr bool check_short2 = etl::be_short_t(0x0123) == (short)(0x0123); - // constexpr bool check_short3 = (short)(0x0123) == etl::be_short_t(0x0123); - - // CHECK(check_short1); - // CHECK(check_short2); - // CHECK(check_short3); - - // constexpr bool check_ushort1 = (unsigned short)(0x0123) == etl::be_ushort_t(0x0123); - // constexpr bool check_ushort2 = etl::be_ushort_t(0x0123) == (unsigned short)(0x0123); - // constexpr bool check_ushort3 = (unsigned short)(0x0123) == etl::be_ushort_t(0x0123); - - // CHECK(check_ushort1); - // CHECK(check_ushort2); - // CHECK(check_ushort3); - - // constexpr bool check_int1 = (int)(0x01234567) == etl::be_int_t(0x01234567); - // constexpr bool check_int2 = etl::be_int_t(0x01234567) == (int)(0x01234567); - // constexpr bool check_int3 = (int)(0x01234567) == etl::be_int_t(0x01234567); - - // CHECK(check_int1); - // CHECK(check_int2); - // CHECK(check_int3); - - // constexpr bool check_uint1 = (unsigned int)(0x01234567) == etl::be_uint_t(0x01234567); - // constexpr bool check_uint2 = etl::be_uint_t(0x01234567) == (unsigned int)(0x01234567); - // constexpr bool check_uint3 = (unsigned int)(0x01234567) == etl::be_uint_t(0x01234567); - - // CHECK(check_uint1); - // CHECK(check_uint2); - // CHECK(check_uint3); - - // if (sizeof(long) == 4U) - // { - // constexpr bool check_long1 = (long)(0x01234567) == etl::be_long_t(0x01234567); - // constexpr bool check_long2 = etl::be_long_t(0x01234567) == (long)(0x01234567); - // constexpr bool check_long3 = (long)(0x01234567) == etl::be_long_t(0x01234567); - - // CHECK(check_long1); - // CHECK(check_long2); - // CHECK(check_long3); - - // constexpr bool check_ulong1 = (unsigned long)(0x01234567) == etl::be_ulong_t(0x01234567); - // constexpr bool check_ulong2 = etl::be_ulong_t(0x01234567) == (unsigned long)(0x01234567); - // constexpr bool check_ulong3 = (unsigned long)(0x01234567) == etl::be_ulong_t(0x01234567); - - // CHECK(check_ulong1); - // CHECK(check_ulong2); - // CHECK(check_ulong3); - // } - - // if (sizeof(long long) == 8U) - // { - // constexpr bool check_long_long1 = (long long)(0x0123456789ABCDEF) == etl::be_long_long_t(0x0123456789ABCDEF); - // constexpr bool check_long_long2 = etl::be_long_long_t(0x0123456789ABCDEF) == (long long)(0x0123456789ABCDEF); - // constexpr bool check_long_long3 = (long long)(0x0123456789ABCDEF) == etl::be_long_long_t(0x0123456789ABCDEF); - - // CHECK(check_long_long1); - // CHECK(check_long_long2); - // CHECK(check_long_long3); - - // constexpr bool check_ulong_long1 = (unsigned long long)(0x0123456789ABCDEF) == etl::be_ulong_long_t(0x0123456789ABCDEF); - // constexpr bool check_ulong_long2 = etl::be_ulong_long_t(0x0123456789ABCDEF) == (unsigned long long)(0x0123456789ABCDEF); - // constexpr bool check_ulong_long3 = (unsigned long long)(0x0123456789ABCDEF) == etl::be_ulong_long_t(0x0123456789ABCDEF); - - // CHECK(check_ulong_long1); - // CHECK(check_ulong_long2); - // CHECK(check_ulong_long3); - // } - //} - - ////************************************************************************* - //TEST(test_be_inequality) - //{ - // constexpr bool check_char1 = etl::be_char_t(0x01) != etl::be_char_t(0x02); - // constexpr bool check_char2 = (char)(0x01) != etl::be_char_t(0x02); - // constexpr bool check_char3 = etl::be_char_t(0x01) != (char)(0x02); - - // CHECK(check_char1); - // CHECK(check_char2); - // CHECK(check_char3); - - // constexpr bool check_schar1 = etl::be_schar_t(0x01) != etl::be_schar_t(0x02); - // constexpr bool check_schar2 = (signed char)(0x01) != etl::be_schar_t(0x02); - // constexpr bool check_schar3 = etl::be_schar_t(0x01) != (signed char)(0x02); - - // CHECK(check_schar1); - // CHECK(check_schar2); - // CHECK(check_schar3); - - // constexpr bool check_uchar1 = etl::be_uchar_t(0x01) != etl::be_uchar_t(0x02); - // constexpr bool check_uchar2 = (unsigned char)(0x01) != etl::be_uchar_t(0x02); - // constexpr bool check_uchar3 = etl::be_uchar_t(0x01) != (unsigned char)(0x02); - - // CHECK(check_uchar1); - // CHECK(check_uchar2); - // CHECK(check_uchar3); - - // constexpr bool check_short1 = (short)(0x0123) != etl::be_short_t(0x0124); - // constexpr bool check_short2 = etl::be_short_t(0x0123) != (short)(0x0124); - // constexpr bool check_short3 = (short)(0x0123) != etl::be_short_t(0x0124); - - // CHECK(check_short1); - // CHECK(check_short2); - // CHECK(check_short3); - - // constexpr bool check_ushort1 = (unsigned short)(0x0123) != etl::be_ushort_t(0x0124); - // constexpr bool check_ushort2 = etl::be_ushort_t(0x0123) != (unsigned short)(0x0124); - // constexpr bool check_ushort3 = (unsigned short)(0x0123) != etl::be_ushort_t(0x0124); - - // CHECK(check_ushort1); - // CHECK(check_ushort2); - // CHECK(check_ushort3); - - // constexpr bool check_int1 = (int)(0x01234567) != etl::be_int_t(0x01244567); - // constexpr bool check_int2 = etl::be_int_t(0x01234567) != (int)(0x01244567); - // constexpr bool check_int3 = (int)(0x01234567) != etl::be_int_t(0x01244567); - - // CHECK(check_int1); - // CHECK(check_int2); - // CHECK(check_int3); - - // constexpr bool check_uint1 = (unsigned int)(0x01234567) != etl::be_uint_t(0x01244567); - // constexpr bool check_uint2 = etl::be_uint_t(0x01234567) != (unsigned int)(0x01244567); - // constexpr bool check_uint3 = (unsigned int)(0x01234567) != etl::be_uint_t(0x01244567); - - // CHECK(check_uint1); - // CHECK(check_uint2); - // CHECK(check_uint3); - - // if (sizeof(long) == 4U) - // { - // constexpr bool check_long1 = (long)(0x01234567) != etl::be_long_t(0x01244567); - // constexpr bool check_long2 = etl::be_long_t(0x01234567) != (long)(0x01244567); - // constexpr bool check_long3 = (long)(0x01234567) != etl::be_long_t(0x01244567); - - // CHECK(check_long1); - // CHECK(check_long2); - // CHECK(check_long3); - - // constexpr bool check_ulong1 = (unsigned long)(0x01234567) != etl::be_ulong_t(0x01244567); - // constexpr bool check_ulong2 = etl::be_ulong_t(0x01234567) != (unsigned long)(0x01244567); - // constexpr bool check_ulong3 = (unsigned long)(0x01234567) != etl::be_ulong_t(0x01244567); - - // CHECK(check_ulong1); - // CHECK(check_ulong2); - // CHECK(check_ulong3); - // } - - // if (sizeof(long long) == 8U) - // { - // constexpr bool check_long_long1 = (long long)(0x0123456789ABCDEF) != etl::be_long_long_t(0x0123457789ABCDEF); - // constexpr bool check_long_long2 = etl::be_long_long_t(0x0123456789ABCDEF) != (long long)(0x0123457789ABCDEF); - // constexpr bool check_long_long3 = (long long)(0x0123456789ABCDEF) != etl::be_long_long_t(0x0123457789ABCDEF); - - // CHECK(check_long_long1); - // CHECK(check_long_long2); - // CHECK(check_long_long3); - - // constexpr bool check_ulong_long1 = (unsigned long long)(0x0123456789ABCDEF) != etl::be_ulong_long_t(0x0123457789ABCDEF); - // constexpr bool check_ulong_long2 = etl::be_ulong_long_t(0x0123456789ABCDEF) != (unsigned long long)(0x0123457789ABCDEF); - // constexpr bool check_ulong_long3 = (unsigned long long)(0x0123456789ABCDEF) != etl::be_ulong_long_t(0x0123457789ABCDEF); - - // CHECK(check_ulong_long1); - // CHECK(check_ulong_long2); - // CHECK(check_ulong_long3); - // } - //} - - ////************************************************************************* - //TEST(test_le_assignment) - //{ - // constexpr etl::le_char_t le_char = 0x01; - // CHECK(0x01 == (signed char)le_char); - - // constexpr etl::le_schar_t le_schar = 0x01; - // CHECK(0x01 == (signed char)le_schar); - - // constexpr etl::le_uchar_t le_uchar = 0x01; - // CHECK(0x01 == (unsigned char)le_uchar); - - // constexpr etl::le_short_t le_short = 0x0123; - // CHECK(0x0123 == (short)le_short); - - // constexpr etl::le_ushort_t le_ushort = 0x0123; - // CHECK(0x0123 == (unsigned short)le_ushort); - - // constexpr etl::le_int_t le_int = 0x01234567; - // CHECK(0x01234567 == (int)le_int); - - // constexpr etl::le_uint_t le_uint = 0x01234567; - // CHECK(0x01234567 == (unsigned int)le_uint); - - // if (sizeof(long) == 4U) - // { - // constexpr etl::le_long_t le_long = 0x01234567; - // CHECK(0x01234567 == (long)le_long); - - // constexpr etl::le_ulong_t le_ulong = 0x01234567; - // CHECK(0x01234567 == (unsigned long)le_ulong); - // } - - // if (sizeof(long long) == 8U) - // { - // constexpr etl::le_long_long_t le_long = 0x0123456789ABCDEF; - // CHECK(0x0123456789ABCDEF == (long long)le_long); - - // constexpr etl::le_ulong_long_t le_ulong = 0x0123456789ABCDEF; - // CHECK(0x0123456789ABCDEF == (unsigned long long)le_ulong); - // } - //} - - ////************************************************************************* - //TEST(test_be_assignment) - //{ - // constexpr etl::be_char_t be_char = 0x01; - // CHECK(0x01 == (signed char)be_char); - - // constexpr etl::be_schar_t be_schar = 0x01; - // CHECK(0x01 == (signed char)be_schar); - - // constexpr etl::be_uchar_t be_uchar = 0x01; - // CHECK(0x01 == (unsigned char)be_uchar); - - // constexpr etl::be_short_t be_short = 0x0123; - // CHECK(0x0123 == (short)be_short); - - // constexpr etl::be_ushort_t be_ushort = 0x0123; - // CHECK(0x0123 == (unsigned short)be_ushort); - - // constexpr etl::be_int_t be_int = 0x01234567; - // CHECK(0x01234567 == (int)be_int); - - // constexpr etl::be_uint_t be_uint = 0x01234567; - // CHECK(0x01234567 == (unsigned int)be_uint); - - // if (sizeof(long) == 4U) - // { - // constexpr etl::be_long_t be_long = 0x01234567; - // CHECK(0x01234567 == (long)be_long); - - // constexpr etl::be_ulong_t be_ulong = 0x01234567; - // CHECK(0x01234567 == (unsigned long)be_ulong); - // } - - // if (sizeof(long long) == 8U) - // { - // constexpr etl::be_long_long_t be_long = 0x0123456789ABCDEF; - // CHECK(0x0123456789ABCDEF == (long long)be_long); - - // constexpr etl::be_ulong_long_t be_ulong = 0x0123456789ABCDEF; - // CHECK(0x0123456789ABCDEF == (unsigned long long)be_ulong); - // } - //} - - ////************************************************************************* - //TEST(test_data) - //{ - // static constexpr etl::be_uint16_t test(0x1234); - // - // constexpr etl::be_uint16_t::const_pointer p1 = test.data(); - // constexpr etl::be_uint16_t::const_pointer p2 = test.data() + 1U; - - // CHECK_EQUAL(0x12, *p1); - // CHECK_EQUAL(0x34, *p2); - //} - - ////************************************************************************* - //TEST(test_begin_end_iterator) - //{ - // using const_iterator = etl::be_uint16_t::const_iterator; - - // static constexpr etl::be_uint16_t test(0x1234); - - // //******************************* - // constexpr const_iterator itr1 = test.begin(); - // CHECK_EQUAL(int(0x12), int(*itr1)); - - // constexpr const_iterator itr2 = test.begin() + 1U; - // CHECK_EQUAL(int(0x34), int(*itr2)); - - // constexpr const_iterator itr3 = test.begin() + 2U; - // CHECK(test.end() == itr3); - //} - - ////************************************************************************* - //TEST(test_rbegin_rend_iterator) - //{ - // using const_reverse_iterator = etl::be_uint16_t::const_reverse_iterator; - - // static constexpr etl::be_uint16_t test(0x1234); - - // //******************************* - // constexpr const_reverse_iterator itr1 = test.rbegin(); - // CHECK_EQUAL(int(0x34), int(*itr1)); - - // constexpr const_reverse_iterator itr2 = test.rbegin() + 1U; - // CHECK_EQUAL(int(0x12), int(*itr2)); - - // constexpr const_reverse_iterator itr3 = test.rbegin() + 2U; - // CHECK(test.rend() == itr3); - //} - - ////************************************************************************* - //TEST(test_index_operator) - //{ - // constexpr etl::le_uint16_t test_le(0x1234); - // constexpr etl::be_uint16_t test_be(0x1234); - - // constexpr const char lea = test_le[0]; - // constexpr const char leb = test_le[1]; - - // constexpr const char bea = test_be[0]; - // constexpr const char beb = test_be[1]; - - // CHECK_EQUAL(0x34, lea); - // CHECK_EQUAL(0x12, leb); - - // CHECK_EQUAL(0x12, bea); - // CHECK_EQUAL(0x34, beb); - //} - - ////************************************************************************* - //TEST(test_value) - //{ - // constexpr etl::le_uint16_t test_le(0x1234); - // constexpr etl::be_uint16_t test_be(0x1234); - - // constexpr uint16_t lev = test_le.value(); - // constexpr uint16_t bev = test_be.value(); - - // CHECK_EQUAL(0x1234, lev); - // CHECK_EQUAL(0x1234, bev); - //} - - ////************************************************************************* - //TEST(test_storage_bytes) - //{ - // constexpr etl::le_uint16_t test_le(0x1234); - // constexpr etl::be_uint16_t test_be(0x1234); - - // constexpr int lev0 = test_le[0]; - // constexpr int lev1 = test_le[1]; - // - // constexpr int bev0 = test_be[0]; - // constexpr int bev1 = test_be[1]; - - // CHECK_EQUAL(0x34, lev0); - // CHECK_EQUAL(0x12, lev1); - // CHECK_EQUAL(0x12, bev0); - // CHECK_EQUAL(0x34, bev1); - //} - }; -} - -#include "etl/private/diagnostic_pop.h" - -#endif +//#include "unit_test_framework.h" +// +//#include "etl/unaligned_type.h" +//#include "etl/integral_limits.h" +// +//#if ETL_USING_CPP14 +// +//#include "etl/private/diagnostic_useless_cast_push.h" +// +//namespace +//{ +// SUITE(test_unaligned_type_constexpr) +// { +// //************************************************************************* +// TEST(test_construction) +// { +// constexpr etl::le_uint32_t le_v1(0x01234567); +// constexpr etl::be_uint32_t be_v1(0x01234567); +// +// CHECK_EQUAL(int(0x01234567), int(le_v1)); +// CHECK_EQUAL(int(0x01234567), int(be_v1)); +// } +// +// ////************************************************************************* +// //TEST(test_copy_construction) +// //{ +// // constexpr etl::le_uint32_t le_v1(0x01234567); +// // constexpr etl::be_uint32_t be_v1(0x01234567); +// // constexpr etl::le_uint32_t le_v2(le_v1); // Copy construct le from le. +// // constexpr etl::be_uint32_t be_v2(be_v1); // Copy construct be from be. +// // constexpr etl::le_uint32_t le_v3(be_v1); // Copy construct le from be. +// // constexpr etl::be_uint32_t be_v3(le_v1); // Copy construct be from le. +// +// // CHECK_EQUAL(int(0x01234567), int(le_v2)); +// // CHECK_EQUAL(int(0x01234567), int(be_v2)); +// // CHECK_EQUAL(int(0x01234567), int(le_v3)); +// // CHECK_EQUAL(int(0x01234567), int(be_v3)); +// //} +// +// ////************************************************************************* +// //TEST(test_le_equality) +// //{ +// // constexpr bool check_char1 = etl::le_char_t(0x01) == etl::le_char_t(0x01); +// // constexpr bool check_char2 = (char)(0x01) == etl::le_char_t(0x01); +// // constexpr bool check_char3 = etl::le_char_t(0x01) == (char)(0x01); +// +// // CHECK_EQUAL(true, check_char1); +// // CHECK(check_char2); +// // CHECK(check_char3); +// +// // constexpr bool check_schar1 = etl::le_schar_t(0x01) == etl::le_schar_t(0x01); +// // constexpr bool check_schar2 = (signed char)(0x01) == etl::le_schar_t(0x01); +// // constexpr bool check_schar3 = etl::le_schar_t(0x01) == (signed char)(0x01); +// // +// // CHECK(check_schar1); +// // CHECK(check_schar2); +// // CHECK(check_schar3); +// +// // constexpr bool check_uchar1 = etl::le_uchar_t(0x01) == etl::le_uchar_t(0x01); +// // constexpr bool check_uchar2 = (unsigned char)(0x01) == etl::le_uchar_t(0x01); +// // constexpr bool check_uchar3 = etl::le_uchar_t(0x01) == (unsigned char)(0x01); +// +// // CHECK(check_uchar1); +// // CHECK(check_uchar2); +// // CHECK(check_uchar3); +// +// // constexpr bool check_short1 = (short)(0x0123) == etl::le_short_t(0x0123); +// // constexpr bool check_short2 = etl::le_short_t(0x0123) == (short)(0x0123); +// // constexpr bool check_short3 = (short)(0x0123) == etl::le_short_t(0x0123); +// // +// // CHECK(check_short1); +// // CHECK(check_short2); +// // CHECK(check_short3); +// +// // constexpr bool check_ushort1 = (unsigned short)(0x0123) == etl::le_ushort_t(0x0123); +// // constexpr bool check_ushort2 = etl::le_ushort_t(0x0123) == (unsigned short)(0x0123); +// // constexpr bool check_ushort3 = (unsigned short)(0x0123) == etl::le_ushort_t(0x0123); +// +// // CHECK(check_ushort1); +// // CHECK(check_ushort2); +// // CHECK(check_ushort3); +// +// // constexpr bool check_int1 = (int)(0x01234567) == etl::le_int_t(0x01234567); +// // constexpr bool check_int2 = etl::le_int_t(0x01234567) == (int)(0x01234567); +// // constexpr bool check_int3 = (int)(0x01234567) == etl::le_int_t(0x01234567); +// +// // CHECK(check_int1); +// // CHECK(check_int2); +// // CHECK(check_int3); +// +// // constexpr bool check_uint1 = (unsigned int)(0x01234567) == etl::le_uint_t(0x01234567); +// // constexpr bool check_uint2 = etl::le_uint_t(0x01234567) == (unsigned int)(0x01234567); +// // constexpr bool check_uint3 = (unsigned int)(0x01234567) == etl::le_uint_t(0x01234567); +// +// // CHECK(check_uint1); +// // CHECK(check_uint2); +// // CHECK(check_uint3); +// +// // if (sizeof(long) == 4U) +// // { +// // constexpr bool check_long1 = (long)(0x01234567) == etl::le_long_t(0x01234567); +// // constexpr bool check_long2 = etl::le_long_t(0x01234567) == (long)(0x01234567); +// // constexpr bool check_long3 = (long)(0x01234567) == etl::le_long_t(0x01234567); +// // +// // CHECK(check_long1); +// // CHECK(check_long2); +// // CHECK(check_long3); +// +// // constexpr bool check_ulong1 = (unsigned long)(0x01234567) == etl::le_ulong_t(0x01234567); +// // constexpr bool check_ulong2 = etl::le_ulong_t(0x01234567) == (unsigned long)(0x01234567); +// // constexpr bool check_ulong3 = (unsigned long)(0x01234567) == etl::le_ulong_t(0x01234567); +// +// // CHECK(check_ulong1); +// // CHECK(check_ulong2); +// // CHECK(check_ulong3); +// // } +// +// // if (sizeof(long long) == 8U) +// // { +// // constexpr bool check_long_long1 = (long long)(0x0123456789ABCDEF) == etl::le_long_long_t(0x0123456789ABCDEF); +// // constexpr bool check_long_long2 = etl::le_long_long_t(0x0123456789ABCDEF) == (long long)(0x0123456789ABCDEF); +// // constexpr bool check_long_long3 = (long long)(0x0123456789ABCDEF) == etl::le_long_long_t(0x0123456789ABCDEF); +// +// // CHECK(check_long_long1); +// // CHECK(check_long_long2); +// // CHECK(check_long_long3); +// +// // constexpr bool check_ulong_long1 = (unsigned long long)(0x0123456789ABCDEF) == etl::le_ulong_long_t(0x0123456789ABCDEF); +// // constexpr bool check_ulong_long2 = etl::le_ulong_long_t(0x0123456789ABCDEF) == (unsigned long long)(0x0123456789ABCDEF); +// // constexpr bool check_ulong_long3 = (unsigned long long)(0x0123456789ABCDEF) == etl::le_ulong_long_t(0x0123456789ABCDEF); +// +// // CHECK(check_ulong_long1); +// // CHECK(check_ulong_long2); +// // CHECK(check_ulong_long3); +// // } +// //} +// +// ////************************************************************************* +// //TEST(test_le_inequality) +// //{ +// // constexpr bool check_char1 = etl::le_char_t(0x01) != etl::le_char_t(0x02); +// // constexpr bool check_char2 = (char)(0x01) != etl::le_char_t(0x02); +// // constexpr bool check_char3 = etl::le_char_t(0x01) != (char)(0x02); +// +// // CHECK(check_char1); +// // CHECK(check_char2); +// // CHECK(check_char3); +// +// // constexpr bool check_schar1 = etl::le_schar_t(0x01) != etl::le_schar_t(0x02); +// // constexpr bool check_schar2 = (signed char)(0x01) != etl::le_schar_t(0x02); +// // constexpr bool check_schar3 = etl::le_schar_t(0x01) != (signed char)(0x02); +// +// // CHECK(check_schar1); +// // CHECK(check_schar2); +// // CHECK(check_schar3); +// +// // constexpr bool check_uchar1 = etl::le_uchar_t(0x01) != etl::le_uchar_t(0x02); +// // constexpr bool check_uchar2 = (unsigned char)(0x01) != etl::le_uchar_t(0x02); +// // constexpr bool check_uchar3 = etl::le_uchar_t(0x01) != (unsigned char)(0x02); +// +// // CHECK(check_uchar1); +// // CHECK(check_uchar2); +// // CHECK(check_uchar3); +// +// // constexpr bool check_short1 = (short)(0x0123) != etl::le_short_t(0x0124); +// // constexpr bool check_short2 = etl::le_short_t(0x0123) != (short)(0x0124); +// // constexpr bool check_short3 = (short)(0x0123) != etl::le_short_t(0x0124); +// +// // CHECK(check_short1); +// // CHECK(check_short2); +// // CHECK(check_short3); +// +// // constexpr bool check_ushort1 = (unsigned short)(0x0123) != etl::le_ushort_t(0x0124); +// // constexpr bool check_ushort2 = etl::le_ushort_t(0x0123) != (unsigned short)(0x0124); +// // constexpr bool check_ushort3 = (unsigned short)(0x0123) != etl::le_ushort_t(0x0124); +// +// // CHECK(check_ushort1); +// // CHECK(check_ushort2); +// // CHECK(check_ushort3); +// +// // constexpr bool check_int1 = (int)(0x01234567) != etl::le_int_t(0x01244567); +// // constexpr bool check_int2 = etl::le_int_t(0x01234567) != (int)(0x01244567); +// // constexpr bool check_int3 = (int)(0x01234567) != etl::le_int_t(0x01244567); +// +// // CHECK(check_int1); +// // CHECK(check_int2); +// // CHECK(check_int3); +// +// // constexpr bool check_uint1 = (unsigned int)(0x01234567) != etl::le_uint_t(0x01244567); +// // constexpr bool check_uint2 = etl::le_uint_t(0x01234567) != (unsigned int)(0x01244567); +// // constexpr bool check_uint3 = (unsigned int)(0x01234567) != etl::le_uint_t(0x01244567); +// +// // CHECK(check_uint1); +// // CHECK(check_uint2); +// // CHECK(check_uint3); +// +// // if (sizeof(long) == 4U) +// // { +// // constexpr bool check_long1 = (long)(0x01234567) != etl::le_long_t(0x01244567); +// // constexpr bool check_long2 = etl::le_long_t(0x01234567) != (long)(0x01244567); +// // constexpr bool check_long3 = (long)(0x01234567) != etl::le_long_t(0x01244567); +// +// // CHECK(check_long1); +// // CHECK(check_long2); +// // CHECK(check_long3); +// +// // constexpr bool check_ulong1 = (unsigned long)(0x01234567) != etl::le_ulong_t(0x01244567); +// // constexpr bool check_ulong2 = etl::le_ulong_t(0x01234567) != (unsigned long)(0x01244567); +// // constexpr bool check_ulong3 = (unsigned long)(0x01234567) != etl::le_ulong_t(0x01244567); +// +// // CHECK(check_ulong1); +// // CHECK(check_ulong2); +// // CHECK(check_ulong3); +// // } +// +// // if (sizeof(long long) == 8U) +// // { +// // constexpr bool check_long_long1 = (long long)(0x0123456789ABCDEF) != etl::le_long_long_t(0x0123457789ABCDEF); +// // constexpr bool check_long_long2 = etl::le_long_long_t(0x0123456789ABCDEF) != (long long)(0x0123457789ABCDEF); +// // constexpr bool check_long_long3 = (long long)(0x0123456789ABCDEF) != etl::le_long_long_t(0x0123457789ABCDEF); +// +// // CHECK(check_long_long1); +// // CHECK(check_long_long2); +// // CHECK(check_long_long3); +// +// // constexpr bool check_ulong_long1 = (unsigned long long)(0x0123456789ABCDEF) != etl::le_ulong_long_t(0x0123457789ABCDEF); +// // constexpr bool check_ulong_long2 = etl::le_ulong_long_t(0x0123456789ABCDEF) != (unsigned long long)(0x0123457789ABCDEF); +// // constexpr bool check_ulong_long3 = (unsigned long long)(0x0123456789ABCDEF) != etl::le_ulong_long_t(0x0123457789ABCDEF); +// +// // CHECK(check_ulong_long1); +// // CHECK(check_ulong_long2); +// // CHECK(check_ulong_long3); +// // } +// //} +// +// ////************************************************************************* +// //TEST(test_be_equality) +// //{ +// // constexpr bool check_char1 = etl::be_char_t(0x01) == etl::be_char_t(0x01); +// // constexpr bool check_char2 = (char)(0x01) == etl::be_char_t(0x01); +// // constexpr bool check_char3 = etl::be_char_t(0x01) == (char)(0x01); +// +// // CHECK(check_char1); +// // CHECK(check_char2); +// // CHECK(check_char3); +// +// // constexpr bool check_schar1 = etl::be_schar_t(0x01) == etl::be_schar_t(0x01); +// // constexpr bool check_schar2 = (signed char)(0x01) == etl::be_schar_t(0x01); +// // constexpr bool check_schar3 = etl::be_schar_t(0x01) == (signed char)(0x01); +// +// // CHECK(check_schar1); +// // CHECK(check_schar2); +// // CHECK(check_schar3); +// +// // constexpr bool check_uchar1 = etl::be_uchar_t(0x01) == etl::be_uchar_t(0x01); +// // constexpr bool check_uchar2 = (unsigned char)(0x01) == etl::be_uchar_t(0x01); +// // constexpr bool check_uchar3 = etl::be_uchar_t(0x01) == (unsigned char)(0x01); +// +// // CHECK(check_uchar1); +// // CHECK(check_uchar2); +// // CHECK(check_uchar3); +// +// // constexpr bool check_short1 = (short)(0x0123) == etl::be_short_t(0x0123); +// // constexpr bool check_short2 = etl::be_short_t(0x0123) == (short)(0x0123); +// // constexpr bool check_short3 = (short)(0x0123) == etl::be_short_t(0x0123); +// +// // CHECK(check_short1); +// // CHECK(check_short2); +// // CHECK(check_short3); +// +// // constexpr bool check_ushort1 = (unsigned short)(0x0123) == etl::be_ushort_t(0x0123); +// // constexpr bool check_ushort2 = etl::be_ushort_t(0x0123) == (unsigned short)(0x0123); +// // constexpr bool check_ushort3 = (unsigned short)(0x0123) == etl::be_ushort_t(0x0123); +// +// // CHECK(check_ushort1); +// // CHECK(check_ushort2); +// // CHECK(check_ushort3); +// +// // constexpr bool check_int1 = (int)(0x01234567) == etl::be_int_t(0x01234567); +// // constexpr bool check_int2 = etl::be_int_t(0x01234567) == (int)(0x01234567); +// // constexpr bool check_int3 = (int)(0x01234567) == etl::be_int_t(0x01234567); +// +// // CHECK(check_int1); +// // CHECK(check_int2); +// // CHECK(check_int3); +// +// // constexpr bool check_uint1 = (unsigned int)(0x01234567) == etl::be_uint_t(0x01234567); +// // constexpr bool check_uint2 = etl::be_uint_t(0x01234567) == (unsigned int)(0x01234567); +// // constexpr bool check_uint3 = (unsigned int)(0x01234567) == etl::be_uint_t(0x01234567); +// +// // CHECK(check_uint1); +// // CHECK(check_uint2); +// // CHECK(check_uint3); +// +// // if (sizeof(long) == 4U) +// // { +// // constexpr bool check_long1 = (long)(0x01234567) == etl::be_long_t(0x01234567); +// // constexpr bool check_long2 = etl::be_long_t(0x01234567) == (long)(0x01234567); +// // constexpr bool check_long3 = (long)(0x01234567) == etl::be_long_t(0x01234567); +// +// // CHECK(check_long1); +// // CHECK(check_long2); +// // CHECK(check_long3); +// +// // constexpr bool check_ulong1 = (unsigned long)(0x01234567) == etl::be_ulong_t(0x01234567); +// // constexpr bool check_ulong2 = etl::be_ulong_t(0x01234567) == (unsigned long)(0x01234567); +// // constexpr bool check_ulong3 = (unsigned long)(0x01234567) == etl::be_ulong_t(0x01234567); +// +// // CHECK(check_ulong1); +// // CHECK(check_ulong2); +// // CHECK(check_ulong3); +// // } +// +// // if (sizeof(long long) == 8U) +// // { +// // constexpr bool check_long_long1 = (long long)(0x0123456789ABCDEF) == etl::be_long_long_t(0x0123456789ABCDEF); +// // constexpr bool check_long_long2 = etl::be_long_long_t(0x0123456789ABCDEF) == (long long)(0x0123456789ABCDEF); +// // constexpr bool check_long_long3 = (long long)(0x0123456789ABCDEF) == etl::be_long_long_t(0x0123456789ABCDEF); +// +// // CHECK(check_long_long1); +// // CHECK(check_long_long2); +// // CHECK(check_long_long3); +// +// // constexpr bool check_ulong_long1 = (unsigned long long)(0x0123456789ABCDEF) == etl::be_ulong_long_t(0x0123456789ABCDEF); +// // constexpr bool check_ulong_long2 = etl::be_ulong_long_t(0x0123456789ABCDEF) == (unsigned long long)(0x0123456789ABCDEF); +// // constexpr bool check_ulong_long3 = (unsigned long long)(0x0123456789ABCDEF) == etl::be_ulong_long_t(0x0123456789ABCDEF); +// +// // CHECK(check_ulong_long1); +// // CHECK(check_ulong_long2); +// // CHECK(check_ulong_long3); +// // } +// //} +// +// ////************************************************************************* +// //TEST(test_be_inequality) +// //{ +// // constexpr bool check_char1 = etl::be_char_t(0x01) != etl::be_char_t(0x02); +// // constexpr bool check_char2 = (char)(0x01) != etl::be_char_t(0x02); +// // constexpr bool check_char3 = etl::be_char_t(0x01) != (char)(0x02); +// +// // CHECK(check_char1); +// // CHECK(check_char2); +// // CHECK(check_char3); +// +// // constexpr bool check_schar1 = etl::be_schar_t(0x01) != etl::be_schar_t(0x02); +// // constexpr bool check_schar2 = (signed char)(0x01) != etl::be_schar_t(0x02); +// // constexpr bool check_schar3 = etl::be_schar_t(0x01) != (signed char)(0x02); +// +// // CHECK(check_schar1); +// // CHECK(check_schar2); +// // CHECK(check_schar3); +// +// // constexpr bool check_uchar1 = etl::be_uchar_t(0x01) != etl::be_uchar_t(0x02); +// // constexpr bool check_uchar2 = (unsigned char)(0x01) != etl::be_uchar_t(0x02); +// // constexpr bool check_uchar3 = etl::be_uchar_t(0x01) != (unsigned char)(0x02); +// +// // CHECK(check_uchar1); +// // CHECK(check_uchar2); +// // CHECK(check_uchar3); +// +// // constexpr bool check_short1 = (short)(0x0123) != etl::be_short_t(0x0124); +// // constexpr bool check_short2 = etl::be_short_t(0x0123) != (short)(0x0124); +// // constexpr bool check_short3 = (short)(0x0123) != etl::be_short_t(0x0124); +// +// // CHECK(check_short1); +// // CHECK(check_short2); +// // CHECK(check_short3); +// +// // constexpr bool check_ushort1 = (unsigned short)(0x0123) != etl::be_ushort_t(0x0124); +// // constexpr bool check_ushort2 = etl::be_ushort_t(0x0123) != (unsigned short)(0x0124); +// // constexpr bool check_ushort3 = (unsigned short)(0x0123) != etl::be_ushort_t(0x0124); +// +// // CHECK(check_ushort1); +// // CHECK(check_ushort2); +// // CHECK(check_ushort3); +// +// // constexpr bool check_int1 = (int)(0x01234567) != etl::be_int_t(0x01244567); +// // constexpr bool check_int2 = etl::be_int_t(0x01234567) != (int)(0x01244567); +// // constexpr bool check_int3 = (int)(0x01234567) != etl::be_int_t(0x01244567); +// +// // CHECK(check_int1); +// // CHECK(check_int2); +// // CHECK(check_int3); +// +// // constexpr bool check_uint1 = (unsigned int)(0x01234567) != etl::be_uint_t(0x01244567); +// // constexpr bool check_uint2 = etl::be_uint_t(0x01234567) != (unsigned int)(0x01244567); +// // constexpr bool check_uint3 = (unsigned int)(0x01234567) != etl::be_uint_t(0x01244567); +// +// // CHECK(check_uint1); +// // CHECK(check_uint2); +// // CHECK(check_uint3); +// +// // if (sizeof(long) == 4U) +// // { +// // constexpr bool check_long1 = (long)(0x01234567) != etl::be_long_t(0x01244567); +// // constexpr bool check_long2 = etl::be_long_t(0x01234567) != (long)(0x01244567); +// // constexpr bool check_long3 = (long)(0x01234567) != etl::be_long_t(0x01244567); +// +// // CHECK(check_long1); +// // CHECK(check_long2); +// // CHECK(check_long3); +// +// // constexpr bool check_ulong1 = (unsigned long)(0x01234567) != etl::be_ulong_t(0x01244567); +// // constexpr bool check_ulong2 = etl::be_ulong_t(0x01234567) != (unsigned long)(0x01244567); +// // constexpr bool check_ulong3 = (unsigned long)(0x01234567) != etl::be_ulong_t(0x01244567); +// +// // CHECK(check_ulong1); +// // CHECK(check_ulong2); +// // CHECK(check_ulong3); +// // } +// +// // if (sizeof(long long) == 8U) +// // { +// // constexpr bool check_long_long1 = (long long)(0x0123456789ABCDEF) != etl::be_long_long_t(0x0123457789ABCDEF); +// // constexpr bool check_long_long2 = etl::be_long_long_t(0x0123456789ABCDEF) != (long long)(0x0123457789ABCDEF); +// // constexpr bool check_long_long3 = (long long)(0x0123456789ABCDEF) != etl::be_long_long_t(0x0123457789ABCDEF); +// +// // CHECK(check_long_long1); +// // CHECK(check_long_long2); +// // CHECK(check_long_long3); +// +// // constexpr bool check_ulong_long1 = (unsigned long long)(0x0123456789ABCDEF) != etl::be_ulong_long_t(0x0123457789ABCDEF); +// // constexpr bool check_ulong_long2 = etl::be_ulong_long_t(0x0123456789ABCDEF) != (unsigned long long)(0x0123457789ABCDEF); +// // constexpr bool check_ulong_long3 = (unsigned long long)(0x0123456789ABCDEF) != etl::be_ulong_long_t(0x0123457789ABCDEF); +// +// // CHECK(check_ulong_long1); +// // CHECK(check_ulong_long2); +// // CHECK(check_ulong_long3); +// // } +// //} +// +// ////************************************************************************* +// //TEST(test_le_assignment) +// //{ +// // constexpr etl::le_char_t le_char = 0x01; +// // CHECK(0x01 == (signed char)le_char); +// +// // constexpr etl::le_schar_t le_schar = 0x01; +// // CHECK(0x01 == (signed char)le_schar); +// +// // constexpr etl::le_uchar_t le_uchar = 0x01; +// // CHECK(0x01 == (unsigned char)le_uchar); +// +// // constexpr etl::le_short_t le_short = 0x0123; +// // CHECK(0x0123 == (short)le_short); +// +// // constexpr etl::le_ushort_t le_ushort = 0x0123; +// // CHECK(0x0123 == (unsigned short)le_ushort); +// +// // constexpr etl::le_int_t le_int = 0x01234567; +// // CHECK(0x01234567 == (int)le_int); +// +// // constexpr etl::le_uint_t le_uint = 0x01234567; +// // CHECK(0x01234567 == (unsigned int)le_uint); +// +// // if (sizeof(long) == 4U) +// // { +// // constexpr etl::le_long_t le_long = 0x01234567; +// // CHECK(0x01234567 == (long)le_long); +// +// // constexpr etl::le_ulong_t le_ulong = 0x01234567; +// // CHECK(0x01234567 == (unsigned long)le_ulong); +// // } +// +// // if (sizeof(long long) == 8U) +// // { +// // constexpr etl::le_long_long_t le_long = 0x0123456789ABCDEF; +// // CHECK(0x0123456789ABCDEF == (long long)le_long); +// +// // constexpr etl::le_ulong_long_t le_ulong = 0x0123456789ABCDEF; +// // CHECK(0x0123456789ABCDEF == (unsigned long long)le_ulong); +// // } +// //} +// +// ////************************************************************************* +// //TEST(test_be_assignment) +// //{ +// // constexpr etl::be_char_t be_char = 0x01; +// // CHECK(0x01 == (signed char)be_char); +// +// // constexpr etl::be_schar_t be_schar = 0x01; +// // CHECK(0x01 == (signed char)be_schar); +// +// // constexpr etl::be_uchar_t be_uchar = 0x01; +// // CHECK(0x01 == (unsigned char)be_uchar); +// +// // constexpr etl::be_short_t be_short = 0x0123; +// // CHECK(0x0123 == (short)be_short); +// +// // constexpr etl::be_ushort_t be_ushort = 0x0123; +// // CHECK(0x0123 == (unsigned short)be_ushort); +// +// // constexpr etl::be_int_t be_int = 0x01234567; +// // CHECK(0x01234567 == (int)be_int); +// +// // constexpr etl::be_uint_t be_uint = 0x01234567; +// // CHECK(0x01234567 == (unsigned int)be_uint); +// +// // if (sizeof(long) == 4U) +// // { +// // constexpr etl::be_long_t be_long = 0x01234567; +// // CHECK(0x01234567 == (long)be_long); +// +// // constexpr etl::be_ulong_t be_ulong = 0x01234567; +// // CHECK(0x01234567 == (unsigned long)be_ulong); +// // } +// +// // if (sizeof(long long) == 8U) +// // { +// // constexpr etl::be_long_long_t be_long = 0x0123456789ABCDEF; +// // CHECK(0x0123456789ABCDEF == (long long)be_long); +// +// // constexpr etl::be_ulong_long_t be_ulong = 0x0123456789ABCDEF; +// // CHECK(0x0123456789ABCDEF == (unsigned long long)be_ulong); +// // } +// //} +// +// ////************************************************************************* +// //TEST(test_data) +// //{ +// // static constexpr etl::be_uint16_t test(0x1234); +// // +// // constexpr etl::be_uint16_t::const_pointer p1 = test.data(); +// // constexpr etl::be_uint16_t::const_pointer p2 = test.data() + 1U; +// +// // CHECK_EQUAL(0x12, *p1); +// // CHECK_EQUAL(0x34, *p2); +// //} +// +// ////************************************************************************* +// //TEST(test_begin_end_iterator) +// //{ +// // using const_iterator = etl::be_uint16_t::const_iterator; +// +// // static constexpr etl::be_uint16_t test(0x1234); +// +// // //******************************* +// // constexpr const_iterator itr1 = test.begin(); +// // CHECK_EQUAL(int(0x12), int(*itr1)); +// +// // constexpr const_iterator itr2 = test.begin() + 1U; +// // CHECK_EQUAL(int(0x34), int(*itr2)); +// +// // constexpr const_iterator itr3 = test.begin() + 2U; +// // CHECK(test.end() == itr3); +// //} +// +// ////************************************************************************* +// //TEST(test_rbegin_rend_iterator) +// //{ +// // using const_reverse_iterator = etl::be_uint16_t::const_reverse_iterator; +// +// // static constexpr etl::be_uint16_t test(0x1234); +// +// // //******************************* +// // constexpr const_reverse_iterator itr1 = test.rbegin(); +// // CHECK_EQUAL(int(0x34), int(*itr1)); +// +// // constexpr const_reverse_iterator itr2 = test.rbegin() + 1U; +// // CHECK_EQUAL(int(0x12), int(*itr2)); +// +// // constexpr const_reverse_iterator itr3 = test.rbegin() + 2U; +// // CHECK(test.rend() == itr3); +// //} +// +// ////************************************************************************* +// //TEST(test_index_operator) +// //{ +// // constexpr etl::le_uint16_t test_le(0x1234); +// // constexpr etl::be_uint16_t test_be(0x1234); +// +// // constexpr const char lea = test_le[0]; +// // constexpr const char leb = test_le[1]; +// +// // constexpr const char bea = test_be[0]; +// // constexpr const char beb = test_be[1]; +// +// // CHECK_EQUAL(0x34, lea); +// // CHECK_EQUAL(0x12, leb); +// +// // CHECK_EQUAL(0x12, bea); +// // CHECK_EQUAL(0x34, beb); +// //} +// +// ////************************************************************************* +// //TEST(test_value) +// //{ +// // constexpr etl::le_uint16_t test_le(0x1234); +// // constexpr etl::be_uint16_t test_be(0x1234); +// +// // constexpr uint16_t lev = test_le.value(); +// // constexpr uint16_t bev = test_be.value(); +// +// // CHECK_EQUAL(0x1234, lev); +// // CHECK_EQUAL(0x1234, bev); +// //} +// +// ////************************************************************************* +// //TEST(test_storage_bytes) +// //{ +// // constexpr etl::le_uint16_t test_le(0x1234); +// // constexpr etl::be_uint16_t test_be(0x1234); +// +// // constexpr int lev0 = test_le[0]; +// // constexpr int lev1 = test_le[1]; +// // +// // constexpr int bev0 = test_be[0]; +// // constexpr int bev1 = test_be[1]; +// +// // CHECK_EQUAL(0x34, lev0); +// // CHECK_EQUAL(0x12, lev1); +// // CHECK_EQUAL(0x12, bev0); +// // CHECK_EQUAL(0x34, bev1); +// //} +// }; +//} +// +//#include "etl/private/diagnostic_pop.h" +// +//#endif