catchorg / catchorg/Catch2

Unable to use TEMPLATE_TEST_CASE_SIG with variadic template arguments

Open
#2,289 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

**Describe the bug**

I've been trying to use `TEMPLATE_TEST_CASE_SIG` with variadic template parameters, just as mentioned in the documentation, but I've never been able to make it work. Suppose the following code:
```
template
class Foo
{
public:
bool Make(Args&&... args)
{
return true;
}
};

TEMPLATE_TEST_CASE_SIG("test", "[test]", ((typename T, typename...Ts), T, Ts...), int, (int, true))
{
auto foo = Foo();
REQUIRE(foo.Make(Ts...));
}
```

Compiler output the following error:
```
2>D:\Tests.cpp(98,1): error C2668: '`anonymous-namespace'::ns_____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____16::get_wrapper': ambiguous call to overloaded function
2>D:\Tests.cpp(98,1): message : could be '`anonymous-namespace'::ns_____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____16::Nttp `anonymous-namespace'::ns_____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____16::get_wrapper(void) noexcept'
2>D:\Tests.cpp(98,1): message : or '`anonymous-namespace'::ns_____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____16::TypeList `anonymous-namespace'::ns_____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____16::get_wrapper(void) noexcept'
2>D:\Tests.cpp(98,1): message : while trying to match the argument list '()'
2>D:\Tests.cpp(98,1): error C2672: 'get_wrapper': no matching overloaded function found
2>D:\Tests.cpp(98,1): error C2974: '`anonymous-namespace'::ns_____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____16::get_wrapper': invalid template argument for 'Cs', type expected
2>D:\Tests.cpp(98): message : see declaration of '`anonymous-namespace'::ns_____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____16::get_wrapper'
2>D:\Tests.cpp(98,1): error C2974: '`anonymous-namespace'::ns_____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____16::get_wrapper': invalid template argument for 'Ts', type expected
2>D:\Tests.cpp(98): message : see declaration of '`anonymous-namespace'::ns_____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____16::get_wrapper'
```

**Expected behavior**

Once the compile issue resolved, expecting the test case to be called with `T = int` then again with `T = int, Ts = true`.

**Reproduction steps**

Try compiling the code snippet above.

**Platform information:**

- OS: **Windows 10 x64**
- Compiler+version: **MSVC 16.11.2 (Visual Studio 2019)**
- Catch version: **v2.13.7**

**Additional context**

Am I understanding correctly what `TEMPLATE_TEST_CASE_SIG` with variadic template parameters is able to do? Also tried to call the macro this way:
```
TEMPLATE_TEST_CASE_SIG("test", "[test]", ((typename T, typename...Ts), T, Ts...), (int, false), (int, true))
```
...but it results in the same error.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.