Skip to content

Commit

Permalink
Trying to fix sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed May 13, 2024
1 parent 1e23484 commit 87a0496
Showing 1 changed file with 11 additions and 3 deletions.
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

0 comments on commit 87a0496

Please sign in to comment.