12#include <ns3/object.h>
14#include <ns3/string.h>
17#include <ns3/uinteger.h>
59 using Tuple2 = std::tuple<double, uint16_t, std::string>;
96 "StringStringEnumTuple",
97 "Tuple1: string, string, enum",
105 "DoubleUintStringTuple",
106 "Tuple2: double, uint16_t, string",
160 void DoRun()
override;
164 :
TestCase(
"test TupleValue attribute value")
174 auto t1 = tupleObject->GetTuple1();
177 "First element of tuple 1 not correctly set");
180 "Second element of tuple 1 not correctly set");
183 "Third element of tuple 1 not correctly set");
186 auto t2 = tupleObject->GetTuple2();
191 "Third element of tuple 2 not correctly set");
194 bool ret1 = tupleObject->SetAttributeFailSafe(
195 "StringStringEnumTuple",
201 ret1 = tupleObject->GetAttributeFailSafe(
"StringStringEnumTuple", tupleValue1);
204 t1 = tupleValue1.
Get();
207 "First element of tuple 1 not correctly set");
210 "Second element of tuple 1 not correctly set");
213 "Third element of tuple 1 not correctly set");
216 bool ret2 = tupleObject->SetAttributeFailSafe(
217 "DoubleUintStringTuple",
222 ret2 = tupleObject->GetAttributeFailSafe(
"DoubleUintStringTuple", tupleValue2);
225 t2 = tupleValue2.
Get();
230 "Third element of tuple 2 not correctly set");
233 ret1 = tupleObject->SetAttributeFailSafe(
"StringStringEnumTuple",
237 t1 = tupleObject->GetTuple1();
240 "First element of tuple 1 not correctly set");
243 "Second element of tuple 1 not correctly set");
246 "Third element of tuple 1 not correctly set");
249 ret2 = tupleObject->SetAttributeFailSafe(
"DoubleUintStringTuple",
253 t2 = tupleObject->GetTuple2();
258 "Third element of tuple 2 not correctly set");
261 ret1 = tupleObject->SetAttributeFailSafe(
"StringStringEnumTuple",
267 "Tuple modified after failed assignment");
269 ret1 = tupleObject->SetAttributeFailSafe(
270 "StringStringEnumTuple",
277 "Tuple modified after failed assignment");
279 ret2 = tupleObject->SetAttributeFailSafe(
280 "DoubleUintStringTuple",
282 {4.83, 14,
"Josephson",
"constant"}));
286 "Tuple modified after failed assignment");
288 ret2 = tupleObject->SetAttributeFailSafe(
289 "DoubleUintStringTuple",
294 "Tuple modified after failed assignment");
296 ret2 = tupleObject->SetAttributeFailSafe(
297 "DoubleUintStringTuple",
302 "Tuple modified after failed assignment");
Object with attribute values storing tuples.
Tuple1 GetTuple1() const
Get tuple1.
void SetTuple1(const Tuple1 &tuple)
Set tuple1.
Tuple1Value::value_type Tuple1Pack
tuple of attribute values
Tuple2 m_tuple2
second tuple
std::tuple< double, uint16_t, std::string > Tuple2
Tuple2 typedef.
static TypeId GetTypeId()
Get the type ID.
Tuple2 GetTuple2() const
Get tuple2.
Tuple1 m_tuple1
first tuple
TupleTestEnum
Test enum type.
void SetTuple2(const Tuple2 &tuple)
Set tuple2.
Tuple1Value::result_type Tuple1
tuple of values
Test instantiation, initialization, access.
~TupleValueTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
A base class which provides memory management and object aggregation.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
AttributeValue implementation for Tuple.
std::tuple< Args... > value_type
Type of value stored in the TupleValue.
result_type Get() const
Get the stored values as a std::tuple.
std::tuple< std::invoke_result_t< decltype(&Args::Get), Args >... > result_type
Type returned by Get or passed in Set.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< const AttributeChecker > MakeStringChecker()
Ptr< const AttributeChecker > MakeTupleChecker(Ts... checkers)
Create a TupleChecker from AttributeCheckers associated with TupleValue elements.
Ptr< const AttributeAccessor > MakeTupleAccessor(T1 a1)
Create an AttributeAccessor for a class data member of type tuple, or a lone class get functor or set...
auto MakeTupleValue(T2 t)
Create a TupleValue object.
Ptr< const AttributeChecker > MakeUintegerChecker()
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
static TupleValueTestSuite g_tupleValueTestSuite
Static variable for test initialization.