]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add test for IN_SET() with bitfield specifier 25134/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 25 Oct 2022 18:32:05 +0000 (03:32 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 26 Oct 2022 21:37:01 +0000 (06:37 +0900)
src/test/test-macro.c

index 049ea2c14e1d3d39230df0a83f66528c6cf8302c..001166d0dcce4c9d5fcf6e703ed0e6ba49034d65 100644 (file)
@@ -209,6 +209,16 @@ TEST(in_set) {
         assert_se(IN_SET(4, 1, 2, 3, 4));
         assert_se(!IN_SET(0, 1));
         assert_se(!IN_SET(0, 1, 2, 3, 4));
+
+        struct {
+                unsigned x:3;
+        } t = { 1 };
+
+        assert_se(IN_SET(t.x, 1));
+        assert_se(IN_SET(t.x, 1, 2, 3, 4));
+        assert_se(IN_SET(t.x, 2, 3, 4, 1));
+        assert_se(!IN_SET(t.x, 0));
+        assert_se(!IN_SET(t.x, 2, 3, 4));
 }
 
 TEST(foreach_pointer) {