Coverage Report - net.sourceforge.combean.test.mathprog.grooml.TestGRow
 
Classes in this File Line Coverage Branch Coverage Complexity
TestGRow
100%
8/8
50%
6/12
0
TestGRow$_testGRowDefinedByClosure_closure1
100%
1/1
N/A
0
TestGRow$_testGRowDefinedByClosure_closure2
N/A
N/A
0
TestGRow$_testGRowDefinedByClosure_closure3
100%
2/2
50%
6/12
0
TestGRow$_testGRowDefinedByClosure_closure4
100%
2/2
50%
1/2
0
 
 1  
 /*
 2  
     This file is part of Combean.
 3  
 
 4  
     Combean is free software; you can redistribute it and/or modify
 5  
     it under the terms of the GNU General Public License as published by
 6  
     the Free Software Foundation; either version 2 of the License, or
 7  
     (at your option) any later version.
 8  
 
 9  
     Combean is distributed in the hope that it will be useful,
 10  
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  
     GNU General Public License for more details.
 13  
 
 14  
     You should have received a copy of the GNU General Public License
 15  
     along with Foobar; if not, write to the Free Software
 16  
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 17  
 */
 18  
 package net.sourceforge.combean.test.mathprog.grooml;
 19  
 
 20  
 import groovy.mock.interceptor.StubFor;
 21  
 
 22  
 import net.sourceforge.combean.mathprog.grooml.GRow;
 23  
 import net.sourceforge.combean.mathprog.grooml.GConstraint;
 24  
 import net.sourceforge.combean.mathprog.grooml.GVariables;
 25  
 import net.sourceforge.combean.mathprog.grooml.GLPModel;
 26  
 import net.sourceforge.combean.mathprog.grooml.GExpression;
 27  
 import net.sourceforge.combean.mathprog.grooml.GSimpleExpression;
 28  
 
 29  
 
 30  
 class TestGRow extends GroovyTestCase {
 31  
 
 32  
         void testGRowDefinedByClosure() {
 33  3
             GExpression expr = new GSimpleExpression("- 2  x [5]");
 34  
             
 35  3
             GVariables vars = new GVariables("x", 4..6, [:]) { 1.0 };
 36  3
             def modelStub = new StubFor(GLPModel);
 37  3
             modelStub.demand.getVariables { vars };
 38  
             
 39  3
             GRow r;
 40  3
             modelStub.use{
 41  3
                     r = new GRow(expr, new GConstraint("foo", "= 1.0"),
 42  3
                             new GLPModel(), [:]);
 43  
             }
 44  
             
 45  3
             assertEquals(1, r.numIterations);
 46  
             
 47  3
             r.expr.evaluate([:]).each{
 48  3
                 assertToString(it, "-2.0 x[5]");
 49  
             }
 50  
         }
 51  
 
 52  
 }