Unable to compile INSTANTIATE_TEST_CASE_P(...)

3,490 views
Skip to first unread message

Michael

unread,
Mar 30, 2011, 5:58:04 PM3/30/11
to Google C++ Testing Framework
I have been using Google Test Framework for about a week now and I am
trying to add a Value Parametrized test case, but if fails to compile
with the following errors :

** SNIP **
C:\...\packetize
>"c:\Program Files\MinGW\bin"\g++.exe -c gtest.cpp -I ..\..\..\Development\gtest
-1.5.0\include -ggdb -o gtest.cpp
gtest.cpp:19: error: `testRandomFillAndEmpty' has not been declared
gtest.cpp:19: error: `ParamType' was not declared in this scope
gtest.cpp:19: error: template argument 1 is invalid
gtest.cpp:19: error: ISO C++ forbids declaration of
`gtest_randomPacketPayloadte
stRandomFillAndEmpty_EvalGenerator_' with no type
gtest.cpp: In function `int
gtest_randomPacketPayloadtestRandomFillAndEmpty_Eval
Generator_()':
gtest.cpp:19: error: cannot convert
`testing::internal::ValueArray5<int, int, int, int, int>'
to `int' in return
gtest.cpp: At global scope:
gtest.cpp:19: error: `testRandomFillAndEmpty' was not declared in this
scope
gtest.cpp:19: error: template argument 1 is invalid
gtest.cpp:19: error: no matching function for call to
`testing::internal::Parame
terizedTestCaseRegistry::GetTestCasePatternHolder(const char[23],
const char[10], int)'

C:\...\packetize
>"c:\Program Files\MinGW\bin"\g++.exe --version
g++.exe (GCC) 3.4.5 (mingw-vista special r3)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There
is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
** SNIP **

I have thinned down my code to the following snippet and it still
exhibits the same error.

** SNIP **
#include <gtest\gtest.h> // Google test framework
class packetBufferRanFixture : public ::testing::TestWithParam<
unsigned int >
{
public :
packetBufferRanFixture( ):
testing::TestWithParam<unsigned int>( ){ }
protected :
virtual void SetUp( ){ }
virtual void TearDown( ){ }
};

TEST_P( packetBufferRanFixture, testRandomFillAndEmpty ){ }

INSTANTIATE_TEST_CASE_P(
randomPacketPayload,
testRandomFillAndEmpty,
::testing::Values( 2,3,5,9,10 )
);

int main( int argn, char **argv, char **env){
::testing::InitGoogleTest( &argn, argv );
return RUN_ALL_TESTS( );
}
** SNIP **

Please, any help would be greatly appreciated.

Pasi Valminen

unread,
Mar 30, 2011, 9:32:00 PM3/30/11
to Michael, Google C++ Testing Framework
Hi,

In your code snippet, change the second argument of INSTANTIATE_TEST_CASE_P to the name of your fixture class i.e. packetBufferRanFixture and it compiles and runs ok.

Regards,
Pasi

Michael

unread,
Mar 31, 2011, 7:30:16 PM3/31/11
to Google C++ Testing Framework
Thank you, works like a charm.

On Mar 30, 7:32 pm, Pasi Valminen <pasi.valmi...@gmail.com> wrote:
> Hi,
>
> In your code snippet, change the second argument of INSTANTIATE_TEST_CASE_P
> to the name of your fixture class i.e. packetBufferRanFixture and it
> compiles and runs ok.
>
> Regards,
> Pasi
> ...
Reply all
Reply to author
Forward
0 new messages