UTBotCpp icon indicating copy to clipboard operation
UTBotCpp copied to clipboard

Strange coverage report for `switch` statement

Open tyuldashev opened this issue 3 years ago • 0 comments

Description Colorization of coverage report for switch looks inconsistent, for instance case: line may be shown uncovered while inside that branch everything is covered.

To Reproduce Generate and run tests on following code and look at coverage report.

int my_switch(int i) {
  int result = 0;

  switch (i) {
  case 0:
    result = 0;
    break;
  
  case 1:
    result = 100;
    break;

  case -1: 
    result = -100;
    break;
  
  default:
    result = -1;
    break;
  }

  return result;
}

Expected behavior All lines are green. Because UTBot actually generated tests for all four branches.

Actual behavior image

There are number of problems with coverage report shown above:

  1. switch (i) line is red, but should be green in this case, as all branches are covered
  2. case and break lines are green, but result assignment is red (should be green too)
  3. lines inside default branch are red and brown but should be green

Additional sample Generate and run tests for enums.c#getSignValue in c-examples project

image

Note that switch(s) is red, but should be brown because some branches are covered and default is not.

tyuldashev avatar Nov 21 '22 16:11 tyuldashev