endian_t -> gmock
This commit is contained in:
parent
28128624eb
commit
9c4bfe4cf9
@ -52,10 +52,6 @@ unit-tests/transaction_manager_t: unit-tests/transaction_manager_t.o $(OBJECTS)
|
|||||||
unit-tests/metadata_t: unit-tests/metadata_t.o $(OBJECTS)
|
unit-tests/metadata_t: unit-tests/metadata_t.o $(OBJECTS)
|
||||||
g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
|
g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
|
||||||
|
|
||||||
unit-tests/endian_t: unit-tests/endian_t.o $(OBJECTS)
|
|
||||||
g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
# gmock tests
|
# gmock tests
|
||||||
|
|
||||||
@ -86,7 +82,8 @@ MOCK_SOURCE=\
|
|||||||
unit-tests/bitset_t.cc \
|
unit-tests/bitset_t.cc \
|
||||||
unit-tests/block_t.cc \
|
unit-tests/block_t.cc \
|
||||||
unit-tests/buffer_t.cc \
|
unit-tests/buffer_t.cc \
|
||||||
unit-tests/cache_t.cc
|
unit-tests/cache_t.cc \
|
||||||
|
unit-tests/endian_t.cc
|
||||||
|
|
||||||
# .gmo files are plain .o files, only they've been built with gmock
|
# .gmo files are plain .o files, only they've been built with gmock
|
||||||
# include paths.
|
# include paths.
|
||||||
|
@ -16,19 +16,17 @@
|
|||||||
// with thin-provisioning-tools. If not, see
|
// with thin-provisioning-tools. If not, see
|
||||||
// <http://www.gnu.org/licenses/>.
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "gmock/gmock.h"
|
||||||
#include "persistent-data/space-maps/disk.h"
|
#include "persistent-data/space-maps/disk.h"
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE EndianTests
|
|
||||||
#include <boost/test/included/unit_test.hpp>
|
|
||||||
|
|
||||||
using namespace base;
|
using namespace base;
|
||||||
using namespace boost;
|
|
||||||
using namespace persistent_data;
|
using namespace persistent_data;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace testing;
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(bitmaps)
|
TEST(EndianTests, bitmaps)
|
||||||
{
|
{
|
||||||
unsigned NR_BITS = 10247;
|
unsigned NR_BITS = 10247;
|
||||||
vector<uint64_t> data((NR_BITS + 63) / 64, 0);
|
vector<uint64_t> data((NR_BITS + 63) / 64, 0);
|
||||||
@ -36,7 +34,7 @@ BOOST_AUTO_TEST_CASE(bitmaps)
|
|||||||
// check all bits are zero
|
// check all bits are zero
|
||||||
void *bits = &data[0];
|
void *bits = &data[0];
|
||||||
for (unsigned i = 0; i < NR_BITS; i++)
|
for (unsigned i = 0; i < NR_BITS; i++)
|
||||||
BOOST_CHECK(!test_bit_le(bits, i));
|
ASSERT_FALSE(test_bit_le(bits, i));
|
||||||
|
|
||||||
// set all bits to one
|
// set all bits to one
|
||||||
for (unsigned i = 0; i < NR_BITS; i++)
|
for (unsigned i = 0; i < NR_BITS; i++)
|
||||||
@ -44,7 +42,7 @@ BOOST_AUTO_TEST_CASE(bitmaps)
|
|||||||
|
|
||||||
// check they're all 1 now
|
// check they're all 1 now
|
||||||
for (unsigned i = 0; i < NR_BITS; i++)
|
for (unsigned i = 0; i < NR_BITS; i++)
|
||||||
BOOST_CHECK(test_bit_le(bits, i));
|
ASSERT_TRUE(test_bit_le(bits, i));
|
||||||
|
|
||||||
// clear every third bit
|
// clear every third bit
|
||||||
for (unsigned i = 0; i < NR_BITS; i += 3)
|
for (unsigned i = 0; i < NR_BITS; i += 3)
|
||||||
@ -53,13 +51,13 @@ BOOST_AUTO_TEST_CASE(bitmaps)
|
|||||||
// check everything is as we expect
|
// check everything is as we expect
|
||||||
for (unsigned i = 0; i < NR_BITS; i++) {
|
for (unsigned i = 0; i < NR_BITS; i++) {
|
||||||
if ((i % 3) == 0)
|
if ((i % 3) == 0)
|
||||||
BOOST_CHECK(!test_bit_le(bits, i));
|
ASSERT_FALSE(test_bit_le(bits, i));
|
||||||
else
|
else
|
||||||
BOOST_CHECK(test_bit_le(bits, i));
|
ASSERT_TRUE(test_bit_le(bits, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(bitmaps_alternate_words)
|
TEST(EndianTests, bitmaps_alternate_words)
|
||||||
{
|
{
|
||||||
unsigned NR_BITS = 10247;
|
unsigned NR_BITS = 10247;
|
||||||
vector<uint64_t> data((NR_BITS + 63) / 64, 0);
|
vector<uint64_t> data((NR_BITS + 63) / 64, 0);
|
||||||
@ -67,13 +65,13 @@ BOOST_AUTO_TEST_CASE(bitmaps_alternate_words)
|
|||||||
// check all bits are zero
|
// check all bits are zero
|
||||||
void *bits = &data[0];
|
void *bits = &data[0];
|
||||||
for (unsigned i = 0; i < 128; i++)
|
for (unsigned i = 0; i < 128; i++)
|
||||||
BOOST_CHECK(!test_bit_le(bits, i));
|
ASSERT_FALSE(test_bit_le(bits, i));
|
||||||
|
|
||||||
for (unsigned i = 0; i < 64; i++)
|
for (unsigned i = 0; i < 64; i++)
|
||||||
set_bit_le(bits, i);
|
set_bit_le(bits, i);
|
||||||
|
|
||||||
for (unsigned i = 64; i < 128; i++)
|
for (unsigned i = 64; i < 128; i++)
|
||||||
BOOST_CHECK(!test_bit_le(bits, i));
|
ASSERT_FALSE(test_bit_le(bits, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user