Written a test case to test size on loading
This commit is contained in:
parent
e52da598f4
commit
e585d12511
@ -3,17 +3,40 @@
|
||||
#include "test/testutils/TempFile.h"
|
||||
|
||||
#include "blobstore/implementations/ondisk/OnDiskBlob.h"
|
||||
#include "blobstore/implementations/ondisk/Data.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using ::testing::Test;
|
||||
using ::testing::WithParamInterface;
|
||||
using ::testing::Values;
|
||||
|
||||
using std::ofstream;
|
||||
using std::unique_ptr;
|
||||
using std::ios;
|
||||
|
||||
using blobstore::ondisk::OnDiskBlob;
|
||||
using namespace blobstore::ondisk;
|
||||
|
||||
namespace bf = boost::filesystem;
|
||||
|
||||
class OnDiskBlobLoadTest: public Test {
|
||||
public:
|
||||
TempFile file;
|
||||
|
||||
void SetFileSize(size_t size) {
|
||||
Data data(size);
|
||||
ofstream writer(file.path().c_str(), ios::trunc | ios::binary);
|
||||
writer.write((char*)data.data(), size);
|
||||
}
|
||||
};
|
||||
|
||||
class OnDiskBlobLoadSizeTest: public OnDiskBlobLoadTest, public WithParamInterface<size_t> {};
|
||||
INSTANTIATE_TEST_CASE_P(OnDiskBlobLoadSizeTest, OnDiskBlobLoadSizeTest, Values(0, 1, 5, 1024, 10*1024*1024));
|
||||
|
||||
TEST_P(OnDiskBlobLoadSizeTest, FileSizeIsCorrect) {
|
||||
SetFileSize(GetParam());
|
||||
|
||||
auto blob = OnDiskBlob::LoadFromDisk(file.path());
|
||||
|
||||
EXPECT_EQ(GetParam(), blob->size());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user