summaryrefslogtreecommitdiff
path: root/test/test-bitset.cpp
blob: 02b389386c90b49ae8a83639552d0389712c6eec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#define BOOST_TEST_MODULE BitSet
#include <boost/test/unit_test.hpp>

#include "helpers.h"
#include <array>
#include <bitset.h>
#include <bitset>
#include <cstddef>
#include <span>

using namespace MyGrate;

// LCOV_EXCL_START
BOOST_TEST_DONT_PRINT_LOG_VALUE(BitSet::Iterator);
// LCOV_EXCL_STOP

BOOST_AUTO_TEST_CASE(bitset)
{
	constexpr std::array<std::byte, 3> bytes {0x00_b, 0xFF_b, 0xa1_b};
	BitSet bs {bytes};

	BOOST_REQUIRE_EQUAL(bs.size(), 24);

	std::bitset<24> exp {0xa1ff00};

	auto iter {bs.begin()};

	for (auto x {0U}; x < 24 && iter != bs.end(); x++) {
		BOOST_TEST_INFO(x);
		BOOST_CHECK_EQUAL(*iter, exp.test(x));
		iter++;
	}

	BOOST_CHECK_EQUAL(iter, bs.end());
}