@ -553,7 +553,6 @@ TEST_F(CustomizableTest, PrepareOptionsTest) {
ConfigOptions prepared ( config_options_ ) ;
ConfigOptions prepared ( config_options_ ) ;
prepared . invoke_prepare_options = true ;
prepared . invoke_prepare_options = true ;
ASSERT_FALSE ( base - > IsPrepared ( ) ) ;
ASSERT_OK ( base - > ConfigureFromString (
ASSERT_OK ( base - > ConfigureFromString (
prepared , " unique=A_1; shared={id=B;string=s}; pointer.id=S " ) ) ;
prepared , " unique=A_1; shared={id=B;string=s}; pointer.id=S " ) ) ;
SimpleOptions * simple = base - > GetOptions < SimpleOptions > ( ) ;
SimpleOptions * simple = base - > GetOptions < SimpleOptions > ( ) ;
@ -561,10 +560,6 @@ TEST_F(CustomizableTest, PrepareOptionsTest) {
ASSERT_NE ( simple - > cu , nullptr ) ;
ASSERT_NE ( simple - > cu , nullptr ) ;
ASSERT_NE ( simple - > cs , nullptr ) ;
ASSERT_NE ( simple - > cs , nullptr ) ;
ASSERT_NE ( simple - > cp , nullptr ) ;
ASSERT_NE ( simple - > cp , nullptr ) ;
ASSERT_TRUE ( base - > IsPrepared ( ) ) ;
ASSERT_TRUE ( simple - > cu - > IsPrepared ( ) ) ;
ASSERT_TRUE ( simple - > cs - > IsPrepared ( ) ) ;
ASSERT_TRUE ( simple - > cp - > IsPrepared ( ) ) ;
delete simple - > cp ;
delete simple - > cp ;
base . reset ( new SimpleConfigurable ( ) ) ;
base . reset ( new SimpleConfigurable ( ) ) ;
ASSERT_OK ( base - > ConfigureFromString (
ASSERT_OK ( base - > ConfigureFromString (
@ -575,16 +570,8 @@ TEST_F(CustomizableTest, PrepareOptionsTest) {
ASSERT_NE ( simple - > cu , nullptr ) ;
ASSERT_NE ( simple - > cu , nullptr ) ;
ASSERT_NE ( simple - > cs , nullptr ) ;
ASSERT_NE ( simple - > cs , nullptr ) ;
ASSERT_NE ( simple - > cp , nullptr ) ;
ASSERT_NE ( simple - > cp , nullptr ) ;
ASSERT_FALSE ( base - > IsPrepared ( ) ) ;
ASSERT_FALSE ( simple - > cu - > IsPrepared ( ) ) ;
ASSERT_FALSE ( simple - > cs - > IsPrepared ( ) ) ;
ASSERT_FALSE ( simple - > cp - > IsPrepared ( ) ) ;
ASSERT_OK ( base - > PrepareOptions ( config_options_ ) ) ;
ASSERT_OK ( base - > PrepareOptions ( config_options_ ) ) ;
ASSERT_TRUE ( base - > IsPrepared ( ) ) ;
ASSERT_TRUE ( simple - > cu - > IsPrepared ( ) ) ;
ASSERT_TRUE ( simple - > cs - > IsPrepared ( ) ) ;
ASSERT_TRUE ( simple - > cp - > IsPrepared ( ) ) ;
delete simple - > cp ;
delete simple - > cp ;
base . reset ( new SimpleConfigurable ( ) ) ;
base . reset ( new SimpleConfigurable ( ) ) ;
simple = base - > GetOptions < SimpleOptions > ( ) ;
simple = base - > GetOptions < SimpleOptions > ( ) ;
@ -597,21 +584,16 @@ TEST_F(CustomizableTest, PrepareOptionsTest) {
ASSERT_OK (
ASSERT_OK (
base - > ConfigureFromString ( prepared , " unique={id=P; can_prepare=true} " ) ) ;
base - > ConfigureFromString ( prepared , " unique={id=P; can_prepare=true} " ) ) ;
ASSERT_NE ( simple - > cu , nullptr ) ;
ASSERT_NE ( simple - > cu , nullptr ) ;
ASSERT_TRUE ( simple - > cu - > IsPrepared ( ) ) ;
ASSERT_OK ( base - > ConfigureFromString ( config_options_ ,
ASSERT_OK ( base - > ConfigureFromString ( config_options_ ,
" unique={id=P; can_prepare=true} " ) ) ;
" unique={id=P; can_prepare=true} " ) ) ;
ASSERT_NE ( simple - > cu , nullptr ) ;
ASSERT_NE ( simple - > cu , nullptr ) ;
ASSERT_FALSE ( simple - > cu - > IsPrepared ( ) ) ;
ASSERT_OK ( simple - > cu - > PrepareOptions ( prepared ) ) ;
ASSERT_OK ( simple - > cu - > PrepareOptions ( prepared ) ) ;
ASSERT_TRUE ( simple - > cu - > IsPrepared ( ) ) ;
ASSERT_OK ( base - > ConfigureFromString ( config_options_ ,
ASSERT_OK ( base - > ConfigureFromString ( config_options_ ,
" unique={id=P; can_prepare=false} " ) ) ;
" unique={id=P; can_prepare=false} " ) ) ;
ASSERT_NE ( simple - > cu , nullptr ) ;
ASSERT_NE ( simple - > cu , nullptr ) ;
ASSERT_FALSE ( simple - > cu - > IsPrepared ( ) ) ;
ASSERT_NOK ( simple - > cu - > PrepareOptions ( prepared ) ) ;
ASSERT_NOK ( simple - > cu - > PrepareOptions ( prepared ) ) ;
ASSERT_FALSE ( simple - > cu - > IsPrepared ( ) ) ;
}
}
namespace {
namespace {
@ -688,6 +670,42 @@ TEST_F(CustomizableTest, WrappedInnerTest) {
ASSERT_EQ ( wc2 - > CheckedCast < TestCustomizable > ( ) , ac . get ( ) ) ;
ASSERT_EQ ( wc2 - > CheckedCast < TestCustomizable > ( ) , ac . get ( ) ) ;
}
}
TEST_F ( CustomizableTest , CopyObjectTest ) {
class CopyCustomizable : public Customizable {
public :
CopyCustomizable ( ) : prepared_ ( 0 ) , validated_ ( 0 ) { }
const char * Name ( ) const override { return " CopyCustomizable " ; }
Status PrepareOptions ( const ConfigOptions & options ) override {
prepared_ + + ;
return Customizable : : PrepareOptions ( options ) ;
}
Status ValidateOptions ( const DBOptions & db_opts ,
const ColumnFamilyOptions & cf_opts ) const override {
validated_ + + ;
return Customizable : : ValidateOptions ( db_opts , cf_opts ) ;
}
int prepared_ ;
mutable int validated_ ;
} ;
CopyCustomizable c1 ;
ConfigOptions config_options ;
Options options ;
ASSERT_OK ( c1 . PrepareOptions ( config_options ) ) ;
ASSERT_OK ( c1 . ValidateOptions ( options , options ) ) ;
ASSERT_EQ ( c1 . prepared_ , 1 ) ;
ASSERT_EQ ( c1 . validated_ , 1 ) ;
CopyCustomizable c2 = c1 ;
ASSERT_OK ( c1 . PrepareOptions ( config_options ) ) ;
ASSERT_OK ( c1 . ValidateOptions ( options , options ) ) ;
ASSERT_EQ ( c2 . prepared_ , 1 ) ;
ASSERT_EQ ( c2 . validated_ , 1 ) ;
ASSERT_EQ ( c1 . prepared_ , 2 ) ;
ASSERT_EQ ( c1 . validated_ , 2 ) ;
}
TEST_F ( CustomizableTest , TestStringDepth ) {
TEST_F ( CustomizableTest , TestStringDepth ) {
class ShallowCustomizable : public Customizable {
class ShallowCustomizable : public Customizable {
public :
public :
@ -983,7 +1001,6 @@ TEST_F(CustomizableTest, MutableOptionsTest) {
std : : string opt_str ;
std : : string opt_str ;
ConfigOptions options = config_options_ ;
ConfigOptions options = config_options_ ;
ASSERT_FALSE ( mc . IsPrepared ( ) ) ;
ASSERT_OK ( mc . ConfigureOption ( options , " mutable " , " {id=B;} " ) ) ;
ASSERT_OK ( mc . ConfigureOption ( options , " mutable " , " {id=B;} " ) ) ;
options . mutable_options_only = true ;
options . mutable_options_only = true ;
ASSERT_OK ( mc . GetOptionString ( options , & opt_str ) ) ;
ASSERT_OK ( mc . GetOptionString ( options , & opt_str ) ) ;