Commit 9d075ada authored by Chinmay Garde's avatar Chinmay Garde

Minor: Add tests to check for addition of multiple constraints

parent a029c93e
......@@ -18,7 +18,7 @@ class Solver {
/// add any for some reason, a cleanup is attempted so that either all
/// constraints will be added or none.
Result addConstraints(List<Constraint> constraints) {
List<Constraint> added = new List<Constraint>(constraints.length);
List<Constraint> added = new List<Constraint>();
bool needsCleanup = false;
Result result = Result.success;
......
......@@ -449,4 +449,23 @@ void main() {
expect(mid.value, 50.0);
expect(right.value, 100.0);
});
test('addition_of_multiple', () {
var left = new Param(0.0);
var right = new Param(0.0);
var mid = new Param(0.0);
Solver s = new Solver();
var c = (left >= CM(0.0));
expect(s.addConstraints([
(left + right == CM(2.0) * mid) as Constraint,
(right - left >= CM(100.0)),
c
]), Result.success);
expect(s.addConstraints([(right >= CM(-20.0)), c]),
Result.duplicateConstraint);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment