39 TEST(EqRelTest, Scoping) {
46 TEST(EqRelTest, Basic) {
75 TEST(EqRelTest, Clear) {
97 TEST(EqRelTest, Duplicates) {
100 for (
int i = 0;
i < 10; ++
i) {
105 for (
int i = 0;
i < 10; ++
i) {
121 TEST(EqRelTest, TransitivityTest) {
144 TEST(EqRelTest, PairwiseIncremental) {
147 const size_t N = 100;
149 for (
size_t i = 1;
i < N; ++
i) {
152 br.insert(
i + (N + 1),
i);
166 TEST(EqRelTest, PairwiseDecremental) {
169 const size_t N = 100;
171 for (
size_t i = N;
i > 1; --
i) {
174 br.insert(
i + (N + 1),
i);
189 TEST(EqRelTest, Shuffled) {
194 std::vector<int>
data;
195 for (
size_t i = 0;
i < N;
i++) {
198 std::random_device rd;
199 std::mt19937 generator(rd());
203 for (
auto x :
data) {
207 for (
size_t i = 0;
i < N; ++
i) {
222 TEST(EqRelTest, Extend) {
240 EXPECT_EQ(br.size(), (7 * 7) + (2 * 2) + (2 * 2) + (1 * 1));
276 EXPECT_EQ(br.size(), (7 * 7) + (2 * 2) + (2 * 2) + (1 * 1));
281 TEST(EqRelTest, Merge) {
287 std::vector<int>
data;
288 for (
int i = 0;
i < N;
i++) {
291 std::random_device rd;
292 std::mt19937 generator(rd());
294 shuffle(
data.begin(),
data.end(), generator);
296 for (
int i = 0;
i < N;
i++) {
301 br.insert(N - 1, N + 1);
349 TEST(EqRelTest, IterEmpty) {
359 TEST(EqRelTest, IterBasic) {
383 TEST(EqRelTest, IterRange) {
397 auto rangeIt = br.getBoundaries<1>({{3, 18293018}});
399 std::vector<size_t> posteriorsCovered;
400 for (
auto tup : rangeIt) {
401 posteriorsCovered.push_back(tup[1]);
406 rangeIt = br.getBoundaries<0>({{332, 888}});
407 posteriorsCovered.clear();
408 for (
auto tup : rangeIt) {
409 posteriorsCovered.push_back(tup[1]);
411 EXPECT_EQ(posteriorsCovered.size(), (7 * 7) + (3 * 3));
414 rangeIt = br.getBoundaries<2>({{2, 3}});
415 posteriorsCovered.clear();
416 for (
auto tup : rangeIt) {
417 posteriorsCovered.push_back(tup[1]);
423 rangeIt = br.getBoundaries<1>({{99, 99}});
424 posteriorsCovered.clear();
425 for (
auto tup : rangeIt) {
426 posteriorsCovered.push_back(tup[1]);
430 rangeIt = br.getBoundaries<2>({{8, 1}});
431 posteriorsCovered.clear();
432 for (
auto tup : rangeIt) {
433 posteriorsCovered.push_back(tup[1]);
441 auto rangeIt = br.getBoundaries<1>({{3, 18293018}});
443 std::vector<size_t> posteriorsCovered;
444 for (
auto tup : rangeIt) {
445 posteriorsCovered.push_back(tup[1]);
450 rangeIt = br.getBoundaries<0>({{332, 888}});
451 posteriorsCovered.clear();
452 for (
auto tup : rangeIt) {
453 posteriorsCovered.push_back(tup[1]);
458 rangeIt = br.getBoundaries<2>({{2, 3}});
459 posteriorsCovered.clear();
460 for (
auto tup : rangeIt) {
461 posteriorsCovered.push_back(tup[1]);
466 rangeIt = br.getBoundaries<1>({{99, 99}});
467 posteriorsCovered.clear();
468 for (
auto tup : rangeIt) {
469 posteriorsCovered.push_back(tup[1]);
473 rangeIt = br.getBoundaries<2>({{8, 1}});
474 posteriorsCovered.clear();
475 for (
auto tup : rangeIt) {
476 posteriorsCovered.push_back(tup[1]);
482 TEST(EqRelTest, IterPartition) {
487 std::vector<std::pair<RamDomain, RamDomain>> values;
493 EXPECT_EQ(
size_t((N + 1) * (N + 1)), br.size());
495 auto chunks = br.partition(400);
499 for (
auto chunk : chunks) {
500 for (
auto x : chunk) {
501 values.push_back(std::make_pair(x[0], x[1]));
515 EXPECT_EQ((
size_t)4 * 1000 / 2, br.size());
517 chunks = br.partition(400);
518 for (
auto chunk : chunks) {
519 for (
auto x : chunk) {
520 values.push_back(std::make_pair(x[0], x[1]));
527 TEST(EqRelTest, Scaling) {
531 for (
int i = 0;
i < N; ++
i) {
539 TEST(EqRelTest, ParallelScaling) {
543 const int N = 100000;
544 std::vector<int> data1;
545 std::vector<int> data2;
546 for (
int i = 0;
i < N; ++
i)
548 for (
int i = 0;
i < N; ++
i)
551 std::random_device rd;
552 std::mt19937 generator(rd());
554 shuffle(data1.begin(), data1.end(), generator);
555 shuffle(data2.begin(), data2.end(), generator);
557 std::cout <<
"number of threads: " << omp_get_max_threads() << std::endl;
560 #pragma omp parallel for
561 for (
int i = 0;
i < N;
i++) {
568 if (N != br.
size()) {
569 throw std::runtime_error(
"here's a gdb trap");