12#include "ns3/object.h"
14#include "ns3/string.h"
17#include "ns3/uinteger.h"
55 using Tuple2 = std::tuple<double, uint16_t, std::string>;
92 "StringStringEnumTuple",
93 "Tuple1: string, string, enum",
101 "DoubleUintStringTuple",
102 "Tuple2: double, uint16_t, string",
156 void DoRun()
override;
160 :
TestCase(
"test TupleValue attribute value")
170 auto t1 = tupleObject->GetTuple1();
173 "First element of tuple 1 not correctly set");
176 "Second element of tuple 1 not correctly set");
179 "Third element of tuple 1 not correctly set");
182 auto t2 = tupleObject->GetTuple2();
187 "Third element of tuple 2 not correctly set");
190 bool ret1 = tupleObject->SetAttributeFailSafe(
191 "StringStringEnumTuple",
197 ret1 = tupleObject->GetAttributeFailSafe(
"StringStringEnumTuple", tupleValue1);
200 t1 = tupleValue1.
Get();
203 "First element of tuple 1 not correctly set");
206 "Second element of tuple 1 not correctly set");
209 "Third element of tuple 1 not correctly set");
212 bool ret2 = tupleObject->SetAttributeFailSafe(
213 "DoubleUintStringTuple",
218 ret2 = tupleObject->GetAttributeFailSafe(
"DoubleUintStringTuple", tupleValue2);
221 t2 = tupleValue2.
Get();
226 "Third element of tuple 2 not correctly set");
229 ret1 = tupleObject->SetAttributeFailSafe(
"StringStringEnumTuple",
233 t1 = tupleObject->GetTuple1();
236 "First element of tuple 1 not correctly set");
239 "Second element of tuple 1 not correctly set");
242 "Third element of tuple 1 not correctly set");
245 ret2 = tupleObject->SetAttributeFailSafe(
"DoubleUintStringTuple",
249 t2 = tupleObject->GetTuple2();
254 "Third element of tuple 2 not correctly set");
257 ret1 = tupleObject->SetAttributeFailSafe(
"StringStringEnumTuple",
263 "Tuple modified after failed assignment");
265 ret1 = tupleObject->SetAttributeFailSafe(
266 "StringStringEnumTuple",
273 "Tuple modified after failed assignment");
275 ret2 = tupleObject->SetAttributeFailSafe(
276 "DoubleUintStringTuple",
278 {4.83, 14,
"Josephson",
"constant"}));
282 "Tuple modified after failed assignment");
284 ret2 = tupleObject->SetAttributeFailSafe(
285 "DoubleUintStringTuple",
290 "Tuple modified after failed assignment");
292 ret2 = tupleObject->SetAttributeFailSafe(
293 "DoubleUintStringTuple",
298 "Tuple modified after failed assignment");
TupleValue< StringValue, StringValue, EnumValue< TupleTestEnum > > Tuple1Value
Tuple1 attribute value.
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.
Object()
Caller graph was not generated because of its size.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
AttributeValue implementation for Tuple.
std::tuple< Args... > value_type
result_type Get() const
Get the stored values as a std::tuple.
std::tuple< std::invoke_result_t< decltype(&Args::Get), Args >... > result_type
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.