wwu-pi / muggl

A Symbolic ATCG
GNU General Public License v3.0
2 stars 1 forks source link

Incomplete covered control graphs #23

Open anfuchs opened 9 years ago

anfuchs commented 9 years ago

Only one condition is tested in a simple if-else construct.

Tried with different Coverage options, resulting all in same generated test case (see below).

Code to test:

public class Foobar {
    public boolean fooTheBar(int x) {
        if(x > 1000) {
            return true;
        } else {
            return false;
        }
    }
}

Generated Test Case:

public class TestClass12 {
    // Fields for test parameters and expected return values.
    private de.wwu.pi.dbtest.sampleapp.Foobar testedClass;
    private boolean booleanfalse;
    private int intm50;

    /**
     * Set up the unit test by initializing the fields to the desired values.
     */
    @Before public void setUp() {
        this.testedClass = new de.wwu.pi.dbtest.sampleapp.Foobar();
        this.booleanfalse = false;
        this.intm50 = -50;
    }

    /**
     * Run the tests on de.wwu.pi.dbtest.sampleapp.Foobar.fooTheBar(int x).
     */
    @Test public void testIt() {
        assertEquals(this.booleanfalse, this.testedClass.fooTheBar(this.intm50));
    }

    /**
     * Invoke JUnit to run the unit tests.
     * @param args Command line arguments, which are ignored here. Just supply null.
     */
    public static void main(String args[]) {
        org.junit.runner.JUnitCore.main("test.unitTests.TestClass12");
    }
}
Dagefoerde commented 8 years ago

Is it possible that this happens only when using JaCoP as a solver? Because currently, JaCoP is limited to integer values in the interval of [-50,50]. You can change this interval by putting smaller(!) values into de.wwu.muggl.solvers.jacop.JaCoPTransformer#DOMAIN_DEPRECIATION, as this constant is used for reducing the domain of IntVars.

Background: If we assume a range of [-50,50], then there is actually no x that can fulfill the criterion x > 1000. This is wrong, of course, but with JaCoP there is currently no other solution.