[PATCH] D83192: Fix off by one error in Bitfields

Guillaume Chatelet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 7 00:08:57 PDT 2020


gchatelet added a comment.

In D83192#2135019 <https://reviews.llvm.org/D83192#2135019>, @courbet wrote:

> Can you add a unit test for this ?


I'll add the following test as a separate commit if it LGTY.
Note: I can't use EXPECT_EQ because it takes the arguments by `const &` and the properties are `static constexpr`, the compiler complains about undefined reference.

  TEST(BitfieldsTest, Properties) {
    using A = Bitfield::Element<bool, 0, 1>;
    EXPECT_TRUE(A::FirstBit == 0U);
    EXPECT_TRUE(A::LastBit == 0U);
    EXPECT_TRUE(A::Shift == 0U);
    EXPECT_TRUE(A::Bits == 1U);
  
    using B = Bitfield::Element<unsigned, 3, 4>;
    EXPECT_TRUE(B::FirstBit == 3U);
    EXPECT_TRUE(B::LastBit == 6U);
    EXPECT_TRUE(B::Shift == 3U);
    EXPECT_TRUE(B::Bits == 4U);
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83192/new/

https://reviews.llvm.org/D83192





More information about the llvm-commits mailing list