Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
TestGVariables |
|
| 0.0;0 | ||||
TestGVariables$_testConstructVarsWithCoeffAndRange_closure2 |
|
| 0.0;0 | ||||
TestGVariables$_testConstructVarsWithCoeffAndStrings_closure3 |
|
| 0.0;0 | ||||
TestGVariables$_testConstructVarsWithDoubleIndex_closure4 |
|
| 0.0;0 | ||||
TestGVariables$_testConstructVarsWithSimpleCoeff_closure1 |
|
| 0.0;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 net.sourceforge.combean.mathprog.grooml.GVariables; | |
21 | import net.sourceforge.combean.mathprog.grooml.GSet; | |
22 | ||
23 | class TestGVariables extends GroovyTestCase { | |
24 | ||
25 | void testConstructVarsWithSimpleCoeff() { | |
26 | 3 | GVariables vars = new GVariables("foo", 1..2, [:]) { 1.5 * it } |
27 | 3 | assertEquals("vars 'foo' : [1.5 | [0.0; Infinity], " + |
28 | 3 | "3.0 | [0.0; Infinity]]", vars.toString()) |
29 | } | |
30 | ||
31 | void testConstructVarsWithCoeffAndRange() { | |
32 | 3 | GVariables vars = new GVariables("foo", 2..3, [:]) { [1.5 * it, -it..it] } |
33 | 3 | assertEquals("vars 'foo' : [3.0 | [-2.0; 2.0], " + |
34 | 3 | "4.5 | [-3.0; 3.0]]", vars.toString()) |
35 | } | |
36 | ||
37 | void testConstructVarsWithCoeffAndStrings() { | |
38 | 3 | def names = ['first', 'second']; |
39 | 3 | def coeffs = [first: 10.0, second: 20.0]; |
40 | 3 | GVariables vars = new GVariables("foo", [it:names], [:]) { |
41 | 6 | [coeffs[it], -1..1] |
42 | } | |
43 | 3 | assertEquals("vars 'foo' : [10.0 | [-1.0; 1.0], " + |
44 | 3 | "20.0 | [-1.0; 1.0]]", vars.toString()) |
45 | } | |
46 | ||
47 | void testConstructVarsWithDoubleIndex() { | |
48 | 3 | GVariables vars = new GVariables("foo", [x:1..2, y:3..4], [:]) { 1.0 }; |
49 | 6 | assertEquals("vars 'foo' : [" + |
50 | 3 | "1.0 | [0.0; Infinity], " + |
51 | 3 | "1.0 | [0.0; Infinity], " + |
52 | "1.0 | [0.0; Infinity], " + | |
53 | 3 | "1.0 | [0.0; Infinity]]", vars.toString()) |
54 | } | |
55 | } |