@@ -537,6 +537,8 @@ impl PartialEq for MatchingRule {
537537 ( MatchingRule :: Include ( str1) , MatchingRule :: Include ( str2) ) => str1 == str2,
538538 ( MatchingRule :: ContentType ( str1) , MatchingRule :: ContentType ( str2) ) => str1 == str2,
539539 ( MatchingRule :: ArrayContains ( variants1) , MatchingRule :: ArrayContains ( variants2) ) => variants1 == variants2,
540+ ( MatchingRule :: EachKey ( definition1) , MatchingRule :: EachKey ( definition2) ) => definition1 == definition2,
541+ ( MatchingRule :: EachValue ( definition1) , MatchingRule :: EachValue ( definition2) ) => definition1 == definition2,
540542 _ => mem:: discriminant ( self ) == mem:: discriminant ( other)
541543 }
542544 }
@@ -2158,7 +2160,7 @@ mod tests {
21582160 ]
21592161 } ) ;
21602162 expect ! ( MatchingRule :: from_json( & json) ) . to ( be_ok ( ) . value (
2161- MatchingRule :: EachValue ( MatchingRuleDefinition :: new ( "{\" price\" : 1.23}" . to_string ( ) ,
2163+ MatchingRule :: EachValue ( MatchingRuleDefinition :: new ( "{\" price\" :1.23}" . to_string ( ) ,
21622164 ValueType :: Unknown , MatchingRule :: Decimal , None ) ) )
21632165 ) ;
21642166 }
@@ -2633,4 +2635,22 @@ mod tests {
26332635 }
26342636 )
26352637 }
2638+
2639+ #[ test]
2640+ #[ should_panic]
2641+ fn each_value_matching_rule_comparation_test ( ) {
2642+ assert_eq ! (
2643+ matchingrules_list!{ "body" ; "$.array_values" => [ MatchingRule :: EachValue ( MatchingRuleDefinition :: new( "[\" string value\" ]" . to_string( ) , ValueType :: Unknown , MatchingRule :: Type , None ) ) ] } ,
2644+ matchingrules_list!{ "body" ; "$.array_values" => [ MatchingRule :: EachValue ( MatchingRuleDefinition :: new( "[\" something else\" ]" . to_string( ) , ValueType :: Unknown , MatchingRule :: Type , None ) ) ] }
2645+ )
2646+ }
2647+
2648+ #[ test]
2649+ #[ should_panic]
2650+ fn each_key_matching_rule_comparation_test ( ) {
2651+ assert_eq ! (
2652+ matchingrules_list!{ "body" ; "$.array_values" => [ MatchingRule :: EachKey ( MatchingRuleDefinition :: new( "a_key" . to_string( ) , ValueType :: Unknown , MatchingRule :: Type , None ) ) ] } ,
2653+ matchingrules_list!{ "body" ; "$.array_values" => [ MatchingRule :: EachKey ( MatchingRuleDefinition :: new( "another_key" . to_string( ) , ValueType :: Unknown , MatchingRule :: Type , None ) ) ] }
2654+ )
2655+ }
26362656}
0 commit comments