A Discrete-Event Network Simulator
API
ns3::int64x64::test::Int64x64DoubleTestCase Class Reference

Test: construct from floating point. More...

+ Inheritance diagram for ns3::int64x64::test::Int64x64DoubleTestCase:
+ Collaboration diagram for ns3::int64x64::test::Int64x64DoubleTestCase:

Public Member Functions

 Int64x64DoubleTestCase ()
 
void Check (const int64_t intPart)
 Check the int64x64 for correctness. More...
 
void Check (const long double dec, const long double frac, const int64_t intPart, const uint64_t lo)
 Check the int64x64 for correctness. More...
 
void DoRun () override
 Implementation to actually run this TestCase. More...
 
- Public Member Functions inherited from ns3::TestCase
 TestCase (const TestCase &)=delete
 
virtual ~TestCase ()
 Destructor. More...
 
std::string GetName () const
 
TestCaseoperator= (const TestCase &)=delete
 

Private Attributes

int m_deltaCount
 The number of times a delta was recorded. More...
 
int64x64_t m_deltaMax
 The maximum observed difference between expected and computed values. More...
 
long double m_last
 The last value tested. More...
 

Static Private Attributes

static constexpr long double MIN_LOW = 1 << MISS_MANT_DIG
 The smallest low word we expect to get from a conversion. More...
 
static const long double MIN_MANT
 Smallest mantissa we expect to convert to a non-zero low word. More...
 
static constexpr int MISS_MANT_DIG = std::max(0, 64 - LDBL_MANT_DIG)
 Compute a multiplier to match the mantissa size on this platform. More...
 

Additional Inherited Members

- Public Types inherited from ns3::TestCase
enum  TestDuration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 }
 How long the test takes to execute. More...
 
- Protected Member Functions inherited from ns3::TestCase
 TestCase (std::string name)
 Constructor. More...
 
void AddTestCase (TestCase *testCase, TestDuration duration=QUICK)
 Add an individual child TestCase to this test suite. More...
 
TestCaseGetParent () const
 Get the parent of this TestCase. More...
 
bool IsStatusFailure () const
 Check if any tests failed. More...
 
bool IsStatusSuccess () const
 Check if all tests passed. More...
 
void SetDataDir (std::string directory)
 Set the data directory where reference trace files can be found. More...
 
void ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, std::string file, int32_t line)
 Log the failure of this TestCase. More...
 
bool MustAssertOnFailure () const
 Check if this run should assert on failure. More...
 
bool MustContinueOnFailure () const
 Check if this run should continue on failure. More...
 
std::string CreateDataDirFilename (std::string filename)
 Construct the full path to a file in the data directory. More...
 
std::string CreateTempDirFilename (std::string filename)
 Construct the full path to a file in a temporary directory. More...
 

Detailed Description

Test: construct from floating point.

Definition at line 1096 of file int64x64-test-suite.cc.

Constructor & Destructor Documentation

◆ Int64x64DoubleTestCase()

ns3::int64x64::test::Int64x64DoubleTestCase::Int64x64DoubleTestCase ( )

Definition at line 1175 of file int64x64-test-suite.cc.

Member Function Documentation

◆ Check() [1/2]

void ns3::int64x64::test::Int64x64DoubleTestCase::Check ( const int64_t  intPart)

Check the int64x64 for correctness.

Parameters
intPartThe expected integer part value of the int64x64.

Definition at line 1332 of file int64x64-test-suite.cc.

References ns3::TestCase::GetName(), ns3::TestCase::GetParent(), m_deltaCount, m_deltaMax, m_last, and ns3::Max().

Referenced by DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Check() [2/2]

void ns3::int64x64::test::Int64x64DoubleTestCase::Check ( const long double  dec,
const long double  frac,
const int64_t  intPart,
const uint64_t  lo 
)

Check the int64x64 for correctness.

