Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

test_bits: add tests for BIT_U*()

Add some additional tests in lib/tests/test_bits.c to cover the
expected results of the fixed type BIT_U*() macros.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Yury Norov <yury.norov@gmail.com>

authored by

Vincent Mailhol and committed by
Yury Norov
e289b488 0405eef6

+10
+10
lib/tests/test_bits.c
··· 9 9 10 10 #define assert_type(t, x) _Generic(x, t: x, default: 0) 11 11 12 + static_assert(assert_type(u8, BIT_U8(0)) == 1u); 13 + static_assert(assert_type(u16, BIT_U16(0)) == 1u); 14 + static_assert(assert_type(u32, BIT_U32(0)) == 1u); 15 + static_assert(assert_type(u64, BIT_U64(0)) == 1ull); 16 + 17 + static_assert(assert_type(u8, BIT_U8(7)) == 0x80u); 18 + static_assert(assert_type(u16, BIT_U16(15)) == 0x8000u); 19 + static_assert(assert_type(u32, BIT_U32(31)) == 0x80000000u); 20 + static_assert(assert_type(u64, BIT_U64(63)) == 0x8000000000000000ull); 21 + 12 22 static_assert(assert_type(unsigned long, GENMASK(31, 0)) == U32_MAX); 13 23 static_assert(assert_type(unsigned long long, GENMASK_ULL(63, 0)) == U64_MAX); 14 24 static_assert(assert_type(u8, GENMASK_U8(7, 0)) == U8_MAX);