Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unnecessary "utbot_abs_error" constant added to the test #405

Closed
tyuldashev opened this issue Aug 26, 2022 · 2 comments
Closed

[BUG] Unnecessary "utbot_abs_error" constant added to the test #405

tyuldashev opened this issue Aug 26, 2022 · 2 comments
Assignees
Labels
question Further information is requested verified Bug fix is verified

Comments

@tyuldashev
Copy link
Collaborator

Version
2022.8.233
Description
UTBot adds unused constant to the test
static const float utbot_abs_error = 1e-6;

Generate code for following function

char a_or_b(char a, char b) {
  if (a == 'a')
    return a;
  else 
    return b;
}

Result is

#include "snippet_dot_c_test.h"

#include "gtest/gtest.h"
namespace UTBot {
static const float utbot_abs_error = 1e-6;


#pragma region regression
TEST(regression, a_or_b_test_1)
{
    char actual = a_or_b('h', 'c');
    EXPECT_EQ('c', actual);
}

TEST(regression, a_or_b_test_2)
{
    char actual = a_or_b('a', 'c');
    EXPECT_EQ('a', actual);
}

#pragma endregion
}

generated constant utbot_abs_error is unused and seems unecessary.

@tyuldashev tyuldashev added the bug Something isn't working label Aug 26, 2022
@korifey korifey moved this to Todo in UTBot C/C++ Aug 26, 2022
@ladisgin ladisgin added question Further information is requested and removed bug Something isn't working labels Aug 26, 2022
@ladisgin
Copy link
Member

@alexey-utkin, we can add check that function has float in parameters or move this value to header

@alexey-utkin
Copy link
Collaborator

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 comparison.

@alexey-utkin alexey-utkin moved this from Todo to In Progress in UTBot C/C++ Sep 5, 2022
alexey-utkin added a commit that referenced this issue Sep 5, 2022
- use `EXPECT_FLOAT_EQ` and `EXPECT_DOUBLE_EQ` instead of `EXPECT_NEAR`
- remove insertion obsolete `utbot_abs_error` to the code
- support comparison `NAN` and `INFINITY` consts
- make inclusion of `main.c` wrapper with relative path
alexey-utkin added a commit that referenced this issue Sep 6, 2022
- remove obsolete `ABS_ERROR`
- printer optimization
alexey-utkin added a commit that referenced this issue Sep 6, 2022
…431)

* [BUG] Unnecessary "utbot_abs_error" constant added to the test #405

- use `EXPECT_FLOAT_EQ` and `EXPECT_DOUBLE_EQ` instead of `EXPECT_NEAR`
- remove insertion obsolete `utbot_abs_error` to the code
- support comparison `NAN` and `INFINITY` consts
- make inclusion of `main.c` wrapper with relative path
- remove obsolete `ABS_ERROR`
- printer optimization
Repository owner moved this from In Progress to Done in UTBot C/C++ Sep 22, 2022
@tyuldashev tyuldashev added the verified Bug fix is verified label Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested verified Bug fix is verified
Projects
Status: Done
Development

No branches or pull requests

3 participants