From 9c4bfe4cf9204d8ed9114395054d20a2b6bea482 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 22 Mar 2013 14:53:53 +0000 Subject: [PATCH] endian_t -> gmock --- unit-tests/Makefile.in | 7 ++----- unit-tests/endian_t.cc | 22 ++++++++++------------ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/unit-tests/Makefile.in b/unit-tests/Makefile.in index 0a3574a..353ac9f 100644 --- a/unit-tests/Makefile.in +++ b/unit-tests/Makefile.in @@ -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) g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT) -unit-tests/endian_t: unit-tests/endian_t.o $(OBJECTS) - g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT) - - #---------------------------------------------------------------- # gmock tests @@ -86,7 +82,8 @@ MOCK_SOURCE=\ unit-tests/bitset_t.cc \ unit-tests/block_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 # include paths. diff --git a/unit-tests/endian_t.cc b/unit-tests/endian_t.cc index 814d0a4..b055318 100644 --- a/unit-tests/endian_t.cc +++ b/unit-tests/endian_t.cc @@ -16,19 +16,17 @@ // with thin-provisioning-tools. If not, see // . +#include "gmock/gmock.h" #include "persistent-data/space-maps/disk.h" -#define BOOST_TEST_MODULE EndianTests -#include - using namespace base; -using namespace boost; using namespace persistent_data; using namespace std; +using namespace testing; //---------------------------------------------------------------- -BOOST_AUTO_TEST_CASE(bitmaps) +TEST(EndianTests, bitmaps) { unsigned NR_BITS = 10247; vector data((NR_BITS + 63) / 64, 0); @@ -36,7 +34,7 @@ BOOST_AUTO_TEST_CASE(bitmaps) // check all bits are zero void *bits = &data[0]; 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 for (unsigned i = 0; i < NR_BITS; i++) @@ -44,7 +42,7 @@ BOOST_AUTO_TEST_CASE(bitmaps) // check they're all 1 now 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 for (unsigned i = 0; i < NR_BITS; i += 3) @@ -53,13 +51,13 @@ BOOST_AUTO_TEST_CASE(bitmaps) // check everything is as we expect for (unsigned i = 0; i < NR_BITS; i++) { if ((i % 3) == 0) - BOOST_CHECK(!test_bit_le(bits, i)); + ASSERT_FALSE(test_bit_le(bits, i)); 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; vector data((NR_BITS + 63) / 64, 0); @@ -67,13 +65,13 @@ BOOST_AUTO_TEST_CASE(bitmaps_alternate_words) // check all bits are zero void *bits = &data[0]; 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++) set_bit_le(bits, i); for (unsigned i = 64; i < 128; i++) - BOOST_CHECK(!test_bit_le(bits, i)); + ASSERT_FALSE(test_bit_le(bits, i)); } //----------------------------------------------------------------