UTBotCpp
UTBotCpp copied to clipboard
[BUG] Not enough tests generated for 'double' and 'long double'
Description
Depending on parameter and variable types UBot generates diffirent number of tests. For double and long double it generates less than for float.
To Reproduce Generate tests for following code, which has three identical functions with only difference in types used inside them.
float my_div_float(float x, float y) {
float temp = x / y;
if (temp >= 0) {
return temp;
}
else
{
return -temp;
}
}
double my_div_double(double x, double y) {
double temp = x / y;
if (temp >= 0) {
return temp;
}
else
{
return -temp;
}
}
long double my_div_long_double(long double x, long double y) {
long double temp = x / y;
if (temp >= 0) {
return temp;
}
else
{
return -temp;
}
}
Resulting tests file
#include "helloworld_dot_c_test.h"
#include "gtest/gtest.h"
namespace UTBot {
static const float utbot_abs_error = 1e-6;
#pragma region regression
TEST(regression, my_div_float_test_1)
{
float actual = my_div_float(3.030574e-39, -1.525881e-05);
EXPECT_NEAR(1.986115e-34, actual, utbot_abs_error);
}
TEST(regression, my_div_float_test_2)
{
float actual = my_div_float(0.000000e+00, 9.219703e-41);
EXPECT_NEAR(0.000000e+00, actual, utbot_abs_error);
}
TEST(regression, my_div_double_test_1)
{
double actual = my_div_double(0.000000e+00, -1.823504e-303);
EXPECT_NEAR(0.000000e+00, actual, utbot_abs_error);
}
#pragma endregion
#pragma region error
TEST(error, my_div_float_test_3)
{
my_div_float(0.000000e+00, 0.000000e+00);
}
TEST(error, my_div_double_test_2)
{
my_div_double(0.000000e+00, 0.000000e+00);
}
TEST(error, my_div_long_double_test_1)
{
my_div_long_double(0.000000e+00, 0.000000e+00);
}
#pragma endregion
}
- Error test are generated for all three functions
- 2 regression test cases are generated for
floattype, one fordoubleand none forlong double. Though it depends on execution, sometimes it creates one regression forlong doubletoo.
Expected that for every three function three tests would be created: one error and two regression
We need to use
EXPECT_FLOAT_EQ and EXPECT_DOUBLE_EQ instead of EXPECT_NEAR.
It makes utbot_abs_error variable obsolete and resolves the problem with NAN and INFINITY comparisson.