Work in progress

This commit is contained in:
John Wellbelove 2022-08-12 13:39:24 +01:00
parent c3bf642c32
commit 3ee5abf74b
16 changed files with 4597 additions and 1470 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -44,7 +44,8 @@ set(TEST_SOURCE_FILES
test_binary.cpp
test_bip_buffer_spsc_atomic.cpp
test_bit.cpp
test_bitset.cpp
test_bitset_legacy.cpp
test_bitset_new.cpp
test_bit_stream.cpp
test_bit_stream_reader_big_endian.cpp
test_bit_stream_reader_little_endian.cpp

View File

@ -75,6 +75,48 @@
}) \
UNITTEST_MULTILINE_MACRO_END
#define UNITTEST_CHECK_NOT_EQUAL(expected, actual) \
UNITTEST_MULTILINE_MACRO_BEGIN \
UNITTEST_IMPL_TRY \
({ \
UnitTest::CheckNotEqual(*UnitTest::CurrentTest::Results(), expected, actual, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \
UNITTEST_IMPL_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream UnitTest_message; \
UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_EQUAL(" #expected ", " #actual ")"; \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
UnitTest_message.GetText()); \
}) \
UNITTEST_IMPL_CATCH_ALL \
({ \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_EQUAL(" #expected ", " #actual ")"); \
}) \
UNITTEST_MULTILINE_MACRO_END
#define UNITTEST_CHECK_NOT_EQUAL_HEX(expected, actual) \
UNITTEST_MULTILINE_MACRO_BEGIN \
UNITTEST_IMPL_TRY \
({ \
UnitTest::CheckNotEqualHex(*UnitTest::CurrentTest::Results(), expected, actual, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \
UNITTEST_IMPL_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream UnitTest_message; \
UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_EQUAL(" #expected ", " #actual ")"; \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
UnitTest_message.GetText()); \
}) \
UNITTEST_IMPL_CATCH_ALL \
({ \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_EQUAL(" #expected ", " #actual ")"); \
}) \
UNITTEST_MULTILINE_MACRO_END
#define UNITTEST_CHECK_CLOSE(expected, actual, tolerance) \
UNITTEST_MULTILINE_MACRO_BEGIN \
UNITTEST_IMPL_TRY \
@ -173,10 +215,22 @@
#endif
#ifdef CHECK_EQUAL_HEX
#error CHECK_EQUAL_HEX already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_EQUAL instead
#error CHECK_EQUAL_HEX already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_EQUAL_HEX instead
#else
#define CHECK_EQUAL_HEX UNITTEST_CHECK_EQUAL_HEX
#endif
#endif
#ifdef CHECK_NOT_EQUAL
#error CHECK_NOT_EQUAL already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_NOT_EQUAL instead
#else
#define CHECK_NOT_EQUAL UNITTEST_CHECK_NOT_EQUAL
#endif
#ifdef CHECK_NOT_EQUAL_HEX
#error CHECK_NOT_EQUAL_HEX already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_NOT_EQUAL_HEX instead
#else
#define CHECK_NOT_EQUAL_HEX UNITTEST_CHECK_NOT_EQUAL_HEX
#endif
#ifdef CHECK_CLOSE
#error CHECK_CLOSE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_CLOSE instead

View File

@ -50,6 +50,30 @@ namespace UnitTest {
}
}
template< typename Expected, typename Actual >
void CheckNotEqual(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details)
{
if (expected == actual)
{
UnitTest::MemoryOutStream stream;
stream << "Expected not equal, but both values are" << actual;
results.OnTestFailure(details, stream.GetText());
}
}
template< typename Expected, typename Actual >
void CheckNotEqualHex(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details)
{
if (expected == actual)
{
UnitTest::MemoryOutStream stream;
stream << std::hex << std::uppercase << std::setfill('0') << std::setw(2 * sizeof(Actual)) << "Expected not equal, but both values are " << actual;
results.OnTestFailure(details, stream.GetText());
}
}
UNITTEST_LINKAGE void CheckEqual(TestResults& results, char const* expected, char const* actual, TestDetails const& details);
UNITTEST_LINKAGE void CheckEqual(TestResults& results, char* expected, char* actual, TestDetails const& details);

View File

@ -0,0 +1,29 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2022 Bo Rydberg, John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include <etl/private/bitset_legacy.h>

View File

@ -5,7 +5,7 @@ Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2021 Bo Rydberg
Copyright(c) 2022 Bo Rydberg, John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
@ -26,4 +26,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include <etl/bitset.h>
#include <etl/private/bitset_new.h>

View File

@ -55,7 +55,8 @@ target_sources(t98 PRIVATE etl_profile.h
../binary.h.t.cpp
../bip_buffer_spsc_atomic.h.t.cpp
../bit.h.t.cpp
../bitset.h.t.cpp
../bitset_legacy.h.t.cpp
../bitset_new.h.t.cpp
../bit_stream.h.t.cpp
../byte.h.t.cpp
../byte_stream.h.t.cpp

View File

@ -55,7 +55,8 @@ target_sources(t11 PRIVATE etl_profile.h
../binary.h.t.cpp
../bip_buffer_spsc_atomic.h.t.cpp
../bit.h.t.cpp
../bitset.h.t.cpp
../bitset_legacy.h.t.cpp
../bitset_new.h.t.cpp
../bit_stream.h.t.cpp
../byte.h.t.cpp
../byte_stream.h.t.cpp

View File

@ -55,7 +55,8 @@ target_sources(t14 PRIVATE etl_profile.h
../binary.h.t.cpp
../bip_buffer_spsc_atomic.h.t.cpp
../bit.h.t.cpp
../bitset.h.t.cpp
../bitset_legacy.h.t.cpp
../bitset_new.h.t.cpp
../bit_stream.h.t.cpp
../byte.h.t.cpp
../byte_stream.h.t.cpp

View File

@ -55,7 +55,8 @@ target_sources(t17 PRIVATE etl_profile.h
../binary.h.t.cpp
../bip_buffer_spsc_atomic.h.t.cpp
../bit.h.t.cpp
../bitset.h.t.cpp
../bitset_legacy.h.t.cpp
../bitset_new.h.t.cpp
../bit_stream.h.t.cpp
../byte.h.t.cpp
../byte_stream.h.t.cpp

View File

@ -32,11 +32,11 @@ SOFTWARE.
#include <type_traits>
#include <bitset>
#include "etl/bitset.h"
#include "etl/private/bitset_legacy.h"
namespace
{
SUITE(test_bitset)
SUITE(test_bitset_legacy)
{
//*************************************************************************
TEST(test_constructor)

1390
test/test_bitset_new.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2439,6 +2439,8 @@
<ClInclude Include="..\..\include\etl\crc8_wcdma.h" />
<ClInclude Include="..\..\include\etl\message_broker.h" />
<ClInclude Include="..\..\include\etl\poly_span.h" />
<ClInclude Include="..\..\include\etl\private\bitset_legacy.h" />
<ClInclude Include="..\..\include\etl\private\bitset_new.h" />
<ClInclude Include="..\..\include\etl\private\diagnostic_pessimizing-move_push.h" />
<ClInclude Include="..\..\include\etl\private\diagnostic_pop.h" />
<ClInclude Include="..\..\include\etl\private\diagnostic_self_assign_overloaded_push.h" />
@ -2602,7 +2604,6 @@
<ClInclude Include="..\..\include\etl\array.h" />
<ClInclude Include="..\..\include\etl\basic_string.h" />
<ClInclude Include="..\..\include\etl\binary.h" />
<ClInclude Include="..\..\include\etl\bitset.h" />
<ClInclude Include="..\..\include\etl\bloom_filter.h" />
<ClInclude Include="..\..\include\etl\char_traits.h" />
<ClInclude Include="..\..\include\etl\checksum.h" />
@ -3377,7 +3378,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force C++03|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\sanity-check\bitset.h.t.cpp">
<ClCompile Include="..\sanity-check\bitset_legacy.h.t.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Built-ins|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Constexpr Algorithms|Win32'">true</ExcludedFromBuild>
@ -3410,6 +3411,34 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - Appveyor|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\sanity-check\bitset_new.h.t.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Small Strings|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Tests|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - No STL|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - Appveyor|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - No STL - Appveyor|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Constexpr Algorithms|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM C++20|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No Unit Tests|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Built-ins|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - String Truncation Is Error|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Clang|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL - Force No Advanced|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force cpp03|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Intel - No STL|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Intel|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Checks|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force C++03|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\sanity-check\bit_stream.h.t.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Built-ins|Win32'">true</ExcludedFromBuild>
@ -11223,6 +11252,7 @@
<ClCompile Include="..\test_alignment.cpp" />
<ClCompile Include="..\test_atomic.cpp" />
<ClCompile Include="..\test_bit.cpp" />
<ClCompile Include="..\test_bitset_new.cpp" />
<ClCompile Include="..\test_bit_stream_reader_big_endian.cpp" />
<ClCompile Include="..\test_bit_stream_reader_little_endian.cpp" />
<ClCompile Include="..\test_bit_stream_writer_big_endian.cpp" />
@ -11330,7 +11360,7 @@
<ClCompile Include="..\test_array_wrapper.cpp" />
<ClCompile Include="..\test_binary.cpp" />
<ClCompile Include="..\test_bip_buffer_spsc_atomic.cpp" />
<ClCompile Include="..\test_bitset.cpp" />
<ClCompile Include="..\test_bitset_legacy.cpp" />
<ClCompile Include="..\test_bloom_filter.cpp" />
<ClCompile Include="..\test_bsd_checksum.cpp" />
<ClCompile Include="..\test_callback_timer.cpp" />

View File

@ -285,9 +285,6 @@
<ClInclude Include="..\..\include\etl\forward_list.h">
<Filter>ETL\Containers</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\bitset.h">
<Filter>ETL\Containers</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\smallest.h">
<Filter>ETL\Utilities</Filter>
</ClInclude>
@ -1326,6 +1323,12 @@
<ClInclude Include="..\..\include\etl\message_broker.h">
<Filter>ETL\Messaging</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\private\bitset_legacy.h">
<Filter>ETL\Private</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\private\bitset_new.h">
<Filter>ETL\Private</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\test_string_char.cpp">
@ -1883,7 +1886,7 @@
<ClCompile Include="..\test_bit.cpp">
<Filter>Tests\Binary</Filter>
</ClCompile>
<ClCompile Include="..\test_bitset.cpp">
<ClCompile Include="..\test_bitset_legacy.cpp">
<Filter>Tests\Binary</Filter>
</ClCompile>
<ClCompile Include="..\test_bit_stream.cpp">
@ -2288,7 +2291,7 @@
<ClCompile Include="..\sanity-check\bit_stream.h.t.cpp">
<Filter>Tests\Sanity Checks\Source</Filter>
</ClCompile>
<ClCompile Include="..\sanity-check\bitset.h.t.cpp">
<ClCompile Include="..\sanity-check\bitset_legacy.h.t.cpp">
<Filter>Tests\Sanity Checks\Source</Filter>
</ClCompile>
<ClCompile Include="..\sanity-check\bloom_filter.h.t.cpp">
@ -3338,6 +3341,12 @@
<ClCompile Include="..\test_char_traits.cpp">
<Filter>Tests\Misc</Filter>
</ClCompile>
<ClCompile Include="..\test_bitset_new.cpp">
<Filter>Tests\Binary</Filter>
</ClCompile>
<ClCompile Include="..\sanity-check\bitset_new.h.t.cpp">
<Filter>Tests\Sanity Checks\Source</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\library.properties">