24 #include "ns3/average.h"
44 virtual void DoRun (
void);
48 :
TestCase (
"Average Object Test using One Integer")
74 for (
long i = 0; i < count; i++)
76 value = multiple * (i + 1);
85 max = multiple * count;
88 stddev = std::sqrt (variance);
112 virtual void DoRun (
void);
116 :
TestCase (
"Average Object Test using Five Integers")
143 for (
long i = 0; i < count; i++)
145 value = multiple * (i + 1);
147 calculator.
Update (value);
150 sqrSum += value * value;
155 max = multiple * count;
157 variance = (count * sqrSum - sum * sum) / (count * (count - 1));
158 stddev = std::sqrt (variance);
182 virtual void DoRun (
void);
186 :
TestCase (
"Average Object Test using Five Double Values")
211 double multiple = 3.14;
213 for (
long i = 0; i < count; i++)
215 value = multiple * (i + 1);
217 calculator.
Update (value);
220 sqrSum += value * value;
225 max = multiple * count;
227 variance = (count * sqrSum - sum * sum) / (count * (count - 1));
228 stddev = std::sqrt (variance);
static AverageTestSuite averageTestSuite
Static variable for test initialization.
Average class - Test case for five double values.
virtual ~FiveDoublesAverageTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
FiveDoublesAverageTestCase()
Average class - Test case for five integers.
virtual ~FiveIntegersAverageTestCase()
FiveIntegersAverageTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
Average class - Test case for a single integer.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~OneIntegerAverageTestCase()
OneIntegerAverageTestCase()
Simple average, min, max and std.
void Update(T const &x)
Add new sample.
T Min() const
Sample minimum.
double Var() const
Sample unbiased nbiased estimate of variance.
T Max() const
Sample maximum.
uint32_t Count() const
Sample size.
double Stddev() const
Sample standard deviation.
double Mean() const
Sample estimate of mean, alias to Avg.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const double TOLERANCE
Tolerance used to check reciprocal of two numbers.