From adeb90224188d633a8417adad1eb7716caf79b0b Mon Sep 17 00:00:00 2001 From: rolandreichweinbmw Date: Sat, 4 Jan 2025 14:33:05 +0100 Subject: [PATCH 1/7] Fix span fixed extent empty (#1007) --- include/etl/span.h | 2 +- test/test_span_fixed_extent.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/etl/span.h b/include/etl/span.h index f1077ea7..0cae5e08 100644 --- a/include/etl/span.h +++ b/include/etl/span.h @@ -238,7 +238,7 @@ namespace etl //************************************************************************* ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT { - return false; + return Extent == 0; } //************************************************************************* diff --git a/test/test_span_fixed_extent.cpp b/test/test_span_fixed_extent.cpp index 157170a0..5a067620 100644 --- a/test/test_span_fixed_extent.cpp +++ b/test/test_span_fixed_extent.cpp @@ -52,6 +52,7 @@ namespace typedef etl::span View; typedef etl::span SView; typedef etl::span CView; + typedef etl::span EView; #if ETL_USING_CPP20 using StdView = std::span; @@ -464,6 +465,9 @@ namespace { View view1(etldata.begin(), etldata.begin()); CHECK(!view1.empty()); + + EView view2(etldata.begin(), etldata.begin()); + CHECK(view2.empty()); } //************************************************************************* From de51170f8a4a15c74f4698e1f75a4eebcef79216 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 4 Jan 2025 13:51:58 +0000 Subject: [PATCH 2/7] Added build to ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8f313ddb..6d624695 100644 --- a/.gitignore +++ b/.gitignore @@ -388,3 +388,4 @@ support/time remaining test.xlsx test/vs2022/Debug MSVC C++20 - Force C++03 test/vs2022/Release MSVC C++20 - No STL - Optimised -O2 - Sanitiser test/test_file_list.txt +test/etl_error_handler/assert_function/build-make From 8f70a3c262fc7cb6ceb6042fac8b9cb7d49f5b6a Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 4 Jan 2025 14:18:45 +0000 Subject: [PATCH 3/7] Fixed include for C++20 & STL --- include/etl/unaligned_type.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/etl/unaligned_type.h b/include/etl/unaligned_type.h index d436229d..1d469c9a 100644 --- a/include/etl/unaligned_type.h +++ b/include/etl/unaligned_type.h @@ -45,7 +45,9 @@ SOFTWARE. #include "exception.h" #include "file_error_numbers.h" -#include +#if ETL_USING_CPP20 && ETL_USING_STL + #include +#endif #include From 599931f0bf30503691b4719a6eebca0d50623392 Mon Sep 17 00:00:00 2001 From: rolandreichweinbmw Date: Sat, 4 Jan 2025 15:31:35 +0100 Subject: [PATCH 4/7] Fixed memory.h: mem_copy, mem_move, mem_compare for pointers to const (#1005) --- include/etl/memory.h | 74 +++++++++++++++++----------------- test/test_memory.cpp | 96 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 37 deletions(-) diff --git a/include/etl/memory.h b/include/etl/memory.h index b285068b..14964b85 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -2264,13 +2264,13 @@ namespace etl /// \param destination begin /// \return A pointer to the destination. //*************************************************************************** - template - typename etl::enable_if::value_type>::value, TPointer>::type - mem_copy(const TPointer sb, const TPointer se, TPointer db) ETL_NOEXCEPT + template + typename etl::enable_if::value_type>::value, T*>::type + mem_copy(const T* sb, const T* se, T* db) ETL_NOEXCEPT { - return reinterpret_cast(memcpy(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(typename etl::iterator_traits::value_type) * static_cast(se - sb))); + return reinterpret_cast(memcpy(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(typename etl::iterator_traits::value_type) * static_cast(se - sb))); } //*************************************************************************** @@ -2280,13 +2280,13 @@ namespace etl /// \param source length /// \param destination begin //*************************************************************************** - template - typename etl::enable_if::value_type>::value, TPointer>::type - mem_copy(const TPointer sb, size_t n, TPointer db) ETL_NOEXCEPT + template + typename etl::enable_if::value_type>::value, T*>::type + mem_copy(const T* sb, size_t n, T* db) ETL_NOEXCEPT { - return reinterpret_cast(memcpy(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(typename etl::iterator_traits::value_type) * n)); + return reinterpret_cast(memcpy(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(typename etl::iterator_traits::value_type) * n)); } //*************************************************************************** @@ -2296,13 +2296,13 @@ namespace etl /// \param source end /// \param destination begin //*************************************************************************** - template - typename etl::enable_if::value_type>::value, TPointer>::type - mem_move(const TPointer sb, const TPointer se, TPointer db) ETL_NOEXCEPT + template + typename etl::enable_if::value_type>::value, T*>::type + mem_move(const T* sb, const T* se, T* db) ETL_NOEXCEPT { - return reinterpret_cast(memmove(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(typename etl::iterator_traits::value_type) * static_cast(se - sb))); + return reinterpret_cast(memmove(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(typename etl::iterator_traits::value_type) * static_cast(se - sb))); } //*************************************************************************** @@ -2312,13 +2312,13 @@ namespace etl /// \param source length /// \param destination begin //*************************************************************************** - template - typename etl::enable_if::value_type>::value, TPointer>::type - mem_move(const TPointer sb, size_t n, TPointer db) ETL_NOEXCEPT + template + typename etl::enable_if::value_type>::value, T*>::type + mem_move(const T* sb, size_t n, T* db) ETL_NOEXCEPT { - return reinterpret_cast(memmove(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(typename etl::iterator_traits::value_type) * n)); + return reinterpret_cast(memmove(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(typename etl::iterator_traits::value_type) * n)); } //*************************************************************************** @@ -2330,14 +2330,14 @@ namespace etl /// 0 The contents of both memory blocks are equal /// > 0 The first byte that does not match in both memory blocks has a greater value in 'sb' than in 'db' when evaluated as unsigned char values. //*************************************************************************** - template + template ETL_NODISCARD - typename etl::enable_if::value_type>::value, int>::type - mem_compare(const TPointer sb, const TPointer se, TPointer db) ETL_NOEXCEPT + typename etl::enable_if::value_type>::value, int>::type + mem_compare(const T* sb, const T* se, const T* db) ETL_NOEXCEPT { - return memcmp(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(typename etl::iterator_traits::value_type) * static_cast(se - sb)); + return memcmp(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(typename etl::iterator_traits::value_type) * static_cast(se - sb)); } //*************************************************************************** @@ -2349,14 +2349,14 @@ namespace etl /// 0 The contents of both memory blocks are equal /// > 0 The first byte that does not match in both memory blocks has a greater value in 'sb' than in 'db' when evaluated as unsigned char values. //*************************************************************************** - template + template ETL_NODISCARD - typename etl::enable_if::value_type>::value, int>::type - mem_compare(const TPointer sb, size_t n, TPointer db) ETL_NOEXCEPT + typename etl::enable_if::value_type>::value, int>::type + mem_compare(const T* sb, size_t n, const T* db) ETL_NOEXCEPT { - return memcmp(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(typename etl::iterator_traits::value_type) * n); + return memcmp(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(typename etl::iterator_traits::value_type) * n); } //*************************************************************************** @@ -2384,7 +2384,7 @@ namespace etl //*************************************************************************** template typename etl::enable_if::value_type>::value, TPointer>::type - mem_set(const TPointer db, size_t n, T value) ETL_NOEXCEPT + mem_set(TPointer db, size_t n, T value) ETL_NOEXCEPT { return reinterpret_cast(memset(reinterpret_cast(db), static_cast(value), diff --git a/test/test_memory.cpp b/test/test_memory.cpp index 9838094d..13cd14e6 100644 --- a/test/test_memory.cpp +++ b/test/test_memory.cpp @@ -1180,6 +1180,17 @@ namespace CHECK(std::equal(src, src + 8, dst)); } + //************************************************************************* + TEST(test_mem_copy_const_pointer_const_pointer_pointer) + { + const uint32_t src[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t dst[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + etl::mem_copy(src, src + 8, dst); + + CHECK(std::equal(src, src + 8, dst)); + } + //************************************************************************* TEST(test_mem_copy_pointer_length_pointer) { @@ -1187,7 +1198,16 @@ namespace uint32_t dst[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; etl::mem_copy(src, 8, dst); + CHECK(std::equal(src, src + 8, dst)); + } + //************************************************************************* + TEST(test_mem_copy_const_pointer_length_pointer) + { + const uint32_t src[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t dst[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + etl::mem_copy(src, 8, dst); CHECK(std::equal(src, src + 8, dst)); } @@ -1202,6 +1222,19 @@ namespace CHECK(std::equal(expected, expected + 8, data + 4)); } + //************************************************************************* + TEST(test_mem_move_const_pointer_const_pointer_pointer) + { + uint32_t expected[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t data[12] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201, 0, 0, 0, 0 }; + const uint32_t* data_begin = &data[0]; + const uint32_t* data_end = &data[8]; + + etl::mem_move(data_begin, data_end, data + 4); + + CHECK(std::equal(expected, expected + 8, data + 4)); + } + //************************************************************************* TEST(test_mem_move_pointer_length_pointer) { @@ -1213,6 +1246,17 @@ namespace CHECK(std::equal(expected, expected + 8, data + 4)); } + //************************************************************************* + TEST(test_mem_move_const_pointer_length_pointer) + { + uint32_t expected[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t data[12] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201, 0, 0, 0, 0 }; + const uint32_t* data_begin = &data[0]; + etl::mem_move(data_begin, 8, data + 4); + + CHECK(std::equal(expected, expected + 8, data + 4)); + } + //************************************************************************* TEST(test_mem_compare_pointer_pointer_pointer) { @@ -1226,6 +1270,32 @@ namespace CHECK(etl::mem_compare(data, data + 8, less) < 0); } + //************************************************************************* + TEST(test_mem_compare_const_pointer_const_pointer_pointer) + { + const uint32_t data[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t same[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t grtr[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67235501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t less[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67134501, 0x45016723, 0x01324576, 0x76453201 }; + + CHECK(etl::mem_compare(data, data + 8, same) == 0); + CHECK(etl::mem_compare(data, data + 8, grtr) > 0); + CHECK(etl::mem_compare(data, data + 8, less) < 0); + } + + //************************************************************************* + TEST(test_mem_compare_const_pointer_const_pointer_const_pointer) + { + const uint32_t data[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + const uint32_t same[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t grtr[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67235501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t less[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67134501, 0x45016723, 0x01324576, 0x76453201 }; + + CHECK(etl::mem_compare(data, data + 8, same) == 0); + CHECK(etl::mem_compare(data, data + 8, grtr) > 0); + CHECK(etl::mem_compare(data, data + 8, less) < 0); + } + //************************************************************************* TEST(test_mem_compare_pointer_length_pointer) { @@ -1239,6 +1309,32 @@ namespace CHECK(etl::mem_compare(data, 8, less) < 0); } + //************************************************************************* + TEST(test_mem_compare_const_pointer_length_pointer) + { + const uint32_t data[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t same[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t grtr[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67235501, 0x45016723, 0x01324576, 0x76453201 }; + uint32_t less[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67134501, 0x45016723, 0x01324576, 0x76453201 }; + + CHECK(etl::mem_compare(data, 8, same) == 0); + CHECK(etl::mem_compare(data, 8, grtr) > 0); + CHECK(etl::mem_compare(data, 8, less) < 0); + } + + //************************************************************************* + TEST(test_mem_compare_const_pointer_length_const_pointer) + { + const uint32_t data[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + const uint32_t same[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67234501, 0x45016723, 0x01324576, 0x76453201 }; + const uint32_t grtr[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67235501, 0x45016723, 0x01324576, 0x76453201 }; + const uint32_t less[8] = { 0x12345678, 0x76543210, 0x01452367, 0x23670145, 0x67134501, 0x45016723, 0x01324576, 0x76453201 }; + + CHECK(etl::mem_compare(data, 8, same) == 0); + CHECK(etl::mem_compare(data, 8, grtr) > 0); + CHECK(etl::mem_compare(data, 8, less) < 0); + } + //************************************************************************* TEST(test_mem_set_pointer_pointer) { From f8cdf432da65fdd8da4abaf8b6bcc2171a30666e Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 4 Jan 2025 14:34:10 +0000 Subject: [PATCH 5/7] Added build files to ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8f313ddb..6d624695 100644 --- a/.gitignore +++ b/.gitignore @@ -388,3 +388,4 @@ support/time remaining test.xlsx test/vs2022/Debug MSVC C++20 - Force C++03 test/vs2022/Release MSVC C++20 - No STL - Optimised -O2 - Sanitiser test/test_file_list.txt +test/etl_error_handler/assert_function/build-make From 7e2aeb9a0acd05b94b9c4ac1614ca7a03d537c4a Mon Sep 17 00:00:00 2001 From: rolandreichweinbmw Date: Sun, 5 Jan 2025 12:42:09 +0100 Subject: [PATCH 6/7] Fix arm64 signed char (#1006) --- test/test_bit_stream.cpp | 10 +++++----- test/test_bit_stream_reader_big_endian.cpp | 8 ++++---- test/test_bit_stream_reader_little_endian.cpp | 2 +- test/test_bresenham_line.cpp | 2 +- test/test_correlation.cpp | 20 +++++++++---------- test/test_covariance.cpp | 20 +++++++++---------- test/test_rms.cpp | 4 ++-- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/test/test_bit_stream.cpp b/test/test_bit_stream.cpp index c0cbd251..9aee68a9 100644 --- a/test/test_bit_stream.cpp +++ b/test/test_bit_stream.cpp @@ -930,8 +930,8 @@ namespace //************************************************************************* TEST(put_get_multiple_variable_size) { - char c1 = 26; // 6 bits - char c2 = -10; // 7 bits + signed char c1 = 26; // 6 bits + signed char c2 = -10; // 7 bits unsigned short s1 = 6742; // 13 bits unsigned short s2 = 1878; // 11 bits int32_t i1 = 2448037L; // 23 bits @@ -983,8 +983,8 @@ namespace bit_stream.restart(); - char rc1 = 0; - char rc2 = 0; + signed char rc1 = 0; + signed char rc2 = 0; unsigned short rs1 = 0; unsigned short rs2 = 0; int32_t ri1 = 0; @@ -1075,4 +1075,4 @@ namespace }; } -#include "etl/private/diagnostic_pop.h" \ No newline at end of file +#include "etl/private/diagnostic_pop.h" diff --git a/test/test_bit_stream_reader_big_endian.cpp b/test/test_bit_stream_reader_big_endian.cpp index 4cdf3d29..c4ae014c 100644 --- a/test/test_bit_stream_reader_big_endian.cpp +++ b/test/test_bit_stream_reader_big_endian.cpp @@ -210,7 +210,7 @@ namespace TEST(test_read_int8_t) { std::array storage = { char(0x01), char(0x5A), char(0xA5), char(0xFF) }; - std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::big); @@ -246,7 +246,7 @@ namespace TEST(test_read_checked_int8_t_using_non_member_function) { std::array storage = { char(0x01), char(0x5A), char(0xA5), char(0xFF) }; - std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::big); @@ -282,7 +282,7 @@ namespace TEST(test_read_unchecked_int8_t_using_non_member_function) { std::array storage = { char(0x01), char(0x5A), char(0xA5), char(0xFF) }; - std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::big); @@ -307,7 +307,7 @@ namespace TEST(test_read_int8_t_5bits) { std::array storage = { char(0x0E), char(0x8B), char(0xF0) }; - std::array expected = { int8_t(0x01), int8_t(0xFA), int8_t(0x05), int8_t(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0xFA), int8_t(0x05), int8_t(0xFF) }; etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::big); diff --git a/test/test_bit_stream_reader_little_endian.cpp b/test/test_bit_stream_reader_little_endian.cpp index 22c724ff..8684508c 100644 --- a/test/test_bit_stream_reader_little_endian.cpp +++ b/test/test_bit_stream_reader_little_endian.cpp @@ -215,7 +215,7 @@ namespace TEST(test_read_int8_t) { std::array storage = { char(0x80), char(0x5A), char(0xA5), char(0xFF) }; - std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little); diff --git a/test/test_bresenham_line.cpp b/test/test_bresenham_line.cpp index 96f5e231..eeb85239 100644 --- a/test/test_bresenham_line.cpp +++ b/test/test_bresenham_line.cpp @@ -44,7 +44,7 @@ namespace etl namespace { - using Value = char; + using Value = signed char; using Point = etl::coordinate_2d; diff --git a/test/test_correlation.cpp b/test/test_correlation.cpp index 82f2d032..72381c77 100644 --- a/test/test_correlation.cpp +++ b/test/test_correlation.cpp @@ -34,17 +34,17 @@ SOFTWARE. namespace { - std::array input_c + std::array input_c { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - std::array input_c_flat + std::array input_c_flat { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - std::array input_c_inv + std::array input_c_inv { 0, -1, -2, -3, -4, -5, -6, -7, -8, -9 }; @@ -86,7 +86,7 @@ namespace //************************************************************************* TEST(test_char_correlation_default_constructor) { - etl::correlation correlation; + etl::correlation correlation; double correlation_result = correlation; @@ -120,21 +120,21 @@ namespace double covariance_result; // Negative correlation. - etl::correlation correlation1(input_c.begin(), input_c.end(), input_c_inv.begin()); + etl::correlation correlation1(input_c.begin(), input_c.end(), input_c_inv.begin()); correlation_result = correlation1; CHECK_CLOSE(-1.0, correlation_result, 0.1); covariance_result = correlation1.get_covariance(); CHECK_CLOSE(-8.25, covariance_result, 0.1); // Zero correlation - etl::correlation correlation2(input_c.begin(), input_c.end(), input_c_flat.begin()); + etl::correlation correlation2(input_c.begin(), input_c.end(), input_c_flat.begin()); correlation_result = correlation2; CHECK_CLOSE(0.0, correlation_result, 0.1); covariance_result = correlation2.get_covariance(); CHECK_CLOSE(0.0, covariance_result, 0.1); // Positive correlation. - etl::correlation correlation3(input_c.begin(), input_c.end(), input_c.begin()); + etl::correlation correlation3(input_c.begin(), input_c.end(), input_c.begin()); correlation_result = correlation3; CHECK_CLOSE(1.0, correlation_result, 0.1); covariance_result = correlation3.get_covariance(); @@ -148,21 +148,21 @@ namespace double covariance_result; // Negative correlation. - etl::correlation correlation1(input_c.begin(), input_c.end(), input_c_inv.begin()); + etl::correlation correlation1(input_c.begin(), input_c.end(), input_c_inv.begin()); correlation_result = correlation1; CHECK_CLOSE(-1.0, correlation_result, 0.1); covariance_result = correlation1.get_covariance(); CHECK_CLOSE(-9.17, covariance_result, 0.1); // Zero correlation - etl::correlation correlation2(input_c.begin(), input_c.end(), input_c_flat.begin()); + etl::correlation correlation2(input_c.begin(), input_c.end(), input_c_flat.begin()); correlation_result = correlation2; CHECK_CLOSE(0.0, correlation_result, 0.1); covariance_result = correlation2.get_covariance(); CHECK_CLOSE(0.0, covariance_result, 0.1); // Positive correlation. - etl::correlation correlation3(input_c.begin(), input_c.end(), input_c.begin()); + etl::correlation correlation3(input_c.begin(), input_c.end(), input_c.begin()); correlation_result = correlation3; CHECK_CLOSE(1.0, correlation_result, 0.1); covariance_result = correlation3.get_covariance(); diff --git a/test/test_covariance.cpp b/test/test_covariance.cpp index a127616c..a3b67a9d 100644 --- a/test/test_covariance.cpp +++ b/test/test_covariance.cpp @@ -34,17 +34,17 @@ SOFTWARE. namespace { - std::array input_c + std::array input_c { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - std::array input_c_flat + std::array input_c_flat { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - std::array input_c_inv + std::array input_c_inv { 0, -1, -2, -3, -4, -5, -6, -7, -8, -9 }; @@ -86,7 +86,7 @@ namespace //************************************************************************* TEST(test_char_covariance_default_constructor) { - etl::covariance covariance; + etl::covariance covariance; double covariance_result = covariance; @@ -119,17 +119,17 @@ namespace double covariance_result; // Negative covariance. - etl::covariance covariance1(input_c.begin(), input_c.end(), input_c_inv.begin()); + etl::covariance covariance1(input_c.begin(), input_c.end(), input_c_inv.begin()); covariance_result = covariance1.get_covariance(); CHECK_CLOSE(-8.25, covariance_result, 0.1); // Zero covariance - etl::covariance covariance2(input_c.begin(), input_c.end(), input_c_flat.begin()); + etl::covariance covariance2(input_c.begin(), input_c.end(), input_c_flat.begin()); covariance_result = covariance2.get_covariance(); CHECK_CLOSE(0.0, covariance_result, 0.1); // Positive covariance. - etl::covariance covariance3(input_c.begin(), input_c.end(), input_c.begin()); + etl::covariance covariance3(input_c.begin(), input_c.end(), input_c.begin()); covariance_result = covariance3.get_covariance(); CHECK_CLOSE(8.25, covariance_result, 0.1); } @@ -140,17 +140,17 @@ namespace double covariance_result; // Negative covariance. - etl::covariance covariance1(input_c.begin(), input_c.end(), input_c_inv.begin()); + etl::covariance covariance1(input_c.begin(), input_c.end(), input_c_inv.begin()); covariance_result = covariance1.get_covariance(); CHECK_CLOSE(-9.17, covariance_result, 0.1); // Zero covariance - etl::covariance covariance2(input_c.begin(), input_c.end(), input_c_flat.begin()); + etl::covariance covariance2(input_c.begin(), input_c.end(), input_c_flat.begin()); covariance_result = covariance2.get_covariance(); CHECK_CLOSE(0.0, covariance_result, 0.1); // Positive covariance. - etl::covariance covariance3(input_c.begin(), input_c.end(), input_c.begin()); + etl::covariance covariance3(input_c.begin(), input_c.end(), input_c.begin()); covariance_result = covariance3.get_covariance(); CHECK_CLOSE(9.17, covariance_result, 0.1); } diff --git a/test/test_rms.cpp b/test/test_rms.cpp index cbc19884..0079819f 100644 --- a/test/test_rms.cpp +++ b/test/test_rms.cpp @@ -34,7 +34,7 @@ SOFTWARE. namespace { - std::array input_c + std::array input_c { // Sawtooth wave 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -8, -7, -6, -5, -4, -3, -2, -1 @@ -52,7 +52,7 @@ namespace //************************************************************************* TEST(test_char_rms) { - etl::rms rms(input_c.begin(), input_c.end()); + etl::rms rms(input_c.begin(), input_c.end()); double result = rms.get_rms(); CHECK_CLOSE(5.21, result, 0.05); From ef6f8781ecf6befd40f091f78010604282650b61 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 5 Jan 2025 13:48:36 +0000 Subject: [PATCH 7/7] Reverted std::array storage = { char(0x01), char(0x5A), char(0xA5), char(0xFF) }; - std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::big); @@ -246,7 +246,7 @@ namespace TEST(test_read_checked_int8_t_using_non_member_function) { std::array storage = { char(0x01), char(0x5A), char(0xA5), char(0xFF) }; - std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::big); @@ -282,7 +282,7 @@ namespace TEST(test_read_unchecked_int8_t_using_non_member_function) { std::array storage = { char(0x01), char(0x5A), char(0xA5), char(0xFF) }; - std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::big); @@ -307,7 +307,7 @@ namespace TEST(test_read_int8_t_5bits) { std::array storage = { char(0x0E), char(0x8B), char(0xF0) }; - std::array expected = { int8_t(0x01), int8_t(0xFA), int8_t(0x05), int8_t(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0xFA), int8_t(0x05), int8_t(0xFF) }; etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::big); diff --git a/test/test_bit_stream_reader_little_endian.cpp b/test/test_bit_stream_reader_little_endian.cpp index 8684508c..fcf91b22 100644 --- a/test/test_bit_stream_reader_little_endian.cpp +++ b/test/test_bit_stream_reader_little_endian.cpp @@ -215,7 +215,7 @@ namespace TEST(test_read_int8_t) { std::array storage = { char(0x80), char(0x5A), char(0xA5), char(0xFF) }; - std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; + std::array expected = { int8_t(0x01), int8_t(0x5A), int8_t(0xA5), int8_t(0xFF) }; etl::bit_stream_reader bit_stream(storage.data(), storage.size(), etl::endian::little);