24 #include "ns3/basic-data-calculators.h"
42 virtual void DoRun (
void);
46 :
TestCase (
"Basic Statistical Functions using One Integer")
73 for (
long i = 0; i < count; i++)
75 value = multiple * (i + 1);
80 sqrSum += value * value;
85 max = multiple * count;
88 stddev = std::sqrt (variance);
114 virtual void DoRun (
void);
118 :
TestCase (
"Basic Statistical Functions using Five Integers")
145 for (
long i = 0; i < count; i++)
147 value = multiple * (i + 1);
149 calculator.
Update (value);
152 sqrSum += value * value;
157 max = multiple * count;
159 variance = (count * sqrSum - sum * sum) / (count * (count - 1));
160 stddev = std::sqrt (variance);
186 virtual void DoRun (
void);
190 :
TestCase (
"Basic Statistical Functions using Five Double Values")
215 double multiple = 3.14;
217 for (
long i = 0; i < count; i++)
219 value = multiple * (i + 1);
221 calculator.
Update (value);
224 sqrSum += value * value;
229 max = multiple * count;
231 variance = (count * sqrSum - sum * sum) / (count * (count - 1));
232 stddev = std::sqrt (variance);
258 :
TestSuite (
"basic-data-calculators", UNIT)
static BasicDataCalculatorsTestSuite basicDataCalculatorsTestSuite
Static variable for test initialization.
MinMaxAvgTotalCalculator class TestSuite.
BasicDataCalculatorsTestSuite()
MinMaxAvgTotalCalculator class - Test case for five double values.
virtual ~FiveDoublesTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
MinMaxAvgTotalCalculator class - Test case for five integers.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FiveIntegersTestCase()
MinMaxAvgTotalCalculator class - Test case for a single integer.
virtual ~OneIntegerTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
Template class MinMaxAvgTotalCalculator.
double getSqrSum() const
Returns the sum of squares.
long getCount() const
Returns the count.
double getSum() const
Returns the sum.
double getStddev() const
Returns the standard deviation.
double getMean() const
Returns the mean value.
double getVariance() const
Returns the current variance.
double getMax() const
Returns the maximum value.
double getMin() const
Returns the minimum value.
void Update(const T i)
Updates all variables of MinMaxAvgTotalCalculator.
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.