Check ratios in fixed rate sampler. (#502)
parent
9c81a01608
commit
b1b0750e5b
|
@ -16,10 +16,15 @@
|
||||||
|
|
||||||
#include "cartographer/common/fixed_ratio_sampler.h"
|
#include "cartographer/common/fixed_ratio_sampler.h"
|
||||||
|
|
||||||
|
#include "glog/logging.h"
|
||||||
|
|
||||||
namespace cartographer {
|
namespace cartographer {
|
||||||
namespace common {
|
namespace common {
|
||||||
|
|
||||||
FixedRatioSampler::FixedRatioSampler(const double ratio) : ratio_(ratio) {}
|
FixedRatioSampler::FixedRatioSampler(const double ratio) : ratio_(ratio) {
|
||||||
|
CHECK_GT(ratio, 0.);
|
||||||
|
CHECK_LE(ratio, 1.);
|
||||||
|
}
|
||||||
|
|
||||||
FixedRatioSampler::~FixedRatioSampler() {}
|
FixedRatioSampler::~FixedRatioSampler() {}
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,10 @@ TEST(FixedRatioSamplerTest, AlwaysTrue) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FixedRatioSamplerTest, AlwaysFalse) {
|
TEST(FixedRatioSamplerTest, NonSensicalRatio) {
|
||||||
FixedRatioSampler fixed_ratio_sampler(0.);
|
EXPECT_DEATH(FixedRatioSampler(0.), "ratio");
|
||||||
for (int i = 0; i < 100; ++i) {
|
EXPECT_DEATH(FixedRatioSampler(2.), "ratio");
|
||||||
EXPECT_FALSE(fixed_ratio_sampler.Pulse());
|
EXPECT_DEATH(FixedRatioSampler(-0.1), "ratio");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FixedRatioSamplerTest, SometimesTrue) {
|
TEST(FixedRatioSamplerTest, SometimesTrue) {
|
||||||
|
|
Loading…
Reference in New Issue