You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#defineDOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include"doctest.h"template<classA, classB>
structTestClass
{
TestClass(int v) : value(v) { }
int value;
};
using TestClassIntFloat = TestClass<int, float>;
TEST_CASE("SomeUnitTest")
{
CHECK(TestClass<int, float>(5).value == 5);
// CHECK_NOTHROW(TestClass<int, float>(5)); // <-- Does not compileCHECK(TestClassIntFloat(5).value == 5);
CHECK_NOTHROW(TestClassIntFloat(5)); // <-- Compiles just fine
}
Line CHECK_NOTHROW(TestClass<int, float>(5)); does not compile. However, if I simply wrap the type via using TestClassIntFloat = TestClass<int, float>; then CHECK_NOTHROW(TestClassIntFloat(5)); compiles just fine. Same issue for CHECK_THROWS.
I am using doctest 2.3.7 and the error occurs on both MSVC 2019 and g++ 10:
MSVC: warning C4002: too many arguments for function-like macro invocation 'DOCTEST_CHECK_THROWS'
g++: error: macro "DOCTEST_CHECK_THROWS" passed 2 arguments, but takes just 1
This came up as I was trying to migrate from catch2 to doctest. When reverting back to catch by using these two lines
#defineCATCH_CONFIG_MAIN
#include"catch.hpp"
everything compiles, as expected.
I had a look at the code and i think changing this line
Let's consider the following sample script:
Line
CHECK_NOTHROW(TestClass<int, float>(5));
does not compile. However, if I simply wrap the type viausing TestClassIntFloat = TestClass<int, float>;
thenCHECK_NOTHROW(TestClassIntFloat(5));
compiles just fine. Same issue forCHECK_THROWS
.I am using doctest
2.3.7
and the error occurs on both MSVC 2019 and g++ 10:warning C4002: too many arguments for function-like macro invocation 'DOCTEST_CHECK_THROWS'
error: macro "DOCTEST_CHECK_THROWS" passed 2 arguments, but takes just 1
This came up as I was trying to migrate from
catch2
todoctest
. When reverting back to catch by using these two lineseverything compiles, as expected.
I had a look at the code and i think changing this line
to
resolves the issue. But I am not sure if this has any other repercussions?
The text was updated successfully, but these errors were encountered: