Skip to content

Commit

Permalink
[ML] Replace boost::size in model unit tests (elastic#1517)
Browse files Browse the repository at this point in the history
Use modern C++ data structures, initialisation to remove the need for
boost::size.

Use uniform braced initialisation of variables consistently.
  • Loading branch information
edsavage authored Sep 30, 2020
1 parent 7930716 commit 53216fe
Show file tree
Hide file tree
Showing 6 changed files with 717 additions and 736 deletions.
18 changes: 9 additions & 9 deletions lib/model/unittest/CCountingModelTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ const std::string EMPTY_STRING;
class CTestFixture : public CModelTestFixtureBase {};

BOOST_FIXTURE_TEST_CASE(testSkipSampling, CTestFixture) {
core_t::TTime startTime(100);
core_t::TTime bucketLength(100);
std::size_t maxAgeBuckets(1);
core_t::TTime startTime{100};
core_t::TTime bucketLength{100};
std::size_t maxAgeBuckets{1};

SModelParams params(bucketLength);
params.s_DecayRate = 0.001;
Expand Down Expand Up @@ -144,8 +144,8 @@ BOOST_FIXTURE_TEST_CASE(testSkipSampling, CTestFixture) {
}

BOOST_FIXTURE_TEST_CASE(testCheckScheduledEvents, CTestFixture) {
core_t::TTime startTime(100);
core_t::TTime bucketLength(100);
core_t::TTime startTime{100};
core_t::TTime bucketLength{100};

SModelParams params(bucketLength);

Expand Down Expand Up @@ -247,8 +247,8 @@ BOOST_FIXTURE_TEST_CASE(testCheckScheduledEvents, CTestFixture) {
BOOST_FIXTURE_TEST_CASE(testInterimBucketCorrector, CTestFixture) {
// Check that we correctly update estimate bucket completeness.

core_t::TTime time(0);
core_t::TTime bucketLength(600);
core_t::TTime time{0};
core_t::TTime bucketLength{600};

SModelParams params(bucketLength);
params.s_DecayRate = 0.001;
Expand All @@ -270,7 +270,7 @@ BOOST_FIXTURE_TEST_CASE(testInterimBucketCorrector, CTestFixture) {
TDoubleVec uniform01;
TSizeVec offsets;

for (std::size_t i = 0; i < 10; ++i, time += bucketLength) {
for (std::size_t i = 0u; i < 10; ++i, time += bucketLength) {
rng.generateUniformSamples(0, bucketLength, 10, offsets);
std::sort(offsets.begin(), offsets.end());
for (auto offset : offsets) {
Expand All @@ -285,7 +285,7 @@ BOOST_FIXTURE_TEST_CASE(testInterimBucketCorrector, CTestFixture) {
rng.generateUniformSamples(0, bucketLength, 10, offsets);
std::sort(offsets.begin(), offsets.end());

for (std::size_t i = 0; i < offsets.size(); ++i) {
for (std::size_t i = 0u; i < offsets.size(); ++i) {
rng.generateUniformSamples(0.0, 1.0, 1, uniform01);
addArrival(*gatherer, m_ResourceMonitor,
time + static_cast<core_t::TTime>(offsets[i]),
Expand Down
Loading

0 comments on commit 53216fe

Please sign in to comment.