9#include "ns3/basic-data-calculators.h"
31 void DoRun()
override;
35 :
TestCase(
"Basic Statistical Functions using One Integer")
62 for (
long i = 0; i < count; i++)
64 value = multiple * (i + 1);
69 sqrSum += value * value;
74 max = multiple * count;
77 stddev = std::sqrt(variance);
89 "Variance value wrong");
105 void DoRun()
override;
109 :
TestCase(
"Basic Statistical Functions using Five Integers")
136 for (
long i = 0; i < count; i++)
138 value = multiple * (i + 1);
143 sqrSum += value * value;
148 max = multiple * count;
150 variance = (count * sqrSum - sum * sum) / (count * (count - 1));
151 stddev = std::sqrt(variance);
163 "Variance value wrong");
179 void DoRun()
override;
183 :
TestCase(
"Basic Statistical Functions using Five Double Values")
208 double multiple = 3.14;
210 for (
long i = 0; i < count; i++)
212 value = multiple * (i + 1);
217 sqrSum += value * value;
222 max = multiple * count;
224 variance = (count * sqrSum - sum * sum) / (count * (count - 1));
225 stddev = std::sqrt(variance);
237 "Variance value wrong");
static BasicDataCalculatorsTestSuite basicDataCalculatorsTestSuite
Static variable for test initialization.
MinMaxAvgTotalCalculator class TestSuite.
BasicDataCalculatorsTestSuite()
MinMaxAvgTotalCalculator class - Test case for five double values.
void DoRun() override
Implementation to actually run this TestCase.
~FiveDoublesTestCase() override
MinMaxAvgTotalCalculator class - Test case for five integers.
~FiveIntegersTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
MinMaxAvgTotalCalculator class - Test case for a single integer.
void DoRun() override
Implementation to actually run this TestCase.
~OneIntegerTestCase() override
Template class MinMaxAvgTotalCalculator.
long getCount() const override
Returns the count.
double getVariance() const override
Returns the current variance.
double getMax() const override
Returns the maximum value.
double getSqrSum() const override
Returns the sum of squares.
double getSum() const override
Returns the sum.
double getStddev() const override
Returns the standard deviation.
double getMean() const override
Returns the mean value.
double getMin() const override
Returns the minimum value.
void Update(const T i)
Updates all variables of MinMaxAvgTotalCalculator.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
static constexpr auto UNIT
#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.