Skip to content

UTBot generates test which covers only corner case of double/double divison #978

Open
@tyuldashev

Description

@tyuldashev

To Reproduce
Generate tests for following code

public class SimpleCalc {
    double div(double a, double b) {
        return a / b;
    }
}

Actual behavior
Only one test is generated with following code

    @Test
    @DisplayName("div: a = Double.POSITIVE_INFINITY, b = Double.POSITIVE_INFINITY -> return NaN")
    public void testDivReturnsNanWithCornerCases() {
        SimpleCalc simpleCalc = new SimpleCalc();

        double actual = simpleCalc.div(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);

        assertEquals(Double.NaN, actual, 1.0E-6);
    }

Expected behavior
More tests are generated which cover some simple scenarios with division like 2.0 / 1.0 = 1.0.

Currently if user makes an error and change original code to return a / b * koef generated test still passes which makes it less valuable for regression testing.

Additional context
The code above is generated when only Fuzzing is used, but with symbolic analysis test is very similar - the test would check that Double.NaN / Double.NaN = Double.NaN . Not sure if we need dedicated issue or there is one root cause such behavior.

Metadata

Metadata

Assignees

Labels

ctg-bugIssue is a bug

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions