20#include <ns3/double.h> 
   23#include <ns3/object.h> 
   25#include <ns3/string.h> 
   28#include <ns3/uinteger.h> 
   69    using Tuple2 = std::tuple<double, uint16_t, std::string>; 
 
  101        TypeId(
"ns3::TupleObject")
 
  103            .SetGroupName(
"Test")
 
  106                "StringStringEnumTuple",
 
  107                "Tuple1: string, string, enum",
 
  110                MakeTupleChecker<Tuple1Pack>(
 
  115                "DoubleUintStringTuple",
 
  116                "Tuple2: double, uint16_t, string",
 
  120                MakeTupleChecker<DoubleValue, UintegerValue, StringValue>(
 
  121                    MakeDoubleChecker<double>(1.0, 10.0),
 
  122                    MakeUintegerChecker<int>(1, 30),
 
  170    void DoRun() 
override;
 
  174    : 
TestCase(
"test TupleValue attribute value")
 
  181    auto tupleObject = CreateObject<TupleObject>();
 
  184    auto t1 = tupleObject->GetTuple1();
 
  187                          "First element of tuple 1 not correctly set");
 
  190                          "Second element of tuple 1 not correctly set");
 
  193                          "Third element of tuple 1 not correctly set");
 
  196    auto t2 = tupleObject->GetTuple2();
 
  201                          "Third element of tuple 2 not correctly set");
 
  204    bool ret1 = tupleObject->SetAttributeFailSafe(
 
  205        "StringStringEnumTuple",
 
  206        MakeTupleValue<TupleObject::Tuple1Pack>(
 
  211    ret1 = tupleObject->GetAttributeFailSafe(
"StringStringEnumTuple", tupleValue1);
 
  214    t1 = tupleValue1.
Get();
 
  217                          "First element of tuple 1 not correctly set");
 
  220                          "Second element of tuple 1 not correctly set");
 
  223                          "Third element of tuple 1 not correctly set");
 
  226    bool ret2 = tupleObject->SetAttributeFailSafe(
 
  227        "DoubleUintStringTuple",
 
  232    ret2 = tupleObject->GetAttributeFailSafe(
"DoubleUintStringTuple", tupleValue2);
 
  235    t2 = tupleValue2.
Get();
 
  240                          "Third element of tuple 2 not correctly set");
 
  243    ret1 = tupleObject->SetAttributeFailSafe(
"StringStringEnumTuple",
 
  247    t1 = tupleObject->GetTuple1();
 
  250                          "First element of tuple 1 not correctly set");
 
  253                          "Second element of tuple 1 not correctly set");
 
  256                          "Third element of tuple 1 not correctly set");
 
  259    ret2 = tupleObject->SetAttributeFailSafe(
"DoubleUintStringTuple",
 
  263    t2 = tupleObject->GetTuple2();
 
  268                          "Third element of tuple 2 not correctly set");
 
  271    ret1 = tupleObject->SetAttributeFailSafe(
"StringStringEnumTuple",
 
  277                          "Tuple modified after failed assignment");
 
  279    ret1 = tupleObject->SetAttributeFailSafe(
 
  280        "StringStringEnumTuple",
 
  281        MakeTupleValue<TupleObject::Tuple1Pack>(
 
  287                          "Tuple modified after failed assignment");
 
  289    ret2 = tupleObject->SetAttributeFailSafe(
 
  290        "DoubleUintStringTuple",
 
  292            {4.83, 14, 
"Josephson", 
"constant"}));
 
  296                          "Tuple modified after failed assignment");
 
  298    ret2 = tupleObject->SetAttributeFailSafe(
 
  299        "DoubleUintStringTuple",
 
  304                          "Tuple modified after failed assignment");
 
  306    ret2 = tupleObject->SetAttributeFailSafe(
 
  307        "DoubleUintStringTuple",
 
  312                          "Tuple modified after failed assignment");
 
  323    : 
TestSuite(
"tuple-value-test-suite", UNIT)
 
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, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
 
Hold objects of type std::tuple<Args...>.
 
result_type Get() const
Get the stored values as a std::tuple.
 
std::tuple< Args... > value_type
Type of value stored in the TupleValue.
 
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 > MakeStringChecker()
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
 
#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(int 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.