@@ -1081,4 +1081,27 @@ ZTEST(util, test_util_memeq)
1081
1081
zassert_false (mem_area_matching_2 );
1082
1082
}
1083
1083
1084
+ static void test_single_bitmask_find_gap (uint32_t mask , size_t num_bits , size_t total_bits ,
1085
+ bool first_match , int exp_rv , int line )
1086
+ {
1087
+ int rv ;
1088
+
1089
+ rv = bitmask_find_gap (mask , num_bits , total_bits , first_match );
1090
+ zassert_equal (rv , exp_rv , "%d Unexpected rv:%d (exp:%d)" , line , rv , exp_rv );
1091
+ }
1092
+
1093
+ ZTEST (util , test_bitmask_find_gap )
1094
+ {
1095
+ test_single_bitmask_find_gap (0x0F0F070F , 6 , 32 , true, -1 , __LINE__ );
1096
+ test_single_bitmask_find_gap (0x0F0F070F , 5 , 32 , true, 11 , __LINE__ );
1097
+ test_single_bitmask_find_gap (0x030F070F , 5 , 32 , true, 26 , __LINE__ );
1098
+ test_single_bitmask_find_gap (0x030F070F , 5 , 32 , false, 11 , __LINE__ );
1099
+ test_single_bitmask_find_gap (0x0F0F070F , 5 , 32 , true, 11 , __LINE__ );
1100
+ test_single_bitmask_find_gap (0x030F070F , 5 , 32 , true, 26 , __LINE__ );
1101
+ test_single_bitmask_find_gap (0x030F070F , 5 , 32 , false, 11 , __LINE__ );
1102
+ test_single_bitmask_find_gap (0x0 , 1 , 32 , true, 0 , __LINE__ );
1103
+ test_single_bitmask_find_gap (0x1F1F071F , 4 , 32 , true, 11 , __LINE__ );
1104
+ test_single_bitmask_find_gap (0x0000000F , 2 , 6 , false, 4 , __LINE__ );
1105
+ }
1106
+
1084
1107
ZTEST_SUITE (util , NULL , NULL , NULL , NULL , NULL );
0 commit comments