A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
Testing
+ Collaboration diagram for Testing:

Topics

 Examples as tests test suite
 
 
 Testing Implementation
 
 

Files

file  example-as-test.cc
 Implementation of classes ns3::ExampleAsTestSuite and ns3::ExampleTestCase.
 
file  example-as-test.h
 Enable examples to be run as meaningful tests.
 
file  sample-test-suite.cc
 Example use of TestSuite.
 
file  test.cc
 ns3::TestCase, ns3::TestSuite, ns3::TestRunner implementations,
 
file  test.h
 ns3::TestCase, ns3::TestSuite, ns3::TestRunner declarations, and NS_TEST_ASSERT macro definitions.
 

Classes

class  ns3::ExampleAsTestCase
 Execute an example program as a test, by comparing the output to a reference file. More...
 
class  ns3::ExampleAsTestSuite
 Execute an example program as a test suite. More...
 
class  ns3::TestCase
 encapsulates test code More...
 
class  ns3::TestSuite
 A suite of tests to run. More...
 
class  ns3::TestVectors< T >
 A simple way to store test vectors (for stimulus or from responses) More...
 

Macros

#define ASSERT_ON_FAILURE
 Check if we should assert on errors, and do so.
 
#define CONTINUE_ON_FAILURE
 If we shouldn't continue on errors, return.
 
#define CONTINUE_ON_FAILURE_RETURNS_BOOL
 If we shouldn't continue on errors, return test status.
 
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
 Test that an actual and expected (limit) value are equal and report and abort if not.
 
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg)
 Test that an actual and expected (limit) value are equal and report and abort if not.
 
#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 abort if not.
 
#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL(actual, limit, tol, msg)
 Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and abort if not.
 
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
 Test that an actual value is greater than a limit and report and abort if not.
 
#define NS_TEST_ASSERT_MSG_GT_OR_EQ(actual, limit, msg)
 Test that an actual value is greater than or equal to a limit and report and abort if not.
 
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
 Test that an actual value is less than a limit and report and abort if not.
 
#define NS_TEST_ASSERT_MSG_LT_OR_EQ(actual, limit, msg)
 Test that an actual value is less than or equal to a limit and report and abort if not.
 
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
 Test that an actual and expected (limit) value are not equal and report and abort if not.
 
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg)
 Test that an actual and expected (limit) value are not equal and report and abort if not.
 
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
 Test that an actual and expected (limit) value are equal and report if not.
 
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
 Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if not.
 
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
 Test that an actual value is greater than a limit and report if not.
 
#define NS_TEST_EXPECT_MSG_GT_OR_EQ(actual, limit, msg)
 Test that an actual value is greater than or equal to limit and report if not.
 
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
 Test that an actual value is less than a limit and report if not.
 
#define NS_TEST_EXPECT_MSG_LT_OR_EQ(actual, limit, msg)
 Test that an actual value is less than or equal to a limit and report if not.
 
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
 Test that an actual and expected (limit) value are not equal and report if not.
 

Functions

bool ns3::TestDoubleIsEqual (const double a, const double b, const double epsilon=std::numeric_limits< double >::epsilon())
 Compare two double precision floating point numbers and declare them equal if they are within some epsilon of each other.
 

Detailed Description

Tools to define and execute unit tests.

This module lists the normal Testing API. Most of these macros forward to the implementation macros in testingimpl. You should generally use these macros only.

Macro Definition Documentation

◆ ASSERT_ON_FAILURE

#define ASSERT_ON_FAILURE
Value:
do \
{ \
if (MustAssertOnFailure()) \
{ \
*(volatile int*)0 = 0; \
} \
} while (false)

Check if we should assert on errors, and do so.

Definition at line 66 of file test.h.

◆ CONTINUE_ON_FAILURE

#define CONTINUE_ON_FAILURE
Value:
do \
{ \
if (!MustContinueOnFailure()) \
{ \
return; \
} \
} while (false)

If we shouldn't continue on errors, return.

Definition at line 79 of file test.h.

◆ CONTINUE_ON_FAILURE_RETURNS_BOOL

#define CONTINUE_ON_FAILURE_RETURNS_BOOL
Value:
do \
{ \
if (!MustContinueOnFailure()) \
{ \
return IsStatusFailure(); \
} \
} while (false)

If we shouldn't continue on errors, return test status.

Definition at line 92 of file test.h.

◆ NS_TEST_ASSERT_MSG_EQ

#define NS_TEST_ASSERT_MSG_EQ ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) == (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) == " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)
#define ASSERT_ON_FAILURE
Check if we should assert on errors, and do so.
Definition test.h:66
#define CONTINUE_ON_FAILURE
If we shouldn't continue on errors, return.
Definition test.h:79

Test that an actual and expected (limit) value are equal and report and abort if not.

Check to see if the expected (limit) value is equal to the actual value found in a test case. If the two values are equal nothing happens, but if the comparison fails, an error is reported in a consistent way and the execution of the current test case is aborted.

The message is interpreted as a stream, for example:

NS_TEST_ASSERT_MSG_EQ (result, true,
"cannot open file " << filename << " in test");
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition test.h:134

is legal.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the expected value of the test.
[in]msgMessage that is output if the test does not pass.
Warning
Do not use this macro if you are comparing floating point numbers (float or double) as it is unlikely to do what you expect. Use NS_TEST_ASSERT_MSG_EQ_TOL instead.

Definition at line 134 of file test.h.

Referenced by TcpFastRetrTest::AfterRTOExpired(), TcpRtoTest::AfterRTOExpired(), TcpSsThreshRtoTest::AfterRTOExpired(), TcpTimeRtoTest::AfterRTOExpired(), RrcHeaderTestCase::AssertEqualRadioResourceConfigDedicated(), LengthTestCase::AssertFalse(), LengthTestCase::AssertTrue(), TcpBytesInFlightTest::BytesInFlightTrace(), ns3::int64x64::test::Int64x64Bug455TestCase::Check(), ns3::int64x64::test::Int64x64Bug863TestCase::Check(), ns3::int64x64::test::Int64x64CompareTestCase::Check(), TestWifiPhyRxTraceHelper::CheckAllStats(), TestWifiPhyRxTraceHelperMloStr::CheckAllStats(), TestWifiPhyRxTraceHelperYans::CheckAllStats(), EmlsrDlTxopTest::CheckApEmlNotificationFrame(), TestUlOfdmaPhyTransmission::CheckApRxEnd(), TestUlOfdmaPhyTransmission::CheckApRxStart(), MultiLinkSetupTest::CheckAssocRequest(), EmlsrDlTxopTest::CheckBlockAck(), EmlsrUlTxopTest::CheckBlockAck(), MultiLinkMuTxTest::CheckBlockAck(), MultiLinkTxTest::CheckBlockAck(), TestMultipleHeTbPreambles::CheckBytesDropped(), SpectrumWifiPhyMultipleInterfacesTest::CheckCcaIndication(), LteRadioLinkFailureTestCase::CheckConnected(), LteRrcConnectionEstablishmentTestCase::CheckConnected(), LteX2HandoverMeasuresTestCase::CheckConnected(), LteX2HandoverTestCase::CheckConnected(), TcpHeaderWithRFC793OptionTestCase::CheckCorrectDeserialize(), QueueDiscTracesTestCase::CheckDroppedAfterDequeue(), QueueDiscTracesTestCase::CheckDroppedBeforeEnqueue(), TestPhyDropDueToTx::CheckDropReason(), EmlOmnExchangeTest::CheckEmlCapabilitiesInAssocReq(), EmlOmnExchangeTest::CheckEmlCapabilitiesInAssocResp(), EmlOmnExchangeTest::CheckEmlNotification(), LteIpv6RoutingTestCase::Checker(), TestMultipleHeTbPreambles::CheckHeTbPreambles(), PacketMetadataTest::CheckHistory(), LteRadioLinkFailureTestCase::CheckIdle(), EmlsrDlTxopTest::CheckInitialControlFrame(), EmlsrLinkSwitchTest::CheckInitialControlFrame(), WifiPhyCcaIndicationTest::CheckLastCcaBusyNotification(), IdealRateManagerChannelWidthTest::CheckLastSelectedMode(), IdealRateManagerMimoTest::CheckLastSelectedMode(), IdealRateManagerMimoTest::CheckLastSelectedNss(), AnimationInterfaceTestCase::CheckLogic(), AnimationRemainingEnergyTestCase::CheckLogic(), ThreeGppSpectrumPropagationLossModelTest::CheckLongTermUpdate(), MultiLinkSetupTest::CheckMlSetup(), TcpHeaderWithRFC793OptionTestCase::CheckNoPadding(), LteRrcConnectionEstablishmentTestCase::CheckNotConnected(), TestUlOfdmaPhyTransmission::CheckOfdmaRxPower(), Ipv4DeduplicationTest::CheckPackets(), TestInterBssConstantObssPdAlgo::CheckPhyDropReasons(), TestAmpduReception::CheckPhyState(), TestInterBssConstantObssPdAlgo::CheckPhyState(), EmlsrDlTxopTest::CheckPmModeAfterAssociation(), LteCellSelectionTestCase::CheckPoint(), EmlsrCcaBusyTest::CheckPoint1(), EmlsrCcaBusyTest::CheckPoint2(), EmlsrCcaBusyTest::CheckPoint3(), OutdoorRandomWalkTestCase::CheckPositionOutdoor(), MultiLinkSetupTest::CheckQosData(), QueueDiscTracesTestCase::CheckQueued(), TestWifiPhyRxTraceHelper::CheckRecords(), TestWifiPhyRxTraceHelperMloStr::CheckRecords(), TestWifiPhyRxTraceHelperYans::CheckRecords(), EmlsrDlTxopTest::CheckResults(), EmlsrUlTxopTest::CheckResults(), SpectrumWifiPhy80Plus80Test::CheckResults(), SpectrumWifiPhyMultipleInterfacesTest::CheckResults(), TestInterBssConstantObssPdAlgo::CheckResults(), TestMultipleCtsResponsesFromMuRts::CheckResults(), TestNonHtDuplicatePhyReception::CheckResults(), WifiTxopTest::CheckResults(), WifiUseAvailBwTest::CheckResults(), TestDlMuMimoPhyTransmission::CheckResultsSta1(), TestDlOfdmaPhyPuncturing::CheckResultsSta1(), TestDlOfdmaPhyTransmission::CheckResultsSta1(), TestDlMuMimoPhyTransmission::CheckResultsSta2(), TestDlOfdmaPhyPuncturing::CheckResultsSta2(), TestDlOfdmaPhyTransmission::CheckResultsSta2(), TestDlMuMimoPhyTransmission::CheckResultsSta3(), TestDlOfdmaPhyTransmission::CheckResultsSta3(), TestUnsupportedBandwidthReception::CheckRx(), TestAmpduReception::CheckRxDroppedBitmapAmpdu1(), TestAmpduReception::CheckRxDroppedBitmapAmpdu2(), TestAmpduReception::CheckRxFailureBitmapAmpdu1(), TestAmpduReception::CheckRxFailureBitmapAmpdu2(), TestUlMuMimoPhyTransmission::CheckRxFromSta(), TestPhyPaddingExclusion::CheckRxFromSta1(), TestUlOfdmaPhyTransmission::CheckRxFromSta1(), TestPhyPaddingExclusion::CheckRxFromSta2(), TestUlOfdmaPhyTransmission::CheckRxFromSta2(), SpectrumWifiPhyMultipleInterfacesTest::CheckRxingState(), TestSpectrumChannelWithBandwidthFilter::CheckRxPacketCount(), TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount(), TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount(), TestAmpduReception::CheckRxSuccessBitmapAmpdu1(), TestAmpduReception::CheckRxSuccessBitmapAmpdu2(), EmlsrDlTxopTest::CheckStaEmlNotificationFrame(), TestWifiPhyRxTraceHelper::CheckStats(), TestWifiPhyRxTraceHelperMloStr::CheckStats(), TestWifiPhyRxTraceHelperMloStr::CheckStats(), TestWifiPhyRxTraceHelperMloStr::CheckStats(), TestWifiPhyRxTraceHelperYans::CheckStats(), LteX2HandoverTestCase::CheckStatsAWhileAfterHandover(), TracedValueCallbackTestCase::CheckType(), TestUlOfdmaPpduUid::CheckUid(), ThreeGppHttpObjectTestCase::ClientRxEmbeddedObjectCallback(), ThreeGppHttpObjectTestCase::ClientRxMainObjectCallback(), TcpFastRetrTest::CongStateTrace(), TcpLargeTransferLossTest::CongStateTrace(), LteRadioLinkFailureTestCase::ConnectionEstablishedUeCallback(), Bug772ChainTest::CreateDevices(), ChainRegressionTest::CreateDevices(), FlameRegressionTest::CreateDevices(), HwmpDoRfRegressionTest::CreateDevices(), HwmpProactiveRegressionTest::CreateDevices(), HwmpSimplestRegressionTest::CreateDevices(), PeerManagementProtocolRegressionTest::CreateDevices(), ns3::olsr::HelloRegressionTest::CreateNodes(), ns3::TcpEcnTest::CWndTrace(), TcpLinuxRenoCongAvoidTest::CWndTrace(), TcpLinuxRenoSSTest::CWndTrace(), TcpSlowStartNormalTest::CWndTrace(), CoDelQueueDiscBasicMark::Dequeue(), LteCqiGenerationDlPowerControlTestCase::DlScheduling(), LteCqiGenerationTestCase::DlScheduling(), LteInterferenceTestCase::DlScheduling(), LteLinkAdaptationTestCase::DlScheduling(), LtePathlossModelSystemTestCase::DlScheduling(), LteRlcAmTransmitterTestCase::DoCheckDataReceived(), LteRlcUmTransmitterTestCase::DoCheckDataReceived(), SpectrumWifiPhyMultipleInterfacesTest::DoCheckInterferences(), TestDlMuMimoPhyTransmission::DoCheckPhyState(), TestDlOfdmaPhyPuncturing::DoCheckPhyState(), TestDlOfdmaPhyTransmission::DoCheckPhyState(), TestPhyPaddingExclusion::DoCheckPhyState(), TestUlMuMimoPhyTransmission::DoCheckPhyState(), TestUlOfdmaPhyTransmission::DoCheckPhyState(), WifiPhyCcaIndicationTest::DoCheckPhyState(), WifiPhyReceptionTest::DoCheckPhyState(), ThreeGppAntennaSetupChangedTest::DoGetChannel(), ThreeGppChannelMatrixUpdateTest::DoGetChannel(), AcousticModemEnergyDepletionTestCase::DoRun(), AttributeContainerSerializationTestCase::DoRun(), AttributeContainerSetGetTestCase::DoRun(), AttributeContainerTestCase::DoRun(), AttributeTestCase< T >::DoRun(), BasicCallbackTestCase::DoRun(), BasicTracedCallbackTestCase::DoRun(), BlockAckRecipientBufferTest::DoRun(), BoxLineIntersectionTestCase::DoRun(), BridgeTest::DoRun(), BriteTopologyStructureTestCase::DoRun(), BufferTest::DoRun(), Bug2222TestCase::DoRun(), Bug2470TestCase::DoRun(), Bug2831TestCase::DoRun(), Bug2843TestCase::DoRun(), Bug730TestCase::DoRun(), BuildingsChannelConditionModelTestCase::DoRun(), BuildingsHelperOneTestCase::DoRun(), BulkSendBasicTestCase::DoRun(), BulkSendSeqTsSizeTestCase::DoRun(), BurstErrorModelSimple::DoRun(), CallbackEqualityTestCase::DoRun(), CallbackValueTestCase::DoRun(), CarrierAggregationConfigTestCase::DoRun(), CarrierAggregationTestCase::DoRun(), ClassicRecoveryTest::DoRun(), CobaltQueueDiscBasicEnqueueDequeue::DoRun(), CobaltQueueDiscCeThresholdTest::DoRun(), CobaltQueueDiscEnhancedBlueTest::DoRun(), CobaltQueueDiscMarkTest::DoRun(), CoDelQueueDiscBasicDrop::DoRun(), CoDelQueueDiscBasicEnqueueDequeue::DoRun(), CoDelQueueDiscBasicMark::DoRun(), CoDelQueueDiscBasicOverflow::DoRun(), CoDelQueueDiscControlLawTest::DoRun(), CoDelQueueDiscNewtonStepTest::DoRun(), CollisionTestCase::DoRun(), CsmaBridgeTestCase::DoRun(), CsmaBroadcastTestCase::DoRun(), CsmaMulticastTestCase::DoRun(), CsmaOneSubnetTestCase::DoRun(), CsmaPacketSocketTestCase::DoRun(), CsmaPingTestCase::DoRun(), CsmaRawIpSocketTestCase::DoRun(), CsmaStarTestCase::DoRun(), DcfImmediateAccessBroadcastTestCase::DoRun(), DeprecatedAttributeTestCase::DoRun(), DhcpTestCase::DoRun(), DiffTestCase::DoRun(), DsaRequestTestCase::DoRun(), DsdvHeaderTestCase::DoRun(), DsdvTableTestCase::DoRun(), DsssModulationTest::DoRun(), EhtAggregationTest::DoRun(), EpcS1uDlTestCase::DoRun(), EpcS1uUlTestCase::DoRun(), EpcTftClassifierTestCase::DoRun(), EpsGtpuHeaderTestCase::DoRun(), ErrorModelSimple::DoRun(), FileHeaderTestCase::DoRun(), FlameHeaderTest::DoRun(), FqCobaltQueueDiscDeficit::DoRun(), FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqCobaltQueueDiscNoSuitableFilter::DoRun(), FqCobaltQueueDiscSetLinearProbing::DoRun(), FqCobaltQueueDiscTCPFlowsSeparation::DoRun(), FqCobaltQueueDiscUDPFlowsSeparation::DoRun(), FqCoDelQueueDiscDeficit::DoRun(), FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqCoDelQueueDiscNoSuitableFilter::DoRun(), FqCoDelQueueDiscSetLinearProbing::DoRun(), FqCoDelQueueDiscTCPFlowsSeparation::DoRun(), FqCoDelQueueDiscUDPFlowsSeparation::DoRun(), FqPieQueueDiscDeficit::DoRun(), FqPieQueueDiscIPFlowsSeparationAndPacketLimit::DoRun(), FqPieQueueDiscNoSuitableFilter::DoRun(), FqPieQueueDiscSetLinearProbing::DoRun(), FqPieQueueDiscTCPFlowsSeparation::DoRun(), FqPieQueueDiscUDPFlowsSeparation::DoRun(), GlobalRouteManagerImplTestCase::DoRun(), HandoverPreparationInfoTestCase::DoRun(), IntegerTraceSourceAttributeTestCase::DoRun(), IntegerTraceSourceTestCase::DoRun(), IpAddressHelperTestCasev4::DoRun(), IpAddressHelperTestCasev6::DoRun(), Ipv4DeduplicationPerformanceTest::DoRun(), Ipv4DeduplicationTest::DoRun(), Ipv4DynamicGlobalRoutingTestCase::DoRun(), Ipv4L3ProtocolTestCase::DoRun(), Ipv6AddressTestCase::DoRun(), Ipv6DadTest::DoRun(), Ipv6L3ProtocolTestCase::DoRun(), LanTest::DoRun(), LinkTest::DoRun(), LrWpanErrorDistanceTestCase::DoRun(), LrWpanPacketTestCase::DoRun(), LteAggregationThroughputScaleTestCase::DoRun(), LteDistributedFfrAreaTestCase::DoRun(), LteDownlinkPowerControlRrcConnectionReconfigurationTestCase::DoRun(), LteDownlinkPowerControlSpectrumValueTestCase::DoRun(), LteEnhancedFfrAreaTestCase::DoRun(), LteEpcE2eDataTestCase::DoRun(), LteHardFrTestCase::DoRun(), LteNoisePsdTestCase::DoRun(), LtePrimaryCellChangeTestCase::DoRun(), LteRadioLinkFailureTestCase::DoRun(), LteRlcAmE2eTestCase::DoRun(), LteRlcUmE2eTestCase::DoRun(), LteSecondaryCellSelectionTestCase::DoRun(), LteSoftFfrAreaTestCase::DoRun(), LteSoftFrAreaTestCase::DoRun(), LteStrictFrAreaTestCase::DoRun(), LteStrictFrTestCase::DoRun(), LteTxPsdTestCase::DoRun(), MakeBoundCallbackTestCase::DoRun(), MakeCallbackTestCase::DoRun(), MatrixPropagationLossModelTestCase::DoRun(), MeasurementReportTestCase::DoRun(), MeshHeaderTest::DoRun(), MeshInformationElementVectorBist::DoRun(), Ns2MobilityHelperTest::DoRun(), ns3::aodv::LoopbackTestCase::DoRun(), ns3::ExampleAsTestCase::DoRun(), ns3::Ipv4ListRoutingNegativeTestCase::DoRun(), ns3::Ipv4ListRoutingPositiveTestCase::DoRun(), ns3::Ipv6ListRoutingNegativeTestCase::DoRun(), ns3::Ipv6ListRoutingPositiveTestCase::DoRun(), ns3::LenaDeactivateBearerTestCase::DoRun(), ns3::RlcAmStatusPduTestCase::DoRun(), ns3::TcpLpInferenceTest1::DoRun(), ns3::TcpLpInferenceTest2::DoRun(), ns3::TcpLpToNewReno::DoRun(), ns3::test::RandomVariable::UniformAntitheticTestCase::DoRun(), ns3::test::RandomVariable::UniformTestCase::DoRun(), ns3::test::RandomVariable::WeibullTestCase::DoRun(), ns3::tests::AlternateFindTestCase::DoRun(), ns3::tests::BasicAddTestCase::DoRun(), ns3::tests::BasicFindTestCase::DoRun(), ns3::tests::BasicRenameTestCase::DoRun(), ns3::tests::BuildProfileTestCase::DoRun(), ns3::tests::CommandLineBooleanTestCase::DoRun(), ns3::tests::CommandLineCharStarTestCase::DoRun(), ns3::tests::CommandLineIntTestCase::DoRun(), ns3::tests::CommandLineInvalidTestCase::DoRun(), ns3::tests::CommandLineNonOptionTestCase::DoRun(), ns3::tests::CommandLineOrderTestCase::DoRun(), ns3::tests::CommandLineStringTestCase::DoRun(), ns3::tests::CommandLineUint8tTestCase::DoRun(), ns3::tests::CommandLineUnsignedIntTestCase::DoRun(), ns3::tests::ComplexMatrixArrayTestCase::DoRun(), ns3::tests::CreateObjectTestCase::DoRun(), ns3::tests::FindPathTestCase::DoRun(), ns3::tests::FullyQualifiedAddTestCase::DoRun(), ns3::tests::FullyQualifiedFindTestCase::DoRun(), ns3::tests::FullyQualifiedRenameTestCase::DoRun(), ns3::tests::GlobalValueTestCase::DoRun(), ns3::tests::MatrixArrayTestCase< T >::DoRun(), ns3::tests::ObjectFactoryTestCase::DoRun(), ns3::tests::ObjectVectorConfigTestCase::DoRun(), ns3::tests::ObjectVectorTraceConfigTestCase::DoRun(), ns3::tests::RelativeAddTestCase::DoRun(), ns3::tests::RelativeFindTestCase::DoRun(), ns3::tests::RelativeRenameTestCase::DoRun(), ns3::tests::RootNamespaceConfigTestCase::DoRun(), ns3::tests::SampleTestCase1::DoRun(), ns3::tests::SearchAttributesOfParentObjectsTestCase::DoRun(), ns3::tests::StringContextAddTestCase::DoRun(), ns3::tests::StringContextFindTestCase::DoRun(), ns3::tests::StringContextRenameTestCase::DoRun(), ns3::tests::TypeTraitsTestCase::DoRun(), ns3::tests::UnderRootNamespaceConfigTestCase::DoRun(), ns3::tests::UnidirectionalAggregateObjectTestCase::DoRun(), ns3::tests::ValArrayTestCase< T >::DoRun(), ns3::tests::WatchdogTestCase::DoRun(), Ns3TcpCubicTestCase::DoRun(), Ns3TcpNoDelayTestCase::DoRun(), Ns3TcpSocketTestCaseCsma::DoRun(), Ns3TcpSocketTestCaseP2P::DoRun(), Ns3WimaxCsParamTlvTestCase::DoRun(), Ns3WimaxSfTlvTestCase::DoRun(), NullifyCallbackTestCase::DoRun(), ObjectMapAttributeTestCase::DoRun(), ObjectVectorAttributeTestCase::DoRun(), OlsrEmfTestCase::DoRun(), OlsrHelloTestCase::DoRun(), OlsrHnaTestCase::DoRun(), OlsrMidTestCase::DoRun(), OlsrTcTestCase::DoRun(), PacketLossCounterTestCase::DoRun(), PairValueSettingsTestCase::DoRun(), PairValueTestCase::DoRun(), PfifoFastQueueDiscDscpPrioritization::DoRun(), PfifoFastQueueDiscNoPriority::DoRun(), PfifoFastQueueDiscOverflow::DoRun(), PfifoFastQueueDiscTosPrioritization::DoRun(), PingTestCase::DoRun(), PointerAttributeTestCase::DoRun(), PrioQueueDiscTestCase::DoRun(), QosFragmentationTestCase::DoRun(), QueueDiscTracesTestCase::DoRun(), RadvdTestCase::DoRun(), RandomRoomPositionAllocatorTestCase::DoRun(), RandomVariableStreamAttributeTestCase::DoRun(), ReadFileTestCase::DoRun(), ReadModeCreateTestCase::DoRun(), RecordHeaderTestCase::DoRun(), RectangleClosestBorderTestCase::DoRun(), RrcConnectionReconfigurationCompleteTestCase::DoRun(), RrcConnectionReconfigurationTestCase::DoRun(), RrcConnectionReestablishmentCompleteTestCase::DoRun(), RrcConnectionReestablishmentRequestTestCase::DoRun(), RrcConnectionReestablishmentTestCase::DoRun(), RrcConnectionRejectTestCase::DoRun(), RrcConnectionRequestTestCase::DoRun(), RrcConnectionSetupCompleteTestCase::DoRun(), RrcConnectionSetupTestCase::DoRun(), SameRoomPositionAllocatorTestCase::DoRun(), SetChannelFrequencyTest::DoRun(), SpectrumIdealPhyTestCase::DoRun(), SpectrumWifiPhyBasicTest::DoRun(), SpectrumWifiPhyInterfacesHelperTest::DoRun(), SpectrumWifiPhyListenerTest::DoRun(), StaWifiMacScanningTestCase::DoRun(), SwitchFlowTableTestCase::DoRun(), TcpHeaderFlagsToString::DoRun(), TcpHeaderGetSetTestCase::DoRun(), TcpHighSpeedDecrementTest::DoRun(), TcpHighSpeedIncrementTest::DoRun(), TcpHtcpIncrementTest::DoRun(), TcpHyblaIncrementTest::DoRun(), TcpIllinoisTest::DoRun(), TcpScalableDecrementTest::DoRun(), TcpScalableIncrementTest::DoRun(), TcpSynConnectionFailedTest::DoRun(), TcpVegasTest::DoRun(), TcpVenoTest::DoRun(), TcpYeahDecrementTest::DoRun(), TcpYeahIncrementTest::DoRun(), ThreeGppCalcLongTermMultiPortTest::DoRun(), ThreeGppChannelMatrixComputationTest::DoRun(), ThreeGppHttpObjectTestCase::DoRun(), ThreeGppMimoPolarizationTest::DoRun(), ThreeGppSpectrumPropagationLossModelTest::DoRun(), ThreeGppV2vBuildingsChCondModelTestCase::DoRun(), TimerStateTestCase::DoRun(), TimeSimpleTestCase::DoRun(), TracedCallbackTestCase::DoRun(), TupleValueTestCase::DoRun(), TwoBridgeTest::DoRun(), TwoLanTest::DoRun(), TwoLinkTest::DoRun(), UanModesListTest::DoRun(), UdpClientServerTestCase::DoRun(), UdpTraceClientServerTestCase::DoRun(), UniqueTypeIdTestCase::DoRun(), WaveformGeneratorTestCase::DoRun(), WifiAcMappingTest::DoRun(), WifiPhyChannel80Plus80Test::DoRun(), WifiPhyThresholdsStrongForeignSignalTest::DoRun(), WifiPhyThresholdsStrongWifiSignalTest::DoRun(), WifiPhyThresholdsWeakForeignSignalTest::DoRun(), WifiPhyThresholdsWeakWifiSignalTest::DoRun(), WriteModeCreateTestCase::DoRun(), FifoQueueDiscTestCase::DoRunFifoTest(), TidToLinkMappingElementTest::DoSetup(), LteHandoverFailureTestCase::DoTeardown(), LteHandoverTargetTestCase::DoTeardown(), LteSecondaryCellHandoverTestCase::DoTeardown(), LteUeMeasurementsHandoverTestCase::DoTeardown(), LteUeMeasurementsPiecewiseTestCase1::DoTeardown(), LteUeMeasurementsPiecewiseTestCase2::DoTeardown(), LteUeMeasurementsPiecewiseTestCase3::DoTeardown(), TcpLinuxRenoCongAvoidTest::DoTeardown(), TcpLinuxRenoSSTest::DoTeardown(), TimeSimpleTestCase::DoTimeOperations(), BufferTest::EnsureWrittenBytes(), CarrierAggregationConfigTestCase::Evaluate(), ns3::TcpBbrCheckGainValuesTest::ExecuteTest(), ns3::TcpBbrPacingEnableTest::ExecuteTest(), TcpBicDecrementTest::ExecuteTest(), TcpBicIncrementTest::ExecuteTest(), TcpDctcpToLinuxReno::ExecuteTest(), TcpLedbatDecrementTest::ExecuteTest(), TcpLedbatIncrementTest::ExecuteTest(), TcpLedbatToNewReno::ExecuteTest(), TestSimpleFrameCaptureModel::Expect1000BPacketDropped(), TestSimpleFrameCaptureModel::Expect1000BPacketReceived(), TestSimpleFrameCaptureModel::Expect1500BPacketDropped(), TestSimpleFrameCaptureModel::Expect1500BPacketReceived(), ns3::TcpCloseWithLossTestCase::FinalChecks(), TcpBytesInFlightTest::FinalChecks(), TcpDataSentCbTestCase::FinalChecks(), TcpFastRetrTest::FinalChecks(), TcpLargeTransferLossTest::FinalChecks(), TcpPktsAckedOpenTest::FinalChecks(), TcpRtoTest::FinalChecks(), TcpRttEstimationTest::FinalChecks(), TcpTimeRtoTest::FinalChecks(), TcpZeroWindowTest::FinalChecks(), LteHandoverTargetTestCase::HandoverStartCallback(), TcpAdvertisedWindowTest::InvalidAwndCb(), TcpAdvWindowOnLossTest::InvalidAwndCb(), PreservePacketsInAmpdus::NotifyMacHeaderEndRx(), TcpHeaderWithRFC793OptionTestCase::OneOptionAtTime(), TcpFastRetrTest::PktDropped(), TcpFastRetrTest::ProcessedAck(), TcpRtoTest::ProcessedAck(), TcpZeroWindowTest::ProcessedAck(), LteRadioLinkFailureTestCase::RadioLinkFailureCallback(), TcpRateLinuxWithBufferTest::RateSampleUpdatedTrace(), TcpRateLinuxWithSocketsTest::RateSampleUpdatedTrace(), TcpRateLinuxWithBufferTest::RateUpdatedTrace(), TcpRateLinuxWithSocketsTest::RateUpdatedTrace(), TcpFastRetrTest::RcvAck(), TcpRtoTest::RcvAck(), TestUlOfdmaPowerControl::ReceiveOkCallbackAtAp(), DynamicNeighborCacheTest::ReceivePkt(), Ipv4DeduplicationTest::ReceivePkt(), Ipv4ForwardingTest::ReceivePkt(), Ipv4GlobalRoutingSlash32TestCase::ReceivePkt(), Ipv4HeaderTest::ReceivePkt(), Ipv4RawSocketImplTest::ReceivePkt(), Ipv4RipCountToInfinityTest::ReceivePkt(), Ipv4RipTest::ReceivePkt(), Ipv4StaticRoutingSlash32TestCase::ReceivePkt(), Ipv6ForwardingTest::ReceivePkt(), Ipv6RawSocketImplTest::ReceivePkt(), Ipv6RipngCountToInfinityTest::ReceivePkt(), Ipv6RipngTest::ReceivePkt(), NixVectorRoutingTest::ReceivePkt(), Udp6SocketImplTest::ReceivePkt(), Udp6SocketLoopbackTest::ReceivePkt(), UdpSocketImplTest::ReceivePkt(), UdpSocketLoopbackTest::ReceivePkt(), Ipv4RawSocketImplTest::ReceivePkt2(), Ipv6RawSocketImplTest::ReceivePkt2(), Udp6SocketImplTest::ReceivePkt2(), UdpSocketImplTest::ReceivePkt2(), Ipv4RipSplitHorizonStrategyTest::ReceivePktProbe(), Ipv6RipngSplitHorizonStrategyTest::ReceivePktProbe(), BulkSendSeqTsSizeTestCase::ReceiveRx(), LteUeMeasurementsTestCase::RecvMeasurementReport(), LteUeMeasurementsHandoverTestCase::RecvMeasurementReportCallback(), LteUeMeasurementsPiecewiseTestCase1::RecvMeasurementReportCallback(), LteUeMeasurementsPiecewiseTestCase2::RecvMeasurementReportCallback(), LteUeMeasurementsPiecewiseTestCase3::RecvMeasurementReportCallback(), PingTestCase::ReportTraceSink(), SpectrumInterferenceTestCase::RetrieveTestResult(), AredQueueDiscTestCase::RunAredDiscTest(), CobaltQueueDiscDropTest::RunDropTest(), FifoQueueDiscTestCase::RunFifoTest(), Issue40TestCase::RunOne(), MldSwapLinksTest::RunOne(), PhyChannelSettingsToOperatingChannelTest::RunOne(), SetWifiOperatingChannelTest::RunOne(), SpectrumWifiPhyGetBandTest::RunOne(), TestPrimary20CoveredByPpdu::RunOne(), Wifi20MHzChannelIndicesTest::RunOne(), Wifi20MHzIndicesCoveringRuTest::RunOne(), PieQueueDiscTestCase::RunPieTest(), RedQueueDiscTestCase::RunRedTest(), TbfQueueDiscTestCase::RunTbfTest(), ns3::TcpEcnTest::Rx(), TcpDctcpCodePointsTest::Rx(), TcpZeroWindowTest::Rx(), SpectrumWifiPhyFilterTest::RxCallback(), Ipv4PacketInfoTagTest::RxCb(), Ipv6PacketInfoTagTest::RxCb(), TestMultipleCtsResponsesFromMuRts::RxCtsSuccess(), TestNonHtDuplicatePhyReception::RxSuccess(), TestUlMuMimoPhyTransmission::RxSuccess(), TcpRateLinuxBasicTest::SendSkb(), BulkSendSeqTsSizeTestCase::SendTx(), ThreeGppHttpObjectTestCase::ServerRxCallback(), TcpRateLinuxBasicTest::SkbDelivered(), EmlsrCcaBusyTest::StartTraffic(), LengthTestCase::TestAddingLengthAndQuantity(), LengthTestCase::TestAddingQuantityAndLength(), LengthTestCase::TestAddingTwoLengths(), PowerRateAdaptationTest::TestAparf(), LengthValueTestCase::TestAttributeConstructor(), LengthValueTestCase::TestAttributeDeserialization(), LengthValueTestCase::TestAttributeSerialization(), LengthTestCase::TestBuilderFreeFunctions(), LengthTestCase::TestConstructLengthFromQuantity(), LengthTestCase::TestConstructLengthFromSIUnits(), LengthTestCase::TestCopyAssignment(), LengthTestCase::TestDefaultLengthIsZero(), PbbTestCase::TestDeserialize(), LengthTestCase::TestDivideLengthByLength(), LengthTestCase::TestDivideLengthByScalar(), TimeSimpleTestCase::TestDivision(), LengthTestCase::TestDivReturnsCorrectRemainder(), LengthTestCase::TestDivReturnsCorrectResult(), LengthTestCase::TestDivReturnsZeroRemainder(), PfifoFastQueueDiscDscpPrioritization::TestDscpValue(), ns3::HeaderSerializationTestCase::TestHeaderSerialization(), LengthTestCase::TestInputStreamOperator(), TcpTxBufferTestCase::TestIsLost(), LengthTestCase::TestLengthCopyConstructor(), LengthTestCase::TestLengthMoveConstructor(), LengthTestCase::TestLengthSerialization(), LengthTestCase::TestModReturnsNonZero(), LengthTestCase::TestModReturnsZero(), LengthTestCase::TestMoveAssignment(), TimeSimpleTestCase::TestMultiplication(), LengthTestCase::TestMultiplyLengthByScalar(), LengthTestCase::TestMultiplyScalarByLength(), TcpTxBufferTestCase::TestNewBlock(), TcpTxBufferTestCase::TestNextSeg(), LengthValueTestCase::TestObjectAttribute(), LengthTestCase::TestOutputStreamOperator(), PowerRateAdaptationTest::TestParf(), LengthTestCase::TestQuantityAssignment(), PowerRateAdaptationTest::TestRrpaa(), PbbTestCase::TestSerialize(), LengthValueTestCase::TestSetAttributeUsingStringValue(), ns3::tests::TrickleTimerTestCase::TestSteadyState(), LengthTestCase::TestSubtractingLengthAndQuantity(), LengthTestCase::TestSubtractingQuantityAndLength(), LengthTestCase::TestSubtractingTwoLengths(), PfifoFastQueueDiscTosPrioritization::TestTosValue(), TcpRxBufferTestCase::TestUpdateSACKList(), BlockAckAggregationDisabledTest::Transmit(), EmlsrOperationsTestBase::Transmit(), MultiLinkOperationsTestBase::Transmit(), StartSeqNoUpdateAfterAddBaTimeoutTest::Transmit(), ns3::TcpEcnTest::Tx(), SackPermittedTestCase::Tx(), TcpDctcpCodePointsTest::Tx(), TcpFastRetrTest::Tx(), TcpTimeRtoTest::Tx(), TcpZeroWindowTest::Tx(), TimestampTestCase::Tx(), WScalingTestCase::Tx(), Issue169TestCase::TxCallback(), PingTestCase::TxTraceSink(), LteCqiGenerationDlPowerControlTestCase::UlScheduling(), LteCqiGenerationTestCase::UlScheduling(), LteInterferenceTestCase::UlScheduling(), TcpRttEstimationTest::UpdatedRttHistory(), WifiFilsFrameTest::ValidateCnt(), WifiFilsFrameTest::ValidateFilsDiscFrame(), TestPhyPaddingExclusion::VerifyEventsCleared(), TestUlMuMimoPhyTransmission::VerifyEventsCleared(), TestUlOfdmaPhyTransmission::VerifyEventsCleared(), and SpectrumWifiPhyTrackedBandsTest::VerifyTrackedBands().

