Skip to content

Cannot run test generated for function with parameter named after C++ keyword #534

Open
@tyuldashev

Description

@tyuldashev

Description
It seems that some C++ keywords cannot be used as parameter names in C functions, because generated tests cannot be run. For instance and, and_eq or bitand and probably others.

To Reproduce

Generate tests for following function and try to run them:

int param_name_and(int and) {
    return and * and;
}

Expected behavior
Tests are generated and executed.

Actual behavior
Tests are generated but execution fails. Following error could be found in the logs:

In file included from /home/utbot/remote/SampleDocker2/tests/makefiles/src/../../../tests/src/params_dot_c_test.cpp:5:
/home/utbot/remote/SampleDocker2/tests/makefiles/src/../../../tests/src/params_dot_c_test.h:65:39: error: expected identifier
return param_name_and_src_params_c(and);

params_dot_c_test.h

...
extern "C" int param_name_and_src_params_c(int and);
static int param_name_and(int and) {
return param_name_and_src_params_c(and);
}
...

Additional context
To verify other keywords please use attached file, rename extension to c and probably comment out param_name_wchar_t function as it seems separate problem. Then generate and run tests.

params.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwrong generationInadequate or empty test suite generated

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions