Make test cases not return bool valuesMake all TestSuite instances be static

This commit is contained in:
Mitch Watrous committed 2011-01-17 12:53:20 -08:00
1 parent 53d882e28b
commit bfef0ebd2f
119 files changed
+751 -1052

No files matched your search

+24 -48
View File
@@ -233,7 +233,7 @@ public:
virtual ~AttributeTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
bool CheckGetCodePaths (Ptr<Object> p, std::string attributeName, std::string expectedString, T expectedValue);
};
@@ -263,15 +263,15 @@ AttributeTestCase<T>::CheckGetCodePaths (
// Get an Attribute value through its StringValue representation.
//
bool ok = p->GetAttributeFailSafe (attributeName.c_str (), stringValue);
NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not GetAttributeFailSafe() " << attributeName << " from Object");
NS_TEST_ASSERT_MSG_EQ (stringValue.Get (), expectedString, "Got unexpected StringValue representation");
NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (ok, true, "Could not GetAttributeFailSafe() " << attributeName << " from Object");
NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (stringValue.Get (), expectedString, "Got unexpected StringValue representation");
//
// Get the existing boolean value through its particular type representation.
//
ok = p->GetAttributeFailSafe (attributeName.c_str (), actualValue);
NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not GetAttributeFailSafe() " << attributeName << " from Object");
NS_TEST_ASSERT_MSG_EQ (actualValue.Get (), expectedValue.Get (), "Got unexpected Value from Object");
NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (ok, true, "Could not GetAttributeFailSafe() " << attributeName << " from Object");
NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (actualValue.Get (), expectedValue.Get (), "Got unexpected Value from Object");
return GetErrorStatus ();
}
@@ -279,7 +279,7 @@ AttributeTestCase<T>::CheckGetCodePaths (
// ===========================================================================
// The actual Attribute type test cases are specialized for each Attribute type
// ===========================================================================
template <> bool
template <> void
AttributeTestCase<BooleanValue>::DoRun (void)
{
AttributeList attrs;
@@ -381,11 +381,9 @@ AttributeTestCase<BooleanValue>::DoRun (void)
ok = CheckGetCodePaths (p, "TestBoolA", "false", BooleanValue (false));
NS_TEST_ASSERT_MSG_EQ (ok, false, "Attribute not set properly by SetAttributeFailSafe() (getter/setter) via StringValue");
return GetErrorStatus ();
}
template <> bool
template <> void
AttributeTestCase<IntegerValue>::DoRun (void)
{
Ptr<AttributeObjectTest> p;
@@ -493,11 +491,9 @@ AttributeTestCase<IntegerValue>::DoRun (void)
ok = CheckGetCodePaths (p, "TestInt16WithBounds", "-5", IntegerValue (-5));
NS_TEST_ASSERT_MSG_EQ (ok, false, "Error in SetAttributeFailSafe() but value changes");
return GetErrorStatus ();
}
template <> bool
template <> void
AttributeTestCase<UintegerValue>::DoRun (void)
{
Ptr<AttributeObjectTest> p;
@@ -566,11 +562,9 @@ AttributeTestCase<UintegerValue>::DoRun (void)
//
ok = p->SetAttributeFailSafe("TestUint8", StringValue ("-1"));
NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via StringValue to -1");
return GetErrorStatus ();
}
template <> bool
template <> void
AttributeTestCase<DoubleValue>::DoRun (void)
{
Ptr<AttributeObjectTest> p;
@@ -594,11 +588,9 @@ AttributeTestCase<DoubleValue>::DoRun (void)
ok = CheckGetCodePaths (p, "TestFloat", "2.3", DoubleValue ((float)2.3));
NS_TEST_ASSERT_MSG_EQ (ok, false, "Attribute not set properly by SetAttributeFailSafe() via DoubleValue");
return GetErrorStatus ();
}
template <> bool
template <> void
AttributeTestCase<EnumValue>::DoRun (void)
{
Ptr<AttributeObjectTest> p;
@@ -651,11 +643,9 @@ AttributeTestCase<EnumValue>::DoRun (void)
ok = CheckGetCodePaths (p, "TestEnum", "TestB", EnumValue (AttributeObjectTest::TEST_B));
NS_TEST_ASSERT_MSG_EQ (ok, false, "Error in SetAttributeFailSafe() but value changes");
return GetErrorStatus ();
}
template <> bool
template <> void
AttributeTestCase<RandomVariableValue>::DoRun (void)
{
Ptr<AttributeObjectTest> p;
@@ -675,8 +665,6 @@ AttributeTestCase<RandomVariableValue>::DoRun (void)
//
ok = p->SetAttributeFailSafe("TestRandom", RandomVariableValue (ConstantVariable (10.)));
NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() a UniformVariable");
return GetErrorStatus ();
}
// ===========================================================================
@@ -690,7 +678,7 @@ public:
virtual ~ObjectVectorAttributeTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
ObjectVectorAttributeTestCase::ObjectVectorAttributeTestCase (std::string description)
@@ -698,7 +686,7 @@ ObjectVectorAttributeTestCase::ObjectVectorAttributeTestCase (std::string descri
{
}
bool
void
ObjectVectorAttributeTestCase::DoRun (void)
{
Ptr<AttributeObjectTest> p;
@@ -743,8 +731,6 @@ ObjectVectorAttributeTestCase::DoRun (void)
//
p->GetAttribute ("TestVector1", vector);
NS_TEST_ASSERT_MSG_EQ (vector.GetN (), 2, "ObjectVectorValue \"TestVector1\" should be incremented");
return GetErrorStatus ();
}
// ===========================================================================
@@ -758,7 +744,7 @@ public:
virtual ~IntegerTraceSourceAttributeTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
IntegerTraceSourceAttributeTestCase::IntegerTraceSourceAttributeTestCase (std::string description)
@@ -766,7 +752,7 @@ IntegerTraceSourceAttributeTestCase::IntegerTraceSourceAttributeTestCase (std::s
{
}
bool
void
IntegerTraceSourceAttributeTestCase::DoRun (void)
{
Ptr<AttributeObjectTest> p;
@@ -837,8 +823,6 @@ IntegerTraceSourceAttributeTestCase::DoRun (void)
ok = p->SetAttributeFailSafe("IntegerTraceSource2", IntegerValue (-129));
NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
return GetErrorStatus ();
}
// ===========================================================================
@@ -852,7 +836,7 @@ public:
virtual ~IntegerTraceSourceTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
void NotifySource1 (int8_t old, int8_t n) {m_got1 = n;}
int64_t m_got1;
@@ -863,7 +847,7 @@ IntegerTraceSourceTestCase::IntegerTraceSourceTestCase (std::string description)
{
}
bool
void
IntegerTraceSourceTestCase::DoRun (void)
{
Ptr<AttributeObjectTest> p;
@@ -911,8 +895,6 @@ IntegerTraceSourceTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via IntegerValue to 1");
NS_TEST_ASSERT_MSG_EQ (m_got1, 0, "Hitting a TracedValue after disconnect still causes callback");
return GetErrorStatus ();
}
// ===========================================================================
@@ -926,7 +908,7 @@ public:
virtual ~TracedCallbackTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
void NotifySource2 (double a, int b, float c) {m_got2 = a;}
@@ -938,7 +920,7 @@ TracedCallbackTestCase::TracedCallbackTestCase (std::string description)
{
}
bool
void
TracedCallbackTestCase::DoRun (void)
{
Ptr<AttributeObjectTest> p;
@@ -987,8 +969,6 @@ TracedCallbackTestCase::DoRun (void)
p->InvokeCb (-1.0, -5, 0.0);
NS_TEST_ASSERT_MSG_EQ (m_got2, 1.0, "Invoking disconnected TracedCallback unexpectedly results in trace callback");
return GetErrorStatus ();
}
// ===========================================================================
@@ -1002,7 +982,7 @@ public:
virtual ~PointerAttributeTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
void NotifySource2 (double a, int b, float c) {m_got2 = a;}
@@ -1014,7 +994,7 @@ PointerAttributeTestCase::PointerAttributeTestCase (std::string description)
{
}
bool
void
PointerAttributeTestCase::DoRun (void)
{
Ptr<AttributeObjectTest> p;
@@ -1077,8 +1057,6 @@ PointerAttributeTestCase::DoRun (void)
p->GetAttribute ("Pointer", ptr);
derived = ptr.Get<Derived> ();
NS_TEST_ASSERT_MSG_NE (p, 0, "Retrieved zero PointerValue Attribute after initializing to non-zero Ptr");
return GetErrorStatus ();
}
// ===========================================================================
@@ -1098,7 +1076,7 @@ public:
}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
Callback<void,int8_t> m_cbValue;
@@ -1112,7 +1090,7 @@ CallbackValueTestCase::CallbackValueTestCase (std::string description)
{
}
bool
void
CallbackValueTestCase::DoRun (void)
{
Ptr<AttributeObjectTest> p;
@@ -1160,9 +1138,7 @@ CallbackValueTestCase::DoRun (void)
//
p->InvokeCbValue (3);
NS_TEST_ASSERT_MSG_EQ (m_gotCbValue, 2, "Callback Attribute set to null callback unexpectedly fired");
return GetErrorStatus ();
}
}
// ===========================================================================
// The Test Suite that glues all of the Test Cases together.
+10 -20
View File
@@ -37,7 +37,7 @@ public:
int Target4 (double a, int b) {m_test4 = true; return 4;}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoSetup (void);
bool m_test1;
@@ -86,7 +86,7 @@ BasicCallbackTestCase::DoSetup (void)
gBasicCallbackTest7 = false;
}
bool
void
BasicCallbackTestCase::DoRun (void)
{
//
@@ -150,8 +150,6 @@ BasicCallbackTestCase::DoRun (void)
Callback<int, int> target7 = Callback<int, int> (&BasicCallbackTarget7, true, true);
target7 (1);
NS_TEST_ASSERT_MSG_EQ (gBasicCallbackTest7, true, "Callback did not fire");
return GetErrorStatus ();
}
// ===========================================================================
@@ -169,7 +167,7 @@ public:
int Target4 (double a, int b) {m_test4 = true; return 4;}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoSetup (void);
bool m_test1;
@@ -218,7 +216,7 @@ MakeCallbackTestCase::DoSetup (void)
gMakeCallbackTest7 = false;
}
bool
void
MakeCallbackTestCase::DoRun (void)
{
//
@@ -282,8 +280,6 @@ MakeCallbackTestCase::DoRun (void)
Callback<int, int> target7 = MakeCallback (&MakeCallbackTarget7);
target7 (1);
NS_TEST_ASSERT_MSG_EQ (gMakeCallbackTest7, true, "Callback did not fire");
return GetErrorStatus ();
}
// ===========================================================================
@@ -296,7 +292,7 @@ public:
virtual ~MakeBoundCallbackTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoSetup (void);
};
@@ -339,7 +335,7 @@ MakeBoundCallbackTestCase::DoSetup (void)
gMakeBoundCallbackTest3b = 0;
}
bool
void
MakeBoundCallbackTestCase::DoRun (void)
{
//
@@ -380,8 +376,6 @@ MakeBoundCallbackTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (result, 1234, "Return value of callback not correct");
NS_TEST_ASSERT_MSG_EQ (gMakeBoundCallbackTest3a, &a, "Callback did not fire or binding not correct");
NS_TEST_ASSERT_MSG_EQ (gMakeBoundCallbackTest3b, 2468, "Callback did not fire or argument not correct");
return GetErrorStatus ();
}
// ===========================================================================
@@ -396,7 +390,7 @@ public:
void Target1 (void) {m_test1 = true;}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoSetup (void);
bool m_test1;
@@ -413,7 +407,7 @@ NullifyCallbackTestCase::DoSetup (void)
m_test1 = false;
}
bool
void
NullifyCallbackTestCase::DoRun (void)
{
//
@@ -429,8 +423,6 @@ NullifyCallbackTestCase::DoRun (void)
target1.Nullify ();
NS_TEST_ASSERT_MSG_EQ (target1.IsNull (), true, "Nullified Callback reports not IsNull()");
return GetErrorStatus ();
}
// ===========================================================================
@@ -446,7 +438,7 @@ public:
void Target1 (void) {m_test1 = true;}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
bool m_test1;
};
@@ -513,7 +505,7 @@ MakeCallbackTemplatesTestCase::MakeCallbackTemplatesTestCase ()
{
}
bool
void
MakeCallbackTemplatesTestCase::DoRun (void)
{
CallbackTestClass that;
@@ -562,8 +554,6 @@ MakeCallbackTemplatesTestCase::DoRun (void)
MakeBoundCallback (&TestFRFive, 1);
that.CheckParentalRights ();
return GetErrorStatus ();
}
// ===========================================================================
+8 -16
View File
@@ -352,7 +352,7 @@ public:
virtual ~CommandLineBooleanTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
@@ -361,7 +361,7 @@ CommandLineBooleanTestCase::CommandLineBooleanTestCase ()
{
}
bool
void
CommandLineBooleanTestCase::DoRun (void)
{
CommandLine cmd;
@@ -374,8 +374,6 @@ CommandLineBooleanTestCase::DoRun (void)
Parse (cmd, 1, "--my-bool=1");
NS_TEST_ASSERT_MSG_EQ (myBool, true, "Command parser did not correctly set a boolean value to true");
return GetErrorStatus ();
}
// ===========================================================================
@@ -388,7 +386,7 @@ public:
virtual ~CommandLineIntTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
@@ -397,7 +395,7 @@ CommandLineIntTestCase::CommandLineIntTestCase ()
{
}
bool
void
CommandLineIntTestCase::DoRun (void)
{
CommandLine cmd;
@@ -414,8 +412,6 @@ CommandLineIntTestCase::DoRun (void)
Parse (cmd, 2, "--my-bool=1", "--my-int32=+2");
NS_TEST_ASSERT_MSG_EQ (myBool, true, "Command parser did not correctly set a boolean value to true");
NS_TEST_ASSERT_MSG_EQ (myInt32, +2, "Command parser did not correctly set an integer value to +2");
return GetErrorStatus ();
}
// ===========================================================================
@@ -428,7 +424,7 @@ public:
virtual ~CommandLineUnsignedIntTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
@@ -437,7 +433,7 @@ CommandLineUnsignedIntTestCase::CommandLineUnsignedIntTestCase ()
{
}
bool
void
CommandLineUnsignedIntTestCase::DoRun (void)
{
CommandLine cmd;
@@ -451,8 +447,6 @@ CommandLineUnsignedIntTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (myBool, false, "Command parser did not correctly set a boolean value to true");
NS_TEST_ASSERT_MSG_EQ (myUint32, 9, "Command parser did not correctly set an unsigned integer value to 9");
return GetErrorStatus ();
}
// ===========================================================================
@@ -465,7 +459,7 @@ public:
virtual ~CommandLineStringTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
@@ -474,7 +468,7 @@ CommandLineStringTestCase::CommandLineStringTestCase ()
{
}
bool
void
CommandLineStringTestCase::DoRun (void)
{
CommandLine cmd;
@@ -488,8 +482,6 @@ CommandLineStringTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (myUint32, 9, "Command parser did not correctly set an unsigned integer value to 9");
NS_TEST_ASSERT_MSG_EQ (myStr, "XX", "Command parser did not correctly set an string value to \"XX\"");
return GetErrorStatus ();
}
// ===========================================================================
+8 -16
View File
@@ -766,7 +766,7 @@ public:
virtual ~RootNamespaceConfigTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
RootNamespaceConfigTestCase::RootNamespaceConfigTestCase ()
@@ -774,7 +774,7 @@ RootNamespaceConfigTestCase::RootNamespaceConfigTestCase ()
{
}
bool
void
RootNamespaceConfigTestCase::DoRun (void)
{
IntegerValue iv;
@@ -812,8 +812,6 @@ RootNamespaceConfigTestCase::DoRun (void)
Config::Set ("/B", IntegerValue (-1));
root->GetAttribute ("B", iv);
NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, "Object Attribute \"B\" not set correctly");
return GetErrorStatus ();
}
// ===========================================================================
@@ -826,7 +824,7 @@ public:
virtual ~UnderRootNamespaceConfigTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
UnderRootNamespaceConfigTestCase::UnderRootNamespaceConfigTestCase ()
@@ -834,7 +832,7 @@ UnderRootNamespaceConfigTestCase::UnderRootNamespaceConfigTestCase ()
{
}
bool
void
UnderRootNamespaceConfigTestCase::DoRun (void)
{
IntegerValue iv;
@@ -912,8 +910,6 @@ UnderRootNamespaceConfigTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (iv.Get (), 4, "Object Attribute \"A\" not set as expected");
b->GetAttribute ("B", iv);
NS_TEST_ASSERT_MSG_EQ (iv.Get (), -4, "Object Attribute \"B\" not set as expected");
return GetErrorStatus ();
}
// ===========================================================================
@@ -926,7 +922,7 @@ public:
virtual ~ObjectVectorConfigTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
ObjectVectorConfigTestCase::ObjectVectorConfigTestCase ()
@@ -934,7 +930,7 @@ ObjectVectorConfigTestCase::ObjectVectorConfigTestCase ()
{
}
bool
void
ObjectVectorConfigTestCase::DoRun (void)
{
IntegerValue iv;
@@ -1068,8 +1064,6 @@ ObjectVectorConfigTestCase::DoRun (void)
obj3->GetAttribute ("A", iv);
NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, "Object Attribute \"A\" not set as expected");
return GetErrorStatus ();
}
// ===========================================================================
@@ -1085,7 +1079,7 @@ public:
void TraceWithPath (std::string path, int16_t old, int16_t newValue) {m_newValue = newValue; m_path = path;}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
int16_t m_newValue;
std::string m_path;
@@ -1096,7 +1090,7 @@ ObjectVectorTraceConfigTestCase::ObjectVectorTraceConfigTestCase ()
{
}
bool
void
ObjectVectorTraceConfigTestCase::DoRun (void)
{
IntegerValue iv;
@@ -1217,8 +1211,6 @@ ObjectVectorTraceConfigTestCase::DoRun (void)
obj3->SetAttribute ("Source", IntegerValue (-4));
NS_TEST_ASSERT_MSG_EQ (m_newValue, -4, "Trace 3 did not fire as expected");
NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/1/Source", "Trace 1 did not provide expected context");
return GetErrorStatus ();
}
// ===========================================================================
+2 -4
View File
@@ -218,7 +218,7 @@ public:
virtual ~GlobalValueTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
GlobalValueTestCase::GlobalValueTestCase ()
@@ -226,7 +226,7 @@ GlobalValueTestCase::GlobalValueTestCase ()
{
}
bool
void
GlobalValueTestCase::DoRun (void)
{
//
@@ -256,8 +256,6 @@ GlobalValueTestCase::DoRun (void)
break;
}
}
return GetErrorStatus ();
}
// ===========================================================================
+28 -56
View File
@@ -70,7 +70,7 @@ public:
virtual ~BasicAddTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -89,7 +89,7 @@ BasicAddTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
BasicAddTestCase::DoRun (void)
{
std::string found;
@@ -117,8 +117,6 @@ BasicAddTestCase::DoRun (void)
found = Names::FindName (childOfObjectTwo);
NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
return false;
}
// ===========================================================================
@@ -137,7 +135,7 @@ public:
virtual ~StringContextAddTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -157,7 +155,7 @@ StringContextAddTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
StringContextAddTestCase::DoRun (void)
{
std::string found;
@@ -185,8 +183,6 @@ StringContextAddTestCase::DoRun (void)
found = Names::FindName (childOfObjectTwo);
NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
return false;
}
// ===========================================================================
@@ -202,7 +198,7 @@ public:
virtual ~FullyQualifiedAddTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -222,7 +218,7 @@ FullyQualifiedAddTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
FullyQualifiedAddTestCase::DoRun (void)
{
std::string found;
@@ -250,8 +246,6 @@ FullyQualifiedAddTestCase::DoRun (void)
found = Names::FindName (childOfObjectTwo);
NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
return false;
}
// ===========================================================================
@@ -270,7 +264,7 @@ public:
virtual ~RelativeAddTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -290,7 +284,7 @@ RelativeAddTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
RelativeAddTestCase::DoRun (void)
{
std::string found;
@@ -318,8 +312,6 @@ RelativeAddTestCase::DoRun (void)
found = Names::FindName (childOfObjectTwo);
NS_TEST_ASSERT_MSG_EQ (found, "Child", "Could not Names::Add and Names::FindName a child Object");
return false;
}
// ===========================================================================
@@ -338,7 +330,7 @@ public:
virtual ~BasicRenameTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -357,7 +349,7 @@ BasicRenameTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
BasicRenameTestCase::DoRun (void)
{
std::string found;
@@ -383,8 +375,6 @@ BasicRenameTestCase::DoRun (void)
found = Names::FindName (childOfObjectOne);
NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
return false;
}
// ===========================================================================
@@ -400,7 +390,7 @@ public:
virtual ~StringContextRenameTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -419,7 +409,7 @@ StringContextRenameTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
StringContextRenameTestCase::DoRun (void)
{
std::string found;
@@ -445,8 +435,6 @@ StringContextRenameTestCase::DoRun (void)
found = Names::FindName (childOfObjectOne);
NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
return false;
}
// ===========================================================================
@@ -462,7 +450,7 @@ public:
virtual ~FullyQualifiedRenameTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -481,7 +469,7 @@ FullyQualifiedRenameTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
FullyQualifiedRenameTestCase::DoRun (void)
{
std::string found;
@@ -507,8 +495,6 @@ FullyQualifiedRenameTestCase::DoRun (void)
found = Names::FindName (childOfObjectOne);
NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
return false;
}
// ===========================================================================
@@ -524,7 +510,7 @@ public:
virtual ~RelativeRenameTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -543,7 +529,7 @@ RelativeRenameTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
RelativeRenameTestCase::DoRun (void)
{
std::string found;
@@ -569,8 +555,6 @@ RelativeRenameTestCase::DoRun (void)
found = Names::FindName (childOfObjectOne);
NS_TEST_ASSERT_MSG_EQ (found, "New Child", "Could not Names::Rename a child Object");
return false;
}
// ===========================================================================
@@ -586,7 +570,7 @@ public:
virtual ~FindPathTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -605,7 +589,7 @@ FindPathTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
FindPathTestCase::DoRun (void)
{
std::string found;
@@ -625,8 +609,6 @@ FindPathTestCase::DoRun (void)
Ptr<TestObject> objectNotThere = CreateObject<TestObject> ();
found = Names::FindPath (objectNotThere);
NS_TEST_ASSERT_MSG_EQ (found, "", "Unexpectedly found a non-existent Object");
return false;
}
// ===========================================================================
@@ -642,7 +624,7 @@ public:
virtual ~BasicFindTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -661,7 +643,7 @@ BasicFindTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
BasicFindTestCase::DoRun (void)
{
Ptr<TestObject> found;
@@ -689,8 +671,6 @@ BasicFindTestCase::DoRun (void)
found = Names::Find<TestObject> (objectTwo, "Child");
NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo, "Could not find a previously named child Object via object context");
return false;
}
// ===========================================================================
@@ -706,7 +686,7 @@ public:
virtual ~StringContextFindTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -725,7 +705,7 @@ StringContextFindTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
StringContextFindTestCase::DoRun (void)
{
Ptr<TestObject> found;
@@ -753,8 +733,6 @@ StringContextFindTestCase::DoRun (void)
found = Names::Find<TestObject> ("/Names/Name Two", "Child");
NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo, "Could not find a previously named child Object via string context");
return false;
}
// ===========================================================================
@@ -770,7 +748,7 @@ public:
virtual ~FullyQualifiedFindTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -789,7 +767,7 @@ FullyQualifiedFindTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
FullyQualifiedFindTestCase::DoRun (void)
{
Ptr<TestObject> found;
@@ -817,8 +795,6 @@ FullyQualifiedFindTestCase::DoRun (void)
found = Names::Find<TestObject> ("/Names/Name Two/Child");
NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo, "Could not find a previously named child Object via string context");
return false;
}
// ===========================================================================
@@ -834,7 +810,7 @@ public:
virtual ~RelativeFindTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -853,7 +829,7 @@ RelativeFindTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
RelativeFindTestCase::DoRun (void)
{
Ptr<TestObject> found;
@@ -881,8 +857,6 @@ RelativeFindTestCase::DoRun (void)
found = Names::Find<TestObject> ("Name Two/Child");
NS_TEST_ASSERT_MSG_EQ (found, childOfObjectTwo, "Could not find a previously named child Object via string context");
return false;
}
// ===========================================================================
@@ -896,7 +870,7 @@ public:
virtual ~AlternateFindTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
virtual void DoTeardown (void);
};
@@ -915,7 +889,7 @@ AlternateFindTestCase::DoTeardown (void)
Names::Clear ();
}
bool
void
AlternateFindTestCase::DoRun (void)
{
Ptr<TestObject> testObject = CreateObject<TestObject> ();
@@ -943,8 +917,6 @@ AlternateFindTestCase::DoRun (void)
foundTestObject = Names::Find<TestObject> ("Alternate Test Object");
NS_TEST_ASSERT_MSG_EQ (foundTestObject, 0,
"Unexpectedly able to GetObject<TestObject> on an AlternateTestObject");
return false;
}
class NamesTestSuite : public TestSuite
+6 -12
View File
@@ -475,7 +475,7 @@ public:
virtual ~CreateObjectTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
CreateObjectTestCase::CreateObjectTestCase ()
@@ -487,7 +487,7 @@ CreateObjectTestCase::~CreateObjectTestCase ()
{
}
bool
void
CreateObjectTestCase::DoRun (void)
{
Ptr<BaseA> baseA = CreateObject<BaseA> ();
@@ -529,8 +529,6 @@ CreateObjectTestCase::DoRun (void)
// object.
//
NS_TEST_ASSERT_MSG_EQ (baseA->GetObject<BaseA> (DerivedA::GetTypeId ()), baseA, "GetObject returns different Ptr");
return GetErrorStatus ();
}
// ===========================================================================
@@ -543,7 +541,7 @@ public:
virtual ~AggregateObjectTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
AggregateObjectTestCase::AggregateObjectTestCase ()
@@ -555,7 +553,7 @@ AggregateObjectTestCase::~AggregateObjectTestCase ()
{
}
bool
void
AggregateObjectTestCase::DoRun (void)
{
Ptr<BaseA> baseA = CreateObject<BaseA> ();
@@ -702,8 +700,6 @@ AggregateObjectTestCase::DoRun (void)
baseA = baseB->GetObject<BaseA> ();
NS_TEST_ASSERT_MSG_NE (baseA, 0, "Unable to GetObject on released object");
return GetErrorStatus ();
}
// ===========================================================================
@@ -716,7 +712,7 @@ public:
virtual ~ObjectFactoryTestCase ();
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
ObjectFactoryTestCase::ObjectFactoryTestCase ()
@@ -728,7 +724,7 @@ ObjectFactoryTestCase::~ObjectFactoryTestCase ()
{
}
bool
void
ObjectFactoryTestCase::DoRun (void)
{
ObjectFactory factory;
@@ -776,8 +772,6 @@ ObjectFactoryTestCase::DoRun (void)
// declaration.
//
NS_TEST_ASSERT_MSG_NE (a->GetObject<DerivedA> (), 0, "Unexpectedly able to work around C++ type system");
return GetErrorStatus ();
}
// ===========================================================================
+2 -4
View File
@@ -53,7 +53,7 @@ public:
PtrTestCase ();
void DestroyNotify (void);
private:
virtual bool DoRun (void);
virtual void DoRun (void);
Ptr<NoCount> CallTest (Ptr<NoCount> p);
Ptr<NoCount> const CallTestConst (Ptr<NoCount> const p);
uint32_t m_nDestroyed;
@@ -114,7 +114,7 @@ PtrTestCase::CallTestConst (Ptr<NoCount> const p)
}
bool
void
PtrTestCase::DoRun (void)
{
m_nDestroyed = false;
@@ -257,8 +257,6 @@ PtrTestCase::DoRun (void)
NS_TEST_EXPECT_MSG_EQ ((p0 == p1), false, "operator == failed");
NS_TEST_EXPECT_MSG_EQ ((p0 != p1), true, "operator != failed");
}
return false;
}
static class PtrTestSuite : public TestSuite
+4 -8
View File
@@ -2055,7 +2055,7 @@ public:
}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
BasicRandomNumberTestCase::BasicRandomNumberTestCase ()
@@ -2063,7 +2063,7 @@ BasicRandomNumberTestCase::BasicRandomNumberTestCase ()
{
}
bool
void
BasicRandomNumberTestCase::DoRun (void)
{
const double desiredMean = 1.0;
@@ -2106,8 +2106,6 @@ BasicRandomNumberTestCase::DoRun (void)
}
double obtainedStdDev = sqrt (sum / (NSAMPLES - 1));
NS_TEST_EXPECT_MSG_EQ_TOL (obtainedStdDev, desiredStdDev, 0.1, "Got unexpected standard deviation from LogNormalVariable");
return GetErrorStatus ();
}
class RandomNumberSerializationTestCase : public TestCase
@@ -2119,7 +2117,7 @@ public:
}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
RandomNumberSerializationTestCase::RandomNumberSerializationTestCase ()
@@ -2127,7 +2125,7 @@ RandomNumberSerializationTestCase::RandomNumberSerializationTestCase ()
{
}
bool
void
RandomNumberSerializationTestCase::DoRun (void)
{
RandomVariableValue val;
@@ -2145,8 +2143,6 @@ RandomNumberSerializationTestCase::DoRun (void)
rng = val.Get ();
NS_TEST_ASSERT_MSG_EQ (val.SerializeToString (MakeRandomVariableChecker ()), "Normal:0.1:0.2:0.15",
"Deserialize and Serialize \"Normal:0.1:0.2:0.15\" mismatch");
return GetErrorStatus ();
}
class BasicRandomNumberTestSuite : public TestSuite
+8 -12
View File
@@ -55,7 +55,7 @@ public:
double ChiSquaredTest (UniformVariable &u);
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
RngUniformTestCase::RngUniformTestCase ()
@@ -102,7 +102,7 @@ RngUniformTestCase::ChiSquaredTest (UniformVariable &u)
return chiSquared;
}
bool
void
RngUniformTestCase::DoRun (void)
{
SeedManager::SetSeed (time (0));
@@ -120,7 +120,6 @@ RngUniformTestCase::DoRun (void)
sum /= (double)N_RUNS;
NS_TEST_ASSERT_MSG_LT (sum, maxStatistic, "Chi-squared statistic out of range");
return false;
}
// ===========================================================================
@@ -139,7 +138,7 @@ public:
double ChiSquaredTest (NormalVariable &n);
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
RngNormalTestCase::RngNormalTestCase ()
@@ -200,7 +199,7 @@ RngNormalTestCase::ChiSquaredTest (NormalVariable &n)
return chiSquared;
}
bool
void
RngNormalTestCase::DoRun (void)
{
SeedManager::SetSeed (time (0));
@@ -218,7 +217,6 @@ RngNormalTestCase::DoRun (void)
sum /= (double)N_RUNS;
NS_TEST_ASSERT_MSG_LT (sum, maxStatistic, "Chi-squared statistic out of range");
return false;
}
// ===========================================================================
@@ -237,7 +235,7 @@ public:
double ChiSquaredTest (ExponentialVariable &n);
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
RngExponentialTestCase::RngExponentialTestCase ()
@@ -297,7 +295,7 @@ RngExponentialTestCase::ChiSquaredTest (ExponentialVariable &e)
return chiSquared;
}
bool
void
RngExponentialTestCase::DoRun (void)
{
SeedManager::SetSeed (time (0));
@@ -315,7 +313,6 @@ RngExponentialTestCase::DoRun (void)
sum /= (double)N_RUNS;
NS_TEST_ASSERT_MSG_LT (sum, maxStatistic, "Chi-squared statistic out of range");
return false;
}
// ===========================================================================
@@ -334,7 +331,7 @@ public:
double ChiSquaredTest (ParetoVariable &p);
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
RngParetoTestCase::RngParetoTestCase ()
@@ -395,7 +392,7 @@ RngParetoTestCase::ChiSquaredTest (ParetoVariable &p)
return chiSquared;
}
bool
void
RngParetoTestCase::DoRun (void)
{
SeedManager::SetSeed (time (0));
@@ -413,7 +410,6 @@ RngParetoTestCase::DoRun (void)
sum /= (double)N_RUNS;
NS_TEST_ASSERT_MSG_LT (sum, maxStatistic, "Chi-squared statistic out of range");
return false;
}
class RngTestSuite : public TestSuite
+11 -14
View File
@@ -21,6 +21,8 @@
#include "abort.h"
#include <math.h>
// Set to true to enable a segmentation fault upon a test case macro test
// failing (for debugging purposes)
bool gBreakOnFailure = false;
namespace ns3 {
@@ -138,7 +140,7 @@ TestCase::ReportEnd (void)
DoReportStart ();
}
bool
void
TestCase::Run (void)
{
//
@@ -150,8 +152,7 @@ TestCase::Run (void)
DoReportStart ();
DoSetup ();
bool result = DoRun ();
UpdateErrorStatus (result);
DoRun ();
DoTeardown ();
@@ -175,7 +176,7 @@ TestCase::Run (void)
DoReportEnd ();
return GetErrorStatus ();
return;
}
void
@@ -456,10 +457,7 @@ TestSuite::Run (void)
DoReportStart ();
DoSetup ();
bool result = DoRun ();
UpdateErrorStatus (result);
DoRun ();
DoTeardown ();
if (GetErrorStatus () == false)
@@ -663,7 +661,7 @@ TestSuite::DoSetup (void)
{
}
bool
void
TestSuite::DoRun (void)
{
SetErrorStatus (false);
@@ -682,19 +680,18 @@ TestSuite::DoRun (void)
//
// Run the test case
//
bool result = (*i)->Run ();
UpdateErrorStatus (result);
(*i)->Run ();
UpdateErrorStatus ((*i)->GetErrorStatus ());
//
// Exit if we have detected an error and we are not allowing multiple filures
// Exit if we have detected an error and we are not allowing multiple failures
//
if (GetErrorStatus () && m_continueOnFailure == false)
{
return GetErrorStatus ();
return;
}
}
return GetErrorStatus ();
}
void
+196 -17
View File
@@ -51,12 +51,6 @@ extern bool gBreakOnFailure;
#define NS_TEST_SOURCEDIR \
TestCase::GetSourceDir (__FILE__)
#define NS_TEST_RETURN_IF_ERROR \
if (GetErrorStatus ()) \
{ \
return true; \
}
// ===========================================================================
// Test for equality (generic version)
// ===========================================================================
@@ -79,7 +73,7 @@ extern bool gBreakOnFailure;
actualStream.str (), limitStream.str (), msgStream.str (), file, line); \
if (!ContinueOnFailure ()) \
{ \
return true; \
return; \
} \
} \
} while (false)
@@ -113,6 +107,61 @@ extern bool gBreakOnFailure;
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg) \
NS_TEST_ASSERT_MSG_EQ_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
/**
* \internal
*/
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \
do { \
if (!((actual) == (limit))) \
{ \
if (gBreakOnFailure) {*(int *)0 = 0;} \
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); \
if (!ContinueOnFailure ()) \
{ \
return true; \
} \
} \
} while (false)
/**
* \brief 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:
*
* \code
* NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (result, true,
* "cannot open file " << filename << " in test");
* \endcode
*
* is legal.
*
* \param actual Expression for the actual value found during the test.
* \param limit Expression for the expected value of the test.
* \param msg Message 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.
*
*/
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg) \
NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
/**
* \internal
*
@@ -189,7 +238,7 @@ extern bool gBreakOnFailure;
ReportTestFailure (condStream.str (), actualStream.str (), limitStream.str (), msgStream.str (), file, line); \
if (!ContinueOnFailure ()) \
{ \
return true; \
return; \
} \
} \
} while (false)
@@ -245,6 +294,85 @@ extern bool gBreakOnFailure;
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg) \
NS_TEST_ASSERT_MSG_EQ_TOL_INTERNAL (actual, limit, tol, msg, __FILE__, __LINE__)
/**
* \internal
*/
#define NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL_INTERNAL(actual, limit, tol, msg, file, line) \
do { \
if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \
{ \
if (gBreakOnFailure) {*(int *)0 = 0;} \
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); \
if (!ContinueOnFailure ()) \
{ \
return true; \
} \
} \
} while (false)
/**
* \brief 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:
*
* \code
* NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (snr, 1128.93, 0.005, "wrong snr (" << snr << ") in test");
* \endcode
*
* is legal.
*
* \param actual Expression for the actual value found during the test.
* \param limit Expression for the expected value of the test.
* \param tol Tolerance of the test.
* \param msg Message that is output if the test does not pass.
*
* This function returns a boolean value.
*
*/
#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__)
/**
* \internal
*
@@ -342,7 +470,7 @@ extern bool gBreakOnFailure;
actualStream.str (), limitStream.str (), msgStream.str (), file, line); \
if (!ContinueOnFailure ()) \
{ \
return true; \
return; \
} \
} \
} while (false)
@@ -375,6 +503,60 @@ extern bool gBreakOnFailure;
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg) \
NS_TEST_ASSERT_MSG_NE_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
/**
* \internal
*/
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL(actual, limit, msg, file, line) \
do { \
if (!((actual) != (limit))) \
{ \
if (gBreakOnFailure) {*(int *)0 = 0;} \
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); \
if (!ContinueOnFailure ()) \
{ \
return true; \
} \
} \
} while (false)
/**
* \brief 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 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:
*
* \code
* NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (result, false,
* "cannot open file " << filename << " in test");
* \endcode
*
* is legal.
*
* \param actual Expression for the actual value found during the test.
* \param limit Expression for the expected value of the test.
* \param msg Message 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.
*
*/
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg) \
NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL_INTERNAL (actual, limit, msg, __FILE__, __LINE__)
/**
* \internal
*
@@ -447,7 +629,7 @@ extern bool gBreakOnFailure;
actualStream.str (), limitStream.str (), msgStream.str (), file, line); \
if (!ContinueOnFailure ()) \
{ \
return true; \
return; \
} \
} \
} while (false)
@@ -531,7 +713,7 @@ extern bool gBreakOnFailure;
actualStream.str (), limitStream.str (), msgStream.str (), file, line); \
if (!ContinueOnFailure ()) \
{ \
return true; \
return; \
} \
} \
} while (false)
@@ -626,9 +808,8 @@ public:
/**
* \brief Run this test case.
* \returns Boolean sense of "an error has occurred."
*/
bool Run (void);
void Run (void);
/**
* \brief Set the verbosity of this test case.
@@ -829,9 +1010,8 @@ protected:
/**
* \internal
* \brief Implementation to actually run this test case.
* \returns Boolean sense of "an error has occurred."
*/
virtual bool DoRun (void) = 0;
virtual void DoRun (void) = 0;
/**
* \internal
@@ -1073,9 +1253,8 @@ protected:
/**
* \internal
* \brief Implementation to actually run this test suite.
* \returns Boolean sense of "an error has occurred."
*/
virtual bool DoRun (void);
virtual void DoRun (void);
/**
* \internal
+2 -4
View File
@@ -28,7 +28,7 @@ public:
virtual ~BasicTracedCallbackTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
void CbOne (uint8_t a, double b);
void CbTwo (uint8_t a, double b);
@@ -54,7 +54,7 @@ BasicTracedCallbackTestCase::CbTwo (uint8_t a, double b)
m_two = true;
}
bool
void
BasicTracedCallbackTestCase::DoRun (void)
{
//
@@ -106,8 +106,6 @@ BasicTracedCallbackTestCase::DoRun (void)
trace (1, 2);
NS_TEST_ASSERT_MSG_EQ (m_one, true, "Callback CbOne not called");
NS_TEST_ASSERT_MSG_EQ (m_two, true, "Callback CbTwo not called");
return GetErrorStatus ();
}
class TracedCallbackTestSuite : public TestSuite
+2 -4
View File
@@ -28,7 +28,7 @@ public:
virtual ~TypeTraitsTestCase () {}
private:
virtual bool DoRun (void);
virtual void DoRun (void);
};
TypeTraitsTestCase::TypeTraitsTestCase (void)
@@ -36,7 +36,7 @@ TypeTraitsTestCase::TypeTraitsTestCase (void)
{
}
bool
void
TypeTraitsTestCase::DoRun (void)
{
NS_TEST_ASSERT_MSG_EQ (TypeTraits<void (TypeTraitsTestCase::*) (void)>::IsPointerToMember, 1, "Check");
@@ -45,8 +45,6 @@ TypeTraitsTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (TypeTraits<void (TypeTraitsTestCase::*) (int) const>::IsPointerToMember, 1, "Check");
NS_TEST_ASSERT_MSG_EQ (TypeTraits<void (TypeTraitsTestCase::*) (void) const>::PointerToMemberTraits::nArgs, 0, "Check");
NS_TEST_ASSERT_MSG_EQ (TypeTraits<void (TypeTraitsTestCase::*) (int) const>::PointerToMemberTraits::nArgs, 1, "Check");
return GetErrorStatus ();
}
class TypeTraitsTestSuite : public TestSuite