diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-05-18 00:06:37 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-05-18 00:06:37 +0100 |
commit | fcdca58617caf6a8c034a91588d6abb399be6b57 (patch) | |
tree | ad77f8e954a2ed05cd26237a7c665f3adc82b9fe /test/test-bitset.cpp | |
download | mygrate-fcdca58617caf6a8c034a91588d6abb399be6b57.tar.bz2 mygrate-fcdca58617caf6a8c034a91588d6abb399be6b57.tar.xz mygrate-fcdca58617caf6a8c034a91588d6abb399be6b57.zip |
Initial commit, still lots to do!
Diffstat (limited to 'test/test-bitset.cpp')
-rw-r--r-- | test/test-bitset.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test-bitset.cpp b/test/test-bitset.cpp new file mode 100644 index 0000000..83e136c --- /dev/null +++ b/test/test-bitset.cpp @@ -0,0 +1,31 @@ +#define BOOST_TEST_MODULE BitSet +#include <boost/test/data/test_case.hpp> +#include <boost/test/unit_test.hpp> + +#include "helpers.h" +#include <bitset.h> +#include <bitset> + +using namespace MyGrate; + +BOOST_TEST_DONT_PRINT_LOG_VALUE(BitSet::Iterator); + +BOOST_AUTO_TEST_CASE(bitset) +{ + std::byte bytes[3] {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()); +} |