19 #include "gtest/gtest.h" 25 TEST(FixedRatioSamplerTest, AlwaysTrue) {
26 FixedRatioSampler fixed_ratio_sampler(1.);
27 for (
int i = 0; i < 100; ++i) {
28 EXPECT_TRUE(fixed_ratio_sampler.Pulse());
32 TEST(FixedRatioSamplerTest, AlwaysFalse) {
33 FixedRatioSampler fixed_ratio_sampler(0.);
34 for (
int i = 0; i < 100; ++i) {
35 EXPECT_FALSE(fixed_ratio_sampler.Pulse());
39 TEST(FixedRatioSamplerTest, SometimesTrue) {
40 FixedRatioSampler fixed_ratio_sampler(0.5);
41 for (
int i = 0; i < 100; ++i) {
42 EXPECT_EQ(i % 2 == 0, fixed_ratio_sampler.Pulse());
46 TEST(FixedRatioSamplerTest, FirstPulseIsTrue) {
48 FixedRatioSampler fixed_ratio_sampler(1e-20);
49 EXPECT_TRUE(fixed_ratio_sampler.Pulse());
50 for (
int i = 0; i < 100; ++i) {
51 EXPECT_FALSE(fixed_ratio_sampler.Pulse());