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

(C++) Unable to (properly) match rawstring literals #473

Open
daantimmer opened this issue Nov 2, 2023 · 1 comment
Open

(C++) Unable to (properly) match rawstring literals #473

daantimmer opened this issue Nov 2, 2023 · 1 comment
Milestone

Comments

@daantimmer
Copy link

daantimmer commented Nov 2, 2023

Describe the bug
C++11 introduced raw string literals. Which are the preferd method of writing regular expressions in C++.
Raw string literals look like: const char* str = R"(this is a raw string literal)";. Raw string literals start with R"( and end with )". Given the current tools provided by VSCucumberAutoComplete it is impossible to properly match raw string literal steps:

// steps/step_implementation_file.cpp
GIVEN(R"(there is a step that is a raw string literal)")
{}

To Reproduce
Steps to reproduce the behavior:

  1. create a file in steps/stepimpl.cpp
  2. add contents shown above
  3. create a feature file containing a scenario with the above step
  4. observe the match to be: (there is a step that is a raw string literal)

Expected behavior
VSCucumberAutoComplete treats the above GIVEN step as capturing the whole string, which is incorrect.
Example:
image

Screenshots
See Expected Behaviour

Cucumberautocomplete part of VSCode settings:

{
    "cucumberautocomplete.steps": [
        "steps/*.cpp"
    ],
    "cucumberautocomplete.gherkinDefinitionPart": "(GIVEN|WHEN|THEN|STEP)\\(R"
}

Step definition:
See above

Gherkin step line
See above

@daantimmer
Copy link
Author

It is possible to workaround the issue using:

{
    "cucumberautocomplete.customParameters": [
        {
            "parameter": "\"(",
            "value": "\""
        },
        {
            "parameter": ")\"",
            "value": "\""
        }
    ]
}

This does mean every occurance of "( and )" within a regular expression would be replaced by ".

@alexkrechik alexkrechik added this to the 3.1.0 milestone May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants