@@ -43,6 +43,7 @@ namespace operations_research {
4343namespace sat {
4444namespace {
4545
46+ using ::testing::DoubleNear;
4647using ::testing::EndsWith;
4748using ::testing::StartsWith;
4849
@@ -863,6 +864,14 @@ TEST(LinMaxCutsTest, AffineCutsFixedVar) {
863864 EXPECT_EQ (0 , manager->num_cuts ());
864865}
865866
867+ MATCHER_P3 (CutDataIs, coeff_matcher, lp_matcher, range_matcher, " " ) {
868+ return ExplainMatchResult (coeff_matcher, arg.coeff .value (),
869+ result_listener) &&
870+ ExplainMatchResult (range_matcher, arg.bound_diff .value (),
871+ result_listener) &&
872+ ExplainMatchResult (lp_matcher, arg.lp_value , result_listener);
873+ }
874+
866875TEST (ImpliedBoundsProcessorTest, PositiveBasicTest) {
867876 Model model;
868877 model.GetOrCreate <SatParameters>()->set_use_implied_bounds (true );
@@ -911,10 +920,8 @@ TEST(ImpliedBoundsProcessorTest, PositiveBasicTest) {
911920 absl::MakeSpan (new_terms), t, &data));
912921
913922 EXPECT_EQ (data.terms .size (), 2 );
914- EXPECT_THAT (data.terms [0 ].DebugString (),
915- ::testing::StartsWith (" coeff=1 lp=0 range=7" ));
916- EXPECT_THAT (data.terms [1 ].DebugString (),
917- ::testing::StartsWith (" coeff=3 lp=0.666667 range=1" ));
923+ EXPECT_THAT (data.terms [0 ], CutDataIs (1 , DoubleNear (0.0 , 1.0e-6 ), 7 ));
924+ EXPECT_THAT (data.terms [1 ], CutDataIs (3 , DoubleNear (0.666667 , 1.0e-6 ), 1 ));
918925 EXPECT_EQ (data.terms [1 ].expr_offset , 0 );
919926}
920927
@@ -967,10 +974,8 @@ TEST(ImpliedBoundsProcessorTest, NegativeBasicTest) {
967974 absl::MakeSpan (new_terms), t, &data));
968975
969976 EXPECT_EQ (data.terms .size (), 2 );
970- EXPECT_THAT (data.terms [0 ].DebugString (),
971- ::testing::StartsWith (" coeff=1 lp=0 range=7" ));
972- EXPECT_THAT (data.terms [1 ].DebugString (),
973- ::testing::StartsWith (" coeff=3 lp=0.666667 range=1" ));
977+ EXPECT_THAT (data.terms [0 ], CutDataIs (1 , DoubleNear (0.0 , 1.0e-6 ), 7 ));
978+ EXPECT_THAT (data.terms [1 ], CutDataIs (3 , DoubleNear (0.666667 , 1.0e-6 ), 1 ));
974979
975980 // This is the only change, we have 1 - bool there actually.
976981 EXPECT_EQ (data.terms [1 ].expr_offset , 1 );
@@ -1032,10 +1037,8 @@ TEST(ImpliedBoundsProcessorTest, DecompositionTest) {
10321037 CutTerm slack_term;
10331038 EXPECT_TRUE (processor.DecomposeWithImpliedLowerBound (X, IntegerValue (1 ),
10341039 bool_term, slack_term));
1035- EXPECT_THAT (bool_term.DebugString (),
1036- ::testing::StartsWith (" coeff=3 lp=0.666667 range=1" ));
1037- EXPECT_THAT (slack_term.DebugString (),
1038- ::testing::StartsWith (" coeff=1 lp=0 range=7" ));
1040+ EXPECT_THAT (bool_term, CutDataIs (3 , DoubleNear (0.666667 , 1.0e-6 ), 1 ));
1041+ EXPECT_THAT (slack_term, CutDataIs (1 , DoubleNear (0.0 , 1.0e-6 ), 7 ));
10391042
10401043 // (9 - X) = 7 * C + slack;
10411044 CutTerm Y = X;
@@ -1044,18 +1047,14 @@ TEST(ImpliedBoundsProcessorTest, DecompositionTest) {
10441047 Y.coeff = -Y.coeff ;
10451048 EXPECT_TRUE (processor.DecomposeWithImpliedLowerBound (Y, IntegerValue (1 ),
10461049 bool_term, slack_term));
1047- EXPECT_THAT (bool_term.DebugString (),
1048- ::testing::StartsWith (" coeff=7 lp=0.5 range=1" ));
1049- EXPECT_THAT (slack_term.DebugString (),
1050- ::testing::StartsWith (" coeff=1 lp=1.5 range=7" ));
1050+ EXPECT_THAT (bool_term, CutDataIs (7 , DoubleNear (0.5 , 1.0e-6 ), 1 ));
1051+ EXPECT_THAT (slack_term, CutDataIs (1 , DoubleNear (1.5 , 1.0e-6 ), 7 ));
10511052
10521053 // X - 2 = 7 * (1 - C) - slack;
10531054 EXPECT_TRUE (processor.DecomposeWithImpliedUpperBound (X, IntegerValue (1 ),
10541055 bool_term, slack_term));
1055- EXPECT_THAT (bool_term.DebugString (),
1056- ::testing::StartsWith (" coeff=7 lp=0.5 range=1" ));
1057- EXPECT_THAT (slack_term.DebugString (),
1058- ::testing::StartsWith (" coeff=-1 lp=1.5 range=7" ));
1056+ EXPECT_THAT (bool_term, CutDataIs (7 , DoubleNear (0.5 , 1.0e-6 ), 1 ));
1057+ EXPECT_THAT (slack_term, CutDataIs (-1 , DoubleNear (1.5 , 1.0e-6 ), 7 ));
10591058}
10601059
10611060TEST (CutDataTest, SimpleExample) {
0 commit comments