endian_t -> gmock
This commit is contained 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. | ||||
|   | ||||
| @@ -16,19 +16,17 @@ | ||||
| // with thin-provisioning-tools.  If not, see | ||||
| // <http://www.gnu.org/licenses/>. | ||||
|  | ||||
| #include "gmock/gmock.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 boost; | ||||
| using namespace persistent_data; | ||||
| using namespace std; | ||||
| using namespace testing; | ||||
|  | ||||
| //---------------------------------------------------------------- | ||||
|  | ||||
| BOOST_AUTO_TEST_CASE(bitmaps) | ||||
| TEST(EndianTests, bitmaps) | ||||
| { | ||||
| 	unsigned NR_BITS = 10247; | ||||
| 	vector<uint64_t> 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<uint64_t> 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)); | ||||
| } | ||||
|  | ||||
| //---------------------------------------------------------------- | ||||
|   | ||||
		Reference in New Issue
	
	Block a user