Parameters
decThe integer part of the value to test.
fracThe fractional part of the value to test.x
intPartThe expected integer part value of the int64x64.
loThe expected low part value of the int64x64.

Definition at line 1184 of file int64x64-test-suite.cc.

References ns3::Abs(), two-ray-to-three-gpp-ch-calibration::delta, epsilon, ns3::TestCase::GetName(), ns3::TestCase::GetParent(), ns3::int64x64_t::implementation, ns3::int64x64_t::ld_impl, m_deltaCount, m_deltaMax, m_last, max, MIN_LOW, MIN_MANT, NS_TEST_ASSERT_MSG_EQ_TOL, and RUNNING_WITH_LIMITED_PRECISION.

+ Here is the call graph for this function:

◆ DoRun()

void ns3::int64x64::test::Int64x64DoubleTestCase::DoRun ( )
overridevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

Definition at line 1453 of file int64x64-test-suite.cc.

References Check(), ns3::TestCase::GetName(), ns3::TestCase::GetParent(), m_deltaCount, m_deltaMax, MIN_LOW, MIN_MANT, and MISS_MANT_DIG.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_deltaCount

int ns3::int64x64::test::Int64x64DoubleTestCase::m_deltaCount
private

The number of times a delta was recorded.

Definition at line 1168 of file int64x64-test-suite.cc.

Referenced by Check(), and DoRun().

◆ m_deltaMax

int64x64_t ns3::int64x64::test::Int64x64DoubleTestCase::m_deltaMax
private

The maximum observed difference between expected and computed values.

Definition at line 1167 of file int64x64-test-suite.cc.

Referenced by Check(), and DoRun().

◆ m_last

long double ns3::int64x64::test::Int64x64DoubleTestCase::m_last
private

The last value tested.

Definition at line 1165 of file int64x64-test-suite.cc.

Referenced by Check().

◆ MIN_LOW

constexpr long double ns3::int64x64::test::Int64x64DoubleTestCase::MIN_LOW = 1 << MISS_MANT_DIG
staticconstexprprivate

The smallest low word we expect to get from a conversion.

MIN_LOW = 2^MISS_MANT_DIG

which will be in [1, 2^64].

Definition at line 1146 of file int64x64-test-suite.cc.

Referenced by Check(), and DoRun().

◆ MIN_MANT

const long double ns3::int64x64::test::Int64x64DoubleTestCase::MIN_MANT
staticprivate
Initial value:
=
std::round(1e22 / std::pow(2.0L, std::min(64, LDBL_MANT_DIG))) / 1e22
#define min(a, b)
Definition: 80211b.c:41

Smallest mantissa we expect to convert to a non-zero low word.

MIN_MANT = MIN_LOW / 2^64
         = 2^(MISS_MANT_DIG - 64)
         = 2^(-EFF_MANT_DIG)

We scale and round this value to match the hard-coded fractional values in Check(intPart) which have 22 decimal digits.

Since we use std::round() which isn't constexpr, just declare this const and initialize below.

Definition at line 1162 of file int64x64-test-suite.cc.

Referenced by Check(), and DoRun().

◆ MISS_MANT_DIG

constexpr int ns3::int64x64::test::Int64x64DoubleTestCase::MISS_MANT_DIG = std::max(0, 64 - LDBL_MANT_DIG)
staticconstexprprivate

Compute a multiplier to match the mantissa size on this platform.

Since we will store the fractional part of a double in the low word (64 bits) of our Q64.64 the most mantissa bits we can take advantage of is

EFF_MANT_DIG = std::min (64, LDBL_MANT_DIG)

We have to bound this for platforms with LDBL_MANT_DIG > 64.

The number of "missing" bits in the mantissa is

MISS_MANT_DIG = 64 - EFF_MANT_DIG = std::max (0, 64 - LDBL_MANT_DIG)

This will lie in the closed interval [0, 64]

Definition at line 1137 of file int64x64-test-suite.cc.

Referenced by DoRun().


The documentation for this class was generated from the following file: