Skip to content

Commit

Permalink
Refs #21385. Add tests for keys
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
  • Loading branch information
richiware committed Jul 26, 2024
1 parent c2524a2 commit 01d4f43
Show file tree
Hide file tree
Showing 11 changed files with 1,335 additions and 233 deletions.
37 changes: 11 additions & 26 deletions src/cpp/fastdds/xtypes/type_representation/TypeObjectUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,22 +829,15 @@ void TypeObjectUtils::add_complete_struct_member(
{
throw InvalidArgumentError("Sequence has another member with same name");
}
}
#endif // !defined(NDEBUG)
auto it = member_seq.begin();
for (; it != member_seq.end(); ++it)
{
// Ordered by the member_index
if (it->common().member_id() > member.common().member_id())
{
break;
}
else if (it->common().member_id() == member.common().member_id())

if (struct_member.common().member_id() == member.common().member_id())
{
throw InvalidArgumentError("Sequence has another member with same ID");
}
}
member_seq.emplace(it, member);
#endif // !defined(NDEBUG)
// Ordered by the member_index
member_seq.emplace_back(member);
}

const AppliedBuiltinTypeAnnotations TypeObjectUtils::build_applied_builtin_type_annotations(
Expand Down Expand Up @@ -999,6 +992,10 @@ void TypeObjectUtils::add_complete_union_member(
{
throw InvalidArgumentError("Sequence has another member with same name");
}
if (union_member.common().member_id() == member.common().member_id())
{
throw InvalidArgumentError("Sequence has another member with same ID");
}
if (member.common().member_flags() & MemberFlagBits::IS_DEFAULT &&
union_member.common().member_flags() & MemberFlagBits::IS_DEFAULT)
{
Expand All @@ -1013,20 +1010,8 @@ void TypeObjectUtils::add_complete_union_member(
}
}
#endif // !defined(NDEBUG)
auto it = complete_union_member_seq.begin();
for (; it != complete_union_member_seq.end(); ++it)
{
// Ordered by member_index
if (it->common().member_id() > member.common().member_id())
{
break;
}
else if (it->common().member_id() == member.common().member_id())
{
throw InvalidArgumentError("Sequence has another member with same ID");
}
}
complete_union_member_seq.emplace(it, member);
// Ordered by the member_index
complete_union_member_seq.emplace_back(member);
}

const CommonDiscriminatorMember TypeObjectUtils::build_common_discriminator_member(
Expand Down
34 changes: 16 additions & 18 deletions test/dds-types-test/appendableCdrAux.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,11 +1276,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const AppendableEmptyInheritanceStruct& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.var_str();

extern void serialize_key(
Cdr& scdr,
const AppendableEmptyStruct& data);
serialize_key(scdr, static_cast<const AppendableEmptyStruct&>(data));
}


Expand Down Expand Up @@ -1363,11 +1362,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const AppendableInheritanceStruct& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.var_str();

extern void serialize_key(
Cdr& scdr,
const AppendableShortStruct& data);
serialize_key(scdr, static_cast<const AppendableShortStruct&>(data));
}


Expand Down Expand Up @@ -1442,9 +1440,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const AppendableInheritanceEmptyStruct& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
extern void serialize_key(
Cdr& scdr,
const AppendableShortStruct& data);
serialize_key(scdr, static_cast<const AppendableShortStruct&>(data));
}


Expand Down Expand Up @@ -1527,11 +1526,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const AppendableExtensibilityInheritance& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.var_long();

extern void serialize_key(
Cdr& scdr,
const AppendableShortStruct& data);
serialize_key(scdr, static_cast<const AppendableShortStruct&>(data));
}


Expand Down
34 changes: 16 additions & 18 deletions test/dds-types-test/finalCdrAux.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,11 +1276,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const FinalEmptyInheritanceStruct& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.var_str();

extern void serialize_key(
Cdr& scdr,
const FinalEmptyStruct& data);
serialize_key(scdr, static_cast<const FinalEmptyStruct&>(data));
}


Expand Down Expand Up @@ -1363,11 +1362,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const FinalInheritanceStruct& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.var_str();

extern void serialize_key(
Cdr& scdr,
const FinalShortStruct& data);
serialize_key(scdr, static_cast<const FinalShortStruct&>(data));
}


Expand Down Expand Up @@ -1442,9 +1440,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const InheritanceEmptyStruct& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
extern void serialize_key(
Cdr& scdr,
const FinalShortStruct& data);
serialize_key(scdr, static_cast<const FinalShortStruct&>(data));
}


Expand Down Expand Up @@ -1527,11 +1526,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const FinalExtensibilityInheritance& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.var_long();

extern void serialize_key(
Cdr& scdr,
const FinalShortStruct& data);
serialize_key(scdr, static_cast<const FinalShortStruct&>(data));
}


Expand Down
58 changes: 24 additions & 34 deletions test/dds-types-test/inheritanceCdrAux.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const InnerStructureHelperChild& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.var_child_longlong();

scdr << data.var_child_ulonglong();

extern void serialize_key(
Cdr& scdr,
const InnerStructureHelper& data);
serialize_key(scdr, static_cast<const InnerStructureHelper&>(data));
}


Expand Down Expand Up @@ -250,13 +247,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const InnerStructureHelperChildChild& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.var_child_childlonglong2();

scdr << data.var_childchild_ulonglong2();

extern void serialize_key(
Cdr& scdr,
const InnerStructureHelperChild& data);
serialize_key(scdr, static_cast<const InnerStructureHelperChild&>(data));
}


Expand Down Expand Up @@ -339,9 +333,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const InnerStructureHelperEmptyChild& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
extern void serialize_key(
Cdr& scdr,
const InnerStructureHelper& data);
serialize_key(scdr, static_cast<const InnerStructureHelper&>(data));
}


Expand Down Expand Up @@ -432,11 +427,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const InnerStructureHelperEmptyChildChild& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.var_char();

extern void serialize_key(
Cdr& scdr,
const InnerStructureHelperEmptyChild& data);
serialize_key(scdr, static_cast<const InnerStructureHelperEmptyChild&>(data));
}


Expand Down Expand Up @@ -519,13 +513,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const InnerEmptyStructureHelperChild& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.var_child_longlong();

scdr << data.var_child_ulonglong();

extern void serialize_key(
Cdr& scdr,
const InnerEmptyStructureHelper& data);
serialize_key(scdr, static_cast<const InnerEmptyStructureHelper&>(data));
}


Expand Down Expand Up @@ -616,11 +607,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const StructAliasInheritanceStruct& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
scdr << data.new_member();

extern void serialize_key(
Cdr& scdr,
const inner_structure_helper_alias& data);
serialize_key(scdr, static_cast<const inner_structure_helper_alias&>(data));
}


Expand Down
21 changes: 12 additions & 9 deletions test/dds-types-test/keyCdrAux.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,9 +1344,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const KeyedEmptyInheritanceStruct& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
extern void serialize_key(
Cdr& scdr,
const KeyedEmptyStruct& data);
serialize_key(scdr, static_cast<const KeyedEmptyStruct&>(data));
}


Expand Down Expand Up @@ -1445,9 +1446,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const KeyedInheritanceStruct& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
extern void serialize_key(
Cdr& scdr,
const KeyedShortStruct& data);
serialize_key(scdr, static_cast<const KeyedShortStruct&>(data));
}


Expand Down Expand Up @@ -1530,9 +1532,10 @@ void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const InheritanceKeyedEmptyStruct& data)
{

static_cast<void>(scdr);
static_cast<void>(data);
extern void serialize_key(
Cdr& scdr,
const KeyedShortStruct& data);
serialize_key(scdr, static_cast<const KeyedShortStruct&>(data));
}


Expand Down
Loading

0 comments on commit 01d4f43

Please sign in to comment.