@ -51,6 +51,7 @@ using ::std::vector;
using : : testing : : AddGlobalTestEnvironment ;
using : : testing : : Bool ;
using : : testing : : Combine ;
using : : testing : : ConvertGenerator ;
using : : testing : : Message ;
using : : testing : : Range ;
using : : testing : : TestWithParam ;
@ -402,7 +403,7 @@ TEST(BoolTest, BoolWorks) {
TEST ( CombineTest , CombineWithTwoParameters ) {
const char * foo = " foo " ;
const char * bar = " bar " ;
const ParamGenerator < std : : tuple < const char * , int > > gen =
const ParamGenerator < std : : tuple < const char * , int > > gen =
Combine ( Values ( foo , bar ) , Values ( 3 , 4 ) ) ;
std : : tuple < const char * , int > expected_values [ ] = {
@ -413,7 +414,7 @@ TEST(CombineTest, CombineWithTwoParameters) {
// Tests that Combine() with three parameters generates the expected sequence.
TEST ( CombineTest , CombineWithThreeParameters ) {
const ParamGenerator < std : : tuple < int , int , int > > gen =
const ParamGenerator < std : : tuple < int , int , int > > gen =
Combine ( Values ( 0 , 1 ) , Values ( 3 , 4 ) , Values ( 5 , 6 ) ) ;
std : : tuple < int , int , int > expected_values [ ] = {
std : : make_tuple ( 0 , 3 , 5 ) , std : : make_tuple ( 0 , 3 , 6 ) ,
@ -427,7 +428,7 @@ TEST(CombineTest, CombineWithThreeParameters) {
// sequence generates a sequence with the number of elements equal to the
// number of elements in the sequence generated by the second parameter.
TEST ( CombineTest , CombineWithFirstParameterSingleValue ) {
const ParamGenerator < std : : tuple < int , int > > gen =
const ParamGenerator < std : : tuple < int , int > > gen =
Combine ( Values ( 42 ) , Values ( 0 , 1 ) ) ;
std : : tuple < int , int > expected_values [ ] = { std : : make_tuple ( 42 , 0 ) ,
@ -439,7 +440,7 @@ TEST(CombineTest, CombineWithFirstParameterSingleValue) {
// sequence generates a sequence with the number of elements equal to the
// number of elements in the sequence generated by the first parameter.
TEST ( CombineTest , CombineWithSecondParameterSingleValue ) {
const ParamGenerator < std : : tuple < int , int > > gen =
const ParamGenerator < std : : tuple < int , int > > gen =
Combine ( Values ( 0 , 1 ) , Values ( 42 ) ) ;
std : : tuple < int , int > expected_values [ ] = { std : : make_tuple ( 0 , 42 ) ,
@ -450,7 +451,7 @@ TEST(CombineTest, CombineWithSecondParameterSingleValue) {
// Tests that when the first parameter produces an empty sequence,
// Combine() produces an empty sequence, too.
TEST ( CombineTest , CombineWithFirstParameterEmptyRange ) {
const ParamGenerator < std : : tuple < int , int > > gen =
const ParamGenerator < std : : tuple < int , int > > gen =
Combine ( Range ( 0 , 0 ) , Values ( 0 , 1 ) ) ;
VerifyGeneratorIsEmpty ( gen ) ;
}
@ -458,7 +459,7 @@ TEST(CombineTest, CombineWithFirstParameterEmptyRange) {
// Tests that when the second parameter produces an empty sequence,
// Combine() produces an empty sequence, too.
TEST ( CombineTest , CombineWithSecondParameterEmptyRange ) {
const ParamGenerator < std : : tuple < int , int > > gen =
const ParamGenerator < std : : tuple < int , int > > gen =
Combine ( Values ( 0 , 1 ) , Range ( 1 , 1 ) ) ;
VerifyGeneratorIsEmpty ( gen ) ;
}
@ -469,7 +470,7 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) {
const char * foo = " foo " ;
const char * bar = " bar " ;
const ParamGenerator <
std : : tuple < const char * , int , int , int , int , int , int , int , int , int > >
std : : tuple < const char * , int , int , int , int , int , int , int , int , int > >
gen =
Combine ( Values ( foo , bar ) , Values ( 1 ) , Values ( 2 ) , Values ( 3 ) , Values ( 4 ) ,
Values ( 5 ) , Values ( 6 ) , Values ( 7 ) , Values ( 8 ) , Values ( 9 ) ) ;
@ -497,11 +498,11 @@ class NonDefaultConstructAssignString {
} ;
TEST ( CombineTest , NonDefaultConstructAssign ) {
const ParamGenerator < std : : tuple < int , NonDefaultConstructAssignString > > gen =
const ParamGenerator < std : : tuple < int , NonDefaultConstructAssignString > > gen =
Combine ( Values ( 0 , 1 ) , Values ( NonDefaultConstructAssignString ( " A " ) ,
NonDefaultConstructAssignString ( " B " ) ) ) ;
ParamGenerator < std : : tuple < int , NonDefaultConstructAssignString > > : : iterator
ParamGenerator < std : : tuple < int , NonDefaultConstructAssignString > > : : iterator
it = gen . begin ( ) ;
EXPECT_EQ ( 0 , std : : get < 0 > ( * it ) ) ;
@ -523,6 +524,63 @@ TEST(CombineTest, NonDefaultConstructAssign) {
EXPECT_TRUE ( it = = gen . end ( ) ) ;
}
template < typename T >
class ConstructFromT {
public :
ConstructFromT ( const T & t ) : t_ ( t ) { }
template < typename . . . Args >
ConstructFromT ( Args & & . . . args ) : t_ ( std : : forward < Args > ( args ) . . . ) { }
bool operator = = ( const ConstructFromT & other ) const { return other . t_ = = t_ ; }
const T & get ( ) const { return t_ ; }
private :
T t_ ;
} ;
TEST ( ConvertTest , CombineWithTwoParameters ) {
const char * foo = " foo " ;
const char * bar = " bar " ;
const ParamGenerator < ConstructFromT < std : : tuple < const char * , int > > > gen =
ConvertGenerator < std : : tuple < const char * , int > > (
Combine ( Values ( foo , bar ) , Values ( 3 , 4 ) ) ) ;
ConstructFromT < std : : tuple < const char * , int > > expected_values [ ] = {
{ foo , 3 } , { foo , 4 } , { bar , 3 } , { bar , 4 } } ;
VerifyGenerator ( gen , expected_values ) ;
}
TEST ( ConvertTest , NonDefaultConstructAssign ) {
const ParamGenerator <
ConstructFromT < std : : tuple < int , NonDefaultConstructAssignString > > >
gen = ConvertGenerator < std : : tuple < int , NonDefaultConstructAssignString > > (
Combine ( Values ( 0 , 1 ) , Values ( NonDefaultConstructAssignString ( " A " ) ,
NonDefaultConstructAssignString ( " B " ) ) ) ) ;
ParamGenerator < ConstructFromT <
std : : tuple < int , NonDefaultConstructAssignString > > > : : iterator it =
gen . begin ( ) ;
EXPECT_EQ ( 0 , std : : get < 0 > ( it - > get ( ) ) ) ;
EXPECT_EQ ( " A " , std : : get < 1 > ( it - > get ( ) ) . str ( ) ) ;
+ + it ;
EXPECT_EQ ( 0 , std : : get < 0 > ( it - > get ( ) ) ) ;
EXPECT_EQ ( " B " , std : : get < 1 > ( it - > get ( ) ) . str ( ) ) ;
+ + it ;
EXPECT_EQ ( 1 , std : : get < 0 > ( it - > get ( ) ) ) ;
EXPECT_EQ ( " A " , std : : get < 1 > ( it - > get ( ) ) . str ( ) ) ;
+ + it ;
EXPECT_EQ ( 1 , std : : get < 0 > ( it - > get ( ) ) ) ;
EXPECT_EQ ( " B " , std : : get < 1 > ( it - > get ( ) ) . str ( ) ) ;
+ + it ;
EXPECT_TRUE ( it = = gen . end ( ) ) ;
}
// Tests that an generator produces correct sequence after being
// assigned from another generator.
TEST ( ParamGeneratorTest , AssignmentWorks ) {