@@ -12,6 +12,9 @@ TEST_CASE("3 variables, 3 constraints", "[lp]")
12
12
{
13
13
tsplp::Model model (3 );
14
14
15
+ REQUIRE (model.GetBinaryVariables ().size () == 3 );
16
+ CHECK (model.GetNumberOfConstraints () == 0 );
17
+
15
18
auto x1 = model.GetBinaryVariables ()[0 ];
16
19
auto x2 = model.GetBinaryVariables ()[1 ];
17
20
auto x3 = model.GetBinaryVariables ()[2 ];
@@ -26,20 +29,25 @@ TEST_CASE("3 variables, 3 constraints", "[lp]")
26
29
auto objective = x1 + 4 * x2 + 9 * x3 - 10 ;
27
30
model.SetObjective (objective);
28
31
32
+ CHECK (model.GetNumberOfConstraints () == 0 );
33
+
29
34
auto c1 = x1 + x2 <= 5 ;
30
35
auto c2 = x1 + x3 >= 10 ;
31
36
auto c3 = -x2 + x3 == 7 ;
32
37
33
- std::vector<tsplp::LinearConstraint> constraints { c1, c2, c3 };
38
+ const std::vector<tsplp::LinearConstraint> constraints { c1, c2, c3 };
34
39
35
40
model.AddConstraints (constraints.cbegin (), constraints.cend ());
36
41
42
+ CHECK (model.GetNumberOfConstraints () == 3 );
43
+
37
44
using namespace std ::chrono_literals;
38
45
auto status = model.Solve (std::chrono::steady_clock::now () + 10ms);
39
46
40
- REQUIRE (status == tsplp::Status::Optimal);
41
- REQUIRE (c1.Evaluate (model));
42
- REQUIRE (c2.Evaluate (model));
43
- REQUIRE (c3.Evaluate (model));
44
- REQUIRE (objective.Evaluate (model) == Approx (44 ));
47
+ CHECK (model.GetNumberOfConstraints () == 3 );
48
+ CHECK (status == tsplp::Status::Optimal);
49
+ CHECK (c1.Evaluate (model));
50
+ CHECK (c2.Evaluate (model));
51
+ CHECK (c3.Evaluate (model));
52
+ CHECK (objective.Evaluate (model) == Approx (44 ));
45
53
}
0 commit comments