fixing typo in config tests

This commit is contained in:
mike@arpaia.co 2014-11-18 18:06:33 -08:00
parent ee15228819
commit 756f755aa4
2 changed files with 6 additions and 5 deletions

View File

@ -2,6 +2,7 @@
#include <algorithm>
#include <future>
#include <random>
#include <sstream>
#include <string>
#include <vector>
@ -112,6 +113,8 @@ int Config::splayValue(int original, int splayPercent) {
return max_value;
}
return (rand() % (max_value - min_value)) + min_value;
std::default_random_engine generator;
std::uniform_int_distribution<int> distribution(min_value, max_value);
return distribution(generator);
}
}

View File

@ -59,14 +59,12 @@ TEST_F(ConfigTests, test_splay) {
EXPECT_GE(val2, 90);
EXPECT_LE(val2, 110);
EXPECT_NE(val1, val2);
auto val3 = Config::splayValue(10, 0);
EXPECT_EQ(val3, 10);
auto val4 = Config::splayValue(100, 1);
EXPECT_GE(val2, 99);
EXPECT_LE(val2, 101);
EXPECT_GE(val4, 99);
EXPECT_LE(val4, 101);
auto val5 = Config::splayValue(1, 10);
EXPECT_EQ(val5, 1);