Skip to content

Commit 0bc433c

Browse files
committed
Refs #20419: Fix TypeIdentifier comparation in TypeObject tests.
Signed-off-by: adriancampo <[email protected]>
1 parent bb5ad27 commit 0bc433c

File tree

1 file changed

+86
-6
lines changed

1 file changed

+86
-6
lines changed

src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectTestingTestSource.stg

+86-6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,86 @@ public:
5353

5454
};
5555

56+
bool compare_type_identifiers(
57+
const TypeIdentifier& a_identifier,
58+
const TypeIdentifier& another_identifier)
59+
{
60+
61+
if (a_identifier._d() != another_identifier._d())
62+
{
63+
return false;
64+
}
65+
66+
switch (a_identifier._d())
67+
{
68+
case TI_STRING8_SMALL:
69+
case TI_STRING16_SMALL:
70+
return (a_identifier.string_sdefn() == another_identifier.string_sdefn());
71+
break;
72+
73+
case TI_STRING8_LARGE:
74+
case TI_STRING16_LARGE:
75+
return (a_identifier.string_ldefn() == another_identifier.string_ldefn());
76+
break;
77+
78+
case TI_PLAIN_SEQUENCE_SMALL:
79+
return (a_identifier.seq_sdefn().header() == another_identifier.seq_sdefn().header() &&
80+
a_identifier.seq_sdefn().bound() == another_identifier.seq_sdefn().bound() &&
81+
*a_identifier.seq_sdefn().element_identifier() == *another_identifier.seq_sdefn().element_identifier());
82+
break;
83+
84+
case TI_PLAIN_SEQUENCE_LARGE:
85+
return (a_identifier.seq_ldefn().header() == another_identifier.seq_ldefn().header() &&
86+
a_identifier.seq_ldefn().bound() == another_identifier.seq_ldefn().bound() &&
87+
*a_identifier.seq_ldefn().element_identifier() == *another_identifier.seq_ldefn().element_identifier());
88+
89+
return (a_identifier.seq_ldefn() == another_identifier.seq_ldefn());
90+
break;
91+
92+
case TI_PLAIN_ARRAY_SMALL:
93+
return (a_identifier.array_sdefn().header() == another_identifier.array_sdefn().header() &&
94+
a_identifier.array_sdefn().array_bound_seq() == another_identifier.array_sdefn().array_bound_seq() &&
95+
*a_identifier.array_sdefn().element_identifier() == *another_identifier.array_sdefn().element_identifier());
96+
break;
97+
98+
case TI_PLAIN_ARRAY_LARGE:
99+
return (a_identifier.array_ldefn().header() == another_identifier.array_ldefn().header() &&
100+
a_identifier.array_ldefn().array_bound_seq() == another_identifier.array_ldefn().array_bound_seq() &&
101+
*a_identifier.array_ldefn().element_identifier() == *another_identifier.array_ldefn().element_identifier());
102+
break;
103+
104+
case TI_PLAIN_MAP_SMALL:
105+
return (a_identifier.map_sdefn().header() == another_identifier.map_sdefn().header() &&
106+
a_identifier.map_sdefn().bound() == another_identifier.map_sdefn().bound() &&
107+
*a_identifier.map_sdefn().element_identifier() == *another_identifier.map_sdefn().element_identifier() &&
108+
a_identifier.map_sdefn().key_flags() == another_identifier.map_sdefn().key_flags() &&
109+
*a_identifier.map_sdefn().key_identifier() == *another_identifier.map_sdefn().key_identifier());
110+
break;
111+
112+
case TI_PLAIN_MAP_LARGE:
113+
return (a_identifier.map_ldefn().header() == another_identifier.map_ldefn().header() &&
114+
a_identifier.map_ldefn().bound() == another_identifier.map_ldefn().bound() &&
115+
*a_identifier.map_ldefn().element_identifier() == *another_identifier.map_ldefn().element_identifier() &&
116+
a_identifier.map_ldefn().key_flags() == another_identifier.map_ldefn().key_flags() &&
117+
*a_identifier.map_ldefn().key_identifier() == *another_identifier.map_ldefn().key_identifier());
118+
break;
119+
120+
case TI_STRONGLY_CONNECTED_COMPONENT:
121+
return (a_identifier.sc_component_id() == another_identifier.sc_component_id());
122+
break;
123+
124+
case EK_COMPLETE:
125+
case EK_MINIMAL:
126+
return (a_identifier.equivalence_hash() == another_identifier.equivalence_hash());
127+
break;
128+
129+
default:
130+
return a_identifier.extended_defn() == another_identifier.extended_defn();
131+
132+
break;
133+
}
134+
}
135+
56136
$definitions;separator="\n"$
57137

58138
int main(
@@ -627,15 +707,15 @@ check_struct_member(member, parent) ::= <<
627707
$get_type_identifier(type=member.typecode, var="member_type_ids")$
628708
if (TK_NONE != member_type_ids.type_identifier2()._d())
629709
{
630-
EXPECT_TRUE(member_type_ids.type_identifier1() == type_objects.minimal_type_object.struct_type().member_seq()[pos].common().member_type_id() ||
631-
member_type_ids.type_identifier1() == type_objects.complete_type_object.struct_type().member_seq()[pos].common().member_type_id());
632-
EXPECT_TRUE(member_type_ids.type_identifier2() == type_objects.minimal_type_object.struct_type().member_seq()[pos].common().member_type_id() ||
633-
member_type_ids.type_identifier2() == type_objects.complete_type_object.struct_type().member_seq()[pos].common().member_type_id());
710+
EXPECT_TRUE(compare_type_identifiers(member_type_ids.type_identifier1(), type_objects.minimal_type_object.minimal().struct_type().member_seq()[pos].common().member_type_id()) ||
711+
compare_type_identifiers(member_type_ids.type_identifier1(), type_objects.complete_type_object.complete().struct_type().member_seq()[pos].common().member_type_id()));
712+
EXPECT_TRUE(compare_type_identifiers(member_type_ids.type_identifier2(), type_objects.minimal_type_object.minimal().struct_type().member_seq()[pos].common().member_type_id()) ||
713+
compare_type_identifiers(member_type_ids.type_identifier2(), type_objects.complete_type_object.complete().struct_type().member_seq()[pos].common().member_type_id()));
634714
}
635715
else
636716
{
637-
EXPECT_EQ(member_type_ids.type_identifier1(), type_objects.minimal_type_object.struct_type().member_seq()[pos].common().member_type_id());
638-
EXPECT_EQ(member_type_ids.type_identifier1(), type_objects.complete_type_object.struct_type().member_seq()[pos].common().member_type_id());
717+
EXPECT_TRUE(compare_type_identifiers(member_type_ids.type_identifier1(), type_objects.minimal_type_object.minimal().struct_type().member_seq()[pos].common().member_type_id()));
718+
EXPECT_TRUE(compare_type_identifiers(member_type_ids.type_identifier1(), type_objects.complete_type_object.complete().struct_type().member_seq()[pos].common().member_type_id()));
639719
}
640720
EXPECT_EQ("$member.name$", type_objects.complete_type_object.struct_type().member_seq()[pos].detail().name().to_string());
641721
EXPECT_EQ(member_name_hashed, type_objects.minimal_type_object.struct_type().member_seq()[pos].detail().name_hash());

0 commit comments

Comments
 (0)