File: fast_set.cpp

package info (click to toggle)
iqtree 2.0.7%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,700 kB
  • sloc: cpp: 142,571; ansic: 57,789; sh: 275; python: 242; makefile: 95
file content (38 lines) | stat: -rw-r--r-- 748 bytes parent folder | download | duplicates (2)
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
36
37
38
#include <catch.hpp>

#include "../lib/ranked_bitvector.hpp"

namespace terraces {
namespace tests {

TEST_CASE("fast_set1", "[fast_set]") {
	basic_ranked_bitvector<std::allocator<index>> set{10, {}};
	for (auto&& el : set) {
		(void)el;
		FAIL("element in empty set!");
	}
	set.set(4);
	set.update_ranks();
	CHECK(*set.begin() == 4);
	CHECK((++set.begin()) == set.end());
	CHECK(set.get(4));
	CHECK(!set.get(5));
	set.clr(4);
	set.set(5);
	set.update_ranks();
	CHECK(!set.get(4));
	CHECK(set.get(5));
	CHECK(*set.begin() == 5);
	CHECK((++set.begin()) == set.end());
	set.set(2);
	set.update_ranks();
	index count = 0;
	for (auto&& el : set) {
		(void)el;
		++count;
	}
	CHECK(count == set.count());
}

} // namespace tests
} // namespace terraces