Use of ElementsAreArray causes compilation errors on Windows with MSVC.
As far as I can tell, I'm doing exactly what is written in the online documentation.
A minimal example
#include <gtest/gtest.h>
#include <gmock/gmock.h>
class MyTestClass : public testing::Test
{
};
class Foo
{
public:
virtual void bar(const int values[]) {}
};
class MockFoo : public Foo
{
public:
MOCK_METHOD(void, bar, (const int[]), (override));
};
TEST_F(MyTestClass, thisShouldWork)
{
const int values[] = { 123, 45 };
MockFoo foo;
EXPECT_CALL(foo, bar(testing::ElementsAreArray(values, 2))).Times(1);
foo.bar(values);
}
Here is the compiler output
PS C:\example\build> cmake --build . --config Debug
MSBuild version 17.9.5+33de0b227 for .NET Framework
gmock.vcxproj -> C:\example\build\lib\Debug\gmock.lib
gmock_main.vcxproj -> C:\example\build\lib\Debug\gmock_main.lib
gtest.vcxproj -> C:\example\build\lib\Debug\gtest.lib
gtest_main.vcxproj -> C:\example\build\lib\Debug\gtest_main.lib
foo_test.cpp
C:\example\src\foo_test.cpp(11,30): warning C4100: 'values': unreferenced formal parameter [C:\example\build\unittests.
vcxproj]
C:\example\dependencies\Debug\googletest-src\googlemock\include\gmock\gmock-matchers.h(3373,20): error C2825: 'testing:
:internal::ElementsAreMatcherImpl<const Container &>::StlContainer': must be a class or namespace when followed by '::'
[C:\example\build\unittests.vcxproj]
C:\example\dependencies\Debug\googletest-src\googlemock\include\gmock\gmock-matchers.h(3373,20): error C2825: w
ith [C:\example\build\unittests.vcxproj]
C:\example\dependencies\Debug\googletest-src\googlemock\include\gmock\gmock-matchers.h(3373,20): error C2825: [
[C:\example\build\unittests.vcxproj]
C:\example\dependencies\Debug\googletest-src\googlemock\include\gmock\gmock-matchers.h(3373,20): error C2825:
Container=const int [C:\example\build\unittests.vcxproj]
C:\example\dependencies\Debug\googletest-src\googlemock\include\gmock\gmock-matchers.h(3373,20): error C2825: ]
[C:\example\build\unittests.vcxproj]
(compiling source file '../src/foo_test.cpp')
C:\example\dependencies\Debug\googletest-src\googlemock\include\gmock\gmock-matchers.h(3373,20):
the template instantiation context (the oldest one first) is
C:\example\src\foo_test.cpp(26,3):
see reference to function template instantiation 'testing::internal::ElementsAreArrayMatcher::operator tes
ting::Matcher<const int >(void) const<const int>' being compiled
C:\example\src\foo_test.cpp(26,68):
see the first reference to 'testing::internal::ElementsAreArrayMatcher::operator testing::Matcher<
const int >' in 'MyTestClass_thisShouldWork_Test::TestBody'
C:\example\dependencies\Debug\googletest-src\googlemock\include\gmock\gmock-matchers.h(3787,35):
see reference to class template instantiation 'testing::internal::ElementsAreMatcherImpl<const Container &>' be
ing compiled
with
[
Container=const int *
]
C:\example\dependencies\Debug\googletest-src\googlemock\include\gmock\gmock-matchers.h(3373,34): error C2510: 'StlConta
iner': left of '::' must be a class/struct/union [C:\example\build\unittests.vcxproj]
(compiling source file '../src/foo_test.cpp')
Describe the issue
Use of ElementsAreArray causes compilation errors on Windows with MSVC.
As far as I can tell, I'm doing exactly what is written in the online documentation.
A minimal example
Here is the compiler output
Steps to reproduce the problem
src/main.cpp
src/foo_test.cpp
CMakeLists.txt
Build commands
Run in powershell
What version of GoogleTest are you using?
1.14.0
What operating system and version are you using?
Windows 11 Enterprise 10.0.22621 Build 22621
What compiler and version are you using?
MSBuild version 17.9.5+33de0b227 for .NET Framework
What build system are you using?
cmake version 3.28.1
Additional context
No response