From f834f8892dedc31fb3f507a4a584ae80b7dfc7bb Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Thu, 5 Mar 2015 22:34:51 +0100 Subject: [PATCH] Added test cases for resizing blobs --- .../onblocks/BlobOnBlocksTest.cpp | 8 --- .../onblocks/BlobResizeTest.cpp | 58 +++++++++++++++++++ .../onblocks/testutils/BlobStoreTest.h | 2 +- 3 files changed, 59 insertions(+), 9 deletions(-) delete mode 100644 test/implementations/onblocks/BlobOnBlocksTest.cpp create mode 100644 test/implementations/onblocks/BlobResizeTest.cpp diff --git a/test/implementations/onblocks/BlobOnBlocksTest.cpp b/test/implementations/onblocks/BlobOnBlocksTest.cpp deleted file mode 100644 index 6c1f17a4..00000000 --- a/test/implementations/onblocks/BlobOnBlocksTest.cpp +++ /dev/null @@ -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()); -} diff --git a/test/implementations/onblocks/BlobResizeTest.cpp b/test/implementations/onblocks/BlobResizeTest.cpp new file mode 100644 index 00000000..6a10fdbb --- /dev/null +++ b/test/implementations/onblocks/BlobResizeTest.cpp @@ -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; +}; +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()); +} diff --git a/test/implementations/onblocks/testutils/BlobStoreTest.h b/test/implementations/onblocks/testutils/BlobStoreTest.h index e5e5c5e7..d81a9369 100644 --- a/test/implementations/onblocks/testutils/BlobStoreTest.h +++ b/test/implementations/onblocks/testutils/BlobStoreTest.h @@ -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; };