@ -168,13 +168,13 @@ class MemFile {
namespace {
namespace {
class SequentialFileImpl : public SequentialFile {
class Mock SequentialFile : public SequentialFile {
public :
public :
explicit SequentialFileImpl ( MemFile * file ) : file_ ( file ) , pos_ ( 0 ) {
explicit Mock SequentialFile( MemFile * file ) : file_ ( file ) , pos_ ( 0 ) {
file_ - > Ref ( ) ;
file_ - > Ref ( ) ;
}
}
~ SequentialFileImpl ( ) {
~ Mock SequentialFile( ) {
file_ - > Unref ( ) ;
file_ - > Unref ( ) ;
}
}
@ -203,13 +203,13 @@ class SequentialFileImpl : public SequentialFile {
size_t pos_ ;
size_t pos_ ;
} ;
} ;
class RandomAccessFileImpl : public RandomAccessFile {
class Mock RandomAccessFile : public RandomAccessFile {
public :
public :
explicit RandomAccessFileImpl ( MemFile * file ) : file_ ( file ) {
explicit Mock RandomAccessFile( MemFile * file ) : file_ ( file ) {
file_ - > Ref ( ) ;
file_ - > Ref ( ) ;
}
}
~ RandomAccessFileImpl ( ) {
~ Mock RandomAccessFile( ) {
file_ - > Unref ( ) ;
file_ - > Unref ( ) ;
}
}
@ -222,15 +222,15 @@ class RandomAccessFileImpl : public RandomAccessFile {
MemFile * file_ ;
MemFile * file_ ;
} ;
} ;
class WritableFileImpl : public WritableFile {
class Mock WritableFile : public WritableFile {
public :
public :
WritableFileImpl ( MemFile * file , RateLimiter * rate_limiter )
Mock WritableFile( MemFile * file , RateLimiter * rate_limiter )
: file_ ( file ) ,
: file_ ( file ) ,
rate_limiter_ ( rate_limiter ) {
rate_limiter_ ( rate_limiter ) {
file_ - > Ref ( ) ;
file_ - > Ref ( ) ;
}
}
~ WritableFileImpl ( ) {
~ Mock WritableFile( ) {
file_ - > Unref ( ) ;
file_ - > Unref ( ) ;
}
}
@ -424,7 +424,7 @@ Status MockEnv::NewSequentialFile(const std::string& fname,
if ( f - > is_lock_file ( ) ) {
if ( f - > is_lock_file ( ) ) {
return Status : : InvalidArgument ( fn , " Cannot open a lock file. " ) ;
return Status : : InvalidArgument ( fn , " Cannot open a lock file. " ) ;
}
}
result - > reset ( new SequentialFileImpl ( f ) ) ;
result - > reset ( new Mock SequentialFile( f ) ) ;
return Status : : OK ( ) ;
return Status : : OK ( ) ;
}
}
@ -441,7 +441,7 @@ Status MockEnv::NewRandomAccessFile(const std::string& fname,
if ( f - > is_lock_file ( ) ) {
if ( f - > is_lock_file ( ) ) {
return Status : : InvalidArgument ( fn , " Cannot open a lock file. " ) ;
return Status : : InvalidArgument ( fn , " Cannot open a lock file. " ) ;
}
}
result - > reset ( new RandomAccessFileImpl ( f ) ) ;
result - > reset ( new Mock RandomAccessFile( f ) ) ;
return Status : : OK ( ) ;
return Status : : OK ( ) ;
}
}
@ -457,7 +457,7 @@ Status MockEnv::NewWritableFile(const std::string& fname,
file - > Ref ( ) ;
file - > Ref ( ) ;
file_map_ [ fn ] = file ;
file_map_ [ fn ] = file ;
result - > reset ( new WritableFileImpl ( file , env_options . rate_limiter ) ) ;
result - > reset ( new Mock WritableFile( file , env_options . rate_limiter ) ) ;
return Status : : OK ( ) ;
return Status : : OK ( ) ;
}
}
@ -613,7 +613,7 @@ Status MockEnv::NewLogger(const std::string& fname,
} else {
} else {
file = iter - > second ;
file = iter - > second ;
}
}
std : : unique_ptr < WritableFile > f ( new WritableFileImpl ( file , nullptr ) ) ;
std : : unique_ptr < WritableFile > f ( new Mock WritableFile( file , nullptr ) ) ;
result - > reset ( new TestMemLogger ( std : : move ( f ) , this ) ) ;
result - > reset ( new TestMemLogger ( std : : move ( f ) , this ) ) ;
return Status : : OK ( ) ;
return Status : : OK ( ) ;
}
}