Added test cases for resizing blobs

This commit is contained in:
Sebastian Messmer 2015-03-05 22:34:51 +01:00
parent 8b7a76c38a
commit f834f8892d
3 changed files with 59 additions and 9 deletions

View File

@ -1,8 +0,0 @@
#include "testutils/BlobStoreTest.h"
class BlobOnBlocksTest: public BlobStoreTest {};
TEST_F(BlobOnBlocksTest, CreatedBlobIsEmpty) {
auto blob = blobStore->create();
EXPECT_EQ(0, blob->size());
}

View File

@ -0,0 +1,58 @@
#include "testutils/BlobStoreTest.h"
using std::unique_ptr;
using namespace blobstore;
class BlobResizeTest: public BlobStoreTest {
public:
BlobResizeTest(): blob(blobStore->create()) {}
static constexpr uint32_t LARGE_SIZE = 10 * 1024 * 1024;
unique_ptr<Blob> blob;
};
constexpr uint32_t BlobResizeTest::LARGE_SIZE;
TEST_F(BlobResizeTest, CreatedBlobIsEmpty) {
EXPECT_EQ(0, blob->size());
}
TEST_F(BlobResizeTest, Growing_1Byte) {
blob->resize(1);
EXPECT_EQ(1, blob->size());
}
TEST_F(BlobResizeTest, Growing_Large) {
blob->resize(LARGE_SIZE);
EXPECT_EQ(LARGE_SIZE, blob->size());
}
TEST_F(BlobResizeTest, Shrinking_Empty) {
blob->resize(LARGE_SIZE);
blob->resize(0);
EXPECT_EQ(0, blob->size());
}
TEST_F(BlobResizeTest, Shrinking_1Byte) {
blob->resize(LARGE_SIZE);
blob->resize(1);
EXPECT_EQ(1, blob->size());
}
TEST_F(BlobResizeTest, ResizingToItself_Empty) {
blob->resize(0);
EXPECT_EQ(0, blob->size());
}
TEST_F(BlobResizeTest, ResizingToItself_1Byte) {
blob->resize(1);
blob->resize(1);
EXPECT_EQ(1, blob->size());
}
TEST_F(BlobResizeTest, ResizingToItself_Large) {
blob->resize(LARGE_SIZE);
blob->resize(LARGE_SIZE);
EXPECT_EQ(LARGE_SIZE, blob->size());
}

View File

@ -6,7 +6,7 @@ class BlobStoreTest: public ::testing::Test {
public:
BlobStoreTest();
static constexpr uint32_t BLOCKSIZE_BYTES = 256;
static constexpr uint32_t BLOCKSIZE_BYTES = 4096;
std::unique_ptr<blobstore::BlobStore> blobStore;
};