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. | |
| void | Check (const long double dec, const long double frac, const int64_t intPart, const uint64_t lo) |
| Check the int64x64 for correctness. | |
| void | DoRun () override |
| Implementation to actually run this TestCase. | |
Public Member Functions inherited from ns3::TestCase | |
| TestCase (const TestCase &)=delete | |
| virtual | ~TestCase () |
| Destructor. | |
| std::string | GetName () const |
| TestCase & | operator= (const TestCase &)=delete |
Private Attributes | |
| int | m_deltaCount |
| The number of times a delta was recorded. | |
| int64x64_t | m_deltaMax |
| The maximum observed difference between expected and computed values. | |
| long double | m_last |
| The last value tested. | |
Static Private Attributes | |
| static constexpr long double | MIN_LOW = 1 << MISS_MANT_DIG |
| The smallest low word we expect to get from a conversion. | |
| static const long double | MIN_MANT |
| Smallest mantissa we expect to convert to a non-zero low word. | |
| static constexpr int | MISS_MANT_DIG = std::max(0, 64 - LDBL_MANT_DIG) |
| Compute a multiplier to match the mantissa size on this platform. | |
Additional Inherited Members | |
Public Types inherited from ns3::TestCase | |
| enum class | Duration { 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. | |
| void | AddTestCase (TestCase *testCase, Duration duration=Duration::QUICK) |
| Add an individual child TestCase to this test suite. | |
| TestCase * | GetParent () const |
| Get the parent of this TestCase. | |
| bool | IsStatusFailure () const |
| Check if any tests failed. | |
| bool | IsStatusSuccess () const |
| Check if all tests passed. | |
| void | SetDataDir (std::string directory) |
| Set the data directory where reference trace files can be found. | |
| 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. | |
| bool | MustAssertOnFailure () const |
| Check if this run should assert on failure. | |
| bool | MustContinueOnFailure () const |
| Check if this run should continue on failure. | |
| std::string | CreateDataDirFilename (std::string filename) |
| Construct the full path to a file in the data directory. | |
| std::string | CreateTempDirFilename (std::string filename) |
| Construct the full path to a file in a temporary directory. | |
Test: construct from floating point.
Definition at line 1114 of file int64x64-test-suite.cc.
| ns3::int64x64::test::Int64x64DoubleTestCase::Int64x64DoubleTestCase | ( | ) |
Definition at line 1194 of file int64x64-test-suite.cc.
References ns3::TestCase::TestCase(), m_deltaCount, m_deltaMax, and m_last.
Here is the call graph for this function:| void ns3::int64x64::test::Int64x64DoubleTestCase::Check | ( | const int64_t | intPart | ) |
Check the int64x64 for correctness.
| intPart | The expected integer part value of the int64x64. |
Definition at line 1351 of file int64x64-test-suite.cc.
References Check(), ns3::TestCase::GetName(), ns3::TestCase::GetParent(), m_deltaCount, m_deltaMax, m_last, and Max.
Referenced by Check(), and DoRun().
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
| dec | The integer part of the value to test. |
| frac | The fractional part of the value to test.x |
| intPart | The expected integer part value of the int64x64. |
| lo | The expected low part value of the int64x64. |
Definition at line 1203 of file int64x64-test-suite.cc.
References ns3::Abs(), epsilon, ns3::TestCase::GetName(), ns3::TestCase::GetParent(), ns3::int64x64_t::implementation, ns3::int64x64_t::ld_impl, m_deltaCount, m_deltaMax, m_last, MIN_LOW, MIN_MANT, NS_TEST_ASSERT_MSG_EQ_TOL, and RUNNING_WITH_LIMITED_PRECISION.
Here is the call graph for this function:
|
overridevirtual |
Implementation to actually run this TestCase.
Subclasses should override this method to conduct their tests.
Implements ns3::TestCase.
Definition at line 1472 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:
|
private |
The number of times a delta was recorded.
Definition at line 1187 of file int64x64-test-suite.cc.
Referenced by Int64x64DoubleTestCase(), Check(), Check(), and DoRun().
|
private |
The maximum observed difference between expected and computed values.
Definition at line 1186 of file int64x64-test-suite.cc.
Referenced by Int64x64DoubleTestCase(), Check(), Check(), and DoRun().
|
private |
The last value tested.
Definition at line 1184 of file int64x64-test-suite.cc.
Referenced by Int64x64DoubleTestCase(), Check(), and Check().
|
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 1165 of file int64x64-test-suite.cc.
|
staticprivate |
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 1181 of file int64x64-test-suite.cc.
|
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 1156 of file int64x64-test-suite.cc.
Referenced by DoRun().