mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Merge branch 'development'
# Conflicts: # include/etl/version.h # library.json # library.properties # support/Release notes.txt
This commit is contained in:
commit
26b0f84439
@ -32,9 +32,136 @@ SOFTWARE.
|
||||
#define ETL_CUMULATIVE_MOVING_AVERAGE_INCLUDED
|
||||
|
||||
#include "type_traits.h"
|
||||
#include "iterator.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace private_cumulative_moving_average
|
||||
{
|
||||
//***************************************************
|
||||
/// Proxy adder.
|
||||
/// Returned by the iterator dereference operator.
|
||||
//***************************************************
|
||||
template <typename TCMA>
|
||||
class proxy_adder
|
||||
{
|
||||
public:
|
||||
|
||||
friend typename TCMA::iterator;
|
||||
|
||||
//***************************************************
|
||||
/// Copy constuctor
|
||||
//***************************************************
|
||||
proxy_adder(const proxy_adder& other)
|
||||
: p_cma(other.p_cma)
|
||||
{
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Assignment from proxy_adder
|
||||
//***************************************************
|
||||
proxy_adder& operator =(const proxy_adder& rhs)
|
||||
{
|
||||
p_cma = rhs.p_cma;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Assignment from value
|
||||
//***************************************************
|
||||
proxy_adder& operator =(typename TCMA::value_type value)
|
||||
{
|
||||
p_cma->add(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//***************************************************
|
||||
/// Private constructor
|
||||
//***************************************************
|
||||
proxy_adder(TCMA* p_cma_)
|
||||
: p_cma(p_cma_)
|
||||
{
|
||||
}
|
||||
|
||||
TCMA* p_cma;
|
||||
};
|
||||
|
||||
//***************************************************
|
||||
/// iterator
|
||||
/// An output iterator used to add new values.
|
||||
//***************************************************
|
||||
template <typename TCMA>
|
||||
class iterator : public etl::iterator<ETL_OR_STD::output_iterator_tag, typename TCMA::value_type>
|
||||
{
|
||||
public:
|
||||
|
||||
friend TCMA;
|
||||
|
||||
//***************************************************
|
||||
/// Default constructor
|
||||
//***************************************************
|
||||
iterator()
|
||||
{
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Copy constuctor
|
||||
//***************************************************
|
||||
iterator(const iterator& other)
|
||||
: adder(other.adder)
|
||||
{
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Assignment operator
|
||||
//***************************************************
|
||||
iterator& operator =(const iterator& rhs)
|
||||
{
|
||||
adder = rhs.adder;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Pre-increment operator
|
||||
//***************************************************
|
||||
iterator& operator ++()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Post-increment operator
|
||||
//***************************************************
|
||||
iterator& operator ++(int)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// De-reference operator
|
||||
//***************************************************
|
||||
proxy_adder<TCMA> operator *() const
|
||||
{
|
||||
return adder;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//***************************************************
|
||||
/// Private constructor
|
||||
//***************************************************
|
||||
iterator(TCMA* p_cma)
|
||||
: adder(p_cma)
|
||||
{
|
||||
}
|
||||
|
||||
/// The adder proxy returned by an iterator dereference.
|
||||
proxy_adder<TCMA> adder;
|
||||
};
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Cumulative Moving Average
|
||||
/// \tparam T The sample value type.
|
||||
@ -58,6 +185,10 @@ namespace etl
|
||||
template <typename T, const size_t SAMPLE_SIZE_, const size_t SCALING_>
|
||||
class cumulative_moving_average<T, SAMPLE_SIZE_, SCALING_, true, false>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef cumulative_moving_average<T, SAMPLE_SIZE_, SCALING_, true, false> this_t;
|
||||
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type scale_t;
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type sample_t;
|
||||
|
||||
@ -66,6 +197,9 @@ namespace etl
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::iterator<this_t> iterator;
|
||||
|
||||
static const size_t SAMPLE_SIZE = SAMPLE_SIZE_; ///< The number of samples averaged over.
|
||||
static const size_t SCALING = SCALING_; ///< The sample scaling factor.
|
||||
|
||||
@ -107,6 +241,15 @@ namespace etl
|
||||
return average;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets an iterator for input.
|
||||
/// \return An iterator.
|
||||
//*************************************************************************
|
||||
iterator input()
|
||||
{
|
||||
return iterator(this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T average; ///< The current cumulative average.
|
||||
@ -121,6 +264,8 @@ namespace etl
|
||||
template <typename T, const size_t SCALING_>
|
||||
class cumulative_moving_average<T, 0, SCALING_, true, false>
|
||||
{
|
||||
typedef cumulative_moving_average<T, 0, SCALING_, true, false> this_t;
|
||||
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type scale_t;
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type sample_t;
|
||||
|
||||
@ -128,6 +273,9 @@ namespace etl
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::iterator<this_t> iterator;
|
||||
|
||||
static const size_t SCALING = SCALING_; ///< The sample scaling factor.
|
||||
|
||||
//*************************************************************************
|
||||
@ -178,6 +326,15 @@ namespace etl
|
||||
return average;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets an iterator for input.
|
||||
/// \return An iterator.
|
||||
//*************************************************************************
|
||||
iterator input()
|
||||
{
|
||||
return iterator(this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T average; ///< The current cumulative average.
|
||||
@ -193,8 +350,13 @@ namespace etl
|
||||
template <typename T, const size_t SAMPLE_SIZE_>
|
||||
class cumulative_moving_average<T, SAMPLE_SIZE_, 1U, false, true>
|
||||
{
|
||||
typedef cumulative_moving_average<T, SAMPLE_SIZE_, 1U, false, true> this_t;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::iterator<this_t> iterator;
|
||||
|
||||
static const size_t SAMPLE_SIZE = SAMPLE_SIZE_;
|
||||
|
||||
//*************************************************************************
|
||||
@ -234,6 +396,15 @@ namespace etl
|
||||
return average;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets an iterator for input.
|
||||
/// \return An iterator.
|
||||
//*************************************************************************
|
||||
iterator input()
|
||||
{
|
||||
return iterator(this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const T reciprocal_samples_plus_1; ///< Reciprocal of one greater than the sample size.
|
||||
@ -241,16 +412,21 @@ namespace etl
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Cumulative Moving Average
|
||||
/// For floating point types.
|
||||
/// \tparam T The sample value type.
|
||||
/// \tparam SAMPLE_SIZE The number of samples to average over.
|
||||
//***************************************************************************
|
||||
/// Cumulative Moving Average
|
||||
/// For floating point types.
|
||||
/// \tparam T The sample value type.
|
||||
/// \tparam SAMPLE_SIZE The number of samples to average over.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class cumulative_moving_average<T, 0U, 1U, false, true>
|
||||
{
|
||||
typedef cumulative_moving_average<T, 0U, 1U, false, true> this_t;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::iterator<this_t> iterator;
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor
|
||||
/// \param initial_value The initial value for the average.
|
||||
@ -297,6 +473,15 @@ namespace etl
|
||||
return average;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets an iterator for input.
|
||||
/// \return An iterator.
|
||||
//*************************************************************************
|
||||
iterator input()
|
||||
{
|
||||
return iterator(this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T reciprocal_samples_plus_1; ///< Reciprocal of one greater than the sample size.
|
||||
|
||||
@ -43,6 +43,132 @@ ETL_STATIC_ASSERT(ETL_8BIT_SUPPORT, "This file does not currently support target
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace private_frame_check_sequence
|
||||
{
|
||||
//***************************************************
|
||||
/// Proxy adder.
|
||||
/// Returned by the iterator dereference operator.
|
||||
//***************************************************
|
||||
template <typename TFCS>
|
||||
class proxy_adder
|
||||
{
|
||||
public:
|
||||
|
||||
friend typename TFCS::iterator;
|
||||
|
||||
//***************************************************
|
||||
/// Copy constuctor
|
||||
//***************************************************
|
||||
proxy_adder(const proxy_adder& other)
|
||||
: p_fcs(other.p_fcs)
|
||||
{
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Assignment from proxy_adder
|
||||
//***************************************************
|
||||
proxy_adder& operator =(const proxy_adder& rhs)
|
||||
{
|
||||
p_fcs = rhs.p_fcs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Assignment from value
|
||||
//***************************************************
|
||||
proxy_adder& operator =(uint8_t value)
|
||||
{
|
||||
p_fcs->add(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//***************************************************
|
||||
/// Private constructor
|
||||
//***************************************************
|
||||
proxy_adder(TFCS* p_fcs_)
|
||||
: p_fcs(p_fcs_)
|
||||
{
|
||||
}
|
||||
|
||||
TFCS* p_fcs;
|
||||
};
|
||||
|
||||
//***************************************************
|
||||
/// iterator
|
||||
/// An output iterator used to add new values.
|
||||
//***************************************************
|
||||
template <typename TFCS>
|
||||
class iterator : public etl::iterator<ETL_OR_STD::output_iterator_tag, typename TFCS::value_type>
|
||||
{
|
||||
public:
|
||||
|
||||
friend TFCS;
|
||||
|
||||
//***************************************************
|
||||
/// Default constructor
|
||||
//***************************************************
|
||||
iterator()
|
||||
{
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Copy constuctor
|
||||
//***************************************************
|
||||
iterator(const iterator& other)
|
||||
: adder(other.adder)
|
||||
{
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Assignment operator
|
||||
//***************************************************
|
||||
iterator& operator =(const iterator& rhs)
|
||||
{
|
||||
adder = rhs.adder;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Pre-increment operator
|
||||
//***************************************************
|
||||
iterator& operator ++()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Post-increment operator
|
||||
//***************************************************
|
||||
iterator& operator ++(int)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// De-reference operator
|
||||
//***************************************************
|
||||
proxy_adder<TFCS> operator *() const
|
||||
{
|
||||
return adder;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//***************************************************
|
||||
/// Private constructor
|
||||
//***************************************************
|
||||
iterator(TFCS* p_fcs)
|
||||
: adder(p_fcs)
|
||||
{
|
||||
}
|
||||
|
||||
/// The adder proxy returned by an iterator dereference.
|
||||
proxy_adder<TFCS> adder;
|
||||
};
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Calculates a frame check sequence according to the specified policy.
|
||||
///\tparam TPolicy The type used to enact the policy.
|
||||
@ -55,6 +181,7 @@ namespace etl
|
||||
|
||||
typedef TPolicy policy_type;
|
||||
typedef typename policy_type::value_type value_type;
|
||||
typedef private_frame_check_sequence::iterator<frame_check_sequence<TPolicy>> iterator;
|
||||
|
||||
ETL_STATIC_ASSERT(etl::is_unsigned<value_type>::value, "Signed frame check type not supported");
|
||||
|
||||
@ -128,6 +255,14 @@ namespace etl
|
||||
return policy.final(frame_check);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets an iterator for input.
|
||||
//*************************************************************************
|
||||
iterator input()
|
||||
{
|
||||
return iterator(this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
value_type frame_check;
|
||||
|
||||
@ -161,8 +161,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// CRC32 Poly 0x1EDC6F41
|
||||
//*************************************************************************
|
||||
template <const uint32_t INITIA, const uint32_t XOR_OUT, const bool REFLECT>
|
||||
class crc32_poly_0x1edc6f41 : public etl::frame_check_sequence<etl::crc32_policy_poly_0x1edc6f41<INITIA, XOR_OUT, REFLECT> >
|
||||
template <const uint32_t INITIAL, const uint32_t XOR_OUT, const bool REFLECT>
|
||||
class crc32_poly_0x1edc6f41 : public etl::frame_check_sequence<etl::crc32_policy_poly_0x1edc6f41<INITIAL, XOR_OUT, REFLECT> >
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@ -193,8 +193,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// CRC64 Poly 0x42F0E1EBA9EA3693
|
||||
//*************************************************************************
|
||||
template <const uint64_t INITIA, const uint64_t XOR_OUT, const bool REFLECT>
|
||||
class crc64_poly_0x42f0e1eba9ea3693 : public etl::frame_check_sequence<etl::crc64_policy_poly_0x42f0e1eba9ea3693<INITIA, XOR_OUT, REFLECT> >
|
||||
template <const uint64_t INITIAL, const uint64_t XOR_OUT, const bool REFLECT>
|
||||
class crc64_poly_0x42f0e1eba9ea3693 : public etl::frame_check_sequence<etl::crc64_policy_poly_0x42f0e1eba9ea3693<INITIAL, XOR_OUT, REFLECT> >
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@ -38,8 +38,8 @@ SOFTWARE.
|
||||
///\ingroup utilities
|
||||
|
||||
#define ETL_VERSION_MAJOR 18
|
||||
#define ETL_VERSION_MINOR 16
|
||||
#define ETL_VERSION_PATCH 5
|
||||
#define ETL_VERSION_MINOR 17
|
||||
#define ETL_VERSION_PATCH 0
|
||||
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library",
|
||||
"version": "18.16.5",
|
||||
"version": "18.17.0",
|
||||
"authors": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "john.wellbelove@etlcpp.com"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library
|
||||
version=18.16.5
|
||||
version=18.17.0
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
@ -1,3 +1,12 @@
|
||||
===============================================================================
|
||||
18.17.0
|
||||
Added iterator API to all etl::frame_check_sequence based template classes, such as CRCs and checksums.
|
||||
Example:
|
||||
std::string data("123456789");
|
||||
etl::crc32 crc;
|
||||
std::copy(data.begin(), data.end(), crc.input());
|
||||
uint32_t value = crc.value();
|
||||
|
||||
===============================================================================
|
||||
18.16.5
|
||||
Add missing include in test etl_profile.h
|
||||
|
||||
@ -172,6 +172,7 @@ namespace
|
||||
CHECK_EQUAL(0x6F, int(value));
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_rotate_left8_constexpr)
|
||||
{
|
||||
@ -179,6 +180,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::rotate_left(uint8_t(0xAA)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_rotate_left16)
|
||||
@ -270,6 +272,7 @@ namespace
|
||||
CHECK_EQUAL(0x6E79, int(value));
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_rotate_left16_constexpr)
|
||||
{
|
||||
@ -277,6 +280,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::rotate_left(uint16_t(0xAA)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_rotate_right8)
|
||||
@ -332,6 +336,7 @@ namespace
|
||||
CHECK_EQUAL(0xDB, int(value));
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_rotate_right8_constexpr)
|
||||
{
|
||||
@ -339,6 +344,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::rotate_right(uint8_t(0xAA)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_rotate_right16)
|
||||
@ -430,6 +436,7 @@ namespace
|
||||
CHECK_EQUAL(0x5B9E, int(value));
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_rotate_right16_constexpr)
|
||||
{
|
||||
@ -437,6 +444,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::rotate_right(uint16_t(0xAA)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_rotate16)
|
||||
@ -455,6 +463,7 @@ namespace
|
||||
CHECK_EQUAL(0xCB73, int(value));
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_rotate16_constexpr)
|
||||
{
|
||||
@ -462,6 +471,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::rotate(uint16_t(0xAA), 1), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bits8)
|
||||
@ -493,6 +503,7 @@ namespace
|
||||
CHECK_EQUAL(0x35, int(value));
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bits8_constexpr)
|
||||
{
|
||||
@ -500,6 +511,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::reverse_bits(uint8_t(0xA5)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bits16)
|
||||
@ -519,6 +531,7 @@ namespace
|
||||
CHECK_EQUAL(0xA5A5, value);
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bits16_constexpr)
|
||||
{
|
||||
@ -526,6 +539,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::reverse_bits(uint16_t(0xA500)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bits32)
|
||||
@ -545,6 +559,7 @@ namespace
|
||||
CHECK_EQUAL(uint32_t(0x5A5A5A5A), value);
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bits32_constexpr)
|
||||
{
|
||||
@ -552,6 +567,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::reverse_bits(uint32_t(0xA5000000)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bits64)
|
||||
@ -571,6 +587,7 @@ namespace
|
||||
CHECK_EQUAL(uint64_t(0x5A5A5A5A5A5A5A5A), value);
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bits64_constexpr)
|
||||
{
|
||||
@ -578,6 +595,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::reverse_bits(uint64_t(0xA500000000000000)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bytes16)
|
||||
@ -597,6 +615,7 @@ namespace
|
||||
CHECK_EQUAL(0x5AA5, value);
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bytes16_constexpr)
|
||||
{
|
||||
@ -604,6 +623,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::reverse_bytes(uint16_t(0xA500)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bytes32)
|
||||
@ -623,6 +643,7 @@ namespace
|
||||
CHECK_EQUAL(0xA5A55A5AU, value);
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bytes32_constexpr)
|
||||
{
|
||||
@ -630,6 +651,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::reverse_bytes(uint32_t(0xA5000000)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bytes64)
|
||||
@ -649,6 +671,7 @@ namespace
|
||||
CHECK_EQUAL(0xA5A55A5AA5A55A5AU, value);
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_reverse_bytes64_constexpr)
|
||||
{
|
||||
@ -656,6 +679,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::reverse_bytes(uint64_t(0xA500000000000000)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_binary_to_gray8)
|
||||
@ -675,6 +699,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_binary_to_gray8_constexpr)
|
||||
{
|
||||
@ -682,6 +707,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::binary_to_gray(uint8_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_binary_to_gray16)
|
||||
@ -701,6 +727,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_binary_to_gray16_constexpr)
|
||||
{
|
||||
@ -708,6 +735,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::binary_to_gray(uint16_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_binary_to_gray32)
|
||||
@ -733,6 +761,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_binary_to_gray32_constexpr)
|
||||
{
|
||||
@ -740,6 +769,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::binary_to_gray(uint32_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_binary_to_gray64)
|
||||
@ -765,6 +795,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_binary_to_gray64_constexpr)
|
||||
{
|
||||
@ -772,6 +803,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::binary_to_gray(uint64_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_gray_to_binary8)
|
||||
@ -783,6 +815,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_gray_to_binary8_constexpr)
|
||||
{
|
||||
@ -790,6 +823,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::gray_to_binary(uint8_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_gray_to_binary16)
|
||||
@ -801,6 +835,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_gray_to_binary16_constexpr)
|
||||
{
|
||||
@ -808,6 +843,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::gray_to_binary(uint16_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_gray_to_binary32)
|
||||
@ -824,6 +860,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_gray_to_binary32_constexpr)
|
||||
{
|
||||
@ -831,6 +868,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::gray_to_binary(uint32_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_gray_to_binary64)
|
||||
@ -847,6 +885,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_gray_to_binary64_constexpr)
|
||||
{
|
||||
@ -854,6 +893,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::gray_to_binary(uint64_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_count_bits_8)
|
||||
@ -865,6 +905,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_count_bits_8_constexpr)
|
||||
{
|
||||
@ -872,6 +913,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::count_bits(uint8_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_count_bits_16)
|
||||
@ -883,6 +925,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_count_bits_16_constexpr)
|
||||
{
|
||||
@ -890,6 +933,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::count_bits(uint16_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_count_bits_32)
|
||||
@ -907,6 +951,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_count_bits_32_constexpr)
|
||||
{
|
||||
@ -914,6 +959,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::count_bits(uint32_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_count_bits_64)
|
||||
@ -931,6 +977,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_count_bits_64_constexpr)
|
||||
{
|
||||
@ -938,6 +985,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::count_bits(uint64_t(0xFF)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_parity_8)
|
||||
@ -949,6 +997,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_parity_8_constexpr)
|
||||
{
|
||||
@ -956,6 +1005,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::parity(uint8_t(0xFE)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_parity_16)
|
||||
@ -967,6 +1017,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_parity_16_constexpr)
|
||||
{
|
||||
@ -974,6 +1025,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::parity(uint16_t(0xFE)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_parity_32)
|
||||
@ -991,6 +1043,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_parity_32_constexpr)
|
||||
{
|
||||
@ -998,6 +1051,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::parity(uint32_t(0xFE)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_parity_64)
|
||||
@ -1015,6 +1069,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_parity_64_constexpr)
|
||||
{
|
||||
@ -1022,6 +1077,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(etl::parity(uint64_t(0xFE)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_fold_bits)
|
||||
@ -1093,6 +1149,7 @@ namespace
|
||||
CHECK_EQUAL(test_fold_bits<uint64_t>(data, 63), (etl::fold_bits<uint64_t, 63>(data)));
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_fold_bits_constexpr)
|
||||
{
|
||||
@ -1100,6 +1157,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL((etl::fold_bits<int64_t, 7>(0xE8C9AACCBC3D9A8F)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_max_value_for_bits)
|
||||
@ -1285,6 +1343,7 @@ namespace
|
||||
CHECK_EQUAL(178956970, (etl::sign_extend<int64_t, 30>(value32)));
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_sign_extend_template1_constexpr)
|
||||
{
|
||||
@ -1292,6 +1351,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL((etl::sign_extend<int8_t, 6>(0x1A)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_sign_extend_template1b)
|
||||
@ -1344,6 +1404,7 @@ namespace
|
||||
CHECK_EQUAL(-22, (etl::sign_extend<int64_t, 6, 26>(value)));
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_sign_extend_template1b_constexpr)
|
||||
{
|
||||
@ -1351,6 +1412,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL((etl::sign_extend<int8_t, 6, 0>(0x1A)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_sign_extend_template2)
|
||||
@ -1398,6 +1460,7 @@ namespace
|
||||
CHECK_EQUAL(178956970, (etl::sign_extend<int64_t>(value32, 30)));
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_sign_extend_template2_constexpr)
|
||||
{
|
||||
@ -1405,6 +1468,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL((etl::sign_extend<int8_t>(0x1A, 6)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_sign_extend_template2b)
|
||||
@ -1457,6 +1521,7 @@ namespace
|
||||
CHECK_EQUAL(-22, (etl::sign_extend<int64_t>(value, 6, 26)));
|
||||
}
|
||||
|
||||
#if !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
//*************************************************************************
|
||||
TEST(test_sign_extend_template2b_constexpr)
|
||||
{
|
||||
@ -1464,6 +1529,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL((etl::sign_extend<int8_t>(0x1A, 6, 0)), sizeof(temp));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_bit)
|
||||
|
||||
@ -121,6 +121,21 @@ namespace
|
||||
CHECK_EQUAL(int(compare), int(sum));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_checksum_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::bsd_checksum<uint8_t> checksum_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), checksum_calculator.input());
|
||||
|
||||
uint8_t sum = checksum_calculator.value();
|
||||
uint8_t compare = reference_checksum<uint8_t>(data.begin(), data.end());
|
||||
|
||||
CHECK_EQUAL(int(compare), int(sum));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_checksum_add_range_sum32)
|
||||
{
|
||||
|
||||
@ -97,6 +97,20 @@ namespace
|
||||
CHECK_EQUAL(221, int(sum));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_checksum_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::checksum<uint8_t> checksum_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), checksum_calculator.input());
|
||||
|
||||
uint8_t sum = checksum_calculator.value();
|
||||
|
||||
CHECK_EQUAL(221, int(sum));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_checksum_add_range_sum16)
|
||||
{
|
||||
@ -111,6 +125,20 @@ namespace
|
||||
CHECK_EQUAL(477, int(sum));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_checksum_add_range_sum16_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::checksum<uint16_t> checksum_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), checksum_calculator.input());
|
||||
|
||||
uint16_t sum = checksum_calculator.value();
|
||||
|
||||
CHECK_EQUAL(477, int(sum));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_checksum_add_range_sum32)
|
||||
{
|
||||
@ -125,6 +153,20 @@ namespace
|
||||
CHECK_EQUAL(477, int(sum));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_checksum_add_range_sum32_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::checksum<uint32_t> checksum_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), checksum_calculator.input());
|
||||
|
||||
uint32_t sum = checksum_calculator.value();
|
||||
|
||||
CHECK_EQUAL(477, int(sum));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_checksum_add_range_endian)
|
||||
{
|
||||
|
||||
@ -99,6 +99,20 @@ namespace
|
||||
CHECK_EQUAL(0xF4, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc8_ccitt_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc8_ccitt crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint8_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0xF4, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc8_ccitt_add_range_endian)
|
||||
{
|
||||
@ -155,6 +169,20 @@ namespace
|
||||
CHECK_EQUAL(0xBB3D, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16 crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0xBB3D, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_add_range_endian)
|
||||
{
|
||||
@ -211,6 +239,20 @@ namespace
|
||||
CHECK_EQUAL(0x29B1, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_ccitt_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_ccitt crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x29B1, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_ccitt_add_range_endian)
|
||||
{
|
||||
@ -267,6 +309,20 @@ namespace
|
||||
CHECK_EQUAL(0x2189, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_kermit_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_kermit crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x2189, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_kermit_add_range_endian)
|
||||
{
|
||||
@ -323,6 +379,20 @@ namespace
|
||||
CHECK_EQUAL(0x4B37, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_modbus_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_modbus crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x4B37, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_modbus_add_range_endian)
|
||||
{
|
||||
@ -379,6 +449,20 @@ namespace
|
||||
CHECK_EQUAL(0xB4C8, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_usb_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_usb crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0xB4C8, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_usb_add_range_endian)
|
||||
{
|
||||
@ -435,6 +519,20 @@ namespace
|
||||
CHECK_EQUAL(0x31C3, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_xmodem_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_xmodem crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x31C3, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_xmodem_add_range_endian)
|
||||
{
|
||||
@ -491,6 +589,20 @@ namespace
|
||||
CHECK_EQUAL(0xE5CC, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_aug_ccitt_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_aug_ccitt crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0xE5CC, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_aug_ccitt_add_range_endian)
|
||||
{
|
||||
@ -547,6 +659,20 @@ namespace
|
||||
CHECK_EQUAL(0xD64E, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_genibus_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_genibus crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0xD64E, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_genibus_add_range_endian)
|
||||
{
|
||||
@ -603,6 +729,20 @@ namespace
|
||||
CHECK_EQUAL(0x906E, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_x25_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc16_x25 crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint16_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x906E, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc16_x25_add_range_endian)
|
||||
{
|
||||
@ -660,6 +800,20 @@ namespace
|
||||
CHECK_EQUAL(0xCBF43926, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc32_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc32 crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint32_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0xCBF43926, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc32_add_range_endian)
|
||||
{
|
||||
@ -717,6 +871,20 @@ namespace
|
||||
CHECK_EQUAL(0xE3069283, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc32_c_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc32_c crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint32_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0xE3069283, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc32_c_add_range_endian)
|
||||
{
|
||||
@ -774,6 +942,20 @@ namespace
|
||||
CHECK_EQUAL(0xFC891918, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc32_bzip2_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc32_bzip2 crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint32_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0xFC891918, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc32_bzip2_add_range_endian)
|
||||
{
|
||||
@ -831,6 +1013,20 @@ namespace
|
||||
CHECK_EQUAL(0x765E7680, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc32_posix_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc32_posix crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint32_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x765E7680, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc32_posix_add_range_endian)
|
||||
{
|
||||
@ -888,6 +1084,20 @@ namespace
|
||||
CHECK_EQUAL(0x0376E6E7, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc32_mpeg2_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc32_mpeg2 crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint32_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x0376E6E7, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc32_mpeg2_add_range_endian)
|
||||
{
|
||||
@ -944,6 +1154,20 @@ namespace
|
||||
CHECK_EQUAL(0x6C40DF5F0B497347U, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc64_ecma_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::crc64_ecma crc_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
|
||||
uint64_t crc = crc_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x6C40DF5F0B497347U, crc);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc64_ecma_add_range_endian)
|
||||
{
|
||||
|
||||
@ -28,6 +28,9 @@ SOFTWARE.
|
||||
|
||||
#include "UnitTest++/UnitTest++.h"
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
#include "etl/cumulative_moving_average.h"
|
||||
#include "etl/scaled_rounding.h"
|
||||
|
||||
@ -41,7 +44,7 @@ namespace
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_positive)
|
||||
{
|
||||
typedef etl::cumulative_moving_average<int, SAMPLE_SIZE, SCALING> CMA;
|
||||
using CMA = etl::cumulative_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -59,10 +62,25 @@ namespace
|
||||
CHECK_EQUAL(280, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_positive_via_iterator)
|
||||
{
|
||||
std::array data{ 9, 1, 8, 2, 7, 3, 6, 4, 5 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
|
||||
std::copy(data.begin(), data.end(), cma.input());
|
||||
|
||||
CHECK_EQUAL(280, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_negative)
|
||||
{
|
||||
typedef etl::cumulative_moving_average<int, SAMPLE_SIZE, SCALING> CMA;
|
||||
using CMA = etl::cumulative_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -80,10 +98,25 @@ namespace
|
||||
CHECK_EQUAL(-280, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_negative_via_iterator)
|
||||
{
|
||||
std::array data{ -9, -1, -8, -2, -7, -3, -6, -4, -5 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
|
||||
std::copy(data.begin(), data.end(), cma.input());
|
||||
|
||||
CHECK_EQUAL(-280, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(integral_unsigned_average_positive)
|
||||
{
|
||||
typedef etl::cumulative_moving_average<unsigned int, SAMPLE_SIZE, SCALING> CMA;
|
||||
using CMA = etl::cumulative_moving_average<unsigned int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0U);
|
||||
|
||||
CHECK_EQUAL(0U, cma.value());
|
||||
@ -101,10 +134,25 @@ namespace
|
||||
CHECK_EQUAL(280U, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(integral_unsigned_average_positive_via_iterator)
|
||||
{
|
||||
std::array data{ 9U, 1U, 8U, 2U, 7U, 3U, 6U, 4U, 5U };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<unsigned int, SAMPLE_SIZE, SCALING>;
|
||||
CMA cma(0U);
|
||||
|
||||
CHECK_EQUAL(0U, cma.value());
|
||||
|
||||
std::copy(data.begin(), data.end(), cma.input());
|
||||
|
||||
CHECK_EQUAL(280U, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_positive_runtime_sample_size)
|
||||
{
|
||||
typedef etl::cumulative_moving_average<int, 0U, SCALING> CMA;
|
||||
using CMA = etl::cumulative_moving_average<int, 0U, SCALING>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -124,10 +172,27 @@ namespace
|
||||
CHECK_EQUAL(280, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_positive_runtime_sample_size_via_iterator)
|
||||
{
|
||||
std::array data{ 9, 1, 8, 2, 7, 3, 6, 4, 5 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<int, 0U, SCALING>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
|
||||
cma.set_sample_size(SAMPLE_SIZE);
|
||||
|
||||
std::copy(data.begin(), data.end(), cma.input());
|
||||
|
||||
CHECK_EQUAL(280, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_negative_runtime_sample_size)
|
||||
{
|
||||
typedef etl::cumulative_moving_average<int, 0U, SCALING> CMA;
|
||||
using CMA = etl::cumulative_moving_average<int, 0U, SCALING>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
@ -147,10 +212,27 @@ namespace
|
||||
CHECK_EQUAL(-280, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(integral_signed_average_negative_runtime_sample_size_via_iterator)
|
||||
{
|
||||
std::array data{ -9, -1, -8, -2, -7, -3, -6, -4, -5 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<int, 0U, SCALING>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0, cma.value());
|
||||
|
||||
cma.set_sample_size(SAMPLE_SIZE);
|
||||
|
||||
std::copy(data.begin(), data.end(), cma.input());
|
||||
|
||||
CHECK_EQUAL(-280, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(integral_unsigned_average_positive_runtime_sample_size)
|
||||
{
|
||||
typedef etl::cumulative_moving_average<unsigned int, 0U, SCALING> CMA;
|
||||
using CMA = etl::cumulative_moving_average<unsigned int, 0U, SCALING>;
|
||||
CMA cma(0U, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0U, cma.value());
|
||||
@ -170,10 +252,27 @@ namespace
|
||||
CHECK_EQUAL(280U, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(integral_unsigned_average_positive_runtime_sample_size_via_iterator)
|
||||
{
|
||||
std::array data{ 9U, 1U, 8U, 2U, 7U, 3U, 6U, 4U, 5U };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<int, 0U, SCALING>;
|
||||
CMA cma(0U, SAMPLE_SIZE * 2U);
|
||||
|
||||
CHECK_EQUAL(0U, cma.value());
|
||||
|
||||
cma.set_sample_size(SAMPLE_SIZE);
|
||||
|
||||
std::copy(data.begin(), data.end(), cma.input());
|
||||
|
||||
CHECK_EQUAL(280U, cma.value());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(floating_point_average)
|
||||
{
|
||||
typedef etl::cumulative_moving_average<double, SAMPLE_SIZE> CMA;
|
||||
using CMA = etl::cumulative_moving_average<double, SAMPLE_SIZE>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0.0, cma.value());
|
||||
@ -191,10 +290,25 @@ namespace
|
||||
CHECK_CLOSE(2.82, cma.value(), 0.01);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(floating_point_average_via_iterator)
|
||||
{
|
||||
std::array data{ 9.0, 1.0, 8.0, 2.0, 7.0, 3.0, 6.0, 4.0, 5.0 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<double, SAMPLE_SIZE>;
|
||||
CMA cma(0);
|
||||
|
||||
CHECK_EQUAL(0.0, cma.value());
|
||||
|
||||
std::copy(data.begin(), data.end(), cma.input());
|
||||
|
||||
CHECK_CLOSE(2.82, cma.value(), 0.01);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(floating_point_average_runtime_sample_size)
|
||||
{
|
||||
typedef etl::cumulative_moving_average<double, 0U> CMA;
|
||||
using CMA = etl::cumulative_moving_average<double, 0U>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2);
|
||||
|
||||
CHECK_EQUAL(0.0, cma.value());
|
||||
@ -213,5 +327,22 @@ namespace
|
||||
|
||||
CHECK_CLOSE(2.82, cma.value(), 0.01);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(floating_point_average_runtime_sample_size_via_iterator)
|
||||
{
|
||||
std::array data{ 9.0, 1.0, 8.0, 2.0, 7.0, 3.0, 6.0, 4.0, 5.0 };
|
||||
|
||||
using CMA = etl::cumulative_moving_average<double, 0U>;
|
||||
CMA cma(0, SAMPLE_SIZE * 2);
|
||||
|
||||
CHECK_EQUAL(0.0, cma.value());
|
||||
|
||||
cma.set_sample_size(SAMPLE_SIZE);
|
||||
|
||||
std::copy(data.begin(), data.end(), cma.input());
|
||||
|
||||
CHECK_CLOSE(2.82, cma.value(), 0.01);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -80,6 +80,20 @@ namespace
|
||||
CHECK_EQUAL(0x24148816U, hash);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_fnv_1_32_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::fnv_1_32 fnv_1_32_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), fnv_1_32_calculator.input());
|
||||
|
||||
uint32_t hash = fnv_1_32_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x24148816U, hash);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_fnv_1_32_add_range_endian)
|
||||
{
|
||||
@ -136,6 +150,20 @@ namespace
|
||||
CHECK_EQUAL(0xBB86B11CU, hash);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_fnv_1a_32_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::fnv_1a_32 fnv_1a_32_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), fnv_1a_32_calculator.input());
|
||||
|
||||
uint32_t hash = fnv_1a_32_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0xBB86B11CU, hash);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_fnv_1a_32_add_range_endian)
|
||||
{
|
||||
@ -192,6 +220,20 @@ namespace
|
||||
CHECK_EQUAL(0xA72FFC362BF916D6U, hash);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_fnv_1_64_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::fnv_1_64 fnv_1_64_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), fnv_1_64_calculator.input());
|
||||
|
||||
uint64_t hash = fnv_1_64_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0xA72FFC362BF916D6U, hash);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_fnv_1_64_add_range_endian)
|
||||
{
|
||||
@ -248,6 +290,20 @@ namespace
|
||||
CHECK_EQUAL(0x06D5573923C6CDFCU, hash);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_fnv_1a_64_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::fnv_1a_64 fnv_1a_64_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), fnv_1a_64_calculator.input());
|
||||
|
||||
uint64_t hash = fnv_1a_64_calculator.value();
|
||||
|
||||
CHECK_EQUAL(0x06D5573923C6CDFCU, hash);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_fnv_1a_64_add_range_endian)
|
||||
{
|
||||
|
||||
@ -103,6 +103,22 @@ namespace
|
||||
CHECK_EQUAL(compare, hash);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_jenkins_add_range_via_iterator)
|
||||
{
|
||||
std::string data("123456789");
|
||||
|
||||
etl::jenkins jenkins_calculator;
|
||||
|
||||
std::copy(data.begin(), data.end(), jenkins_calculator.input());
|
||||
|
||||
uint32_t hash = jenkins_calculator.value();
|
||||
|
||||
uint32_t compare = jenkins(data.begin(), data.end());
|
||||
|
||||
CHECK_EQUAL(compare, hash);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_jenkins_add_range_endian)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user