diff --git a/include/etl/bitset.h b/include/etl/bitset.h index 9d59243d..b5a28d5a 100644 --- a/include/etl/bitset.h +++ b/include/etl/bitset.h @@ -589,7 +589,7 @@ namespace etl // Needs checking? if ((state && (value != ALL_CLEAR)) || - (!state && (value != ALL_SET))) + (!state && (value != ALL_SET))) { // For each bit in the element... while ((bit < BITS_PER_ELEMENT) && (position < NBITS)) @@ -608,7 +608,7 @@ namespace etl } else { - position += BITS_PER_ELEMENT; + position += BITS_PER_ELEMENT - bit; } // Start at the beginning for all other elements. diff --git a/test/test_bitset.cpp b/test/test_bitset.cpp index ab961254..aad8331c 100644 --- a/test/test_bitset.cpp +++ b/test/test_bitset.cpp @@ -1012,6 +1012,24 @@ namespace CHECK_EQUAL(4U, data.find_next(true, 1)); } + //************************************************************************* + TEST(test_find_next_github_issue_336) + { + etl::bitset<16> bits16; + bits16.set(12); + + etl::bitset<24> bits24; + bits24.set(12); + + CHECK_EQUAL(12, bits16.find_first(true)); + CHECK_EQUAL(12, bits16.find_next(true, 4)); + CHECK_EQUAL(16, bits16.find_next(true, 13)); + + CHECK_EQUAL(12, bits24.find_first(true)); + CHECK_EQUAL(12, bits24.find_next(true, 4)); + CHECK_EQUAL(24, bits16.find_next(true, 13)); + } + //************************************************************************* TEST(test_swap) { diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index 73098722..9fd73520 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -456,6 +456,22 @@ namespace CHECK((etl::is_same::type, std::make_signed::type>::value)); CHECK((etl::is_same::type, std::make_signed::type>::value)); CHECK((etl::is_same::type, std::make_signed::type>::value)); + + enum class ue : uint8_t + { + One, + Two + }; + + CHECK((etl::is_same::type, std::make_signed::type>::value)); + + enum class se : int8_t + { + One, + Two + }; + + CHECK((etl::is_same::type, std::make_signed::type>::value)); } //************************************************************************* @@ -482,6 +498,22 @@ namespace CHECK((etl::is_same::type, std::make_unsigned::type>::value)); CHECK((etl::is_same::type, std::make_unsigned::type>::value)); CHECK((etl::is_same::type, std::make_unsigned::type>::value)); + + enum class ue : uint8_t + { + One, + Two + }; + + CHECK((etl::is_same::type, std::make_unsigned::type>::value)); + + enum class se : int8_t + { + One, + Two + }; + + CHECK((etl::is_same::type, std::make_unsigned::type>::value)); } //*************************************************************************