Commit 882a17f7 authored by Chinmay Garde's avatar Chinmay Garde

Minor: Add more tests

parent 8be3c640
...@@ -140,7 +140,7 @@ class Solver { ...@@ -140,7 +140,7 @@ class Solver {
return _dualOptimize(); return _dualOptimize();
} }
void updateVariable() { void flushVariableUpdates() {
for (Variable variable in _vars.keys) { for (Variable variable in _vars.keys) {
_Symbol symbol = _vars[variable]; _Symbol symbol = _vars[variable];
_Row row = _rows[symbol]; _Row row = _rows[symbol];
......
...@@ -422,4 +422,30 @@ void main() { ...@@ -422,4 +422,30 @@ void main() {
expect(((left + right) >= (CM(2.0) * mid)) is Constraint, true); expect(((left + right) >= (CM(2.0) * mid)) is Constraint, true);
}); });
test('single_item', () {
var left = new Param(-20.0);
Solver s = new Solver();
s << (left >= CM(0.0));
s.flushVariableUpdates();
expect(left.value, 0.0);
});
test('midpoints', () {
var left = new Param(0.0);
var right = new Param(0.0);
var mid = new Param(0.0);
Solver s = new Solver();
s << ((left + right == CM(2.0) * mid) as Constraint);
s << (right - left >= CM(100.0));
s << (left >= CM(0.0));
s.flushVariableUpdates();
expect(left.value, 0.0);
expect(mid.value, 50.0);
expect(right.value, 100.0);
});
} }
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