23 void add(
const int value)
37 ASSERT_TRUE(m > low && m < hi) << title <<
' ' <<
to_string() <<
" outside of range=(" << low <<
',' << hi <<
')';
67 const unsigned int skew_factor,
72 const Time::Duration after =
TimeSkew::skew(dur, skew_factor, prng);
73 md.
mean.
add(
static_cast<int>(after.to_binary_ms()));
74 md.
dev.
add(
my_abs(
int(dur.to_binary_ms()) -
int(after.to_binary_ms())));
76 OPENVPN_LOG(
"BEFORE=" << dur.to_binary_ms() <<
" AFTER=" << after.to_binary_ms());
83 for (
int i = 0; i < 10000; ++i)
108 if (sec != last_sec || frac != last_frac)
119 const Time::Duration d = t1 - t2;
122 ASSERT_GE(d.raw(), 100000u);
124 ASSERT_EQ(d.raw(), 0u);
127static void sub(
const Time::Duration &d1,
const Time::Duration &d2)
129 const Time::Duration d = d1 - d2;
131 Time::Duration x = d1;
133 ASSERT_EQ(x, d) <<
"D-D INCONSISTENCY DETECTED";
136static void add(
const Time &t1,
const Time::Duration &d1)
138 const Time t = t1 + d1;
142 ASSERT_EQ(x, t) <<
"T+D INCONSISTENCY DETECTED";
145static void add(
const Time::Duration &d1,
const Time::Duration &d2)
147 const Time::Duration d = d1 + d2;
149 Time::Duration x = d1;
151 ASSERT_EQ(x, d) <<
"D+D INCONSISTENCY DETECTED";
159 sub(now, now,
false);
161 sub(now, inf,
false);
162 sub(inf, inf,
false);
165 const Time::Duration sec = Time::Duration::seconds(1);
175 const Time::Duration df = Time::Duration::seconds(1);
183 const Time::Duration sec = Time::Duration::seconds(1);
void add(const int value)
std::string to_string() const
void check_mean_range(const std::string &title, const int low, const int hi) const
Abstract base class for random number generators.
static TimeType infinite()
base_type seconds_since_epoch() const
T fractional_binary_ms() const
#define OPENVPN_LOG(args)
std::string printfmt(const std::string &fmt, Args... args)
std::string to_string() const
static Time::Duration skew(const Time::Duration &dur, const unsigned int factor, RandomAPI &prng)
void test_skew(const Time::Duration &dur, const unsigned int skew_factor, MeanDev &md, const bool verbose, RandomAPI &prng)
int my_abs(const int value)
static void add(const Time &t1, const Time::Duration &d1)
static void sub(const Time &t1, const Time &t2, bool large)