Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: trying to fix sonar in interval_test #2309

Open
wants to merge 8 commits into
base: unstable
Choose a base branch
from
14 changes: 11 additions & 3 deletions tests/cppunit/interval_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include <gtest/gtest.h>

#include <random>

#include "search/ir.h"

using namespace kqir;
Expand Down Expand Up @@ -68,10 +70,16 @@ TEST(IntervalSet, Simple) {
IntervalSet({2, 5}) | IntervalSet({7, 8}));
ASSERT_EQ(~IntervalSet({2, 8}), IntervalSet({IntervalSet::minf, 2}) | IntervalSet({8, IntervalSet::inf}));

std::uniform_real_distribution<double> dist;
std::uniform_int_distribution<int> dist_int(0, 50);
std::random_device rd{};
// Using random seed 0
std::mt19937 rand_gen(rd());
for (auto i = 0; i < 2000; ++i) {
auto gen = [] { return static_cast<double>(std::rand()) / 100; };
auto geni = [&gen] {
auto r = std::rand() % 50;
// generate random double
auto gen = [&dist, &rand_gen] { return dist(rand_gen); };
auto geni = [&dist_int, &rand_gen, &gen] {
int r = dist_int(rand_gen);
if (r == 0) {
return IntervalSet(NumericCompareExpr::GET, gen());
} else if (r == 1) {
Expand Down
Loading