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

CATCH_CONFIG_DISABLE fails CAPTURE(i,j) #2316

Open
laoshaw opened this issue Oct 30, 2021 · 0 comments
Open

CATCH_CONFIG_DISABLE fails CAPTURE(i,j) #2316

laoshaw opened this issue Oct 30, 2021 · 0 comments

Comments

@laoshaw
Copy link

@laoshaw laoshaw commented Oct 30, 2021

Describe the bug
when I turn on CATCH_CONFIG_DISABLE, all CAPTURE(i,j) , i.e. more than one arg will err.

Expected behavior
No such error

Reproduction steps
Build below code with -DCATCH_CONFIG_DISABLE

#include "catch.hpp"

TEST_CASE("generators") {
    auto i = GENERATE(as<std::string>(), "a", "b", "c");
    SECTION("one") {
        auto j = GENERATE(range(8, 11), 2);
        CAPTURE(i, j);
        SUCCEED();
    }
    SECTION("two") {
        auto j = GENERATE(3, 141, 1.379);
        CAPTURE(i, j);
        SUCCEED();
    }
}

// cross-product of two ranges.
TEST_CASE("100x100 ints", "[.][approvals]") {
    auto x = GENERATE(range(0, 100));
    auto y = GENERATE(range(200, 300));
    CHECK(x < y);
}

will lead to below errs:

generate.cpp:7:21: error: macro "CAPTURE" passed 2 arguments, but takes just 1
    7 |         CAPTURE(i, j);
      |                     ^
In file included from generate.cpp:1:
catch.hpp:17887: note: macro "CAPTURE" defined here
17887 | #define CAPTURE( msg ) (void)(0)
      | 
generate.cpp:12:21: error: macro "CAPTURE" passed 2 arguments, but takes just 1
   12 |         CAPTURE(i, j);
      |                     ^
In file included from generate.cpp:1:
catch.hpp:17887: note: macro "CAPTURE" defined here
17887 | #define CAPTURE( msg ) (void)(0)
      | 
generate.cpp: In function ‘void ____C_A_T_C_H____T_E_S_T____0()’:
generate.cpp:7:9: error: ‘CAPTURE’ was not declared in this scope
    7 |         CAPTURE(i, j);
      |         ^~~~~~~
generate.cpp:12:9: error: ‘CAPTURE’ was not declared in this scope
   12 |         CAPTURE(i, j);

Platform information:

  • OS: Linux
  • Compiler+version: G++ v9.3
  • Catch version: v2.13.7, the newest

Additional context

My fix is below to get it working:

17886c17886,17887
< #define CAPTURE( msg ) (void)(0)
---
> #define CAPTURE( ... ) (void)(0)
@laoshaw laoshaw changed the title CATCH_CONFIG_DISABLE failes CAPTURE(i,j) CATCH_CONFIG_DISABLE fails CAPTURE(i,j) Oct 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants