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

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

CATCH_CONFIG_DISABLE fails CAPTURE(i,j) #2316

laoshaw opened this issue Oct 30, 2021 · 0 comments
Labels
Bug Good First Issue Issues that can be undertaken by someone new to the project

Comments

@laoshaw
Copy link

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
@horenmar horenmar added Good First Issue Issues that can be undertaken by someone new to the project Bug labels Oct 30, 2021
johnbeard added a commit to johnbeard/Catch2 that referenced this issue Mar 2, 2022
This causes errors on CAPTURE(a,b) when CATCH_CONFIG_DISABLE
is set.
johnbeard added a commit to johnbeard/Catch2 that referenced this issue Mar 2, 2022
This caused errors on CAPTURE(a,b) when CATCH_CONFIG_DISABLE
is set.

Closes: catchorg#2316
horenmar pushed a commit that referenced this issue Mar 4, 2022
@horenmar horenmar closed this as completed Mar 4, 2022
johnbeard added a commit to johnbeard/Catch2 that referenced this issue Mar 5, 2022
This makes sure that CAPTURE works when called with variadic arguments,
and also works that way when disabled.

The underlying fix to catchorg#2316 is not applicable (CAPTURE is already
variadic when disabled).

This is a port of 5e94498 to the
devel branch.
horenmar pushed a commit that referenced this issue Mar 5, 2022
This makes sure that CAPTURE works when called with variadic arguments,
and also works that way when disabled.

The underlying fix to #2316 is not applicable (CAPTURE is already
variadic when disabled).

This is a port of 5e94498 to the
devel branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Good First Issue Issues that can be undertaken by someone new to the project
Projects
None yet
Development

No branches or pull requests

2 participants