A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
test.h File Reference
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <limits>
#include <stdint.h>
#include "system-wall-clock-ms.h"
#include "deprecated.h"
+ Include dependency graph for test.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ns3::TestCase
 encapsulates test code More...
 
class  ns3::TestRunner
 A runner to execute tests. 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...
 

Namespaces

 ns3
 Every class exported by the ns3 library is enclosed in the ns3 namespace.
 

Macros

#define ASSERT_ON_FAILURE
 
#define CONTINUE_ON_FAILURE
 
#define CONTINUE_ON_FAILURE_RETURNS_BOOL
 
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)   NS_TEST_ASSERT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
 Test that an actual and expected (limit) value are equal and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_EQ_INTERNAL(actual, limit, msg, file, line)
 
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg)   NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
 Test that an actual and expected (limit) value are equal and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line)
 
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)   NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
 Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line)
 
#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL(actual, limit, tol, msg)   NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
 Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL(actual, limit, tol, msg, file, line)
 
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)   NS_TEST_ASSERT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
 Test that an actual value is greater than a limit and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_GT_INTERNAL(actual, limit, msg, file, line)
 
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)   NS_TEST_ASSERT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
 Test that an actual value is less than a limit and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_LT_INTERNAL(actual, limit, msg, file, line)
 
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)   NS_TEST_ASSERT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
 Test that an actual and expected (limit) value are not equal and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_NE_INTERNAL(actual, limit, msg, file, line)
 
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg)   NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
 Test that an actual and expected (limit) value are not equal and report and abort if not. More...
 
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line)
 
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)   NS_TEST_EXPECT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
 Test that an actual and expected (limit) value are equal and report if not. More...
 
#define NS_TEST_EXPECT_MSG_EQ_INTERNAL(actual, limit, msg, file, line)
 
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)   NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
 Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if not. More...
 
#define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL(actual, limit, tol, msg, file, line)
 
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)   NS_TEST_EXPECT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
 Test that an actual value is greater than a limit and report if not. More...
 
#define NS_TEST_EXPECT_MSG_GT_INTERNAL(actual, limit, msg, file, line)
 
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)   NS_TEST_EXPECT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
 Test that an actual value is less than a limit and report if not. More...
 
#define NS_TEST_EXPECT_MSG_LT_INTERNAL(actual, limit, msg, file, line)
 
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)   NS_TEST_EXPECT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
 Test that an actual and expected (limit) value are not equal and report if not. More...
 
#define NS_TEST_EXPECT_MSG_NE_INTERNAL(actual, limit, msg, file, line)
 

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. More...
 

Macro Definition Documentation

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

Check if we should assert on errors, and do so

Definition at line 49 of file test.h.

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

If we shouldn't continue on errors, return

Definition at line 62 of file test.h.

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

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

Definition at line 75 of file test.h.

#define NS_TEST_ASSERT_MSG_EQ (   actual,
  limit,
  msg 
)    NS_TEST_ASSERT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)

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");

is legal.

Parameters
actualExpression for the actual value found during the test.
limitExpression for the expected value of the test.
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 137 of file test.h.

Referenced by ns3::RrcHeaderTestCase::AssertEqualRadioResourceConfigDedicated(), ns3::LteRrcConnectionEstablishmentTestCase::CheckConnected(), ns3::LteX2HandoverTestCase::CheckConnected(), ns3::LteX2HandoverMeasuresTestCase::CheckConnected(), ns3::AnimationInterfaceTestCase::CheckLogic(), ns3::AnimationRemainingEnergyTestCase::CheckLogic(), ns3::LteCellSelectionTestCase::CheckPoint(), PeerManagementProtocolRegressionTest::CreateDevices(), ns3::aodv::Bug772ChainTest::CreateDevices(), HwmpProactiveRegressionTest::CreateDevices(), FlameRegressionTest::CreateDevices(), HwmpDoRfRegressionTest::CreateDevices(), HwmpSimplestRegressionTest::CreateDevices(), ns3::aodv::ChainRegressionTest::CreateDevices(), ns3::olsr::Bug780Test::CreateNodes(), ns3::olsr::HelloRegressionTest::CreateNodes(), ns3::LteInterferenceTestCase::DlScheduling(), ns3::LteLinkAdaptationTestCase::DlScheduling(), ns3::LtePathlossModelSystemTestCase::DlScheduling(), ns3::LteRlcAmTransmitterTestCase::DoCheckDataReceived(), ns3::LteRlcUmTransmitterTestCase::DoCheckDataReceived(), BufferTest::DoRun(), SampleTestCase1::DoRun(), Ipv6AddressTestCase1::DoRun(), WatchdogTestCase::DoRun(), ns3::OlsrEmfTestCase::DoRun(), BasicTracedCallbackTestCase::DoRun(), TypeTraitsTestCase::DoRun(), TimeSimpleTestCase::DoRun(), ns3::GlobalValueTestCase::DoRun(), ns3::flame::FlameHeaderTest::DoRun(), IpAddressHelperTestCasev6::DoRun(), ns3::aodv::LoopbackTestCase::DoRun(), ns3::dot11s::MeshHeaderTest::DoRun(), BasicCallbackTestCase::DoRun(), ns3::BriteTopologyStructureTestCase::DoRun(), ns3::UniqueTypeIdTestCase::DoRun(), ns3::MeshInformationElementVectorBist::DoRun(), SwitchFlowTableTestCase::DoRun(), ns3::LteRlcAmE2eTestCase::DoRun(), ns3::LteRlcUmE2eTestCase::DoRun(), ns3::EpsGtpuHeaderTestCase::DoRun(), StaticRoutingSlash32TestCase::DoRun(), UdpClientServerTestCase::DoRun(), ns3::Ipv4L3ProtocolTestCase::DoRun(), BasicEnergyUpdateTest::DoRun(), ns3::OlsrMidTestCase::DoRun(), DsaRequestTestCase::DoRun(), ns3::Ipv6L3ProtocolTestCase::DoRun(), Ns3TcpNoDelayTestCase::DoRun(), Ns3TcpSocketTestCase1::DoRun(), Ns3WimaxCsParamTlvTestCase::DoRun(), TimerStateTestCase::DoRun(), ns3::DsdvHeaderTestCase::DoRun(), DynamicGlobalRoutingTestCase::DoRun(), NscTcpLossTestCase1::DoRun(), Ipv4ListRoutingNegativeTestCase::DoRun(), WifiInterferenceTestCase::DoRun(), CsmaBridgeTestCase::DoRun(), BatteryLifetimeTest::DoRun(), Ipv6ListRoutingNegativeTestCase::DoRun(), ns3::EpcTftClassifierTestCase::DoRun(), ns3::RandomRoomPositionAllocatorTestCase::DoRun(), BasicAddTestCase::DoRun(), ErrorModelSimple::DoRun(), RandomVariableStreamUniformTestCase::DoRun(), ns3::SpectrumIdealPhyTestCase::DoRun(), ns3::LteNoisePsdTestCase::DoRun(), OcbWifiMacTestCase::DoRun(), ns3::EpcS1uDlTestCase::DoRun(), Ipv4ListRoutingPositiveTestCase::DoRun(), CommandLineBooleanTestCase::DoRun(), WriteModeCreateTestCase::DoRun(), Ipv6ListRoutingPositiveTestCase::DoRun(), ns3::LteEpcE2eDataTestCase::DoRun(), ns3::BuildingsHelperOneTestCase::DoRun(), RandomNumberSerializationTestCase::DoRun(), ns3::DsdvTableTestCase::DoRun(), ns3::CreateObjectTestCase::DoRun(), ns3::LteTxPsdTestCase::DoRun(), ns3::CollisionTestCase::DoRun(), UdpTraceClientServerTestCase::DoRun(), StringContextAddTestCase::DoRun(), CommandLineIntTestCase::DoRun(), Ns3WimaxSfTlvTestCase::DoRun(), RootNamespaceConfigTestCase::DoRun(), BurstErrorModelSimple::DoRun(), ns3::SameRoomPositionAllocatorTestCase::DoRun(), ns3::OlsrHelloTestCase::DoRun(), Ns3TcpSocketTestCase2::DoRun(), CsmaBroadcastTestCase::DoRun(), NscTcpLossTestCase2::DoRun(), MakeCallbackTestCase::DoRun(), CommandLineUnsignedIntTestCase::DoRun(), Int64x64Bug455TestCase::DoRun(), ns3::AggregateObjectTestCase::DoRun(), Ns3TcpCwndTestCase1::DoRun(), RandomVariableStreamUniformAntitheticTestCase::DoRun(), IpAddressHelperTestCasev4::DoRun(), PacketLossCounterTestCase::DoRun(), FullyQualifiedAddTestCase::DoRun(), ns3::AcousticModemEnergyDepletionTestCase::DoRun(), ReadModeCreateTestCase::DoRun(), UnderRootNamespaceConfigTestCase::DoRun(), CommandLineStringTestCase::DoRun(), Int64x64Bug863TestCase::DoRun(), BasicEnergyDepletionTest::DoRun(), ns3::OlsrTcTestCase::DoRun(), ns3::Ns2MobilityHelperTest::DoRun(), Int64x64CompareTestCase::DoRun(), ns3::RrcConnectionRequestTestCase::DoRun(), ns3::OlsrHnaTestCase::DoRun(), RelativeAddTestCase::DoRun(), ns3::EpcS1uUlTestCase::DoRun(), CsmaMulticastTestCase::DoRun(), GlobalRoutingSlash32TestCase::DoRun(), ns3::RrcConnectionSetupTestCase::DoRun(), MakeBoundCallbackTestCase::DoRun(), ObjectVectorConfigTestCase::DoRun(), AttributeTestCase< T >::DoRun(), BasicRenameTestCase::DoRun(), ns3::RrcConnectionSetupCompleteTestCase::DoRun(), ns3::ObjectFactoryTestCase::DoRun(), MatrixPropagationLossModelTestCase::DoRun(), ns3::Bug555TestCase::DoRun(), Ns3TcpCwndTestCase2::DoRun(), ns3::RrcConnectionReconfigurationCompleteTestCase::DoRun(), StringContextRenameTestCase::DoRun(), FileHeaderTestCase::DoRun(), ns3::RrcConnectionReconfigurationTestCase::DoRun(), CsmaOneSubnetTestCase::DoRun(), FullyQualifiedRenameTestCase::DoRun(), ObjectVectorTraceConfigTestCase::DoRun(), RelativeRenameTestCase::DoRun(), NullifyCallbackTestCase::DoRun(), CsmaPacketSocketTestCase::DoRun(), FindPathTestCase::DoRun(), BasicFindTestCase::DoRun(), ns3::HandoverPreparationInfoTestCase::DoRun(), RecordHeaderTestCase::DoRun(), CsmaPingTestCase::DoRun(), StringContextFindTestCase::DoRun(), ns3::RrcConnectionReestablishmentRequestTestCase::DoRun(), RandomVariableStreamAttributeTestCase::DoRun(), FullyQualifiedFindTestCase::DoRun(), ns3::RrcConnectionReestablishmentTestCase::DoRun(), CsmaRawIpSocketTestCase::DoRun(), ObjectVectorAttributeTestCase::DoRun(), ns3::RrcConnectionReestablishmentCompleteTestCase::DoRun(), RelativeFindTestCase::DoRun(), ns3::RrcConnectionRejectTestCase::DoRun(), ObjectMapAttributeTestCase::DoRun(), AlternateFindTestCase::DoRun(), CsmaStarTestCase::DoRun(), ns3::MeasurementReportTestCase::DoRun(), IntegerTraceSourceAttributeTestCase::DoRun(), ReadFileTestCase::DoRun(), IntegerTraceSourceTestCase::DoRun(), DiffTestCase::DoRun(), TracedCallbackTestCase::DoRun(), PointerAttributeTestCase::DoRun(), CallbackValueTestCase::DoRun(), ns3::LteHandoverTargetTestCase::DoTeardown(), ns3::LteUeMeasurementsPiecewiseTestCase1::DoTeardown(), ns3::LteUeMeasurementsPiecewiseTestCase2::DoTeardown(), ns3::LteUeMeasurementsHandoverTestCase::DoTeardown(), ns3::LteHandoverTargetTestCase::HandoverStartCallback(), ns3::LteUeMeasurementsTestCase::RecvMeasurementReport(), ns3::LteUeMeasurementsPiecewiseTestCase1::RecvMeasurementReportCallback(), ns3::LteUeMeasurementsPiecewiseTestCase2::RecvMeasurementReportCallback(), ns3::LteUeMeasurementsHandoverTestCase::RecvMeasurementReportCallback(), ns3::SpectrumInterferenceTestCase::RetrieveTestResult(), Ipv6PacketInfoTagTest::RxCb(), Ipv4PacketInfoTagTest::RxCb(), PbbTestCase::TestDeserialize(), PbbTestCase::TestSerialize(), ns3::LteInterferenceTestCase::UlScheduling(), and Ns3TcpCwndTestCase2::VerifyCwndRun().

#define NS_TEST_ASSERT_MSG_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
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
Definition: test.h:62
#define ASSERT_ON_FAILURE
Definition: test.h:49
Internal:

Definition at line 92 of file test.h.

Referenced by PacketMetadataTest::CheckHistory(), and BufferTest::EnsureWrittenBytes().

#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (   actual,
  limit,
  msg 
)    NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)

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");

is legal.

Parameters
actualExpression for the actual value found during the test.
limitExpression for the expected value of the test.
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 191 of file test.h.

Referenced by BatteryLifetimeTest::ConstantLoadTest(), BasicEnergyDepletionTest::DepletionTestCase(), UanTest::DoPhyTests(), BasicEnergyUpdateTest::StateSwitchTest(), and ns3::Ns2MobilityHelperTest::WriteTrace().

#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
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
Definition: test.h:49
#define CONTINUE_ON_FAILURE_RETURNS_BOOL
Definition: test.h:75
Internal:

Definition at line 143 of file test.h.

#define NS_TEST_ASSERT_MSG_EQ_TOL (   actual,
  limit,
  tol,
  msg 
)    NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)

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 won't 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().

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");

is legal.

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

Definition at line 326 of file test.h.

Referenced by ns3::AnimationRemainingEnergyTestCase::CheckLogic(), SampleTestCase1::DoRun(), TimeSimpleTestCase::DoRun(), RttTestCase::DoRun(), ns3::LiIonEnergyTestCase::DoRun(), ns3::LenaMimoTestCase::DoRun(), OneIntegerAverageTestCase::DoRun(), OneIntegerTestCase::DoRun(), UanTest::DoRun(), ns3::LteEarfcnTestCase::DoRun(), ns3::LenaHarqTestCase::DoRun(), ns3::ItuR1411LosPropagationLossModelTestCase::DoRun(), ns3::ItuR1411NlosOverRooftopPropagationLossModelTestCase::DoRun(), ns3::Kun2600MhzPropagationLossModelTestCase::DoRun(), ns3::OkumuraHataPropagationLossModelTestCase::DoRun(), ns3::BuildingsShadowingTestCase::DoRun(), ns3::BuildingsPathlossTestCase::DoRun(), ns3::LenaRrFfMacSchedulerTestCase::DoRun(), ns3::LenaDataPhyErrorModelTestCase::DoRun(), ns3::LenaPfFfMacSchedulerTestCase1::DoRun(), ns3::LenaFdBetFfMacSchedulerTestCase1::DoRun(), ns3::LenaFdTbfqFfMacSchedulerTestCase1::DoRun(), LenaFdMtFfMacSchedulerTestCase::DoRun(), ns3::LenaPssFfMacSchedulerTestCase1::DoRun(), ns3::LenaTdBetFfMacSchedulerTestCase1::DoRun(), LenaTdMtFfMacSchedulerTestCase::DoRun(), ns3::LenaTdTbfqFfMacSchedulerTestCase1::DoRun(), LenaTtaFfMacSchedulerTestCase::DoRun(), ns3::LteLinkAdaptationTestCase::DoRun(), ns3::AcousticModemEnergyTestCase::DoRun(), ns3::LteInterferenceTestCase::DoRun(), ns3::LtePathlossModelSystemTestCase::DoRun(), ns3::LteEnbAntennaTestCase::DoRun(), ns3::LenaPfFfMacSchedulerTestCase2::DoRun(), ns3::LenaFdBetFfMacSchedulerTestCase2::DoRun(), ns3::LenaTdBetFfMacSchedulerTestCase2::DoRun(), ns3::LenaTdTbfqFfMacSchedulerTestCase2::DoRun(), ns3::LenaFdTbfqFfMacSchedulerTestCase2::DoRun(), ns3::LenaPssFfMacSchedulerTestCase2::DoRun(), ns3::LenaDlCtrlPhyErrorModelTestCase::DoRun(), ns3::LteEarfcnDlTestCase::DoRun(), ns3::SpectrumIdealPhyTestCase::DoRun(), ns3::LteEarfcnUlTestCase::DoRun(), TimesWithSignsTestCase::DoRun(), FiveIntegersAverageTestCase::DoRun(), FiveIntegersTestCase::DoRun(), FiveDoublesAverageTestCase::DoRun(), FiveDoublesTestCase::DoRun(), RandomVariableStreamConstantTestCase::DoRun(), RandomVariableStreamSequentialTestCase::DoRun(), RandomVariableStreamNormalTestCase::DoRun(), RandomVariableStreamNormalAntitheticTestCase::DoRun(), RandomVariableStreamExponentialTestCase::DoRun(), RandomVariableStreamExponentialAntitheticTestCase::DoRun(), RandomVariableStreamParetoTestCase::DoRun(), RandomVariableStreamParetoAntitheticTestCase::DoRun(), RandomVariableStreamWeibullTestCase::DoRun(), RandomVariableStreamWeibullAntitheticTestCase::DoRun(), RandomVariableStreamLogNormalTestCase::DoRun(), RandomVariableStreamLogNormalAntitheticTestCase::DoRun(), RandomVariableStreamGammaTestCase::DoRun(), RandomVariableStreamGammaAntitheticTestCase::DoRun(), RandomVariableStreamErlangTestCase::DoRun(), RandomVariableStreamErlangAntitheticTestCase::DoRun(), RandomVariableStreamZipfTestCase::DoRun(), RandomVariableStreamZipfAntitheticTestCase::DoRun(), RandomVariableStreamZetaTestCase::DoRun(), RandomVariableStreamZetaAntitheticTestCase::DoRun(), RandomVariableStreamDeterministicTestCase::DoRun(), RandomVariableStreamEmpiricalTestCase::DoRun(), RandomVariableStreamEmpiricalAntitheticTestCase::DoRun(), ns3::LteUeMeasurementsTestCase::ReportUeMeasurements(), and ProbeTestCase1::TraceSink().

#define NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL (   actual,
  limit,
  tol,
  msg,
  file,
  line 
)
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)
#define CONTINUE_ON_FAILURE
Definition: test.h:62
#define ASSERT_ON_FAILURE
Definition: test.h:49
Internal:

Definition at line 255 of file test.h.

#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (   actual,
  limit,
  tol,
  msg 
)    NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)

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 won't 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().

The message is interpreted as a stream, for example:

NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (snr, 1128.93, 0.005, "wrong snr (" << snr << ") in test");

is legal.

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

This function returns a boolean value.

Definition at line 406 of file test.h.

Referenced by BasicEnergyUpdateTest::StateSwitchTest(), and BatteryLifetimeTest::VariableLoadTest().

#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL (   actual,
  limit,
  tol,
  msg,
  file,
  line 
)
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)
#define ASSERT_ON_FAILURE
Definition: test.h:49
#define CONTINUE_ON_FAILURE_RETURNS_BOOL
Definition: test.h:75
Internal:

Definition at line 332 of file test.h.

#define NS_TEST_ASSERT_MSG_GT (   actual,
  limit,
  msg 
)    NS_TEST_ASSERT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)

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
actualExpression for the actual value found during the test.
limitExpression for the limit value of the test.
msgMessage that is output if the test does not pass.

Definition at line 773 of file test.h.

Referenced by ns3::LteX2HandoverMeasuresTestCase::CheckStats(), ns3::LteX2HandoverTestCase::CheckStatsAWhileAfterHandover(), OneUniformRandomVariableManyGetValueCallsTestCase::DoRun(), ManyUniformRandomVariablesOneGetValueCallTestCase::DoRun(), ns3::BuildingsShadowingTestCase::DoRun(), WifiMsduAggregatorThroughputTest::DoRun(), ProbeTestCase1::DoRun(), ns3::RandomRoomPositionAllocatorTestCase::DoRun(), OcbWifiMacTestCase::DoRun(), ns3::LteHandoverTargetTestCase::HandoverStartCallback(), and ProbeTestCase1::TraceSink().

#define NS_TEST_ASSERT_MSG_GT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
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
Definition: test.h:62
#define ASSERT_ON_FAILURE
Definition: test.h:49
Internal:

Definition at line 739 of file test.h.

#define NS_TEST_ASSERT_MSG_LT (   actual,
  limit,
  msg 
)    NS_TEST_ASSERT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)

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
actualExpression for the actual value found during the test.
limitExpression for the limit value of the test.
msgMessage that is output if the test does not pass.

Definition at line 688 of file test.h.

Referenced by ManyUniformRandomVariablesOneGetValueCallTestCase::DoRun(), OneUniformRandomVariableManyGetValueCallsTestCase::DoRun(), ns3::BuildingsShadowingTestCase::DoRun(), RngUniformTestCase::DoRun(), ns3::RandomRoomPositionAllocatorTestCase::DoRun(), RandomVariableStreamUniformTestCase::DoRun(), OcbWifiMacTestCase::DoRun(), RngNormalTestCase::DoRun(), RandomVariableStreamUniformAntitheticTestCase::DoRun(), RngExponentialTestCase::DoRun(), RngParetoTestCase::DoRun(), RandomVariableStreamNormalTestCase::DoRun(), RandomVariableStreamNormalAntitheticTestCase::DoRun(), RandomVariableStreamExponentialTestCase::DoRun(), RandomVariableStreamExponentialAntitheticTestCase::DoRun(), RandomVariableStreamParetoTestCase::DoRun(), RandomVariableStreamParetoAntitheticTestCase::DoRun(), RandomVariableStreamWeibullTestCase::DoRun(), RandomVariableStreamWeibullAntitheticTestCase::DoRun(), RandomVariableStreamLogNormalTestCase::DoRun(), RandomVariableStreamLogNormalAntitheticTestCase::DoRun(), RandomVariableStreamGammaTestCase::DoRun(), RandomVariableStreamGammaAntitheticTestCase::DoRun(), RandomVariableStreamErlangTestCase::DoRun(), RandomVariableStreamErlangAntitheticTestCase::DoRun(), ns3::LteHandoverDelayTestCase::EnbHandoverEndOkCallback(), ProbeTestCase1::TraceSink(), and ns3::LteHandoverDelayTestCase::UeHandoverEndOkCallback().

#define NS_TEST_ASSERT_MSG_LT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
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
Definition: test.h:62
#define ASSERT_ON_FAILURE
Definition: test.h:49
Internal:

Definition at line 654 of file test.h.

#define NS_TEST_ASSERT_MSG_NE (   actual,
  limit,
  msg 
)    NS_TEST_ASSERT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)

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");

is legal.

Parameters
actualExpression for the actual value found during the test.
limitExpression for the value that actual is tested against.
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_ASSERT_MSG_FLNE instead.

Definition at line 539 of file test.h.

Referenced by ns3::LteRrcConnectionEstablishmentTestCase::CheckConnected(), ns3::LteX2HandoverTestCase::CheckConnected(), ns3::LteX2HandoverMeasuresTestCase::CheckConnected(), ns3::AbstractAnimationInterfaceTestCase::CheckFileExistence(), BufferTest::DoRun(), ns3::RocketfuelTopologyReaderTest::DoRun(), SwitchFlowTableTestCase::DoRun(), ns3::CreateObjectTestCase::DoRun(), ns3::CollisionTestCase::DoRun(), ns3::AggregateObjectTestCase::DoRun(), RandomVariableStreamConstantTestCase::DoRun(), AttributeTestCase< T >::DoRun(), ns3::ObjectFactoryTestCase::DoRun(), FileHeaderTestCase::DoRun(), RecordHeaderTestCase::DoRun(), RandomVariableStreamAttributeTestCase::DoRun(), ObjectVectorAttributeTestCase::DoRun(), ObjectMapAttributeTestCase::DoRun(), IntegerTraceSourceAttributeTestCase::DoRun(), IntegerTraceSourceTestCase::DoRun(), TracedCallbackTestCase::DoRun(), PointerAttributeTestCase::DoRun(), and CallbackValueTestCase::DoRun().

#define NS_TEST_ASSERT_MSG_NE_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
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
Definition: test.h:62
#define ASSERT_ON_FAILURE
Definition: test.h:49
Internal:

Definition at line 495 of file test.h.

#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (   actual,
  limit,
  msg 
)    NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)

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");

is legal.

Parameters
actualExpression for the actual value found during the test.
limitExpression for the expected value of the test.
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_ASSERT_MSG_FLNE instead.

This function returns a boolean value.

Definition at line 592 of file test.h.

Referenced by ns3::Ns2MobilityHelperTest::CheckInitialPositions(), and BasicEnergyUpdateTest::StateSwitchTest().

#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
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
Definition: test.h:49
#define CONTINUE_ON_FAILURE_RETURNS_BOOL
Definition: test.h:75
Internal:

Definition at line 545 of file test.h.

#define NS_TEST_EXPECT_MSG_EQ (   actual,
  limit,
  msg 
)    NS_TEST_EXPECT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)

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

Check to see if the expected (lmit) 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
actualExpression for the actual value found during the test.
limitExpression for the expected value of the test.
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 244 of file test.h.

Referenced by ns3::HashTestCase::Check(), Int64x64FracTestCase::CheckFrac(), ns3::Ns2MobilityHelperTest::CheckInitialPositions(), PacketTagListTest::CheckRef(), ns3::aodv::AodvRqueueTest::CheckSizeLimit(), ns3::dsr::DsrSendBuffTest::CheckSizeLimit(), Int64x64InputTestCase::CheckString(), Int64x64InputOutputTestCase::CheckString(), ns3::aodv::AodvRqueueTest::CheckTimeout(), ns3::dsr::DsrSendBuffTest::CheckTimeout(), ns3::aodv::NeighborTest::CheckTimeout1(), ns3::aodv::IdCacheTest::CheckTimeout1(), ns3::aodv::NeighborTest::CheckTimeout2(), ns3::aodv::IdCacheTest::CheckTimeout2(), ns3::aodv::NeighborTest::CheckTimeout3(), ns3::aodv::IdCacheTest::CheckTimeout3(), ns3::Ns2MobilityHelperTest::CourseChange(), ns3::WaypointMobilityModelNotifyTest::CourseChangeCallback(), HwmpReactiveRegressionTest::CreateDevices(), ns3::olsr::TcRegressionTest::CreateNodes(), PacketTest::DoCheck(), BufferTest::DoRun(), NetworkNumberAllocatorTestCase::DoRun(), DropTailQueueTestCase::DoRun(), ns3::HistogramTestCase::DoRun(), NetworkNumber6AllocatorTestCase::DoRun(), NetworkAllocatorHelperTestCase::DoRun(), SimulatorEventsTestCase::DoRun(), ns3::aodv::NeighborTest::DoRun(), RttTestCase::DoRun(), ns3::EventGarbageCollectorTestCase::DoRun(), TestEmptyOptionField::DoRun(), ns3::RocketfuelTopologyReaderTest::DoRun(), ns3::aodv::IdCacheTest::DoRun(), ns3::olsr::OlsrMprTestCase::DoRun(), Ns3WimaxFragmentationTestCase::DoRun(), Ns3WimaxNetworkEntryTestCase::DoRun(), PtrTestCase::DoRun(), DualStackTestCase::DoRun(), ThreadedSimulatorEventsTestCase::DoRun(), ns3::dsr::DsrFsHeaderTest::DoRun(), TcpTestCase::DoRun(), PacketBufferingCaseA::DoRun(), Ipv6ForwardingTest::DoRun(), Ipv4ForwardingTest::DoRun(), AddressAllocator6TestCase::DoRun(), AddressAllocatorHelperTestCase::DoRun(), SixlowpanHc1ImplTest::DoRun(), SixlowpanIphcImplTest::DoRun(), Ipv6RawSocketImplTest::DoRun(), AddressAllocatorTestCase::DoRun(), Ipv4HeaderTest::DoRun(), Ipv4RawSocketImplTest::DoRun(), TestOptionWithoutAlignment::DoRun(), Ipv4FragmentationTest::DoRun(), ns3::dsr::DsrRreqHeaderTest::DoRun(), SixlowpanFragmentationTest::DoRun(), ns3::aodv::TypeHeaderTest::DoRun(), ns3::DsdvTableTestCase::DoRun(), Ipv6FragmentationTest::DoRun(), UdpSocketLoopbackTest::DoRun(), Ns3WimaxManagementConnectionsTestCase::DoRun(), ResetAllocatorHelperTestCase::DoRun(), ns3::aodv::RreqHeaderTest::DoRun(), NetworkAndAddress6TestCase::DoRun(), NetworkAndAddressTestCase::DoRun(), ns3::dsr::DsrRrepHeaderTest::DoRun(), TestOptionWithAlignment::DoRun(), PacketBufferingCaseB::DoRun(), Udp6SocketLoopbackTest::DoRun(), ExampleAddress6GeneratorTestCase::DoRun(), ns3::aodv::RrepHeaderTest::DoRun(), ns3::dsr::DsrSRHeaderTest::DoRun(), TestFulfilledAlignment::DoRun(), ExampleAddressGeneratorTestCase::DoRun(), ns3::QosUtilsIsOldPacketTest::DoRun(), UdpSocketImplTest::DoRun(), AddressCollision6TestCase::DoRun(), ns3::aodv::RrepAckHeaderTest::DoRun(), ns3::dot11s::PeerLinkFrameStartTest::DoRun(), CtrlBAckResponseHeaderTest::DoRun(), PacketTest::DoRun(), ns3::dsr::DsrRerrHeaderTest::DoRun(), ns3::aodv::RerrHeaderTest::DoRun(), AddressCollisionTestCase::DoRun(), PacketMetadataTest::DoRun(), ns3::dsr::DsrAckReqHeaderTest::DoRun(), ns3::aodv::QueueEntryTest::DoRun(), ns3::aodv::AodvRqueueTest::DoRun(), ns3::dsr::DsrAckHeaderTest::DoRun(), ns3::dsr::DsrCacheEntryTest::DoRun(), ns3::dsr::DsrSendBuffTest::DoRun(), ns3::aodv::AodvRtableEntryTest::DoRun(), Udp6SocketImplTest::DoRun(), PacketTagListTest::DoRun(), ns3::aodv::AodvRtableTest::DoRun(), ns3::dsr::DsrRreqTableTest::DoRun(), DiffTestCase::DoRun(), Ipv6ForwardingTest::DoSendData(), Ipv4ForwardingTest::DoSendData(), SixlowpanHc1ImplTest::DoSendData(), SixlowpanIphcImplTest::DoSendData(), Ipv6RawSocketImplTest::DoSendData(), Ipv6PacketInfoTagTest::DoSendData(), Ipv4RawSocketImplTest::DoSendData(), Ipv4PacketInfoTagTest::DoSendData(), UdpSocketImplTest::DoSendData(), Udp6SocketImplTest::DoSendData(), Ipv4RawSocketImplTest::DoSendData_IpHdr(), Ipv4HeaderTest::DoSendData_IpHdr_Dscp(), ns3::DcfManagerTest::EndTest(), Ns3TcpStateTestCase::Ipv4L3Tx(), Ns3TcpLossTestCase::Ipv4L3Tx(), Ns3TcpInteroperabilityTestCase::Ipv4L3Tx(), ns3::DcfManagerTest::NotifyAccessGranted(), ns3::DcfManagerTest::NotifyChannelSwitching(), ns3::DcfManagerTest::NotifyCollision(), ns3::DcfManagerTest::NotifyInternalCollision(), Ipv6RawSocketImplTest::ReceivePkt2(), RedQueueTestCase::RunRedTest(), TcpTestCase::ServerHandleRecv(), TcpTestCase::ServerHandleSend(), TcpTestCase::SourceHandleRecv(), TcpTestCase::SourceHandleSend(), ns3::flame::FlameRtableTest::TestExpire(), ns3::dot11s::HwmpRtableTest::TestExpire(), ns3::flame::FlameRtableTest::TestLookup(), ns3::dot11s::HwmpRtableTest::TestLookup(), WaypointInitialPositionIsWaypoint::TestNumWaypoints(), and ns3::dot11s::HwmpRtableTest::TestPrecursorFind().

#define NS_TEST_EXPECT_MSG_EQ_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
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
Definition: test.h:49
Internal:

Required to avoid use of return statement which allows use in methods (esp. callbacks) returning void.

Definition at line 200 of file test.h.

Referenced by PacketTest::DoCheck().

#define NS_TEST_EXPECT_MSG_EQ_TOL (   actual,
  limit,
  tol,
  msg 
)    NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)

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 won't 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().

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");

is legal.

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

Definition at line 485 of file test.h.

Referenced by ns3::SteadyStateRandomWaypointTest::DistribCompare(), ns3::HistogramTestCase::DoRun(), ns3::OneVectorConstructorTestCase::DoRun(), ns3::DegreesToRadiansTestCase::DoRun(), ns3::IsotropicAntennaModelTestCase::DoRun(), BasicRandomNumberTestCase::DoRun(), FriisPropagationLossModelTestCase::DoRun(), ns3::CosineAntennaModelTestCase::DoRun(), ns3::ParabolicAntennaModelTestCase::DoRun(), ns3::RadiansToDegreesTestCase::DoRun(), ns3::TwoVectorsConstructorTestCase::DoRun(), TwoRayGroundPropagationLossModelTestCase::DoRun(), LogDistancePropagationLossModelTestCase::DoRun(), and RangePropagationLossModelTestCase::DoRun().

#define NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (   actual,
  limit,
  tol,
  msg,
  file,
  line 
)
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)
#define ASSERT_ON_FAILURE
Definition: test.h:49
Internal:

Required to avoid use of return statement which allows use in methods (esp. callbacks) returning void.

Definition at line 415 of file test.h.

Referenced by WaypointLazyNotifyFalse::CourseChangeCallback(), WaypointLazyNotifyTrue::CourseChangeCallback(), WaypointLazyNotifyFalse::TestXPosition(), WaypointLazyNotifyTrue::TestXPosition(), WaypointInitialPositionIsWaypoint::TestXPosition(), and WaypointMobilityModelViaHelper::TestXPosition().

#define NS_TEST_EXPECT_MSG_GT (   actual,
  limit,
  msg 
)    NS_TEST_EXPECT_MSG_GT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)

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
actualExpression for the actual value found during the test.
limitExpression for the limit value of the test.
msgMessage that is output if the test does not pass.

Definition at line 814 of file test.h.

Referenced by RedQueueTestCase::RunRedTest().

#define NS_TEST_EXPECT_MSG_GT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
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
Definition: test.h:49
Internal:

Required to avoid use of return statement which allows use in methods (callbacks) returning void.

Definition at line 782 of file test.h.

#define NS_TEST_EXPECT_MSG_LT (   actual,
  limit,
  msg 
)    NS_TEST_EXPECT_MSG_LT_INTERNAL (actual, limit, msg, __FILE__, __LINE__)

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
actualExpression for the actual value found during the test.
limitExpression for the limit value of the test.
msgMessage that is output if the test does not pass.

Definition at line 729 of file test.h.

Referenced by ns3::Ns2MobilityHelperTest::CourseChange(), ns3::CosineAntennaModelTestCase::DoRun(), and ns3::ParabolicAntennaModelTestCase::DoRun().

#define NS_TEST_EXPECT_MSG_LT_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
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
Definition: test.h:49
Internal:

Required to avoid use of return statement which allows use in methods (callbacks) returning void.

Definition at line 697 of file test.h.

#define NS_TEST_EXPECT_MSG_NE (   actual,
  limit,
  msg 
)    NS_TEST_EXPECT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)

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");

is legal.

Parameters
actualExpression for the actual value found during the test.
limitExpression for the value that actual is tested against.
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 644 of file test.h.

Referenced by PacketTest::DoCheck(), and RedQueueTestCase::RunRedTest().

#define NS_TEST_EXPECT_MSG_NE_INTERNAL (   actual,
  limit,
  msg,
  file,
  line 
)
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
Definition: test.h:49
Internal:

Required to avoid use of return statement which allows use in methods (callbacks) returning void.

Definition at line 601 of file test.h.