core: Extend attribute container serialization test for a vector of tuples

This commit is contained in:
Sébastien Deronne
2023-05-15 22:56:37 +02:00
committed by Sébastien Deronne
parent 03e3633fc6
commit 6dfd7f10f0

View File

@@ -26,7 +26,9 @@
#include <ns3/ptr.h>
#include <ns3/string.h>
#include <ns3/test.h>
#include <ns3/tuple.h>
#include <ns3/type-id.h>
#include <ns3/uinteger.h>
#include <algorithm>
#include <iterator>
@@ -396,6 +398,24 @@ AttributeContainerSerializationTestCase::DoRun()
std::string reserialized = attr.SerializeToString(checker);
NS_TEST_ASSERT_MSG_EQ(reserialized, pairs, "Reserialization failed");
}
{
std::string tupleVec = "{-1, 2, 3.4};{-2, 1, 4.3}";
AttributeContainerValue<TupleValue<IntegerValue, UintegerValue, DoubleValue>, ';'> attr;
auto checker = MakeAttributeContainerChecker(attr);
auto acchecker = DynamicCast<AttributeContainerChecker>(checker);
acchecker->SetItemChecker(MakeTupleChecker<IntegerValue, UintegerValue, DoubleValue>(
MakeIntegerChecker<int8_t>(),
MakeUintegerChecker<uint16_t>(),
MakeDoubleChecker<double>()));
NS_TEST_ASSERT_MSG_EQ(attr.DeserializeFromString(tupleVec, checker),
true,
"Deserialization failed");
NS_TEST_ASSERT_MSG_EQ(attr.GetN(), 2, "Incorrect container size");
std::string reserialized = attr.SerializeToString(checker);
NS_TEST_ASSERT_MSG_EQ(reserialized, tupleVec, "Reserialization failed");
}
}
/**