From 14b50c65410c21988f2a15616612aabbc3478060 Mon Sep 17 00:00:00 2001 From: Zob314 Date: Fri, 24 Jan 2025 08:20:05 -0700 Subject: [PATCH] Allow compile time CRC calculation (#1016) * Making crc constexpr for c++14. Allows compile time CRC computation. * Fix syntax when using c++03 or `ETL_FORCE_NO_ADVANCED_CPP` * Remove use of `ETL_FORCE_NO_ADVANCED_CPP` option since it is no longer used. --------- Co-authored-by: Zach O'Brien Co-authored-by: John Wellbelove --- include/etl/frame_check_sequence.h | 16 +++---- include/etl/private/crc_implementation.h | 53 ++++++++++++++++++------ test/test_crc16.cpp | 22 ++++++++++ test/test_crc16_a.cpp | 33 +++++++++++++++ test/test_crc16_arc.cpp | 33 +++++++++++++++ test/test_crc16_aug_ccitt.cpp | 33 +++++++++++++++ test/test_crc16_buypass.cpp | 33 +++++++++++++++ test/test_crc16_ccitt.cpp | 33 +++++++++++++++ test/test_crc16_cdma2000.cpp | 33 +++++++++++++++ test/test_crc16_dds110.cpp | 33 +++++++++++++++ test/test_crc16_dectr.cpp | 33 +++++++++++++++ test/test_crc16_dectx.cpp | 33 +++++++++++++++ test/test_crc16_dnp.cpp | 33 +++++++++++++++ test/test_crc16_en13757.cpp | 33 +++++++++++++++ test/test_crc16_genibus.cpp | 33 +++++++++++++++ test/test_crc16_kermit.cpp | 33 +++++++++++++++ test/test_crc16_m17.cpp | 33 +++++++++++++++ test/test_crc16_maxim.cpp | 33 +++++++++++++++ test/test_crc16_mcrf4xx.cpp | 33 +++++++++++++++ test/test_crc16_modbus.cpp | 33 +++++++++++++++ test/test_crc16_profibus.cpp | 33 +++++++++++++++ test/test_crc16_riello.cpp | 33 +++++++++++++++ test/test_crc16_t10dif.cpp | 33 +++++++++++++++ test/test_crc16_teledisk.cpp | 33 +++++++++++++++ test/test_crc16_tms37157.cpp | 33 +++++++++++++++ test/test_crc16_usb.cpp | 33 +++++++++++++++ test/test_crc16_x25.cpp | 33 +++++++++++++++ test/test_crc16_xmodem.cpp | 33 +++++++++++++++ test/test_crc32.cpp | 22 ++++++++++ test/test_crc32_bzip2.cpp | 33 +++++++++++++++ test/test_crc32_c.cpp | 33 +++++++++++++++ test/test_crc32_d.cpp | 33 +++++++++++++++ test/test_crc32_jamcrc.cpp | 33 +++++++++++++++ test/test_crc32_mpeg2.cpp | 33 +++++++++++++++ test/test_crc32_posix.cpp | 33 +++++++++++++++ test/test_crc32_q.cpp | 33 +++++++++++++++ test/test_crc32_xfer.cpp | 33 +++++++++++++++ test/test_crc64_ecma.cpp | 33 +++++++++++++++ test/test_crc8_ccitt.cpp | 33 +++++++++++++++ test/test_crc8_cdma2000.cpp | 33 +++++++++++++++ test/test_crc8_darc.cpp | 33 +++++++++++++++ test/test_crc8_dvbs2.cpp | 33 +++++++++++++++ test/test_crc8_ebu.cpp | 33 +++++++++++++++ test/test_crc8_icode.cpp | 33 +++++++++++++++ test/test_crc8_itu.cpp | 33 +++++++++++++++ test/test_crc8_j1850.cpp | 33 +++++++++++++++ test/test_crc8_j1850_zero.cpp | 33 +++++++++++++++ test/test_crc8_maxim.cpp | 33 +++++++++++++++ test/test_crc8_rohc.cpp | 33 +++++++++++++++ test/test_crc8_wcdma.cpp | 33 +++++++++++++++ 50 files changed, 1610 insertions(+), 21 deletions(-) diff --git a/include/etl/frame_check_sequence.h b/include/etl/frame_check_sequence.h index ec67e1ba..71bc31d4 100644 --- a/include/etl/frame_check_sequence.h +++ b/include/etl/frame_check_sequence.h @@ -107,7 +107,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - frame_check_sequence() + ETL_CONSTEXPR14 frame_check_sequence() : frame_check() { reset(); } @@ -118,7 +118,7 @@ namespace etl /// \param end End of the range. //************************************************************************* template - frame_check_sequence(TIterator begin, const TIterator end) + ETL_CONSTEXPR14 frame_check_sequence(TIterator begin, const TIterator end) : frame_check() { ETL_STATIC_ASSERT(sizeof(typename etl::iterator_traits::value_type) == 1, "Type not supported"); @@ -129,7 +129,7 @@ namespace etl //************************************************************************* /// Resets the FCS to the initial state. //************************************************************************* - void reset() + ETL_CONSTEXPR14 void reset() { frame_check = policy.initial(); } @@ -140,7 +140,7 @@ namespace etl /// \param end //************************************************************************* template - void add(TIterator begin, const TIterator end) + ETL_CONSTEXPR14 void add(TIterator begin, const TIterator end) { ETL_STATIC_ASSERT(sizeof(typename etl::iterator_traits::value_type) == 1, "Type not supported"); @@ -154,7 +154,7 @@ namespace etl //************************************************************************* /// \param value The uint8_t to add to the FCS. //************************************************************************* - void add(uint8_t value_) + ETL_CONSTEXPR14 void add(uint8_t value_) { frame_check = policy.add(frame_check, value_); } @@ -162,7 +162,7 @@ namespace etl //************************************************************************* /// Gets the FCS value. //************************************************************************* - value_type value() const + ETL_CONSTEXPR14 value_type value() const { return policy.final(frame_check); } @@ -170,7 +170,7 @@ namespace etl //************************************************************************* /// Conversion operator to value_type. //************************************************************************* - operator value_type () const + ETL_CONSTEXPR14 operator value_type () const { return policy.final(frame_check); } @@ -178,7 +178,7 @@ namespace etl //************************************************************************* /// Gets an add_insert_iterator for input. //************************************************************************* - add_insert_iterator input() + ETL_CONSTEXPR14 add_insert_iterator input() { return add_insert_iterator(*this); } diff --git a/include/etl/private/crc_implementation.h b/include/etl/private/crc_implementation.h index d94f0f18..9e642907 100644 --- a/include/etl/private/crc_implementation.h +++ b/include/etl/private/crc_implementation.h @@ -163,7 +163,7 @@ namespace etl // Accumulator_Bits > Chunk_Bits // Not Reflected template - static + static ETL_CONSTEXPR14 typename etl::enable_if<(Accumulator_Bits > Chunk_Bits) && !Reflect, TAccumulator>::type crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) { @@ -181,7 +181,7 @@ namespace etl // Accumulator_Bits > Chunk_Bits // Reflected template - static + static ETL_CONSTEXPR14 typename etl::enable_if<(Accumulator_Bits > Chunk_Bits) && Reflect, TAccumulator>::type crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) { @@ -199,7 +199,7 @@ namespace etl // Accumulator_Bits == Chunk_Bits // Not Reflected template - static + static ETL_CONSTEXPR14 typename etl::enable_if<(Accumulator_Bits == Chunk_Bits) && !Reflect, TAccumulator>::type crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) { @@ -216,7 +216,7 @@ namespace etl // Accumulator_Bits == Chunk_Bits // Reflected template - static + static ETL_CONSTEXPR14 typename etl::enable_if<(Accumulator_Bits == Chunk_Bits) && Reflect, TAccumulator>::type crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) { @@ -241,8 +241,10 @@ namespace etl struct crc_table { //************************************************************************* +#if !ETL_USING_CPP11 TAccumulator add(TAccumulator crc, uint8_t value) const { +#endif static ETL_CONSTANT TAccumulator table[4U] = { crc_table_entry::value, @@ -250,7 +252,10 @@ namespace etl crc_table_entry::value, crc_table_entry::value }; - +#if ETL_USING_CPP11 + ETL_CONSTEXPR14 TAccumulator add(TAccumulator crc, uint8_t value) const + { +#endif if ETL_IF_CONSTEXPR(Reflect) { crc = crc_update_chunk(crc, value, table); @@ -269,6 +274,10 @@ namespace etl return crc; } }; +#if ETL_USING_CPP11 + template + ETL_CONSTANT TAccumulator crc_table::table[4U]; +#endif //********************************* // Table size of 16. @@ -276,8 +285,10 @@ namespace etl struct crc_table { //************************************************************************* +#if !ETL_USING_CPP11 TAccumulator add(TAccumulator crc, uint8_t value) const { +#endif static ETL_CONSTANT TAccumulator table[16U] = { crc_table_entry::value, @@ -297,7 +308,10 @@ namespace etl crc_table_entry::value, crc_table_entry::value }; - +#if ETL_USING_CPP11 + ETL_CONSTEXPR14 TAccumulator add(TAccumulator crc, uint8_t value) const + { +#endif if ETL_IF_CONSTEXPR(Reflect) { crc = crc_update_chunk(crc, value, table); @@ -312,6 +326,10 @@ namespace etl return crc; } }; +#if ETL_USING_CPP11 + template + ETL_CONSTANT TAccumulator crc_table::table[16U]; +#endif //********************************* // Table size of 256. @@ -319,9 +337,11 @@ namespace etl struct crc_table { //************************************************************************* +#if !ETL_USING_CPP11 TAccumulator add(TAccumulator crc, uint8_t value) const { - static ETL_CONSTANT TAccumulator table[256U] = +#endif + static ETL_CONSTANT TAccumulator table[256U]= { crc_table_entry::value, crc_table_entry::value, @@ -580,13 +600,20 @@ namespace etl crc_table_entry::value, crc_table_entry::value }; +#if ETL_USING_CPP11 + ETL_CONSTEXPR14 TAccumulator add(TAccumulator crc, uint8_t value) const + { +#endif crc = crc_update_chunk(crc, value, table); return crc; } }; - +#if ETL_USING_CPP11 + template + ETL_CONSTANT TAccumulator crc_table::table[256U]; +#endif //***************************************************************************** // CRC Policies. //***************************************************************************** @@ -615,7 +642,7 @@ namespace etl } //************************************************************************* - accumulator_type final(accumulator_type crc) const + ETL_CONSTEXPR accumulator_type final(accumulator_type crc) const { return crc ^ TCrcParameters::Xor_Out; } @@ -643,7 +670,7 @@ namespace etl } //************************************************************************* - accumulator_type final(accumulator_type crc) const + ETL_CONSTEXPR accumulator_type final(accumulator_type crc) const { return crc ^ TCrcParameters::Xor_Out; } @@ -671,7 +698,7 @@ namespace etl } //************************************************************************* - accumulator_type final(accumulator_type crc) const + ETL_CONSTEXPR accumulator_type final(accumulator_type crc) const { return crc ^ TCrcParameters::Xor_Out; } @@ -691,7 +718,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - crc_type() + ETL_CONSTEXPR14 crc_type() { this->reset(); } @@ -702,7 +729,7 @@ namespace etl /// \param end End of the range. //************************************************************************* template - crc_type(TIterator begin, const TIterator end) + ETL_CONSTEXPR14 crc_type(TIterator begin, const TIterator end) { this->reset(); this->add(begin, end); diff --git a/test/test_crc16.cpp b/test/test_crc16.cpp index b1f2328d..d70b90c4 100644 --- a/test/test_crc16.cpp +++ b/test/test_crc16.cpp @@ -127,6 +127,17 @@ namespace CHECK_EQUAL(0xBB3DU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_t16(data, data + 9); + + CHECK_EQUAL(0xBB3DU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_16_add_values) { @@ -199,6 +210,17 @@ namespace CHECK_EQUAL(0xBB3DU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_t4(data, data + 9); + + CHECK_EQUAL(0xBB3DU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_4_add_values) { diff --git a/test/test_crc16_a.cpp b/test/test_crc16_a.cpp index fe922a2e..2367fefb 100644 --- a/test/test_crc16_a.cpp +++ b/test/test_crc16_a.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xBF05U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_a_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_a(data, data + 9); + + CHECK_EQUAL(0xBF05U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_a_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xBF05U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_a_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_a_t16(data, data + 9); + + CHECK_EQUAL(0xBF05U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_a_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xBF05U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_a_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_a_t4(data, data + 9); + + CHECK_EQUAL(0xBF05U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_a_4_add_values) { diff --git a/test/test_crc16_arc.cpp b/test/test_crc16_arc.cpp index 3e7768f7..eaf17dc1 100644 --- a/test/test_crc16_arc.cpp +++ b/test/test_crc16_arc.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xBB3DU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_arc_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_arc(data, data + 9); + + CHECK_EQUAL(0xBB3DU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_arc_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xBB3DU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_arc_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_arc_t16(data, data + 9); + + CHECK_EQUAL(0xBB3DU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_arc_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xBB3DU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_arc_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_arc_t4(data, data + 9); + + CHECK_EQUAL(0xBB3DU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_arc_4_add_values) { diff --git a/test/test_crc16_aug_ccitt.cpp b/test/test_crc16_aug_ccitt.cpp index 8f5a1612..a89bf787 100644 --- a/test/test_crc16_aug_ccitt.cpp +++ b/test/test_crc16_aug_ccitt.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xE5CCU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_aug_ccitt_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_aug_ccitt(data, data + 9); + + CHECK_EQUAL(0xE5CCU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_aug_ccitt_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xE5CCU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_aug_ccitt_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_aug_ccitt_t16(data, data + 9); + + CHECK_EQUAL(0xE5CCU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_aug_ccitt_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xE5CCU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_aug_ccitt_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_aug_ccitt_t4(data, data + 9); + + CHECK_EQUAL(0xE5CCU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_aug_ccitt_4_add_values) { diff --git a/test/test_crc16_buypass.cpp b/test/test_crc16_buypass.cpp index 9aa81364..9104ed2f 100644 --- a/test/test_crc16_buypass.cpp +++ b/test/test_crc16_buypass.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xFEE8U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_buypass_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_buypass(data, data + 9); + + CHECK_EQUAL(0xFEE8U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_buypass_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xFEE8U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_buypass_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_buypass_t16(data, data + 9); + + CHECK_EQUAL(0xFEE8U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_buypass_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xFEE8U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_buypass_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_buypass_t4(data, data + 9); + + CHECK_EQUAL(0xFEE8U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_buypass_4_add_values) { diff --git a/test/test_crc16_ccitt.cpp b/test/test_crc16_ccitt.cpp index e81dce28..78399252 100644 --- a/test/test_crc16_ccitt.cpp +++ b/test/test_crc16_ccitt.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x29B1U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_ccitt_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_ccitt(data, data + 9); + + CHECK_EQUAL(0x29B1U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_ccitt_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x29B1U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_ccitt_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_ccitt_t16(data, data + 9); + + CHECK_EQUAL(0x29B1U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_ccitt_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x29B1U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_ccitt_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_ccitt_t4(data, data + 9); + + CHECK_EQUAL(0x29B1U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_ccitt_4_add_values) { diff --git a/test/test_crc16_cdma2000.cpp b/test/test_crc16_cdma2000.cpp index 885a237a..18324f80 100644 --- a/test/test_crc16_cdma2000.cpp +++ b/test/test_crc16_cdma2000.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x4C06U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_cdma2000_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_cdma2000(data, data + 9); + + CHECK_EQUAL(0x4C06U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_cdma2000_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x4C06U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_cdma2000_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_cdma2000_t16(data, data + 9); + + CHECK_EQUAL(0x4C06U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_cdma2000_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x4C06U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_cdma2000_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_cdma2000_t4(data, data + 9); + + CHECK_EQUAL(0x4C06U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_cdma2000_4_add_values) { diff --git a/test/test_crc16_dds110.cpp b/test/test_crc16_dds110.cpp index 8bed8046..3eaee997 100644 --- a/test/test_crc16_dds110.cpp +++ b/test/test_crc16_dds110.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x9ECFU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dds110_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dds110(data, data + 9); + + CHECK_EQUAL(0x9ECFU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dds110_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x9ECFU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dds110_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dds110_t16(data, data + 9); + + CHECK_EQUAL(0x9ECFU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dds110_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x9ECFU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dds110_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dds110_t4(data, data + 9); + + CHECK_EQUAL(0x9ECFU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dds110_4_add_values) { diff --git a/test/test_crc16_dectr.cpp b/test/test_crc16_dectr.cpp index d99d9d61..1f5f1454 100644 --- a/test/test_crc16_dectr.cpp +++ b/test/test_crc16_dectr.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x007EU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dect_r_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dectr(data, data + 9); + + CHECK_EQUAL(0x007EU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dect_r_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x007EU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dect_r_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dect_r_t16(data, data + 9); + + CHECK_EQUAL(0x007EU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dect_r_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x007EU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dect_r_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dect_r_t4(data, data + 9); + + CHECK_EQUAL(0x007EU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dect_r_4_add_values) { diff --git a/test/test_crc16_dectx.cpp b/test/test_crc16_dectx.cpp index bf7db423..e5510a39 100644 --- a/test/test_crc16_dectx.cpp +++ b/test/test_crc16_dectx.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x007FU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dect_x_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dectx(data, data + 9); + + CHECK_EQUAL(0x007FU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dect_x_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x007FU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dect_x_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dect_x_t16(data, data + 9); + + CHECK_EQUAL(0x007FU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dect_x_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x007FU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dect_x_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dect_x_t4(data, data + 9); + + CHECK_EQUAL(0x007FU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dect_x_4_add_values) { diff --git a/test/test_crc16_dnp.cpp b/test/test_crc16_dnp.cpp index 82069d6a..e8245cc9 100644 --- a/test/test_crc16_dnp.cpp +++ b/test/test_crc16_dnp.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xEA82U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dnp_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dnp(data, data + 9); + + CHECK_EQUAL(0xEA82U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dnp_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xEA82U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dnp_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dnp_t16(data, data + 9); + + CHECK_EQUAL(0xEA82U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dnp_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xEA82U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_dnp_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_dnp_t4(data, data + 9); + + CHECK_EQUAL(0xEA82U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_dnp_4_add_values) { diff --git a/test/test_crc16_en13757.cpp b/test/test_crc16_en13757.cpp index f63df0d1..c4bf990b 100644 --- a/test/test_crc16_en13757.cpp +++ b/test/test_crc16_en13757.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xC2B7U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_en13757_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_en13757(data, data + 9); + + CHECK_EQUAL(0xC2B7U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_en13757_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xC2B7U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_en13757_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_en13757_t16(data, data + 9); + + CHECK_EQUAL(0xC2B7U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_en13757_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xC2B7U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_en13757_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_en13757_t4(data, data + 9); + + CHECK_EQUAL(0xC2B7U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_en13757_4_add_values) { diff --git a/test/test_crc16_genibus.cpp b/test/test_crc16_genibus.cpp index 3ab8f68b..fc8380dd 100644 --- a/test/test_crc16_genibus.cpp +++ b/test/test_crc16_genibus.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xD64EU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_genibus_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_genibus(data, data + 9); + + CHECK_EQUAL(0xD64EU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_genibus_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xD64EU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_genibus_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_genibus_t16(data, data + 9); + + CHECK_EQUAL(0xD64EU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_genibus_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xD64EU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_genibus_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_genibus_t4(data, data + 9); + + CHECK_EQUAL(0xD64EU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_genibus_4_add_values) { diff --git a/test/test_crc16_kermit.cpp b/test/test_crc16_kermit.cpp index 62769114..27dd89c8 100644 --- a/test/test_crc16_kermit.cpp +++ b/test/test_crc16_kermit.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x2189U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_kermit_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_kermit(data, data + 9); + + CHECK_EQUAL(0x2189U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_kermit_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x2189U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_kermit_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_kermit_t16(data, data + 9); + + CHECK_EQUAL(0x2189U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_kermit_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x2189U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_kermit_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_kermit_t4(data, data + 9); + + CHECK_EQUAL(0x2189U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_kermit_4_add_values) { diff --git a/test/test_crc16_m17.cpp b/test/test_crc16_m17.cpp index b28d624b..2af0155f 100644 --- a/test/test_crc16_m17.cpp +++ b/test/test_crc16_m17.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x772BU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_m17_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_m17(data, data + 9); + + CHECK_EQUAL(0x772BU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_m17_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x772BU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_m17_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_m17_t16(data, data + 9); + + CHECK_EQUAL(0x772BU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_m17_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x772BU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_m17_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_m17_t4(data, data + 9); + + CHECK_EQUAL(0x772BU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_m17_4_add_values) { diff --git a/test/test_crc16_maxim.cpp b/test/test_crc16_maxim.cpp index a2a92e40..df7e527c 100644 --- a/test/test_crc16_maxim.cpp +++ b/test/test_crc16_maxim.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x44C2U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_maxim_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_maxim(data, data + 9); + + CHECK_EQUAL(0x44C2U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_maxim_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x44C2U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_maxim_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_maxim_t16(data, data + 9); + + CHECK_EQUAL(0x44C2U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_maxim_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x44C2U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_maxim_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_maxim_t4(data, data + 9); + + CHECK_EQUAL(0x44C2U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_maxim_4_add_values) { diff --git a/test/test_crc16_mcrf4xx.cpp b/test/test_crc16_mcrf4xx.cpp index eed2f024..d645282e 100644 --- a/test/test_crc16_mcrf4xx.cpp +++ b/test/test_crc16_mcrf4xx.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x6F91U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_mcrf4xx_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_mcrf4xx(data, data + 9); + + CHECK_EQUAL(0x6F91U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_mcrf4xx_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x6F91U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_mcrf4xx_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_mcrf4xx_t16(data, data + 9); + + CHECK_EQUAL(0x6F91U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_mcrf4xx_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x6F91U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_mcrf4xx_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_mcrf4xx_t4(data, data + 9); + + CHECK_EQUAL(0x6F91U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_mcrf4xx_4_add_values) { diff --git a/test/test_crc16_modbus.cpp b/test/test_crc16_modbus.cpp index 6f5779f9..430773bb 100644 --- a/test/test_crc16_modbus.cpp +++ b/test/test_crc16_modbus.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x4B37U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_modbus_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_modbus(data, data + 9); + + CHECK_EQUAL(0x4B37U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_modbus_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x4B37U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_modbus_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_modbus_t16(data, data + 9); + + CHECK_EQUAL(0x4B37U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_modbus_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x4B37U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_modbus_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_modbus_t4(data, data + 9); + + CHECK_EQUAL(0x4B37U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_modbus_4_add_values) { diff --git a/test/test_crc16_profibus.cpp b/test/test_crc16_profibus.cpp index 35139534..dce88f22 100644 --- a/test/test_crc16_profibus.cpp +++ b/test/test_crc16_profibus.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xA819U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_profibus_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_profibus(data, data + 9); + + CHECK_EQUAL(0xA819U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_profibus_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xA819U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_profibus_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_profibus_t16(data, data + 9); + + CHECK_EQUAL(0xA819U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_profibus_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xA819U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_profibus_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_profibus_t4(data, data + 9); + + CHECK_EQUAL(0xA819U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_profibus_4_add_values) { diff --git a/test/test_crc16_riello.cpp b/test/test_crc16_riello.cpp index d54d0fab..b4aa86d3 100644 --- a/test/test_crc16_riello.cpp +++ b/test/test_crc16_riello.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x63D0U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_riello_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_riello(data, data + 9); + + CHECK_EQUAL(0x63D0U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_riello_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x63D0U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_riello_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_riello_t16(data, data + 9); + + CHECK_EQUAL(0x63D0U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_riello_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x63D0U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_riello_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_riello_t4(data, data + 9); + + CHECK_EQUAL(0x63D0U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_riello_4_add_values) { diff --git a/test/test_crc16_t10dif.cpp b/test/test_crc16_t10dif.cpp index 78e3107d..21568718 100644 --- a/test/test_crc16_t10dif.cpp +++ b/test/test_crc16_t10dif.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xD0DBU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_t10dif_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_t10dif(data, data + 9); + + CHECK_EQUAL(0xD0DBU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_t10dif_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xD0DBU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_t10dif_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_t10dif_t16(data, data + 9); + + CHECK_EQUAL(0xD0DBU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_t10dif_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xD0DBU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_t10dif_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_t10dif_t4(data, data + 9); + + CHECK_EQUAL(0xD0DBU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_t10dif_4_add_values) { diff --git a/test/test_crc16_teledisk.cpp b/test/test_crc16_teledisk.cpp index 063c725f..6ffa7a3d 100644 --- a/test/test_crc16_teledisk.cpp +++ b/test/test_crc16_teledisk.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x0FB3U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_teledisk_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_teledisk(data, data + 9); + + CHECK_EQUAL(0x0FB3U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_teledisk_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x0FB3U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_teledisk_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_teledisk_t16(data, data + 9); + + CHECK_EQUAL(0x0FB3U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_teledisk_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x0FB3U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_teledisk_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_teledisk_t4(data, data + 9); + + CHECK_EQUAL(0x0FB3U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_teledisk_4_add_values) { diff --git a/test/test_crc16_tms37157.cpp b/test/test_crc16_tms37157.cpp index 1fc0d3e6..4304d19c 100644 --- a/test/test_crc16_tms37157.cpp +++ b/test/test_crc16_tms37157.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x26B1U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_tms37157_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_tms37157(data, data + 9); + + CHECK_EQUAL(0x26B1U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_tms37157_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x26B1U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_tms37157_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_tms37157_t16(data, data + 9); + + CHECK_EQUAL(0x26B1U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_tms37157_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x26B1U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_tms37157_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_tms37157_t4(data, data + 9); + + CHECK_EQUAL(0x26B1U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_tms37157_4_add_values) { diff --git a/test/test_crc16_usb.cpp b/test/test_crc16_usb.cpp index 3f3d23b6..5479992e 100644 --- a/test/test_crc16_usb.cpp +++ b/test/test_crc16_usb.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xB4C8U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_usb_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_usb(data, data + 9); + + CHECK_EQUAL(0xB4C8U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_usb_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xB4C8U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_usb_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_usb_t16(data, data + 9); + + CHECK_EQUAL(0xB4C8U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_usb_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xB4C8U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_usb_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_usb_t4(data, data + 9); + + CHECK_EQUAL(0xB4C8U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_usb_4_add_values) { diff --git a/test/test_crc16_x25.cpp b/test/test_crc16_x25.cpp index 2906214a..77c7f7fb 100644 --- a/test/test_crc16_x25.cpp +++ b/test/test_crc16_x25.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x906EU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_x25_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_x25(data, data + 9); + + CHECK_EQUAL(0x906EU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_x25_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x906EU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_x25_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_x25_t16(data, data + 9); + + CHECK_EQUAL(0x906EU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_x25_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x906EU, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_x25_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_x25_t4(data, data + 9); + + CHECK_EQUAL(0x906EU, crc); + } +#endif + //************************************************************************* TEST(test_crc16_x25_4_add_values) { diff --git a/test/test_crc16_xmodem.cpp b/test/test_crc16_xmodem.cpp index e303ee24..e116126d 100644 --- a/test/test_crc16_xmodem.cpp +++ b/test/test_crc16_xmodem.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x31C3U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_xmodem_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_xmodem(data, data + 9); + + CHECK_EQUAL(0x31C3U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_xmodem_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x31C3U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_xmodem_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_xmodem_t16(data, data + 9); + + CHECK_EQUAL(0x31C3U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_xmodem_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x31C3U, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc16_xmodem_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint16_t crc = etl::crc16_xmodem_t4(data, data + 9); + + CHECK_EQUAL(0x31C3U, crc); + } +#endif + //************************************************************************* TEST(test_crc16_xmodem_4_add_values) { diff --git a/test/test_crc32.cpp b/test/test_crc32.cpp index bbc278e5..2cfa169f 100644 --- a/test/test_crc32.cpp +++ b/test/test_crc32.cpp @@ -127,6 +127,17 @@ namespace CHECK_EQUAL(0xCBF43926UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_t16(data, data + 9); + + CHECK_EQUAL(0xCBF43926UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_16_add_values) { @@ -199,6 +210,17 @@ namespace CHECK_EQUAL(0xCBF43926UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_t4(data, data + 9); + + CHECK_EQUAL(0xCBF43926UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_4_add_values) { diff --git a/test/test_crc32_bzip2.cpp b/test/test_crc32_bzip2.cpp index 76655dd0..857fe005 100644 --- a/test/test_crc32_bzip2.cpp +++ b/test/test_crc32_bzip2.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xFC891918UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_bzip2_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_bzip2(data, data + 9); + + CHECK_EQUAL(0xFC891918UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_bzip2_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xFC891918UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_bzip2_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_bzip2_t16(data, data + 9); + + CHECK_EQUAL(0xFC891918UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_bzip2_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xFC891918UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_bzip2_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_bzip2_t4(data, data + 9); + + CHECK_EQUAL(0xFC891918UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_bzip2_4_add_values) { diff --git a/test/test_crc32_c.cpp b/test/test_crc32_c.cpp index a0259eae..a6010343 100644 --- a/test/test_crc32_c.cpp +++ b/test/test_crc32_c.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xE3069283UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_c_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_c(data, data + 9); + + CHECK_EQUAL(0xE3069283UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_c_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xE3069283UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_c_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_c_t16(data, data + 9); + + CHECK_EQUAL(0xE3069283UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_c_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xE3069283UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_c_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_c_t4(data, data + 9); + + CHECK_EQUAL(0xE3069283UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_c_4_add_values) { diff --git a/test/test_crc32_d.cpp b/test/test_crc32_d.cpp index 8dc77f71..c6b33efb 100644 --- a/test/test_crc32_d.cpp +++ b/test/test_crc32_d.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x87315576UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_d_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_d(data, data + 9); + + CHECK_EQUAL(0x87315576UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_d_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x87315576UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_d_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_d_t16(data, data + 9); + + CHECK_EQUAL(0x87315576UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_d_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x87315576UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_d_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_d_t4(data, data + 9); + + CHECK_EQUAL(0x87315576UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_d_4_add_values) { diff --git a/test/test_crc32_jamcrc.cpp b/test/test_crc32_jamcrc.cpp index 167b55de..1bd48cb3 100644 --- a/test/test_crc32_jamcrc.cpp +++ b/test/test_crc32_jamcrc.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x340BC6D9UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_jamcrc_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_jamcrc(data, data + 9); + + CHECK_EQUAL(0x340BC6D9UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_jamcrc_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x340BC6D9UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_jamcrc_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_jamcrc_t16(data, data + 9); + + CHECK_EQUAL(0x340BC6D9UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_jamcrc_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x340BC6D9UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_jamcrc_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_jamcrc_t4(data, data + 9); + + CHECK_EQUAL(0x340BC6D9UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_jamcrc_4_add_values) { diff --git a/test/test_crc32_mpeg2.cpp b/test/test_crc32_mpeg2.cpp index d297c389..635a990f 100644 --- a/test/test_crc32_mpeg2.cpp +++ b/test/test_crc32_mpeg2.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x0376E6E7UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_mpeg2_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_mpeg2(data, data + 9); + + CHECK_EQUAL(0x0376E6E7UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_mpeg2_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x0376E6E7UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_mpeg2_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_mpeg2_t16(data, data + 9); + + CHECK_EQUAL(0x0376E6E7UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_mpeg2_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x0376E6E7UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_mpeg2_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_mpeg2_t4(data, data + 9); + + CHECK_EQUAL(0x0376E6E7UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_mpeg2_4_add_values) { diff --git a/test/test_crc32_posix.cpp b/test/test_crc32_posix.cpp index df132d5c..f01d2e4c 100644 --- a/test/test_crc32_posix.cpp +++ b/test/test_crc32_posix.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x765E7680UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_posix_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_posix(data, data + 9); + + CHECK_EQUAL(0x765E7680UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_posix_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x765E7680UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_posix_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_posix_t16(data, data + 9); + + CHECK_EQUAL(0x765E7680UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_posix_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x765E7680UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_posix_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_posix_t4(data, data + 9); + + CHECK_EQUAL(0x765E7680UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_posix_4_add_values) { diff --git a/test/test_crc32_q.cpp b/test/test_crc32_q.cpp index 0d2dc260..7404c51c 100644 --- a/test/test_crc32_q.cpp +++ b/test/test_crc32_q.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x3010BF7FUL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_q_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_q(data, data + 9); + + CHECK_EQUAL(0x3010BF7FUL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_q_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x3010BF7FUL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_q_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_q_t16(data, data + 9); + + CHECK_EQUAL(0x3010BF7FUL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_q_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x3010BF7FUL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_q_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_q_t4(data, data + 9); + + CHECK_EQUAL(0x3010BF7FUL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_q_4_add_values) { diff --git a/test/test_crc32_xfer.cpp b/test/test_crc32_xfer.cpp index 4c886bbc..96ed2ab4 100644 --- a/test/test_crc32_xfer.cpp +++ b/test/test_crc32_xfer.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xBD0BE338UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_xfer_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_xfer(data, data + 9); + + CHECK_EQUAL(0xBD0BE338UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_xfer_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xBD0BE338UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_xfer_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_xfer_t16(data, data + 9); + + CHECK_EQUAL(0xBD0BE338UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_xfer_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xBD0BE338UL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc32_xfer_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint32_t crc = etl::crc32_xfer_t4(data, data + 9); + + CHECK_EQUAL(0xBD0BE338UL, crc); + } +#endif + //************************************************************************* TEST(test_crc32_xfer_4_add_values) { diff --git a/test/test_crc64_ecma.cpp b/test/test_crc64_ecma.cpp index 1b32ce8f..54a8d8cb 100644 --- a/test/test_crc64_ecma.cpp +++ b/test/test_crc64_ecma.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x6C40DF5F0B497347ULL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc64_ecma_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint64_t crc = etl::crc64_ecma(data, data + 9); + + CHECK_EQUAL(0x6C40DF5F0B497347ULL, crc); + } +#endif + //************************************************************************* TEST(test_crc64_ecma_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x6C40DF5F0B497347ULL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc64_ecma_16_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint64_t crc = etl::crc64_ecma_t16(data, data + 9); + + CHECK_EQUAL(0x6C40DF5F0B497347ULL, crc); + } +#endif + //************************************************************************* TEST(test_crc64_ecma_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x6C40DF5F0B497347ULL, crc); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc64_ecma_4_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint64_t crc = etl::crc64_ecma_t4(data, data + 9); + + CHECK_EQUAL(0x6C40DF5F0B497347ULL, crc); + } +#endif + //************************************************************************* TEST(test_crc64_ecma_4_add_values) { diff --git a/test/test_crc8_ccitt.cpp b/test/test_crc8_ccitt.cpp index bb531a68..25cc048e 100644 --- a/test/test_crc8_ccitt.cpp +++ b/test/test_crc8_ccitt.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xF4U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_ccitt_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_ccitt_t4(data, data + 9); + + CHECK_EQUAL(0xF4U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_ccitt_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xF4U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_ccitt_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_ccitt_t16(data, data + 9); + + CHECK_EQUAL(0xF4U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_ccitt_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xF4U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_ccitt_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_ccitt(data, data + 9); + + CHECK_EQUAL(0xF4U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_ccitt_256_add_values) { diff --git a/test/test_crc8_cdma2000.cpp b/test/test_crc8_cdma2000.cpp index bf43d73e..df57b3a3 100644 --- a/test/test_crc8_cdma2000.cpp +++ b/test/test_crc8_cdma2000.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xDAU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_cdma2000_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_cdma2000_t4(data, data + 9); + + CHECK_EQUAL(0xDAU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_cdma2000_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xDAU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_cdma2000_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_cdma2000_t16(data, data + 9); + + CHECK_EQUAL(0xDAU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_cdma2000_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xDAU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_cdma2000_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_cdma2000(data, data + 9); + + CHECK_EQUAL(0xDAU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_cdma2000_256_add_values) { diff --git a/test/test_crc8_darc.cpp b/test/test_crc8_darc.cpp index 098ca4ce..d1fdb201 100644 --- a/test/test_crc8_darc.cpp +++ b/test/test_crc8_darc.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x15U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_darc_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_darc_t4(data, data + 9); + + CHECK_EQUAL(0x15U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_darc_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x15U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_darc_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_darc_t16(data, data + 9); + + CHECK_EQUAL(0x15U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_darc_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x15U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_darc_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_darc(data, data + 9); + + CHECK_EQUAL(0x15U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_darc_256_add_values) { diff --git a/test/test_crc8_dvbs2.cpp b/test/test_crc8_dvbs2.cpp index 54667146..0f5e2f91 100644 --- a/test/test_crc8_dvbs2.cpp +++ b/test/test_crc8_dvbs2.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xBCU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_dvbs2_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_dvbs2_t4(data, data + 9); + + CHECK_EQUAL(0xBCU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_dvbs2_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xBCU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_dvbs2_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_dvbs2_t16(data, data + 9); + + CHECK_EQUAL(0xBCU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_dvbs2_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xBCU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_dvbs2_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_dvbs2(data, data + 9); + + CHECK_EQUAL(0xBCU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_dvbs2_256_add_values) { diff --git a/test/test_crc8_ebu.cpp b/test/test_crc8_ebu.cpp index 0e378e93..9168cbda 100644 --- a/test/test_crc8_ebu.cpp +++ b/test/test_crc8_ebu.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x97U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_ebu_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_ebu_t4(data, data + 9); + + CHECK_EQUAL(0x97U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_ebu_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x97U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_ebu_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_ebu_t16(data, data + 9); + + CHECK_EQUAL(0x97U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_ebu_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x97U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_ebu_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_ebu(data, data + 9); + + CHECK_EQUAL(0x97U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_ebu_256_add_values) { diff --git a/test/test_crc8_icode.cpp b/test/test_crc8_icode.cpp index 32fd5468..bda00884 100644 --- a/test/test_crc8_icode.cpp +++ b/test/test_crc8_icode.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x7EU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_icode_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_icode_t4(data, data + 9); + + CHECK_EQUAL(0x7EU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_icode_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x7EU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_icode_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_icode_t16(data, data + 9); + + CHECK_EQUAL(0x7EU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_icode_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x7EU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_icode_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_icode(data, data + 9); + + CHECK_EQUAL(0x7EU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_icode_256_add_values) { diff --git a/test/test_crc8_itu.cpp b/test/test_crc8_itu.cpp index 6a14613f..b6cf0b28 100644 --- a/test/test_crc8_itu.cpp +++ b/test/test_crc8_itu.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xA1U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_itu_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_itu_t4(data, data + 9); + + CHECK_EQUAL(0xA1U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_itu_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xA1U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_itu_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_itu_t16(data, data + 9); + + CHECK_EQUAL(0xA1U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_itu_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xA1U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_itu_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_itu(data, data + 9); + + CHECK_EQUAL(0xA1U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_itu_256_add_values) { diff --git a/test/test_crc8_j1850.cpp b/test/test_crc8_j1850.cpp index 1b50b14a..24d67cc1 100644 --- a/test/test_crc8_j1850.cpp +++ b/test/test_crc8_j1850.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x4BU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_j1850_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_j1850_t4(data, data + 9); + + CHECK_EQUAL(0x4BU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_j1850_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x4BU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_j1850_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_j1850_t16(data, data + 9); + + CHECK_EQUAL(0x4BU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_j1850_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x4BU, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_j1850_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_j1850(data, data + 9); + + CHECK_EQUAL(0x4BU, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_j1850_256_add_values) { diff --git a/test/test_crc8_j1850_zero.cpp b/test/test_crc8_j1850_zero.cpp index 3ab0bae3..1d179a3b 100644 --- a/test/test_crc8_j1850_zero.cpp +++ b/test/test_crc8_j1850_zero.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x37U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_j1850_zero_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_j1850_zero_t4(data, data + 9); + + CHECK_EQUAL(0x37U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_j1850_zero_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x37U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_j1850_zero_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_j1850_zero_t16(data, data + 9); + + CHECK_EQUAL(0x37U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_j1850_zero_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x37U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_j1850_zero_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_j1850_zero(data, data + 9); + + CHECK_EQUAL(0x37U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_j1850_zero_256_add_values) { diff --git a/test/test_crc8_maxim.cpp b/test/test_crc8_maxim.cpp index 8c68d85c..b9b6775c 100644 --- a/test/test_crc8_maxim.cpp +++ b/test/test_crc8_maxim.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xA1U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_maxim_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_maxim_t4(data, data + 9); + + CHECK_EQUAL(0xA1U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_maxim_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xA1U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_maxim_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_maxim_t16(data, data + 9); + + CHECK_EQUAL(0xA1U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_maxim_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xA1U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_maxim_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_maxim(data, data + 9); + + CHECK_EQUAL(0xA1U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_maxim_256_add_values) { diff --git a/test/test_crc8_rohc.cpp b/test/test_crc8_rohc.cpp index 366474fc..f9dff526 100644 --- a/test/test_crc8_rohc.cpp +++ b/test/test_crc8_rohc.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0xD0U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_rohc_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_rohc_t4(data, data + 9); + + CHECK_EQUAL(0xD0U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_rohc_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0xD0U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_rohc_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_rohc_t16(data, data + 9); + + CHECK_EQUAL(0xD0U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_rohc_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0xD0U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_rohc_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_rohc(data, data + 9); + + CHECK_EQUAL(0xD0U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_rohc_256_add_values) { diff --git a/test/test_crc8_wcdma.cpp b/test/test_crc8_wcdma.cpp index 7dfc5215..8b3613a9 100644 --- a/test/test_crc8_wcdma.cpp +++ b/test/test_crc8_wcdma.cpp @@ -55,6 +55,17 @@ namespace CHECK_EQUAL(0x25U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_wcdma_4_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_wcdma_t4(data, data + 9); + + CHECK_EQUAL(0x25U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_wcdma_4_add_values) { @@ -127,6 +138,17 @@ namespace CHECK_EQUAL(0x25U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_wcdma_16_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_wcdma_t16(data, data + 9); + + CHECK_EQUAL(0x25U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_wcdma_16_add_values) { @@ -199,6 +221,17 @@ namespace CHECK_EQUAL(0x25U, int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc8_wcdma_256_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc8_wcdma(data, data + 9); + + CHECK_EQUAL(0x25U, int(crc)); + } +#endif + //************************************************************************* TEST(test_crc8_wcdma_256_add_values) {