◆ NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL

#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) == (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) == " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)
#define CONTINUE_ON_FAILURE_RETURNS_BOOL
If we shouldn't continue on errors, return test status.
Definition test.h:92

Test that an actual and expected (limit) value are equal and report and abort if not.

Check to see if the expected (limit) value is equal to the actual value found in a test case. If the two values are equal nothing happens, but if the comparison fails, an error is reported in a consistent way and the execution of the current test case is aborted.

The message is interpreted as a stream, for example:

"cannot open file " << filename << " in test");
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition test.h:189

is legal.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the expected value of the test.
[in]msgMessage that is output if the test does not pass.
Warning
Do not use this macro if you are comparing floating point numbers (float or double) as it is unlikely to do what you expect. Use NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_TOL instead.

This function returns a Boolean value.

Definition at line 189 of file test.h.

Referenced by UanTest::DoPhyTests(), and Ns2MobilityHelperTest::WriteTrace().

◆ NS_TEST_ASSERT_MSG_EQ_TOL

#define NS_TEST_ASSERT_MSG_EQ_TOL ( actual,
limit,
tol,
msg )
Value:
do \
{ \
if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit << " +- " << tol; \
std::ostringstream condStream; \
condStream << #actual << " (actual) < " << #limit << " (limit) + " << #tol \
<< " (tol) && " << #actual << " (actual) > " << #limit << " (limit) - " \
<< #tol << " (tol)"; \
ReportTestFailure(condStream.str(), \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and abort if not.

Check to see if the expected (limit) value is equal to the actual value found in a test case to some tolerance. This is not the same thing as asking if two floating point are equal to within some epsilon, but is useful for that case. This assertion is geared toward more of a measurement problem. Consider measuring a physical rod of some kind that you have ordered. You need to determine if it is "good." You want to measure the rod to an arbitrary precision of sixteen significant figures, you will measure the rod to determine if its length is within the tolerances you provided. For example, 12.00 inches plus or minus .005 inch may be just fine.

In ns-3, you might want to measure a signal to noise ratio and check to see if the answer is what you expect. If you naively measure (double)1128.93 and compare this number with a constant 1128.93 you are almost certainly going to have your test fail because of floating point rounding errors. We provide a floating point comparison function ns3::TestDoubleIsEqual() but you will probably quickly find that is not what you want either. It may turn out to be the case that when you measured an SNR that printed as 1128.93, what was actually measured was something more like 1128.9287653857625442 for example. Given that the double epsilon is on the order of 0.0000000000000009, you would need to provide sixteen significant figures of expected value for this kind of test to pass even with a typical test for floating point "approximate equality." That is clearly not required or desired. You really want to be able to provide 1128.93 along with a tolerance just like you provided 12 inches +- 0.005 inch above.

This assertion is designed for real measurements by taking into account measurement tolerances. By doing so it also automatically compensates for floating point rounding errors. If you really want to check floating point equality down to the numeric_limits<double>::epsilon () range, consider using ns3::TestDoubleIsEqual().

Note
Mixing signed and unsigned types can lead to misleading results.

The message is interpreted as a stream, for example:

NS_TEST_ASSERT_MSG_EQ_TOL (snr, 1128.93, 0.005,
"wrong snr (" << snr << ") in test");
#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...
Definition test.h:327

is legal.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the expected value of the test.
[in]tolTolerance of the test.
[in]msgMessage that is output if the test does not pass.

Definition at line 327 of file test.h.

Referenced by TcpTimeRtoTest::AfterRTOExpired(), ns3::int64x64::test::Int64x64ArithmeticTestCase::Check(), ns3::int64x64::test::Int64x64DoubleTestCase::Check(), TimestampValueTestCase::Check(), ns3::int64x64::test::Int64x64InvertTestCase::CheckCase(), AnimationRemainingEnergyTestCase::CheckLogic(), TestUlOfdmaPhyTransmission::CheckNonOfdmaRxPower(), LteFrAreaTestCase::DlDataRxStart(), AcousticModemEnergyTestCase::DoRun(), BasicEnergyHarvesterTestCase::DoRun(), BuildingsPathlossTestCase::DoRun(), BuildingsShadowingTestCase::DoRun(), FiveDoublesAverageTestCase::DoRun(), FiveDoublesTestCase::DoRun(), FiveIntegersAverageTestCase::DoRun(), FiveIntegersTestCase::DoRun(), FtrFadingModelAverageTest::DoRun(), GeoToCartesianTestCase::DoRun(), ItuR1411LosPropagationLossModelTestCase::DoRun(), ItuR1411NlosOverRooftopPropagationLossModelTestCase::DoRun(), Kun2600MhzPropagationLossModelTestCase::DoRun(), LenaCqaFfMacSchedulerTestCase1::DoRun(), LenaCqaFfMacSchedulerTestCase2::DoRun(), LenaDataPhyErrorModelTestCase::DoRun(), LenaDlCtrlPhyErrorModelTestCase::DoRun(), LenaFdBetFfMacSchedulerTestCase1::DoRun(), LenaFdBetFfMacSchedulerTestCase2::DoRun(), LenaFdMtFfMacSchedulerTestCase::DoRun(), LenaFdTbfqFfMacSchedulerTestCase1::DoRun(), LenaFdTbfqFfMacSchedulerTestCase2::DoRun(), LenaHarqTestCase::DoRun(), LenaMimoTestCase::DoRun(), LenaPfFfMacSchedulerTestCase1::DoRun(), LenaPfFfMacSchedulerTestCase2::DoRun(), LenaPssFfMacSchedulerTestCase1::DoRun(), LenaPssFfMacSchedulerTestCase2::DoRun(), LenaRrFfMacSchedulerTestCase::DoRun(), LenaTdBetFfMacSchedulerTestCase1::DoRun(), LenaTdBetFfMacSchedulerTestCase2::DoRun(), LenaTdMtFfMacSchedulerTestCase::DoRun(), LenaTdTbfqFfMacSchedulerTestCase1::DoRun(), LenaTdTbfqFfMacSchedulerTestCase2::DoRun(), LenaTtaFfMacSchedulerTestCase::DoRun(), LiIonEnergyTestCase::DoRun(), LrWpanErrorModelTestCase::DoRun(), LrWpanSpectrumValueHelperTestCase::DoRun(), LteAggregationThroughputScaleTestCase::DoRun(), LteDownlinkPowerControlTestCase::DoRun(), LteEarfcnDlTestCase::DoRun(), LteEarfcnTestCase::DoRun(), LteEarfcnUlTestCase::DoRun(), LteEnbAntennaTestCase::DoRun(), LteInterferenceHardFrTestCase::DoRun(), LteInterferenceStrictFrTestCase::DoRun(), LteInterferenceTestCase::DoRun(), LteLinkAdaptationTestCase::DoRun(), LtePathlossModelSystemTestCase::DoRun(), ns3::LenaDeactivateBearerTestCase::DoRun(), ns3::test::RandomVariable::BernoulliAntitheticTestCase::DoRun(), ns3::test::RandomVariable::BernoulliTestCase::DoRun(), ns3::test::RandomVariable::BinomialAntitheticTestCase::DoRun(), ns3::test::RandomVariable::BinomialTestCase::DoRun(), ns3::test::RandomVariable::ConstantTestCase::DoRun(), ns3::test::RandomVariable::DeterministicTestCase::DoRun(), ns3::test::RandomVariable::EmpiricalAntitheticTestCase::DoRun(), ns3::test::RandomVariable::EmpiricalTestCase::DoRun(), ns3::test::RandomVariable::ErlangAntitheticTestCase::DoRun(), ns3::test::RandomVariable::ErlangTestCase::DoRun(), ns3::test::RandomVariable::ExponentialAntitheticTestCase::DoRun(), ns3::test::RandomVariable::ExponentialTestCase::DoRun(), ns3::test::RandomVariable::GammaAntitheticTestCase::DoRun(), ns3::test::RandomVariable::GammaTestCase::DoRun(), ns3::test::RandomVariable::LaplacianTestCase::DoRun(), ns3::test::RandomVariable::LargestExtremeValueTestCase::DoRun(), ns3::test::RandomVariable::LogNormalAntitheticTestCase::DoRun(), ns3::test::RandomVariable::LogNormalTestCase::DoRun(), ns3::test::RandomVariable::NormalAntitheticTestCase::DoRun(), ns3::test::RandomVariable::NormalTestCase::DoRun(), ns3::test::RandomVariable::ParetoAntitheticTestCase::DoRun(), ns3::test::RandomVariable::ParetoTestCase::DoRun(), ns3::test::RandomVariable::SequentialTestCase::DoRun(), ns3::test::RandomVariable::WeibullAntitheticTestCase::DoRun(), ns3::test::RandomVariable::WeibullTestCase::DoRun(), ns3::test::RandomVariable::ZetaAntitheticTestCase::DoRun(), ns3::test::RandomVariable::ZetaTestCase::DoRun(), ns3::test::RandomVariable::ZipfAntitheticTestCase::DoRun(), ns3::test::RandomVariable::ZipfTestCase::DoRun(), ns3::tests::MatrixArrayTestCase< T >::DoRun(), ns3::tests::SampleTestCase1::DoRun(), OkumuraHataPropagationLossModelTestCase::DoRun(), OneIntegerAverageTestCase::DoRun(), OneIntegerTestCase::DoRun(), RttEstimatorTestCase::DoRun(), SpectrumIdealPhyTestCase::DoRun(), TableBasedErrorRateTestCase::DoRun(), TcpHyblaIncrementTest::DoRun(), ThreeGppChannelMatrixComputationTest::DoRun(), TimeSimpleTestCase::DoRun(), TimeWithSignTestCase::DoRun(), TvSpectrumTransmitterTestCase::DoRun(), UanTest::DoRun(), WifiErrorRateModelsTestCaseDsss::DoRun(), WifiErrorRateModelsTestCaseMimo::DoRun(), WifiErrorRateModelsTestCaseNist::DoRun(), LteUplinkPowerControlTestCase::PucchTxPowerTrace(), LteUplinkPowerControlTestCase::PuschTxPowerTrace(), TestUlOfdmaPowerControl::ReceiveOkCallbackAtAp(), PingTestCase::ReportTraceSink(), LteUeMeasurementsTestCase::ReportUeMeasurements(), PingTestCase::RttTraceSink(), LteUplinkPowerControlTestCase::SrsTxPowerTrace(), LengthTestCase::TestConstructLengthFromString(), LengthTestCase::TestConstructLengthFromUSUnits(), LengthTestCase::TestTryParseReturnsTrue(), ProbeTestCase1::TraceSink(), TcpTimeRtoTest::Tx(), LteFrAreaTestCase::UlDataRxStart(), and WifiFilsFrameTest::ValidateTiming().

◆ NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL

#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL ( actual,
limit,
tol,
msg )
Value:
do \
{ \
if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit << " +- " << tol; \
std::ostringstream condStream; \
condStream << #actual << " (actual) < " << #limit << " (limit) + " << #tol \
<< " (tol) && " << #actual << " (actual) > " << #limit << " (limit) - " \
<< #tol << " (tol)"; \
ReportTestFailure(condStream.str(), \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and abort if not.

Check to see if the expected (limit) value is equal to the actual value found in a test case to some tolerance. This is not the same thing as asking if two floating point are equal to within some epsilon, but is useful for that case. This assertion is geared toward more of a measurement problem. Consider measuring a physical rod of some kind that you have ordered. You need to determine if it is "good." You want to measure the rod to an arbitrary precision of sixteen significant figures, you will measure the rod to determine if its length is within the tolerances you provided. For example, 12.00 inches plus or minus .005 inch may be just fine.

In ns-3, you might want to measure a signal to noise ratio and check to see if the answer is what you expect. If you naively measure (double)1128.93 and compare this number with a constant 1128.93 you are almost certainly going to have your test fail because of floating point rounding errors. We provide a floating point comparison function ns3::TestDoubleIsEqual() but you will probably quickly find that is not what you want either. It may turn out to be the case that when you measured an SNR that printed as 1128.93, what was actually measured was something more like 1128.9287653857625442 for example. Given that the double epsilon is on the order of 0.0000000000000009, you would need to provide sixteen significant figures of expected value for this kind of test to pass even with a typical test for floating point "approximate equality." That is clearly not required or desired. You really want to be able to provide 1128.93 along with a tolerance just like you provided 12 inches +- 0.005 inch above.

This assertion is designed for real measurements by taking into account measurement tolerances. By doing so it also automatically compensates for floating point rounding errors. If you really want to check floating point equality down to the numeric_limits<double>::epsilon () range, consider using ns3::TestDoubleIsEqual().

Note
Mixing signed and unsigned types can lead to misleading results.

The message is interpreted as a stream, for example:

"wrong snr (" << snr << ") in test");
#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition test.h:415

is legal.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the expected value of the test.
[in]tolTolerance of the test.
[in]msgMessage that is output if the test does not pass.

This function returns a Boolean value.

Definition at line 415 of file test.h.

◆ NS_TEST_ASSERT_MSG_GT

#define NS_TEST_ASSERT_MSG_GT ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) > (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) > " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual value is greater than a limit and report and abort if not.

Check to see if the actual value found in a test case is greater than the limit value. If the actual value is greater nothing happens, but if the check fails, an error is reported in a consistent way and the execution of the current test case is aborted.

The message is interpreted as a stream.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the limit value of the test.
[in]msgMessage that is output if the test does not pass.

Definition at line 864 of file test.h.

Referenced by TcpLargeTransferLossTest::TcpLargeTransferLossTest(), BackoffGenerationTest::BackoffGenerated(), LteX2HandoverMeasuresTestCase::CheckStats(), ThreeGppHttpObjectTestCase::ClientRxEmbeddedObjectCallback(), ThreeGppHttpObjectTestCase::ClientRxMainObjectCallback(), BuildingsShadowingTestCase::DoRun(), LrWpanDataIfsTestCase::DoRun(), ns3::RlcAmStatusPduTestCase::DoRun(), ns3::test::RandomVariable::NormalCachingTestCase::DoRun(), ns3::test::RandomVariable::UniformTestCase::DoRun(), ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestCase::DoRun(), ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::DoRun(), ProbeTestCase1::DoRun(), RandomRoomPositionAllocatorTestCase::DoRun(), TestActiveScanPanDescriptors::DoRun(), TvHelperDistributionTestCase::DoRun(), WifiErrorRateModelsTestCaseMimo::DoRun(), WifiMsduAggregatorThroughputTest::DoRun(), LteHandoverTargetTestCase::HandoverStartCallback(), PieQueueDiscTestCase::RunPieTest(), RedQueueDiscTestCase::RunRedTest(), ThreeGppHttpObjectTestCase::ServerRxCallback(), and ProbeTestCase1::TraceSink().

◆ NS_TEST_ASSERT_MSG_GT_OR_EQ

#define NS_TEST_ASSERT_MSG_GT_OR_EQ ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) >= (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) > " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual value is greater than or equal to a limit and report and abort if not.

Check to see if the actual value found in a test case is greater than or equal to the limit value. If the actual value is greater nothing happens, but if the check fails, an error is reported in a consistent way and the execution of the current test case is aborted.

The message is interpreted as a stream.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the limit value of the test.
[in]msgMessage that is output if the test does not pass.

Definition at line 905 of file test.h.

Referenced by EmlsrLinkSwitchTest::CheckResults(), OfdmaAckSequenceTest::CheckResults(), TcpSlowStartNormalTest::CWndTrace(), PrrRecoveryTest::DoRun(), WifiAcMappingTest::DoRun(), TcpFastRetrTest::ProcessedAck(), TcpRateLinuxWithSocketsTest::RateUpdatedTrace(), BulkSendSeqTsSizeTestCase::ReceiveRx(), PingTestCase::ReportTraceSink(), and BulkSendSeqTsSizeTestCase::SendTx().

◆ NS_TEST_ASSERT_MSG_LT

#define NS_TEST_ASSERT_MSG_LT ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) < (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) < " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual value is less than a limit and report and abort if not.

Check to see if the actual value found in a test case is less than the limit value. If the actual value is lesser nothing happens, but if the check fails, an error is reported in a consistent way and the execution of the current test case is aborted.

The message is interpreted as a stream.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the limit value of the test.
[in]msgMessage that is output if the test does not pass.

Definition at line 699 of file test.h.

Referenced by BuildingsShadowingTestCase::DoRun(), ns3::RlcAmStatusPduTestCase::DoRun(), ns3::test::RandomVariable::BernoulliAntitheticTestCase::DoRun(), ns3::test::RandomVariable::BernoulliTestCase::DoRun(), ns3::test::RandomVariable::BinomialAntitheticTestCase::DoRun(), ns3::test::RandomVariable::BinomialTestCase::DoRun(), ns3::test::RandomVariable::EmpiricalTestCase::DoRun(), ns3::test::RandomVariable::ErlangAntitheticTestCase::DoRun(), ns3::test::RandomVariable::ErlangTestCase::DoRun(), ns3::test::RandomVariable::ExponentialAntitheticTestCase::DoRun(), ns3::test::RandomVariable::ExponentialTestCase::DoRun(), ns3::test::RandomVariable::GammaAntitheticTestCase::DoRun(), ns3::test::RandomVariable::GammaTestCase::DoRun(), ns3::test::RandomVariable::LogNormalAntitheticTestCase::DoRun(), ns3::test::RandomVariable::LogNormalTestCase::DoRun(), ns3::test::RandomVariable::NormalAntitheticTestCase::DoRun(), ns3::test::RandomVariable::NormalCachingTestCase::DoRun(), ns3::test::RandomVariable::NormalTestCase::DoRun(), ns3::test::RandomVariable::ParetoAntitheticTestCase::DoRun(), ns3::test::RandomVariable::ParetoTestCase::DoRun(), ns3::test::RandomVariable::UniformAntitheticTestCase::DoRun(), ns3::test::RandomVariable::UniformTestCase::DoRun(), ns3::test::RandomVariable::WeibullAntitheticTestCase::DoRun(), ns3::test::RandomVariable::WeibullTestCase::DoRun(), ns3::tests::ManyUniformRandomVariablesOneGetValueCallTestCase::DoRun(), ns3::tests::OneUniformRandomVariableManyGetValueCallsTestCase::DoRun(), RandCartAroundGeoTestCase::DoRun(), RandomRoomPositionAllocatorTestCase::DoRun(), RngExponentialTestCase::DoRun(), RngNormalTestCase::DoRun(), RngParetoTestCase::DoRun(), RngUniformTestCase::DoRun(), TestActiveScanPanDescriptors::DoRun(), TvHelperDistributionTestCase::DoRun(), LteHandoverDelayTestCase::EnbHandoverEndOkCallback(), LteRadioLinkFailureTestCase::RadioLinkFailureCallback(), AredQueueDiscTestCase::RunAredDiscTest(), MldSwapLinksTest::RunOne(), PieQueueDiscTestCase::RunPieTest(), RedQueueDiscTestCase::RunRedTest(), ProbeTestCase1::TraceSink(), and LteHandoverDelayTestCase::UeHandoverEndOkCallback().

◆ NS_TEST_ASSERT_MSG_LT_OR_EQ

#define NS_TEST_ASSERT_MSG_LT_OR_EQ ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) <= (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) < " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual value is less than or equal to a limit and report and abort if not.

Check to see if the actual value found in a test case is less than or equal to the limit value. If the actual value is lesser or equal nothing happens, but if the check fails, an error is reported in a consistent way and the execution of the current test case is aborted.

The message is interpreted as a stream.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the limit value of the test.
[in]msgMessage that is output if the test does not pass.

Definition at line 740 of file test.h.

Referenced by TcpNewRenoCongAvoidNormalTest::Check(), TcpLinuxRenoSSTest::CWndTrace(), TcpSlowStartNormalTest::CWndTrace(), CartesianToGeoTestCase::DoRun(), PrrRecoveryTest::DoRun(), TcpHyblaIncrementTest::DoRun(), and TcpPacingTest::Tx().

◆ NS_TEST_ASSERT_MSG_NE

#define NS_TEST_ASSERT_MSG_NE ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) != (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) != " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual and expected (limit) value are not equal and report and abort if not.

Check to see if the expected (limit) value is not equal to the actual value found in a test case. If the two values are not equal nothing happens, but if the comparison fails, an error is reported in a consistent way and the execution of the current test case is aborted.

The message is interpreted as a stream, for example:

NS_TEST_ASSERT_MSG_NE (result, false,
"cannot open file " << filename << " in test");
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Definition test.h:554

is legal.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the value that actual is tested against.
[in]msgMessage that is output if the test does not pass.

Definition at line 554 of file test.h.

Referenced by TcpLargeTransferLossTest::TcpLargeTransferLossTest(), LteRadioLinkFailureTestCase::CheckConnected(), LteX2HandoverMeasuresTestCase::CheckConnected(), LteX2HandoverTestCase::CheckConnected(), Ipv4DeduplicationTest::CheckDrops(), AbstractAnimationInterfaceTestCase::CheckFileExistence(), EmlsrLinkSwitchTest::CheckInitialControlFrame(), MultiLinkSetupTest::CheckQosData(), EmlsrLinkSwitchTest::CheckResults(), AttributeContainerTestCase::DoRun(), AttributeTestCase< T >::DoRun(), BridgeTest::DoRun(), BufferTest::DoRun(), CallbackValueTestCase::DoRun(), CobaltQueueDiscBasicEnqueueDequeue::DoRun(), CoDelQueueDiscBasicEnqueueDequeue::DoRun(), CollisionTestCase::DoRun(), DeprecatedAttributeTestCase::DoRun(), FileHeaderTestCase::DoRun(), IntegerTraceSourceAttributeTestCase::DoRun(), IntegerTraceSourceTestCase::DoRun(), LanTest::DoRun(), LinkTest::DoRun(), ns3::test::RandomVariable::ConstantTestCase::DoRun(), ns3::tests::AggregateObjectTestCase::DoRun(), ns3::tests::CreateObjectTestCase::DoRun(), ns3::tests::MatrixArrayTestCase< T >::DoRun(), ns3::tests::ObjectFactoryTestCase::DoRun(), ns3::tests::UnidirectionalAggregateObjectTestCase::DoRun(), ns3::tests::ValArrayTestCase< T >::DoRun(), ObjectMapAttributeTestCase::DoRun(), ObjectVectorAttributeTestCase::DoRun(), PointerAttributeTestCase::DoRun(), QueueDiscTracesTestCase::DoRun(), RandomVariableStreamAttributeTestCase::DoRun(), RecordHeaderTestCase::DoRun(), RocketfuelTopologyReaderMapsTest::DoRun(), RocketfuelTopologyReaderWeightsTest::DoRun(), SwitchFlowTableTestCase::DoRun(), TcpHyblaIncrementTest::DoRun(), ThreeGppHttpObjectTestCase::DoRun(), TracedCallbackTestCase::DoRun(), TwoBridgeTest::DoRun(), TwoLanTest::DoRun(), TwoLinkTest::DoRun(), FifoQueueDiscTestCase::DoRunFifoTest(), EmlsrOperationsTestBase::DoSetup(), MultiLinkOperationsTestBase::DoSetup(), AredQueueDiscTestCase::RunAredDiscTest(), CobaltQueueDiscDropTest::RunDropTest(), PieQueueDiscTestCase::RunPieTest(), RedQueueDiscTestCase::RunRedTest(), TbfQueueDiscTestCase::RunTbfTest(), ns3::TcpEcnTest::Rx(), TcpDctcpCodePointsTest::Rx(), MultiLinkMuTxTest::StartTraffic(), MultiLinkMuTxTest::Transmit(), ns3::TcpEcnTest::Tx(), and TcpRttEstimationTest::Tx().

◆ NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL

#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) != (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) != " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual and expected (limit) value are not equal and report and abort if not.

Check to see if the expected (limit) value is not equal to the actual value found in a test case. If the two values are equal nothing happens, but if the comparison fails, an error is reported in a consistent way and the execution of the current test case is aborted.

The message is interpreted as a stream, for example:

"cannot open file " << filename << " in test");
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Definition test.h:605

is legal.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the expected value of the test.
[in]msgMessage that is output if the test does not pass.

This function returns a Boolean value.

Definition at line 605 of file test.h.

Referenced by Ns2MobilityHelperTest::CheckInitialPositions().

◆ NS_TEST_EXPECT_MSG_EQ

#define NS_TEST_EXPECT_MSG_EQ ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) == (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) == " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual and expected (limit) value are equal and report if not.

Check to see if the expected (limit) value is equal to the actual value found in a test case. If the two values are equal nothing happens, but if the comparison fails, an error is reported in a consistent way. EXPECT* macros do not return if an error is detected.

The message is interpreted as a stream, for example:

NS_TEST_EXPECT_MSG_EQUAL (result, true,
"cannot open file " << filename << " in test");

is legal.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the expected value of the test.
[in]msgMessage that is output if the test does not pass.
Warning
Do not use this macro if you are comparing floating point numbers (float or double) as it is unlikely to do what you expect. Use NS_TEST_EXPECT_MSG_EQ_TOL instead.

Definition at line 241 of file test.h.

Referenced by FqCobaltQueueDiscEcnMarking::AddPacket(), FqCoDelQueueDiscECNMarking::AddPacket(), BackoffGenerationTest::BackoffGenerated(), EmlsrUlTxopTest::BackoffGenerated(), ns3::int64x64::test::Int64x64Bug1786TestCase::Check(), ns3::int64x64::test::Int64x64HiLoTestCase::Check(), ns3::int64x64::test::Int64x64InputTestCase::Check(), ns3::int64x64::test::Int64x64IntRoundTestCase::Check(), ns3::tests::EnvVarTestCase::Check(), ns3::tests::HashTestCase::Check(), ns3::tests::SplitStringTestCase::Check(), TimeInputOutputTestCase::Check(), MultiLinkOperationsTestBase::CheckAddresses(), TimInformationElementTest::CheckAidSet(), TimeInputOutputTestCase::CheckAs(), WifiPrimaryChannelsTest::CheckAssociation(), MultiLinkSetupTest::CheckAssocRequest(), MultiLinkSetupTest::CheckAssocResponse(), MultiLinkSetupTest::CheckBeacon(), EmlsrUlTxopTest::CheckBlockAck(), MultiLinkMuTxTest::CheckBlockAck(), MultiLinkTxTest::CheckBlockAck(), EmlsrOperationsTestBase::CheckBlockedLink(), MultiLinkOperationsTestBase::CheckCapabilities(), EmlsrUlTxopTest::CheckCtsFrames(), DataRateTestCase::CheckDataRateEqual(), TcFlowControlTestCase::CheckDeviceQueueStopped(), MultiLinkSetupTest::CheckDisabledLinks(), Ipv4DeduplicationTest::CheckDrops(), EmlOmnExchangeTest::CheckEmlNotification(), EmlOmnExchangeTest::CheckEmlsrLinks(), ns3::tests::EnvVarTestCase::CheckGet(), EmlsrDlTxopTest::CheckInitialControlFrame(), EmlsrLinkSwitchTest::CheckInitialControlFrame(), EmlsrUlTxopTest::CheckInitialControlFrame(), Ns2MobilityHelperTest::CheckInitialPositions(), MultiLinkSetupTest::CheckMlSetup(), Ipv4DeduplicationTest::CheckPackets(), TcFlowControlTestCase::CheckPacketsInDeviceQueue(), TcFlowControlTestCase::CheckPacketsInQueueDisc(), PhyHeaderSectionsTest::CheckPhyHeaderSections(), EmlsrDlTxopTest::CheckPmModeAfterAssociation(), EmlsrCcaBusyTest::CheckPoint1(), MultiLinkSetupTest::CheckProbeResponse(), MultiLinkSetupTest::CheckQosData(), EmlsrDlTxopTest::CheckQosFrames(), WifiPrimaryChannelsTest::CheckReceivedMuPpdus(), WifiPrimaryChannelsTest::CheckReceivedSuPpdus(), WifiPrimaryChannelsTest::CheckReceivedTriggerFrames(), PacketTagListTest::CheckRef(), Bug772ChainTest::CheckResults(), EmlsrDlTxopTest::CheckResults(), EmlsrLinkSwitchTest::CheckResults(), EmlsrUlTxopTest::CheckResults(), OfdmaAckSequenceTest::CheckResults(), TestUnsupportedModulationReception::CheckResults(), WifiTxopTest::CheckResults(), WifiUseAvailBwTest::CheckResults(), EmlsrLinkSwitchTest::CheckRtsFrame(), EmlsrUlTxopTest::CheckRtsFrames(), TimInformationElementTest::CheckSerializationAgainstBuffer(), WifiEhtCapabilitiesIeTest::CheckSerializedByte(), WifiIeFragmentationTest::CheckSerializedByte(), DsrSendBuffTest::CheckSizeLimit(), ns3::aodv::AodvRqueueTest::CheckSizeLimit(), DsrSendBuffTest::CheckTimeout(), ns3::aodv::AodvRqueueTest::CheckTimeout(), ns3::aodv::IdCacheTest::CheckTimeout1(), ns3::aodv::NeighborTest::CheckTimeout1(), ns3::aodv::IdCacheTest::CheckTimeout2(), ns3::aodv::NeighborTest::CheckTimeout2(), ns3::aodv::IdCacheTest::CheckTimeout3(), ns3::aodv::NeighborTest::CheckTimeout3(), DataRateTestCase::CheckTimesEqual(), RttEstimatorTestCase::CheckValues(), WrapToRangeTestCase::CheckWrappingPoint(), UniformPlanarArrayTestCase::ComputeGain(), Ns2MobilityHelperTest::CourseChange(), WaypointMobilityModelAddWaypointTest::CourseChangeCallback(), WaypointMobilityModelNotifyTest::CourseChangeCallback(), HwmpReactiveRegressionTest::CreateDevices(), ns3::olsr::Bug780Test::CreateNodes(), ns3::olsr::TcRegressionTest::CreateNodes(), CobaltQueueDiscCeThresholdTest::Dequeue(), CobaltQueueDiscMarkTest::Dequeue(), CoDelQueueDiscBasicDrop::Dequeue(), TbfQueueDiscTestCase::DequeueAndCheck(), PacketTest::DoCheck(), ChannelAccessManagerTest< TxopType >::DoCheckBusy(), PacketTest::DoCheckData(), AddressAllocator6TestCase::DoRun(), AddressAllocatorHelperTestCase::DoRun(), AddressAllocatorTestCase::DoRun(), AddressCollision6TestCase::DoRun(), AddressCollisionTestCase::DoRun(), AddressTest::DoRun(), AidAssignmentTest::DoRun(), AmpduAggregationTest::DoRun(), BackoffGenerationTest::DoRun(), BasicMultiLinkElementTest::DoRun(), BitDeserializerTest::DoRun(), BitSerializerTest::DoRun(), BlockAckAggregationDisabledTest::DoRun(), BufferTest::DoRun(), CCAVulnerableWindowTest::DoRun(), ChannelTest::DoRun(), ClickIfidFromNameTest::DoRun(), ClickIpMacAddressFromNameTest::DoRun(), ClickTrivialTest::DoRun(), CtrlBAckResponseHeaderTest::DoRun(), DiffTestCase::DoRun(), DropTailQueueTestCase::DoRun(), DsdvTableTestCase::DoRun(), DsrAckHeaderTest::DoRun(), DsrAckReqHeaderTest::DoRun(), DsrCacheEntryTest::DoRun(), DsrFsHeaderTest::DoRun(), DsrRerrHeaderTest::DoRun(), DsrRrepHeaderTest::DoRun(), DsrRreqHeaderTest::DoRun(), DsrRreqTableTest::DoRun(), DsrSendBuffTest::DoRun(), DsrSRHeaderTest::DoRun(), DualStackTestCase::DoRun(), DuplicateTest::DoRun(), DynamicNeighborCacheTest::DoRun(), DynamicPartialTest::DoRun(), EhtAggregationTest::DoRun(), EmlOmnExchangeTest::DoRun(), EmlOperatingModeNotificationTest::DoRun(), ExampleAddress6GeneratorTestCase::DoRun(), ExampleAddressGeneratorTestCase::DoRun(), FlushTest::DoRun(), FqCobaltQueueDiscEcnMarking::DoRun(), FqCobaltQueueDiscL4sMode::DoRun(), FqCoDelQueueDiscECNMarking::DoRun(), FqCoDelQueueDiscL4sMode::DoRun(), FqPieQueueDiscL4sMode::DoRun(), GetRnrLinkInfoTest::DoRun(), HeaderTest::DoRun(), HeAggregationTest::DoRun(), HeRuMcsDataRateTestCase::DoRun(), HeSigBDurationTest::DoRun(), HistogramTestCase::DoRun(), IcmpEchoReplyTestCase::DoRun(), IcmpTimeExceedTestCase::DoRun(), IcmpV6EchoReplyTestCase::DoRun(), IcmpV6TimeExceedTestCase::DoRun(), InterfaceContainerTest::DoRun(), InterferenceTest::DoRun(), InternetStackHelperTestCase::DoRun(), Ipv4DeduplicationTest::DoRun(), Ipv4ForwardingTest::DoRun(), Ipv4FragmentationTest::DoRun(), Ipv4GlobalRoutingSlash32TestCase::DoRun(), Ipv4HeaderTest::DoRun(), Ipv4RawSocketImplTest::DoRun(), Ipv4RipCountToInfinityTest::DoRun(), Ipv4RipSplitHorizonStrategyTest::DoRun(), Ipv4RipTest::DoRun(), Ipv4StaticRoutingSlash32TestCase::DoRun(), Ipv6ForwardingTest::DoRun(), Ipv6FragmentationTest::DoRun(), Ipv6RawSocketImplTest::DoRun(), Ipv6RipngCountToInfinityTest::DoRun(), Ipv6RipngSplitHorizonStrategyTest::DoRun(), Ipv6RipngTest::DoRun(), Issue211Test::DoRun(), LogicalLoraChannelTest::DoRun(), LollipopCounterTest::DoRun(), LrWpanAckTestCase::DoRun(), LrWpanCcaTestCase::DoRun(), LrWpanCollisionTestCase::DoRun(), LrWpanDataIfsTestCase::DoRun(), LrWpanEdTestCase::DoRun(), LrWpanSlottedCsmacaTestCase::DoRun(), MultiLinkMuTxTest::DoRun(), MultiLinkSetupTest::DoRun(), MultiLinkTxTest::DoRun(), MultiStaCtrlBAckResponseHeaderTest::DoRun(), NetDeviceContainerTest::DoRun(), NetworkAllocatorHelperTestCase::DoRun(), NetworkAndAddress6TestCase::DoRun(), NetworkAndAddressTestCase::DoRun(), NetworkNumber6AllocatorTestCase::DoRun(), NetworkNumberAllocatorTestCase::DoRun(), NixVectorRoutingTest::DoRun(), ns3::aodv::AodvRqueueTest::DoRun(), ns3::aodv::AodvRtableEntryTest::DoRun(), ns3::aodv::AodvRtableTest::DoRun(), ns3::aodv::IdCacheTest::DoRun(), ns3::aodv::NeighborTest::DoRun(), ns3::aodv::QueueEntryTest::DoRun(), ns3::aodv::RerrHeaderTest::DoRun(), ns3::aodv::RrepAckHeaderTest::DoRun(), ns3::aodv::RrepHeaderTest::DoRun(), ns3::aodv::RreqHeaderTest::DoRun(), ns3::aodv::TypeHeaderTest::DoRun(), ns3::olsr::Bug780Test::DoRun(), ns3::test::RandomVariable::EmpiricalAntitheticTestCase::DoRun(), ns3::test::RandomVariable::EmpiricalTestCase::DoRun(), ns3::test::RandomVariable::LaplacianTestCase::DoRun(), ns3::test::RandomVariable::ShuffleElementsTest::DoRun(), ns3::tests::EnvVarTestCase::DoRun(), ns3::tests::EventGarbageCollectorTestCase::DoRun(), ns3::tests::PtrTestCase::DoRun(), Ns3WimaxFragmentationTestCase::DoRun(), Ns3WimaxManagementConnectionsTestCase::DoRun(), Ns3WimaxNetworkEntryTestCase::DoRun(), OlsrMprTestCase::DoRun(), OrigBlockAckWindowStalled::DoRun(), OriginatorBlockAckWindowTest::DoRun(), PacketBufferingCaseA::DoRun(), PacketBufferingCaseB::DoRun(), PacketMetadataTest::DoRun(), PacketSocketAppsTest::DoRun(), PacketTagListTest::DoRun(), PacketTest::DoRun(), PeerLinkFrameStartTest::DoRun(), PhyConnectivityTest::DoRun(), PointToPointTest::DoRun(), PreservePacketsInAmpdus::DoRun(), QosUtilsIsOldPacketTest::DoRun(), ReleaseSeqNoAfterCtsTimeoutTest::DoRun(), ResetAllocatorHelperTestCase::DoRun(), RocketfuelTopologyReaderMapsTest::DoRun(), RocketfuelTopologyReaderWeightsTest::DoRun(), RttEstimatorTestCase::DoRun(), SimulatorEventsTestCase::DoRun(), SixlowpanFragmentationTest::DoRun(), SixlowpanHc1ImplTest::DoRun(), SixlowpanIphcImplTest::DoRun(), SixlowpanIphcStatefulImplTest::DoRun(), StartSeqNoUpdateAfterAddBaTimeoutTest::DoRun(), TcpTestCase::DoRun(), TestActiveScanPanDescriptors::DoRun(), TestDlMuTxVector::DoRun(), TestEmptyOptionField::DoRun(), TestFulfilledAlignment::DoRun(), TestOptionWithAlignment::DoRun(), TestOptionWithoutAlignment::DoRun(), TestOrphanScan::DoRun(), TestRxOffWhenIdleAfterCsmaFailure::DoRun(), ThreadedSimulatorEventsTestCase::DoRun(), ThreeGppHttpObjectTestCase::DoRun(), TimInformationElementTest::DoRun(), TwoLevelAggregationTest::DoRun(), TxDurationTest::DoRun(), Udp6SocketImplTest::DoRun(), Udp6SocketLoopbackTest::DoRun(), UdpSocketImplTest::DoRun(), UdpSocketLoopbackTest::DoRun(), WifiChannelSwitchingTest::DoRun(), WifiEhtCapabilitiesIeTest::DoRun(), WifiExtractExpiredMpdusTest::DoRun(), WifiIeFragmentationTest::DoRun(), WifiMacQueueDropOldestTest::DoRun(), WifiMgtHeaderTest::DoRun(), Ipv4ForwardingTest::DoSendData(), Ipv4GlobalRoutingSlash32TestCase::DoSendData(), Ipv4PacketInfoTagTest::DoSendData(), Ipv4RawSocketImplTest::DoSendData(), Ipv4RipCountToInfinityTest::DoSendData(), Ipv4RipTest::DoSendData(), Ipv4StaticRoutingSlash32TestCase::DoSendData(), Ipv6ForwardingTest::DoSendData(), Ipv6PacketInfoTagTest::DoSendData(), Ipv6RawSocketImplTest::DoSendData(), Ipv6RipngCountToInfinityTest::DoSendData(), Ipv6RipngTest::DoSendData(), SixlowpanHc1ImplTest::DoSendData(), SixlowpanIphcImplTest::DoSendData(), UdpSocketImplTest::DoSendData(), Ipv4RawSocketImplTest::DoSendData_IpHdr(), Ipv4HeaderTest::DoSendData_IpHdr_Dscp(), Udp6SocketImplTest::DoSendDataTo(), UdpSocketImplTest::DoSendDataTo(), DynamicNeighborCacheTest::DoSendDatav4(), DynamicNeighborCacheTest::DoSendDatav6(), Ipv4DeduplicationTest::DoSendPacket(), TidToLinkMappingElementTest::DoSetup(), Ipv4DeduplicationTest::DropPkt(), ChannelAccessManagerTest< TxopType >::EndTest(), ChannelAccessManagerTest< TxopType >::GenerateBackoff(), UdpSocketImplTest::GetPriority(), Ns3TcpLossTestCase::Ipv4L3Tx(), Ns3TcpStateTestCase::Ipv4L3Tx(), BackoffGenerationTest::MissedBackoff(), ChannelAccessManagerTest< TxopType >::NotifyAccessGranted(), ChannelAccessManagerTest< TxopType >::NotifyChannelSwitching(), ChannelAccessManagerTest< TxopType >::NotifyInternalCollision(), PreservePacketsInAmpdus::NotifyMacForwardUp(), PreservePacketsInAmpdus::NotifyMacHeaderEndRx(), TestInterBssConstantObssPdAlgo::NotifyPhyTxBegin(), PreservePacketsInAmpdus::NotifyPsduForwardedDown(), WifiPrimaryChannelsTest::ReceiveDl(), IcmpEchoReplyTestCase::ReceivePkt(), IcmpTimeExceedTestCase::ReceivePkt(), IcmpV6EchoReplyTestCase::ReceivePkt(), IcmpV6TimeExceedTestCase::ReceivePkt(), Ipv6RawSocketImplTest::ReceivePkt2(), Ipv4RipSplitHorizonStrategyTest::ReceivePktProbe(), Ipv6RipngSplitHorizonStrategyTest::ReceivePktProbe(), ns3::olsr::HelloRegressionTest::ReceivePktProbeA(), ns3::olsr::TcRegressionTest::ReceivePktProbeA(), ns3::olsr::HelloRegressionTest::ReceivePktProbeB(), ns3::olsr::TcRegressionTest::ReceivePktProbeB(), ns3::olsr::TcRegressionTest::ReceivePktProbeC(), WifiPrimaryChannelsTest::ReceiveUl(), LargestIdlePrimaryChannelTest::RunOne(), MldSwapLinksTest::RunOne(), IcmpEchoReplyTestCase::SendData(), IcmpTimeExceedTestCase::SendData(), IcmpV6EchoReplyTestCase::SendData(), TcpTestCase::ServerHandleRecv(), TcpTestCase::ServerHandleSend(), AidAssignmentTest::SetSsid(), TcpTestCase::SetupDefaultSim(), TcpTestCase::SetupDefaultSim6(), ns3::tests::EnvVarTestCase::SetVariable(), TcpTestCase::SourceHandleRecv(), TcpTestCase::SourceHandleSend(), TcpOptionTSTestCase::TestDeserialize(), TcpOptionWSTestCase::TestDeserialize(), FlameRtableTest::TestExpire(), HwmpRtableTest::TestExpire(), ns3::HeaderSerializationTestCase::TestHeaderSerialization(), FlameRtableTest::TestLookup(), HwmpRtableTest::TestLookup(), WaypointInitialPositionIsWaypoint::TestNumWaypoints(), HwmpRtableTest::TestPrecursorFind(), ns3::tests::TrickleTimerTestCase::TestRedundancy(), TcpOptionTSTestCase::TestSerialize(), TcpOptionWSTestCase::TestSerialize(), ns3::tests::TrickleTimerTestCase::TestSteadyState(), BlockAckAggregationDisabledTest::Transmit(), EmlOmnExchangeTest::Transmit(), EmlsrDlTxopTest::Transmit(), EmlsrLinkSwitchTest::Transmit(), EmlsrUlTxopTest::Transmit(), MultiLinkMuTxTest::Transmit(), OrigBlockAckWindowStalled::Transmit(), WifiUseAvailBwTest::Transmit(), EmlsrCcaBusyTest::TransmitPacketToAp(), and ns3::tests::EnvVarTestCase::UnsetVariable().

◆ NS_TEST_EXPECT_MSG_EQ_TOL

#define NS_TEST_EXPECT_MSG_EQ_TOL ( actual,
limit,
tol,
msg )
Value:
do \
{ \
if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit << " +- " << tol; \
std::ostringstream condStream; \
condStream << #actual << " (actual) < " << #limit << " (limit) + " << #tol \
<< " (tol) && " << #actual << " (actual) > " << #limit << " (limit) - " \
<< #tol << " (tol)"; \
ReportTestFailure(condStream.str(), \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if not.

Check to see if the expected (limit) value is equal to the actual value found in a test case to some tolerance. This is not the same thing as asking if two floating point are equal to within some epsilon, but is useful for that case. This assertion is geared toward more of a measurement problem. Consider measuring a physical rod of some kind that you have ordered. You need to determine if it is "good." You want to measure the rod to an arbitrary precision of sixteen significant figures, you will measure the rod to determine if its length is within the tolerances you provided. For example, 12.00 inches plus or minus .005 inch may be just fine.

In ns-3, you might want to measure a signal to noise ratio and check to see if the answer is what you expect. If you naively measure (double)1128.93 and compare this number with a constant 1128.93 you are almost certainly going to have your test fail because of floating point rounding errors. We provide a floating point comparison function ns3::TestDoubleIsEqual() but you will probably quickly find that is not what you want either. It may turn out to be the case that when you measured an SNR that printed as 1128.93, what was actually measured was something more like 1128.9287653857625442 for example. Given that the double epsilon is on the order of 0.0000000000000009, you would need to provide sixteen significant figures of expected value for this kind of test to pass even with a typical test for floating point "approximate equality." That is clearly not required or desired. You really want to be able to provide 1128.93 along with a tolerance just like you provided 12 inches +- 0.005 inch above.

This assertion is designed for real measurements by taking into account measurement tolerances. By doing so it also automatically compensates for floating point rounding errors. If you really want to check floating point equality down to the numeric_limits<double>::epsilon () range, consider using ns3::TestDoubleIsEqual().

Note
Mixing signed and unsigned types can lead to misleading results.

The message is interpreted as a stream, for example:

NS_TEST_EXPECT_MSG_EQ_TOL (snr, 1128.93, 0.005,
"wrong snr (" << snr << ") in test");
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
Definition test.h:500

is legal.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the expected value of the test.
[in]tolTolerance of the test.
[in]msgMessage that is output if the test does not pass.

Definition at line 500 of file test.h.

Referenced by ns3::int64x64::test::Int64x64HiLoTestCase::Check(), ns3::int64x64::test::Int64x64InputOutputTestCase::Check(), ns3::int64x64::test::Int64x64InputTestCase::Check(), GeoToAndFromTopocentricTestCase::CheckTestPass(), RttEstimatorTestCase::CheckValuesWithTolerance(), WaypointLazyNotifyFalse::CourseChangeCallback(), WaypointLazyNotifyTrue::CourseChangeCallback(), SteadyStateRandomWaypointTest::DistribCompare(), ArrayResponseTest::DoRun(), BuildingsPenetrationLossesTestCase::DoRun(), CosineAntennaModelTestCase::DoRun(), DegreesToRadiansTestCase::DoRun(), FriisPropagationLossModelTestCase::DoRun(), HistogramTestCase::DoRun(), IsotropicAntennaModelTestCase::DoRun(), LogDistancePropagationLossModelTestCase::DoRun(), OneVectorConstructorTestCase::DoRun(), OverallGainAverageTest::DoRun(), ParabolicAntennaModelTestCase::DoRun(), RadiansToDegreesTestCase::DoRun(), RangePropagationLossModelTestCase::DoRun(), ThreeGppChannelConditionModelTestCase::DoRun(), ThreeGppIndoorOfficePropagationLossModelTestCase::DoRun(), ThreeGppRmaPropagationLossModelTestCase::DoRun(), ThreeGppShadowingTestCase::DoRun(), ThreeGppUmaPropagationLossModelTestCase::DoRun(), ThreeGppUmiPropagationLossModelTestCase::DoRun(), ThreeGppV2vHighwayLosNlosvChCondModelTestCase::DoRun(), ThreeGppV2vHighwayPropagationLossModelTestCase::DoRun(), ThreeGppV2vUrbanLosNlosvChCondModelTestCase::DoRun(), ThreeGppV2vUrbanPropagationLossModelTestCase::DoRun(), TimeOnAirTest::DoRun(), TwoRayGroundPropagationLossModelTestCase::DoRun(), TwoVectorsConstructorTestCase::DoRun(), UniformPlanarArrayTestCase::DoRun(), V2vHighwayProbChCondModelTestCase::DoRun(), V2vUrbanProbChCondModelTestCase::DoRun(), WifiOfdmMaskSlopesTestCase::DoRun(), WrapToRangeFunctionalTestCase::DoRun(), TestMultipleCtsResponsesFromMuRts::RxCtsSuccess(), CircularApertureAntennaModelTestCase::TestAntennaGain(), ThreeGppNTNPropagationLossModelTestCase::TestChannelGain(), WaypointInitialPositionIsWaypoint::TestXPosition(), WaypointLazyNotifyFalse::TestXPosition(), WaypointLazyNotifyTrue::TestXPosition(), WaypointMobilityModelViaHelper::TestXPosition(), and WifiPhyCcaThresholdsTest::VerifyCcaThreshold().

◆ NS_TEST_EXPECT_MSG_GT

#define NS_TEST_EXPECT_MSG_GT ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) > (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) > " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual value is greater than a limit and report if not.

Check to see if the actual value found in a test case is greater than the limit value. If the actual value is greater nothing happens, but if the check fails, an error is reported in a consistent way. EXPECT* macros do not return if an error is detected.

The message is interpreted as a stream.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the limit value of the test.
[in]msgMessage that is output if the test does not pass.

Definition at line 946 of file test.h.

Referenced by MultiLinkSetupTest::CheckQosData(), EmlsrDlTxopTest::CheckResults(), WifiTxopTest::CheckResults(), BasicMultiLinkElementTest::DoRun(), BlockAckAggregationDisabledTest::DoRun(), Issue211Test::DoRun(), and LrWpanAckTestCase::DoRun().

◆ NS_TEST_EXPECT_MSG_GT_OR_EQ

#define NS_TEST_EXPECT_MSG_GT_OR_EQ ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) >= (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) > " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual value is greater than or equal to limit and report if not.

Check to see if the actual value found in a test case is greater than or equal to the limit value. If the actual value is greater nothing happens, but if the check fails, an error is reported in a consistent way. EXPECT* macros do not return if an error is detected.

The message is interpreted as a stream.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the limit value of the test.
[in]msgMessage that is output if the test does not pass.

Definition at line 986 of file test.h.

Referenced by EmlsrLinkSwitchTest::CheckInitialControlFrame(), EmlsrCcaBusyTest::CheckPoint1(), EmlsrCcaBusyTest::CheckPoint2(), EmlsrCcaBusyTest::CheckPoint3(), EmlsrUlTxopTest::CheckResults(), OfdmaAckSequenceTest::CheckResults(), WifiTxopTest::CheckResults(), ns3::tests::TrickleTimerTestCase::TestSteadyState(), and OrigBlockAckWindowStalled::Transmit().

◆ NS_TEST_EXPECT_MSG_LT

#define NS_TEST_EXPECT_MSG_LT ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) < (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) < " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual value is less than a limit and report if not.

Check to see if the actual value found in a test case is less than the limit value. If the actual value is lesser nothing happens, but if the check fails, an error is reported in a consistent way. EXPECT* macros do not return if an error is detected.

The message is interpreted as a stream.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the limit value of the test.
[in]msgMessage that is output if the test does not pass.

Definition at line 780 of file test.h.

Referenced by BackoffGenerationTest::BackoffGenerated(), EmlsrDlTxopTest::CheckInitialControlFrame(), EmlsrCcaBusyTest::CheckPoint1(), MultiLinkSetupTest::CheckQosData(), EmlsrDlTxopTest::CheckResults(), EmlsrUlTxopTest::CheckResults(), OfdmaAckSequenceTest::CheckResults(), WifiTxopTest::CheckResults(), WifiUseAvailBwTest::CheckResults(), Ns2MobilityHelperTest::CourseChange(), BlockAckAggregationDisabledTest::DoRun(), BuildingsPenetrationLossesTestCase::DoRun(), CosineAntennaModelTestCase::DoRun(), LrWpanAckTestCase::DoRun(), ParabolicAntennaModelTestCase::DoRun(), and OrigBlockAckWindowStalled::Transmit().

◆ NS_TEST_EXPECT_MSG_LT_OR_EQ

#define NS_TEST_EXPECT_MSG_LT_OR_EQ ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) <= (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) < " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual value is less than or equal to a limit and report if not.

Check to see if the actual value found in a test case is less than or equal to the limit value. If the actual value is lesser or equal nothing happens, but if the check fails, an error is reported in a consistent way. EXPECT* macros do not return if an error is detected.

The message is interpreted as a stream.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the limit value of the test.
[in]msgMessage that is output if the test does not pass.

Definition at line 820 of file test.h.

Referenced by EmlsrLinkSwitchTest::CheckInitialControlFrame(), EmlsrUlTxopTest::CheckResults(), OfdmaAckSequenceTest::CheckResults(), WifiTxopTest::CheckResults(), MultiLinkMuTxTest::DoRun(), MultiLinkTxTest::DoRun(), Ipv6FragmentationTest::HandleClientTx(), Ipv6FragmentationTest::HandleServerRx(), ns3::tests::TrickleTimerTestCase::TestSteadyState(), and QosFragmentationTestCase::Transmit().

◆ NS_TEST_EXPECT_MSG_NE

#define NS_TEST_EXPECT_MSG_NE ( actual,
limit,
msg )
Value:
do \
{ \
if (!((actual) != (limit))) \
{ \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream limitStream; \
limitStream << limit; \
ReportTestFailure(std::string(#actual) + " (actual) != " + std::string(#limit) + \
" (limit)", \
actualStream.str(), \
limitStream.str(), \
msgStream.str(), \
__FILE__, \
__LINE__); \
} \
} while (false)

Test that an actual and expected (limit) value are not equal and report if not.

Check to see if the expected (limit) value is not equal to the actual value found in a test case. If the two values are not equal nothing happens, but if the comparison fails, an error is reported in a consistent way. EXPECT* macros do not return if an error is detected.

The message is interpreted as a stream, for example:

NS_TEST_EXPECT_MSG_NE (result, false,
"cannot open file " << filename << " in test");
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
Definition test.h:656

is legal.

Parameters
[in]actualExpression for the actual value found during the test.
[in]limitExpression for the value that actual is tested against.
[in]msgMessage that is output if the test does not pass.
Warning
Do not use this macro if you are comparing floating point numbers (float or double). Use NS_TEST_EXPECT_MSG_FLNE instead.

Definition at line 656 of file test.h.

Referenced by MultiLinkSetupTest::CheckAssocRequest(), MultiLinkSetupTest::CheckAssocResponse(), EmlsrCcaBusyTest::CheckPoint1(), EmlsrUlTxopTest::CheckResults(), OfdmaAckSequenceTest::CheckResults(), PacketTest::DoCheck(), PacketTest::DoCheckData(), DropTailQueueTestCase::DoRun(), FqCoDelQueueDiscECNMarking::DoRun(), InternetStackHelperTestCase::DoRun(), Ipv4FragmentationTest::DoRun(), Ipv6FragmentationTest::DoRun(), LogicalLoraChannelTest::DoRun(), LteUplinkDataSinrTestCase::DoRun(), PreservePacketsInAmpdus::NotifyMacHeaderEndRx(), UdpSocketImplTest::SentPkt(), and ns3::tests::EnvVarTestCase::SetVariable().

Function Documentation

◆ TestDoubleIsEqual()

bool ns3::TestDoubleIsEqual ( const double a,
const double b,
const double epsilon = std::numeric_limits< double >::epsilon() )

Compare two double precision floating point numbers and declare them equal if they are within some epsilon of each other.

Approximate comparison of floating point numbers near equality is trickier than one may expect and is well-discussed in the literature. Basic strategies revolve around a suggestion by Knuth to compare the floating point numbers as binary integers, supplying a maximum difference between them . This max difference is specified in Units in the Last Place (ulps) or a floating point epsilon.

This routine is based on the GNU Scientific Library function gsl_fcmp.

Parameters
[in]aThe first of double precision floating point numbers to compare
[in]bThe second of double precision floating point numbers to compare
[in]epsilonThe tolerance to use in the comparison.
Returns
Returns true if the doubles are equal to a precision defined by epsilon

Definition at line 36 of file test.cc.

References epsilon, and NS_LOG_FUNCTION.

Referenced by WifiOfdmMaskSlopesTestCase::InterpolateAndAppendValues(), and TestInterBssConstantObssPdAlgo::NotifyPhyTxBegin().

+ Here is the caller graph for this function: