Index: src/core/test/attribute-test-suite.cc |
=================================================================== |
--- a/src/core/test/attribute-test-suite.cc |
+++ b/src/core/test/attribute-test-suite.cc |
@@ -38,7 +38,16 @@ |
using namespace ns3; |
/** |
- * Test class for TracedValue callbacks. |
+ * \ingroup core |
+ * \defgroup core-test core module tests |
+ */ |
+ |
+ |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Test class for TracedValue callbacks. |
* \see attribute_ValueClassTest |
*/ |
class ValueClassTest |
@@ -56,10 +65,17 @@ |
const ValueClassTest newValue); |
private: |
- int m_v; |
+ int m_v; ///< test variable |
}; |
+ /** |
+ * Not equal comparison operator for ValueClassTest |
+ * |
+ * \param [in] a first value to compare |
+ * \param [in] b second value to compare |
+ * \returns true if not equl |
+ */ |
bool operator != (const ValueClassTest &a, const ValueClassTest &b) |
{ |
return true; |
@@ -76,9 +92,19 @@ |
ATTRIBUTE_HELPER_HEADER (ValueClassTest); |
ATTRIBUTE_HELPER_CPP (ValueClassTest); |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Derived test class |
+ */ |
class Derived : public Object |
{ |
public: |
+ /** |
+ * \brief Get the type ID. |
+ * \return the object TypeId |
+ */ |
static TypeId GetTypeId (void) { |
static TypeId tid = TypeId ("ns3::Derived") |
.AddConstructor<Derived> () |
@@ -91,14 +117,28 @@ |
NS_OBJECT_ENSURE_REGISTERED (Derived); |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Attribute object test class |
+ */ |
class AttributeObjectTest : public Object |
{ |
public: |
+ /** |
+ * \enum Test_e |
+ * \brief test enumeration |
+ */ |
enum Test_e { |
TEST_A, |
TEST_B, |
TEST_C |
}; |
+ /** |
+ * \brief Get the type ID. |
+ * \return the object TypeId |
+ */ |
static TypeId GetTypeId (void) { |
static TypeId tid = TypeId ("ns3::AttributeObjectTest") |
.AddConstructor<AttributeObjectTest> () |
@@ -240,13 +280,29 @@ |
virtual ~AttributeObjectTest (void) {}; |
+ /// Add to vector test |
void AddToVector1 (void) { m_vector1.push_back (CreateObject<Derived> ()); } |
+ /// Add to vector test |
void AddToVector2 (void) { m_vector2.push_back (CreateObject<Derived> ()); } |
+ /** |
+ * Add to map test |
+ * \param i value to add |
+ */ |
void AddToMap1 (uint32_t i) { m_map1.insert (std::pair <uint32_t, Ptr<Derived> > (i, CreateObject<Derived> ())); } |
+ /** |
+ * Invoke callback test |
+ * \param a double value |
+ * \param b int value |
+ * \param c float value |
+ */ |
void InvokeCb (double a, int b, float c) { m_cb (a,b,c); } |
+ /** |
+ * Invoke callback value test |
+ * \param a int8 value |
+ */ |
void InvokeCbValue (int8_t a) |
{ |
if (!m_cbValue.IsNull ()) { |
@@ -255,63 +311,122 @@ |
} |
private: |
+ /** |
+ * Set test B function |
+ * \param v bool value |
+ */ |
void DoSetTestB (bool v) { m_boolTestA = v; } |
+ /** |
+ * Get test B function |
+ * \returns the bool test value |
+ */ |
bool DoGetTestB (void) const { return m_boolTestA; } |
+ /** |
+ * Get Int16 function |
+ * \returns int16 test value |
+ */ |
int16_t DoGetInt16 (void) const { return m_int16SetGet; } |
+ /** |
+ * Set Int16 function |
+ * \param v the int16 value |
+ */ |
void DoSetInt16 (int16_t v) { m_int16SetGet = v; } |
+ /** |
+ * Get vector size function |
+ * \returns the size of the test vector |
+ */ |
uint32_t DoGetVectorN (void) const { return m_vector2.size (); } |
+ /** |
+ * Get vector value function |
+ * \param i the vector index |
+ * \returns the vector value |
+ */ |
Ptr<Derived> DoGetVector (uint32_t i) const { return m_vector2[i]; } |
+ /** |
+ * Set integer source |
+ * \param v the int8 value |
+ * \returns true |
+ */ |
bool DoSetIntSrc (int8_t v) { m_intSrc2 = v; return true; } |
+ /** |
+ * Get integer source |
+ * \returns the int8 value |
+ */ |
int8_t DoGetIntSrc (void) const { return m_intSrc2; } |
+ /** |
+ * Set enum function |
+ * \param v the enum value |
+ * \returns true |
+ */ |
bool DoSetEnum (Test_e v) { m_enumSetGet = v; return true; } |
+ /** |
+ * Get enum function |
+ * \returns the enum value |
+ */ |
Test_e DoGetEnum (void) const { return m_enumSetGet; } |
- bool m_boolTestA; |
- bool m_boolTest; |
- int16_t m_int16; |
- int16_t m_int16WithBounds; |
- int16_t m_int16SetGet; |
- uint8_t m_uint8; |
- float m_float; |
- enum Test_e m_enum; |
- enum Test_e m_enumSetGet; |
- Ptr<RandomVariableStream> m_random; |
- std::vector<Ptr<Derived> > m_vector1; |
- std::vector<Ptr<Derived> > m_vector2; |
- std::map <uint32_t, Ptr<Derived> > m_map1; |
- Callback<void,int8_t> m_cbValue; |
- TracedValue<int8_t> m_intSrc1; |
- TracedValue<int8_t> m_intSrc2; |
+ bool m_boolTestA; ///< test variable |
+ bool m_boolTest; ///< test variable |
+ int16_t m_int16; ///< test variable |
+ int16_t m_int16WithBounds; ///< test variable |
+ int16_t m_int16SetGet; ///< test variable |
+ uint8_t m_uint8; ///< test variable |
+ float m_float; ///< test variable |
+ enum Test_e m_enum; ///< test variable |
+ enum Test_e m_enumSetGet; ///< test variable |
+ Ptr<RandomVariableStream> m_random; ///< random variable for testign |
+ std::vector<Ptr<Derived> > m_vector1; ///< test variable |
+ std::vector<Ptr<Derived> > m_vector2; ///< test variable |
+ std::map <uint32_t, Ptr<Derived> > m_map1; ///< test variable |
+ Callback<void,int8_t> m_cbValue; ///< test variable |
+ TracedValue<int8_t> m_intSrc1; ///< test variable |
+ TracedValue<int8_t> m_intSrc2; ///< test variable |
- typedef void (* NumericTracedCallback) (double, int, float); |
- TracedCallback<double, int, float> m_cb; |
- TracedValue<ValueClassTest> m_valueSrc; |
- Ptr<Derived> m_ptr; |
- Ptr<Derived> m_ptrInitialized; |
- Ptr<Derived> m_ptrInitialized2; |
- TracedValue<uint8_t> m_uintSrc; |
- TracedValue<enum Test_e> m_enumSrc; |
- TracedValue<double> m_doubleSrc; |
- TracedValue<bool> m_boolSrc; |
- Time m_timeWithBounds; |
+ typedef void (* NumericTracedCallback) (double, int, float); ///< callback function typedef |
+ TracedCallback<double, int, float> m_cb; ///< test variable |
+ TracedValue<ValueClassTest> m_valueSrc; ///< test variable |
+ Ptr<Derived> m_ptr; ///< test variable |
+ Ptr<Derived> m_ptrInitialized; ///< test variable |
+ Ptr<Derived> m_ptrInitialized2; ///< test variable |
+ TracedValue<uint8_t> m_uintSrc; ///< test variable |
+ TracedValue<enum Test_e> m_enumSrc; ///< test variable |
+ TracedValue<double> m_doubleSrc; ///< test variable |
+ TracedValue<bool> m_boolSrc; ///< test variable |
+ Time m_timeWithBounds; ///< test variable |
}; |
NS_OBJECT_ENSURE_REGISTERED (AttributeObjectTest); |
-// =========================================================================== |
-// Test case template used for generic Attribute Value types -- used to make |
-// sure that Attributes work as expected. |
-// =========================================================================== |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Test case template used for generic Attribute Value types -- used to make |
+ * sure that Attributes work as expected. |
+ */ |
template <typename T> |
class AttributeTestCase : public TestCase |
{ |
public: |
+ /** |
+ * Constructor |
+ * |
+ * \param description description |
+ */ |
AttributeTestCase (std::string description); |
virtual ~AttributeTestCase (); |
private: |
virtual void DoRun (void); |
+ /** |
+ * Check get code paths function |
+ * \param p the object to check |
+ * \param attributeName The attribute name |
+ * \param expectedString The expected string |
+ * \param expectedValue The expected value |
+ * \returns true if the expected string / value is found |
+ */ |
bool CheckGetCodePaths (Ptr<Object> p, std::string attributeName, std::string expectedString, T expectedValue); |
}; |
@@ -780,15 +895,27 @@ |
NS_TEST_ASSERT_MSG_EQ (ok, true, "Error in SetAttributeFailSafe() but value changes"); |
} |
-// =========================================================================== |
-// Test the Attributes of type RandomVariableStream. |
-// =========================================================================== |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Test the Attributes of type RandomVariableStream. |
+ */ |
class RandomVariableStreamAttributeTestCase : public TestCase |
{ |
public: |
+ /** |
+ * Constructor |
+ * |
+ * \param description the description |
+ */ |
RandomVariableStreamAttributeTestCase (std::string description); |
virtual ~RandomVariableStreamAttributeTestCase () {} |
+ /** |
+ * test callback function |
+ * \param a the int8 value |
+ */ |
void InvokeCbValue (int8_t a) |
{ |
if (!m_cbValue.IsNull ()) { |
@@ -799,11 +926,15 @@ |
private: |
virtual void DoRun (void); |
- Callback<void,int8_t> m_cbValue; |
+ Callback<void,int8_t> m_cbValue; ///< callback value |
+ /** |
+ * notify callback function |
+ * \param a the int8 value |
+ */ |
void NotifyCallbackValue (int8_t a) { m_gotCbValue = a; } |
- int16_t m_gotCbValue; |
+ int16_t m_gotCbValue; ///< callback test value |
}; |
RandomVariableStreamAttributeTestCase::RandomVariableStreamAttributeTestCase (std::string description) |
@@ -833,13 +964,21 @@ |
NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() a ConstantRandomVariable"); |
} |
-// =========================================================================== |
-// Test case for Object Vector Attributes. Generic nature is pretty much lost |
-// here, so we just break the class out. |
-// =========================================================================== |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Test case for Object Vector Attributes. Generic nature is pretty much lost |
+ * here, so we just break the class out. |
+ */ |
class ObjectVectorAttributeTestCase : public TestCase |
{ |
public: |
+ /** |
+ * Constructor |
+ * |
+ * \param description the description |
+ */ |
ObjectVectorAttributeTestCase (std::string description); |
virtual ~ObjectVectorAttributeTestCase () {} |
@@ -899,12 +1038,20 @@ |
NS_TEST_ASSERT_MSG_EQ (vector.GetN (), 2, "ObjectVectorValue \"TestVector1\" should be incremented"); |
} |
-// =========================================================================== |
-// Test case for Object Map Attributes. |
-// =========================================================================== |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Test case for Object Map Attributes. |
+ */ |
class ObjectMapAttributeTestCase : public TestCase |
{ |
public: |
+ /** |
+ * Constructor |
+ * |
+ * \param description te description |
+ */ |
ObjectMapAttributeTestCase (std::string description); |
virtual ~ObjectMapAttributeTestCase () {} |
@@ -964,13 +1111,21 @@ |
NS_TEST_ASSERT_MSG_EQ (map.GetN (), 2, "ObjectVectorValue \"TestMap1\" should be incremented"); |
} |
-// =========================================================================== |
-// Trace sources with value semantics can be used like Attributes. Make sure |
-// we can use them that way. |
-// =========================================================================== |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Trace sources with value semantics can be used like Attributes. Make sure |
+ * we can use them that way. |
+ */ |
class IntegerTraceSourceAttributeTestCase : public TestCase |
{ |
public: |
+ /** |
+ * Constructor |
+ * |
+ * \param description the description |
+ */ |
IntegerTraceSourceAttributeTestCase (std::string description); |
virtual ~IntegerTraceSourceAttributeTestCase () {} |
@@ -1056,21 +1211,35 @@ |
NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129"); |
} |
-// =========================================================================== |
-// Trace sources used like Attributes must also work as trace sources. Make |
-// sure we can use them that way. |
-// =========================================================================== |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Trace sources used like Attributes must also work as trace sources. Make |
+ * sure we can use them that way. |
+ * =========================================================================== |
+ */ |
class IntegerTraceSourceTestCase : public TestCase |
{ |
public: |
+ /** |
+ * Constructor |
+ * |
+ * \param description the description |
+ */ |
IntegerTraceSourceTestCase (std::string description); |
virtual ~IntegerTraceSourceTestCase () {} |
private: |
virtual void DoRun (void); |
+ /** |
+ * notify source function |
+ * \param old unused |
+ * \param n the test value |
+ */ |
void NotifySource1 (int8_t old, int8_t n) { m_got1 = n; } |
- int64_t m_got1; |
+ int64_t m_got1; ///< trace target variable |
}; |
IntegerTraceSourceTestCase::IntegerTraceSourceTestCase (std::string description) |
@@ -1128,22 +1297,36 @@ |
NS_TEST_ASSERT_MSG_EQ (m_got1, 0, "Hitting a TracedValue after disconnect still causes callback"); |
} |
-// =========================================================================== |
-// Trace sources used like Attributes must also work as trace sources. Make |
-// sure we can use them that way. |
-// =========================================================================== |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Trace sources used like Attributes must also work as trace sources. Make |
+ * sure we can use them that way. |
+ */ |
class TracedCallbackTestCase : public TestCase |
{ |
public: |
+ /** |
+ * Constructor |
+ * |
+ * \param description the description |
+ */ |
TracedCallbackTestCase (std::string description); |
virtual ~TracedCallbackTestCase () {} |
private: |
virtual void DoRun (void); |
+ /** |
+ * notify source function |
+ * \param a the test value |
+ * \param b unused |
+ * \param c unused |
+ */ |
void NotifySource2 (double a, int b, float c) { m_got2 = a; } |
- double m_got2; |
+ double m_got2; ///< trace target variable |
}; |
TracedCallbackTestCase::TracedCallbackTestCase (std::string description) |
@@ -1202,22 +1385,36 @@ |
NS_TEST_ASSERT_MSG_EQ (m_got2, 1.0, "Invoking disconnected TracedCallback unexpectedly results in trace callback"); |
} |
-// =========================================================================== |
-// Smart pointers (Ptr) are central to our architecture, so they must work as |
-// attributes. |
-// =========================================================================== |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Smart pointers (Ptr) are central to our architecture, so they must work as |
+ * attributes. |
+ */ |
class PointerAttributeTestCase : public TestCase |
{ |
public: |
+ /** |
+ * Constructor |
+ * |
+ * \param description the description |
+ */ |
PointerAttributeTestCase (std::string description); |
virtual ~PointerAttributeTestCase () {} |
private: |
virtual void DoRun (void); |
+ /** |
+ * notify source function |
+ * \param a the test value |
+ * \param b unused |
+ * \param c unused |
+ */ |
void NotifySource2 (double a, int b, float c) { m_got2 = a; } |
- double m_got2; |
+ double m_got2; ///< attribute target variable |
}; |
PointerAttributeTestCase::PointerAttributeTestCase (std::string description) |
@@ -1314,15 +1511,27 @@ |
NS_TEST_ASSERT_MSG_NE (storedPtr4, storedPtr5, "aotPtr and aotPtr2 are unique, but their Derived member is not"); |
} |
-// =========================================================================== |
-// Test the Attributes of type CallbackValue. |
-// =========================================================================== |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief Test the Attributes of type CallbackValue. |
+ */ |
class CallbackValueTestCase : public TestCase |
{ |
public: |
+ /** |
+ * Constructor |
+ * |
+ * \param description the description |
+ */ |
CallbackValueTestCase (std::string description); |
virtual ~CallbackValueTestCase () {} |
+ /** |
+ * invoke callback function |
+ * \param a the test value |
+ */ |
void InvokeCbValue (int8_t a) |
{ |
if (!m_cbValue.IsNull ()) { |
@@ -1333,11 +1542,15 @@ |
private: |
virtual void DoRun (void); |
- Callback<void,int8_t> m_cbValue; |
+ Callback<void,int8_t> m_cbValue; ///< callback value |
+ /** |
+ * notify callback function |
+ * \param a the test value |
+ */ |
void NotifyCallbackValue (int8_t a) { m_gotCbValue = a; } |
- int16_t m_gotCbValue; |
+ int16_t m_gotCbValue; ///< target callback variable |
}; |
CallbackValueTestCase::CallbackValueTestCase (std::string description) |
@@ -1395,9 +1608,12 @@ |
NS_TEST_ASSERT_MSG_EQ (m_gotCbValue, 2, "Callback Attribute set to null callback unexpectedly fired"); |
} |
-// =========================================================================== |
-// The Test Suite that glues all of the Test Cases together. |
-// =========================================================================== |
+/** |
+ * \ingroup core-test |
+ * \ingroup tests |
+ * |
+ * \brief The Test Suite that glues all of the Test Cases together. |
+ */ |
class AttributesTestSuite : public TestSuite |
{ |
public: |