libcryfs/test/implementations/onblocks/utils/IntPowTest.cpp
Sebastian Messmer a44b6318e2 - Refactor math functions for reuse (and write test cases for them)
- Implemented BlobOnBlocks::read() and write(). Not tested yet.
2015-02-26 20:19:12 +01:00

73 lines
1.3 KiB
C++

#include <google/gtest/gtest.h>
#include "../../../../implementations/onblocks/utils/Math.h"
using namespace blobstore::onblocks::utils;
using ::testing::Test;
class IntPowTest: public Test {};
TEST_F(IntPowTest, ExponentAndBaseAreZero) {
EXPECT_EQ(1, intPow(0, 0));
}
TEST_F(IntPowTest, ExponentIsZero1) {
EXPECT_EQ(1, intPow(1, 0));
}
TEST_F(IntPowTest, ExponentIsZero2) {
EXPECT_EQ(1, intPow(1000, 0));
}
TEST_F(IntPowTest, BaseIsZero1) {
EXPECT_EQ(0, intPow(0, 1));
}
TEST_F(IntPowTest, BaseIsZero2) {
EXPECT_EQ(0, intPow(0, 1000));
}
TEST_F(IntPowTest, ExponentIsOne1) {
EXPECT_EQ(0, intPow(0, 1));
}
TEST_F(IntPowTest, ExponentIsOne2) {
EXPECT_EQ(2, intPow(2, 1));
}
TEST_F(IntPowTest, ExponentIsOne3) {
EXPECT_EQ(1000, intPow(1000, 1));
}
TEST_F(IntPowTest, BaseIsTwo1) {
EXPECT_EQ(1024, intPow(2, 10));
}
TEST_F(IntPowTest, BaseIsTwo2) {
EXPECT_EQ(1024*1024, intPow(2, 20));
}
TEST_F(IntPowTest, BaseIsTwo3) {
EXPECT_EQ(1024*1024*1024, intPow(2, 30));
}
TEST_F(IntPowTest, BaseIsTen1) {
EXPECT_EQ(100, intPow(10, 2));
}
TEST_F(IntPowTest, BaseIsTen2) {
EXPECT_EQ(1000000, intPow(10, 6));
}
TEST_F(IntPowTest, ArbitraryNumbers1) {
EXPECT_EQ(4096, intPow(4, 6));
}
TEST_F(IntPowTest, ArbitraryNumbers2) {
EXPECT_EQ(1296, intPow(6, 4));
}
TEST_F(IntPowTest, ArbitraryNumbers3) {
EXPECT_EQ(282475249, intPow(7, 10));
}