@@ -554,23 +554,41 @@ static void meta_probability(void **state)
554554 assert_ok (bf_matcher_new_from_raw (& matcher , BF_MATCHER_META_PROBABILITY ,
555555 BF_MATCHER_EQ , "0%" ));
556556 assert_non_null (matcher );
557- assert_int_equal (* (uint8_t * )bf_matcher_payload (matcher ), 0 );
557+ assert_true (* (float * )bf_matcher_payload (matcher ) == 0.0f );
558558 bf_matcher_dump (matcher , & prefix );
559559 bf_matcher_free (& matcher );
560560
561561 // Test with 50%
562562 assert_ok (bf_matcher_new_from_raw (& matcher , BF_MATCHER_META_PROBABILITY ,
563563 BF_MATCHER_EQ , "50%" ));
564564 assert_non_null (matcher );
565- assert_int_equal (* (uint8_t * )bf_matcher_payload (matcher ), 50 );
565+ assert_true (* (float * )bf_matcher_payload (matcher ) == 50.0f );
566566 bf_matcher_dump (matcher , & prefix );
567567 bf_matcher_free (& matcher );
568568
569569 // Test with 100%
570570 assert_ok (bf_matcher_new_from_raw (& matcher , BF_MATCHER_META_PROBABILITY ,
571571 BF_MATCHER_EQ , "100%" ));
572572 assert_non_null (matcher );
573- assert_int_equal (* (uint8_t * )bf_matcher_payload (matcher ), 100 );
573+ assert_true (* (float * )bf_matcher_payload (matcher ) == 100.0f );
574+ bf_matcher_dump (matcher , & prefix );
575+ bf_matcher_free (& matcher );
576+
577+ // Test with floating-point value
578+ assert_ok (bf_matcher_new_from_raw (& matcher , BF_MATCHER_META_PROBABILITY ,
579+ BF_MATCHER_EQ , "33.33%" ));
580+ assert_non_null (matcher );
581+ assert_true (* (float * )bf_matcher_payload (matcher ) > 33.32f );
582+ assert_true (* (float * )bf_matcher_payload (matcher ) < 33.34f );
583+ bf_matcher_dump (matcher , & prefix );
584+ bf_matcher_free (& matcher );
585+
586+ // Test with small floating-point value
587+ assert_ok (bf_matcher_new_from_raw (& matcher , BF_MATCHER_META_PROBABILITY ,
588+ BF_MATCHER_EQ , "0.1%" ));
589+ assert_non_null (matcher );
590+ assert_true (* (float * )bf_matcher_payload (matcher ) > 0.09f );
591+ assert_true (* (float * )bf_matcher_payload (matcher ) < 0.11f );
574592 bf_matcher_dump (matcher , & prefix );
575593}
576594
@@ -584,6 +602,10 @@ static void meta_probability_invalid(void **state)
584602 assert_err (bf_matcher_new_from_raw (& matcher , BF_MATCHER_META_PROBABILITY ,
585603 BF_MATCHER_EQ , "101%" ));
586604
605+ // Test with value slightly over 100%
606+ assert_err (bf_matcher_new_from_raw (& matcher , BF_MATCHER_META_PROBABILITY ,
607+ BF_MATCHER_EQ , "100.01%" ));
608+
587609 // Test without % sign
588610 assert_err (bf_matcher_new_from_raw (& matcher , BF_MATCHER_META_PROBABILITY ,
589611 BF_MATCHER_EQ , "50" ));
0 commit comments