File: fast_set.cpp

package info (click to toggle)
terraphast 0.0%2Bgit20200413.8af2e4c%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 812 kB
  • sloc: cpp: 5,923; sh: 93; ansic: 55; makefile: 26
file content (38 lines) | stat: -rw-r--r-- 752 bytes parent folder | download | duplicates (3)
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_t>> 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_t count = 0;
	for (auto&& el : set) {
		(void)el;
		++count;
	}
	CHECK(count == set.count());
}

} // namespace tests
} // namespace terraces