Question about C++ and gtest
: neither of which is something that i work with frequently, so forgive if this is a simple question.
I can’t seem to be able to have my tests discovered if i use extern
function in any of my tests:
I work in VS 2022: I added a Google test project and referenced a C++ project under test. I am attempting to test Function1
which is defined in project under test as
#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) BYTE* Function1(BYTE* obj1, int len) noexcept(false)
{
...
}
In my test project i have the following:
extern "C"
{
extern BYTE* Function1(BYTE* obj1, int len);
}
TEST(TestCaseName, TestName)
{
retVal = Function1(GetObj1(), GetLen());
EXPECT_TRUE(0 == std::memcmp(retVal, GetExpectedResult(), sizeof(retVal)));
}
When I build the solution with both projects in it, i get an error in test explorer “Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again
“
If I dont call Function1
in my test, the tests show up in Test Explorer
What am i doing wrong here?
4