mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Added constexpr to CRC1
This commit is contained in:
parent
14b50c6541
commit
b3f7d82900
@ -52,19 +52,19 @@ namespace etl
|
||||
};
|
||||
|
||||
//*********************************
|
||||
value_type initial() const
|
||||
ETL_CONSTEXPR14 value_type initial() const
|
||||
{
|
||||
return even_parity;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
uint8_t add(int parity, uint8_t value) const
|
||||
ETL_CONSTEXPR14 uint8_t add(int parity, uint8_t value) const
|
||||
{
|
||||
return parity ^ etl::parity(value);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
uint8_t final(uint8_t parity) const
|
||||
ETL_CONSTEXPR14 uint8_t final(uint8_t parity) const
|
||||
{
|
||||
return parity;
|
||||
}
|
||||
@ -83,7 +83,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
//*************************************************************************
|
||||
crc1()
|
||||
ETL_CONSTEXPR14 crc1()
|
||||
{
|
||||
this->reset();
|
||||
}
|
||||
@ -94,7 +94,7 @@ namespace etl
|
||||
/// \param end End of the range.
|
||||
//*************************************************************************
|
||||
template<typename TIterator>
|
||||
crc1(TIterator begin, const TIterator end)
|
||||
ETL_CONSTEXPR14 crc1(TIterator begin, const TIterator end)
|
||||
{
|
||||
this->reset();
|
||||
this->add(begin, end);
|
||||
|
||||
@ -107,7 +107,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 frame_check_sequence() : frame_check()
|
||||
ETL_CONSTEXPR14 frame_check_sequence()
|
||||
: frame_check()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
@ -66,6 +66,17 @@ namespace
|
||||
CHECK_EQUAL(calculate_parity(data.begin(), data.end()), int(crc));
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP14
|
||||
//*************************************************************************
|
||||
TEST(test_crc1_constructor_constexpr)
|
||||
{
|
||||
constexpr char data[] = "123456789";
|
||||
constexpr uint8_t crc = etl::crc1(data, data + 9);
|
||||
|
||||
CHECK_EQUAL(calculate_parity(data, data + 9), int(crc));
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_crc1_add_values)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user