7#include "ns3/boolean.h"
8#include "ns3/callback.h"
10#include "ns3/double.h"
12#include "ns3/integer.h"
13#include "ns3/nstime.h"
14#include "ns3/object-factory.h"
15#include "ns3/object-map.h"
16#include "ns3/object-vector.h"
17#include "ns3/object.h"
18#include "ns3/pointer.h"
19#include "ns3/random-variable-stream.h"
20#include "ns3/string.h"
22#include "ns3/trace-source-accessor.h"
23#include "ns3/traced-value.h"
24#include "ns3/uinteger.h"
164 TypeId(
"ns3::AttributeObjectTest")
167 .HideFromDocumentation()
168 .AddAttribute(
"TestBoolName",
173 .AddAttribute(
"TestBoolA",
179 .AddAttribute(
"TestInt16",
184 .AddAttribute(
"TestInt16WithBounds",
189 .AddAttribute(
"TestInt16SetGet",
195 .AddAttribute(
"TestUint8",
200 .AddAttribute(
"TestEnum",
205 .AddAttribute(
"TestEnumSetGet",
211 .AddAttribute(
"TestEnumClass",
221 .AddAttribute(
"TestEnumClassSetGet",
232 .AddAttribute(
"TestRandom",
234 StringValue(
"ns3::ConstantRandomVariable[Constant=1.0]"),
237 .AddAttribute(
"TestFloat",
242 .AddAttribute(
"TestVector1",
247 .AddAttribute(
"TestVector2",
253 .AddAttribute(
"TestMap1",
258 .AddAttribute(
"TestUnorderedMap",
263 .AddAttribute(
"IntegerTraceSource1",
268 .AddAttribute(
"IntegerTraceSource2",
274 .AddAttribute(
"UIntegerTraceSource",
279 .AddAttribute(
"DoubleTraceSource",
284 .AddAttribute(
"BoolTraceSource",
295 .AddAttribute(
"ValueClassSource",
300 .AddTraceSource(
"Source1",
303 "ns3::TracedValueCallback::Int8")
304 .AddTraceSource(
"Source2",
307 "ns3::AttributeObjectTest::NumericTracedCallback")
308 .AddTraceSource(
"ValueSource",
311 "ns3::ValueClassTest::TracedValueCallback")
312 .AddAttribute(
"Pointer",
317 .AddAttribute(
"PointerInitialized",
322 .AddAttribute(
"PointerInitialized2",
327 .AddAttribute(
"Callback",
332 .AddAttribute(
"TestTimeWithBounds",
337 .AddAttribute(
"TestDeprecated",
343 "DEPRECATED test working.");
550 std::unordered_map<uint64_t, Ptr<Derived>>
600 std::string attributeName,
601 std::string expectedString,
619 std::string attributeName,
620 std::string expectedString,
629 bool ok1 = p->GetAttributeFailSafe(attributeName, stringValue);
630 bool ok2 = stringValue.
Get() == expectedString;
635 bool ok3 = p->GetAttributeFailSafe(attributeName, actualValue);
636 bool ok4 = expectedValue.Get() == actualValue.Get();
638 return ok1 && ok2 && ok3 && ok4;
659 bool ok = CheckGetCodePaths(p,
"TestBoolName",
"true",
BooleanValue(
true));
662 std::string expected(
"Attribute 'TestDeprecated' is deprecated: DEPRECATED test working.\n");
664 std::stringstream buffer;
665 std::streambuf* oldBuffer = std::cerr.rdbuf(buffer.rdbuf());
672 std::cerr.rdbuf(oldBuffer);
683 ok = CheckGetCodePaths(p,
"TestBoolName",
"false",
BooleanValue(
false));
689 ok = p->SetAttributeFailSafe(
"TestBoolName",
StringValue(
"true"));
692 ok = CheckGetCodePaths(p,
"TestBoolName",
"true",
BooleanValue(
true));
695 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
700 ok = p->SetAttributeFailSafe(
"TestBoolName",
StringValue(
"false"));
703 ok = CheckGetCodePaths(p,
"TestBoolName",
"false",
BooleanValue(
false));
706 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
720 ok = p->SetAttributeFailSafe(
"TestBoolA",
StringValue(
"true"));
723 ok = CheckGetCodePaths(p,
"TestBoolA",
"true",
BooleanValue(
true));
727 "Attribute not set properly by SetAttributeFailSafe() (getter/setter) via StringValue");
732 ok = p->SetAttributeFailSafe(
"TestBoolA",
StringValue(
"false"));
735 ok = CheckGetCodePaths(p,
"TestBoolA",
"false",
BooleanValue(
false));
739 "Attribute not set properly by SetAttributeFailSafe() (getter/setter) via StringValue");
753 bool ok = CheckGetCodePaths(p,
"TestInt16",
"-2",
IntegerValue(-2));
759 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-5"));
762 ok = CheckGetCodePaths(p,
"TestInt16",
"-5",
IntegerValue(-5));
765 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
770 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"+2"));
773 ok = CheckGetCodePaths(p,
"TestInt16",
"2",
IntegerValue(2));
776 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
781 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-32768"));
784 ok = CheckGetCodePaths(p,
"TestInt16",
"-32768",
IntegerValue(-32768));
788 "Attribute not set properly by SetAttributeFailSafe() (most negative) via StringValue");
794 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-32769"));
797 "Unexpectedly could SetAttributeFailSafe() via StringValue to -32769");
799 ok = CheckGetCodePaths(p,
"TestInt16",
"-32768",
IntegerValue(-32768));
805 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"32767"));
808 ok = CheckGetCodePaths(p,
"TestInt16",
"32767",
IntegerValue(32767));
812 "Attribute not set properly by SetAttributeFailSafe() (most positive) via StringValue");
818 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"32768"));
821 "Unexpectedly could SetAttributeFailSafe() via StringValue to 32768");
823 ok = CheckGetCodePaths(p,
"TestInt16",
"32767",
IntegerValue(32767));
830 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(10));
833 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"10",
IntegerValue(10));
837 "Attribute not set properly by SetAttributeFailSafe() (positive limit) via StringValue");
842 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(11));
845 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 11");
847 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"10",
IntegerValue(10));
853 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(-5));
856 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"-5",
IntegerValue(-5));
860 "Attribute not set properly by SetAttributeFailSafe() (negative limit) via StringValue");
865 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(-6));
868 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -6");
870 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"-5",
IntegerValue(-5));
885 bool ok = CheckGetCodePaths(p,
"TestUint8",
"1",
UintegerValue(1));
894 ok = CheckGetCodePaths(p,
"TestUint8",
"0",
UintegerValue(0));
897 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
902 ok = p->SetAttributeFailSafe(
"TestUint8",
UintegerValue(255));
905 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
909 "Attribute not set properly by SetAttributeFailSafe() (positive limit) via UintegerValue");
915 ok = p->SetAttributeFailSafe(
"TestUint8",
UintegerValue(256));
918 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
925 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"255"));
928 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
931 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
937 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"256"));
940 "Unexpectedly could SetAttributeFailSafe() via StringValue to 256");
942 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
948 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"-1"));
951 "Unexpectedly could SetAttributeFailSafe() via StringValue to -1");
965 bool ok = CheckGetCodePaths(p,
"TestFloat",
"-1.1",
DoubleValue(-1.1F));
971 ok = p->SetAttributeFailSafe(
"TestFloat",
DoubleValue(2.3F));
974 ok = CheckGetCodePaths(p,
"TestFloat",
"2.3",
DoubleValue(2.3F));
977 "Attribute not set properly by SetAttributeFailSafe() via DoubleValue");
1003 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
1021 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
1026 ok = p->SetAttributeFailSafe(
"TestEnum",
StringValue(
"TestB"));
1032 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
1048 ok = p->SetAttributeFailSafe(
"TestEnum",
EnumValue(5));
1066 bool ok = CheckGetCodePaths(p,
1078 ok = CheckGetCodePaths(p,
1084 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
1090 ok = CheckGetCodePaths(p,
1091 "TestEnumClassSetGet",
1099 ok = p->SetAttributeFailSafe(
"TestEnumClassSetGet",
1103 ok = CheckGetCodePaths(p,
1104 "TestEnumClassSetGet",
1109 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
1114 ok = p->SetAttributeFailSafe(
"TestEnumClass",
StringValue(
"TestE"));
1117 ok = CheckGetCodePaths(p,
1123 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
1132 ok = CheckGetCodePaths(p,
1142 ok = p->SetAttributeFailSafe(
"TestEnumClass",
EnumValue(5));
1145 ok = CheckGetCodePaths(p,
1165 bool ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(5)));
1168 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+5e+09ns",
TimeValue(
Seconds(5)));
1171 "Attribute not set properly by SetAttributeFailSafe(5s) via TimeValue");
1173 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
StringValue(
"3s"));
1176 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+3e+09ns",
TimeValue(
Seconds(3)));
1179 "Attribute not set properly by SetAttributeFailSafe(3s) via StringValue");
1189 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(10)));
1192 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+1e+10ns",
TimeValue(
Seconds(10)));
1196 "Attribute not set properly by SetAttributeFailSafe(10s [positive limit]) via StringValue");
1201 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(11)));
1204 "Unexpectedly could SetAttributeFailSafe() via TimeValue to 11s [greater "
1205 "than positive limit]");
1207 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+1e+10ns",
TimeValue(
Seconds(10)));
1213 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(-5)));
1216 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"-5e+09ns",
TimeValue(
Seconds(-5)));
1220 "Attribute not set properly by SetAttributeFailSafe(-5s [negative limit]) via StringValue");
1225 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(-6)));
1228 "Unexpectedly could SetAttributeFailSafe() via TimeValue to -6s");
1230 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"-5e+09ns",
TimeValue(
Seconds(-5)));
1265 void DoRun()
override;
1283 std::string description)
1297 bool ok = p->SetAttributeFailSafe(
"TestRandom",
1298 StringValue(
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
1304 ok = p->SetAttributeFailSafe(
"TestRandom",
1305 StringValue(
"ns3::ConstantRandomVariable[Constant=1.0]"));
1330 void DoRun()
override;
1350 p->GetAttribute(
"TestVector1", vector);
1353 "Initial count of ObjectVectorValue \"TestVector1\" should be zero");
1362 "Initial count of ObjectVectorValue \"TestVector1\" should still be zero");
1367 p->GetAttribute(
"TestVector1", vector);
1370 "ObjectVectorValue \"TestVector1\" should be incremented");
1384 "Count of ObjectVectorValue \"TestVector1\" should still be one");
1389 p->GetAttribute(
"TestVector1", vector);
1392 "ObjectVectorValue \"TestVector1\" should be incremented");
1414 void DoRun()
override;
1434 p->GetAttribute(
"TestMap1", map);
1437 "Initial count of ObjectVectorValue \"TestMap1\" should be zero");
1445 "Initial count of ObjectVectorValue \"TestMap1\" should still be zero");
1450 p->GetAttribute(
"TestMap1", map);
1465 "Count of ObjectVectorValue \"TestMap1\" should still be one");
1470 p->GetAttribute(
"TestMap1", map);
1478 p->AddToUnorderedMap(4);
1479 p->AddToUnorderedMap(2);
1480 p->AddToUnorderedMap(1);
1481 p->AddToUnorderedMap(3);
1483 p->RemoveFromUnorderedMap(2);
1484 p->GetAttribute(
"TestUnorderedMap", unorderedMap);
1487 "ObjectMapValue \"TestUnorderedMap\" should have three values");
1491 "ObjectMapValue \"TestUnorderedMap\" should have value with key 1");
1495 "ObjectMapValue \"TestUnorderedMap\" should not have value with key 2");
1496 auto it = unorderedMap.
Begin();
1499 "ObjectMapValue \"TestUnorderedMap\" should have a value with key 1");
1503 "ObjectMapValue \"TestUnorderedMap\" should have a value with key 3");
1507 "ObjectMapValue \"TestUnorderedMap\" should have a value with key 4");
1530 void DoRun()
override;
1550 p->GetAttribute(
"IntegerTraceSource1", iv);
1556 bool ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(5));
1559 p->GetAttribute(
"IntegerTraceSource1", iv);
1562 "Attribute not set properly by SetAttributeFailSafe() via IntegerValue");
1567 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(127));
1570 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(128));
1573 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128");
1575 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-128));
1578 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-129));
1581 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
1587 p->GetAttribute(
"IntegerTraceSource2", iv);
1593 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(5));
1596 p->GetAttribute(
"IntegerTraceSource2", iv);
1599 "Attribute not set properly by SetAttributeFailSafe() via IntegerValue");
1604 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(127));
1607 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(128));
1610 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128");
1612 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(-128));
1615 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(-129));
1618 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
1641 void DoRun()
override;
1673 bool ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-1));
1682 ok = p->TraceConnectWithoutContext(
1687 "Could not TraceConnectWithoutContext() \"Source1\" to NodifySource1()");
1694 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(0));
1699 "Hitting a TracedValue does not cause trace callback to be called");
1705 ok = p->TraceDisconnectWithoutContext(
1710 "Could not TraceConnectWithoutContext() \"Source1\" to NodifySource1()");
1712 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(1));
1717 "Hitting a TracedValue after disconnect still causes callback");
1740 void DoRun()
override;
1780 p->InvokeCb(1.0, -5, 0.0);
1784 "Invoking a newly created TracedCallback results in an unexpected callback");
1791 p->TraceConnectWithoutContext(
"Source2",
1799 p->InvokeCb(1.0, -5, 0.0);
1807 ok = p->TraceDisconnectWithoutContext(
1812 p->InvokeCb(-1.0, -5, 0.0);
1816 "Invoking disconnected TracedCallback unexpectedly results in trace callback");
1839 void DoRun()
override;
1872 p->GetAttribute(
"Pointer", ptr);
1877 "Unexpectedly found non-null pointer in newly initialized PointerValue Attribute");
1884 bool ok = p->SetAttributeFailSafe(
"Pointer",
PointerValue(derived));
1887 "Could not SetAttributeFailSafe() a PointerValue of the correct type");
1893 p->GetAttribute(
"Pointer", ptr);
1897 "Retrieved Attribute does not match stored PointerValue");
1905 p->GetAttribute(
"Pointer", ptr);
1909 "Retrieved Ptr<Object> does not match stored Ptr<Derived>");
1915 p->GetAttribute(
"Pointer", ptr);
1919 "Unexpectedly retrieved unrelated Ptr<type> from stored Ptr<Derived>");
1925 p->GetAttribute(
"PointerInitialized", ptr);
1929 p2->GetAttribute(
"PointerInitialized", ptr2);
1933 "ptr and ptr2 both have PointerInitialized pointing to the same object");
1935 p2->GetAttribute(
"PointerInitialized", ptr3);
1939 "ptr and ptr3 both have PointerInitialized pointing to the same object");
1945 factory.
SetTypeId(
"ns3::AttributeObjectTest");
1953 aotPtr->GetAttribute(
"PointerInitialized", ptr4);
1956 aotPtr2->GetAttribute(
"PointerInitialized", ptr5);
1960 "aotPtr and aotPtr2 are unique, but their Derived member is not");
1994 void DoRun()
override;
2038 p->InvokeCbValue(2);
2043 bool ok = p->SetAttributeFailSafe(
"Callback", cbValue);
2049 p->InvokeCbValue(2);
2058 p->InvokeCbValue(3);
2061 "Callback Attribute set to null callback unexpectedly fired");
2079 TestCase::Duration::QUICK);
2081 TestCase::Duration::QUICK);
2083 TestCase::Duration::QUICK);
2085 TestCase::Duration::QUICK);
2087 "Check Attributes of type EnumValue"),
2088 TestCase::Duration::QUICK);
2090 "Check Attributes of type EnumValue (wrapping an enum class)"),
2091 TestCase::Duration::QUICK);
2093 TestCase::Duration::QUICK);
2096 TestCase::Duration::QUICK);
2098 TestCase::Duration::QUICK);
2100 TestCase::Duration::QUICK);
2102 TestCase::Duration::QUICK);
2104 TestCase::Duration::QUICK);
2106 "Ensure TracedValue<uint8_t> can be set like IntegerValue"),
2107 TestCase::Duration::QUICK);
2110 TestCase::Duration::QUICK);
2112 "Ensure TracedCallback<double, int, float> works as trace source"),
2113 TestCase::Duration::QUICK);
static AttributesTestSuite g_attributesTestSuite
Static variable for test initialization.
Class used to check attributes.
std::size_t DoGetVectorN() const
Get the length of m_vector2.
Ptr< Derived > DoGetVector(std::size_t i) const
Get the i-th item of m_vector2.
bool DoSetIntSrc(int8_t v)
Set the m_intSrc2 value.
bool m_boolTest
Boolean test.
std::unordered_map< uint64_t, Ptr< Derived > > m_unorderedMap
Unordered map of uint64_t, derived objects.
void AddToVector2()
Add an object to the second vector.
std::map< uint32_t, Ptr< Derived > > m_map1
Map of uint32_t, derived objects.
int16_t m_int16SetGet
16-bit integer set-get.
Test_e DoGetEnum() const
Get the m_enumSetGet value.
bool DoGetTestA() const
Get the m_boolTestA value.
Test_ec m_enumClassSetGet
Enum class set-get.
void InvokeCb(double a, int b, float c)
Invoke the m_cb callback.
Test_ec m_enumclass
Enum class.
Ptr< RandomVariableStream > m_random
Random number generator.
bool m_boolTestA
Boolean test A.
int16_t m_int16
16-bit integer.
void AddToUnorderedMap(uint64_t i)
Adds an object to the unordered map.
static TypeId GetTypeId()
Get the type ID.
~AttributeObjectTest() override
std::vector< Ptr< Derived > > m_vector1
First vector of derived objects.
Callback< void, int8_t > m_cbValue
Callback accepting an integer.
void InvokeCbValue(int8_t a)
Invoke the m_cbValue callback.
TracedValue< double > m_doubleSrc
double Traced value.
bool m_boolTestDeprecated
Boolean test deprecated.
void AddToMap1(uint32_t i)
Adds an object to the first map.
Test_ec DoGetEnumClass() const
Get the m_enumClassSetGet value.
TracedCallback< double, int, float > m_cb
TracedCallback (double, int, float).
bool DoSetEnumClass(Test_ec v)
Set the m_enumClassSetGet value.
Ptr< Derived > m_ptr
Pointer to Derived class.
int16_t m_int16WithBounds
16-bit integer with bounds.
TracedValue< int8_t > m_intSrc1
First int8_t Traced value.
TracedValue< Test_e > m_enumSrc
enum Traced value.
Ptr< Derived > m_ptrInitialized
Pointer to Derived class.
void AddToVector1()
Add an object to the first vector.
Ptr< Derived > m_ptrInitialized2
Pointer to Derived class.
int16_t DoGetInt16() const
Get the m_int16SetGet value.
TracedValue< ValueClassTest > m_valueSrc
ValueClassTest Traced value.
void DoSetTestA(bool v)
Set the m_boolTestA value.
TracedValue< uint8_t > m_uintSrc
uint8_t Traced value.
TracedValue< bool > m_boolSrc
bool Traced value.
TracedValue< int8_t > m_intSrc2
Second int8_t Traced value.
Test_e m_enumSetGet
Enum set-get.
Time m_timeWithBounds
Time with bounds.
int8_t DoGetIntSrc() const
Get the m_intSrc2 value.
uint8_t m_uint8
8-bit integer.
std::vector< Ptr< Derived > > m_vector2
Second vector of derived objects.
bool DoSetEnum(Test_e v)
Set the m_enumSetGet value.
void(* NumericTracedCallback)(double, int, float)
Traced callbacks for (double, int, float) values.
void RemoveFromUnorderedMap(uint64_t i)
Remove an object from the first map.
void DoSetInt16(int16_t v)
Set the m_int16SetGet value.
Test case template used for generic Attribute Value types – used to make sure that Attributes work as...
~AttributeTestCase() override
bool CheckGetCodePaths(Ptr< Object > p, std::string attributeName, std::string expectedString, T expectedValue)
Check the attribute path and value.
AttributeTestCase(std::string description)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
The attributes Test Suite.
Test the Attributes of type CallbackValue.
CallbackValueTestCase(std::string description)
Constructor.
void NotifyCallbackValue(int8_t a)
Function invoked when the callback is fired.
void DoRun() override
Implementation to actually run this TestCase.
void InvokeCbValue(int8_t a)
Function to invoke the callback.
Callback< void, int8_t > m_cbValue
The callback.
~CallbackValueTestCase() override
int16_t m_gotCbValue
Value used to verify that source 2 was called.
Simple class derived from ns3::Object, used to check attribute constructors.
static TypeId GetTypeId()
Get the type ID.
Trace sources with value semantics can be used like Attributes, make sure we can use them that way.
IntegerTraceSourceAttributeTestCase(std::string description)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
~IntegerTraceSourceAttributeTestCase() override
Trace sources used like Attributes must also work as trace sources, make sure we can use them that wa...
int64_t m_got1
Value used to verify that source 1 was called.
IntegerTraceSourceTestCase(std::string description)
Constructor.
~IntegerTraceSourceTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
void NotifySource1(int8_t old, int8_t n)
Notify the call of source 1.
Test case for Object Map Attributes.
~ObjectMapAttributeTestCase() override
ObjectMapAttributeTestCase(std::string description)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Test case for Object Vector Attributes.
ObjectVectorAttributeTestCase(std::string description)
Constructor.
~ObjectVectorAttributeTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
Smart pointers (Ptr) are central to our architecture, so they must work as attributes.
void DoRun() override
Implementation to actually run this TestCase.
double m_got2
Value used to verify that source 2 was called.
~PointerAttributeTestCase() override
PointerAttributeTestCase(std::string description)
Constructor.
void NotifySource2(double a, int b, float c)
Notify the call of source 2.
Test the Attributes of type RandomVariableStream.
void InvokeCbValue(int8_t a)
Invoke the m_cbValue.
Callback< void, int8_t > m_cbValue
Callback used in the test.
~RandomVariableStreamAttributeTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
void NotifyCallbackValue(int8_t a)
Function called when the callback is used.
RandomVariableStreamAttributeTestCase(std::string description)
Constructor.
int16_t m_gotCbValue
Value used to verify that the callback has been invoked.
Trace sources used like Attributes must also work as trace sources, make sure we can use them that wa...
~TracedCallbackTestCase() override
TracedCallbackTestCase(std::string description)
Constructor.
void NotifySource2(double a, int b, float c)
Notify the call of source 2.
double m_got2
Value used to verify that source 2 was called.
void DoRun() override
Implementation to actually run this TestCase.
AttributeValue implementation for Boolean.
bool IsNull() const
Check for null implementation.
AttributeValue implementation for Callback.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
Hold a signed integer type.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
A base class which provides memory management and object aggregation.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Container for a set of ns3::Object pointers.
std::size_t GetN() const
Get the number of Objects.
Iterator Begin() const
Get an iterator to the first Object.
Ptr< Object > Get(std::size_t i) const
Get a specific Object.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
static void SetResolution(Unit resolution)
AttributeValue implementation for Time.
Forward calls to a chain of Callback.
Trace classes with value semantics.
a unique identifier for an interface.
TypeId AddConstructor()
Record in this TypeId the fact that the default constructor is accessible.
@ DEPRECATED
Attribute or trace source is deprecated; user is warned.
Hold an unsigned integer type.
Test class for TracedValue callbacks attributes.
void(* TracedValueCallback)(const ValueClassTest oldValue, const ValueClassTest newValue)
TracedValue callback signature for ValueClassTest.
AttributeValue implementation for ValueClassTest.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeCallbackAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeCallbackChecker()
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeIntegerChecker()
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
ObjectPtrContainerValue ObjectMapValue
ObjectMapValue is an alias for ObjectPtrContainerValue.
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Ptr< const AttributeChecker > MakeObjectMapChecker()
Ptr< const AttributeChecker > MakeObjectVectorChecker()
ObjectPtrContainerValue ObjectVectorValue
ObjectVectorValue is an alias for ObjectPtrContainerValue.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeValueClassTestAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeValueClassTestChecker()
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
Callback< R, Args... > MakeNullCallback()
void SetDefault(std::string name, const AttributeValue &value)
bool SetDefaultFailSafe(std::string fullName, const AttributeValue &value)
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
std::ostream & operator<<(std::ostream &os, const Angles &a)
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
std::istream & operator>>(std::istream &is, Angles &a)