a44b6318e2
- Implemented BlobOnBlocks::read() and write(). Not tested yet.
79 lines
2.3 KiB
C++
79 lines
2.3 KiB
C++
#include <google/gtest/gtest.h>
|
|
#include "../../../../implementations/onblocks/utils/Math.h"
|
|
|
|
#include <limits>
|
|
|
|
using namespace blobstore::onblocks::utils;
|
|
using ::testing::Test;
|
|
using std::numeric_limits;
|
|
|
|
class MaxZeroSubtractionTest: public Test {};
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractToZero1) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(0, 0));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractToZero2) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(5, 5));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractToZero3) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(184930, 184930));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractToZero4) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(numeric_limits<uint32_t>::max()-1, numeric_limits<uint32_t>::max()-1));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractToZero5) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(numeric_limits<uint32_t>::max(), numeric_limits<uint32_t>::max()));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractPositive1) {
|
|
EXPECT_EQ(1, maxZeroSubtraction(5, 4));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractPositive2) {
|
|
EXPECT_EQ(181081, maxZeroSubtraction(184930, 3849));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractPositive3) {
|
|
EXPECT_EQ(numeric_limits<uint32_t>::max()-1, maxZeroSubtraction(numeric_limits<uint32_t>::max(), 1));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractPositive4) {
|
|
EXPECT_EQ(5, maxZeroSubtraction(numeric_limits<uint32_t>::max(), numeric_limits<uint32_t>::max()-5));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractNegative1) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(4, 5));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractNegative2) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(3849, 184930));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractNegative3) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(numeric_limits<uint32_t>::max()-1, numeric_limits<uint32_t>::max()));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractNegative4) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(numeric_limits<uint32_t>::max()-5, numeric_limits<uint32_t>::max()));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractNegative5) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(5, numeric_limits<uint32_t>::max()));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractFromZero1) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(0, 1));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractFromZero2) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(0, 184930));
|
|
}
|
|
|
|
TEST_F(MaxZeroSubtractionTest, SubtractFromZero3) {
|
|
EXPECT_EQ(0, maxZeroSubtraction(0, numeric_limits<uint32_t>::max()));
|
|
}
|