Skip to content

Commit

Permalink
Review - Refactor Tests
Browse files Browse the repository at this point in the history
Signed-off-by: tempate <danieldiaz@eprosima.com>
  • Loading branch information
Tempate committed Jul 5, 2024
1 parent aeb371b commit 722ac43
Show file tree
Hide file tree
Showing 184 changed files with 7,075 additions and 20,380 deletions.
86 changes: 25 additions & 61 deletions test/unittest/dds/xtypes/serializers/idl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,95 +13,59 @@
# limitations under the License.

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/alias_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/alias_struct.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/alias_struct/alias_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/alias_struct/alias_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/arrays_and_sequences.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/arrays_and_sequences.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/array_struct/array_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/array_struct/array_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/basic_array_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/basic_array_struct.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/bitmask_struct/bitmask_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/bitmask_struct/bitmask_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/basic_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/basic_struct.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/bitset_struct/bitset_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/bitset_struct/bitset_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/bitmask_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/bitmask_struct.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/enum_struct/enum_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/enum_struct/enum_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/bitset_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/bitset_struct.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/extensibility_struct/extensibility_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/extensibility_struct/extensibility_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/char_sequence.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/char_sequence.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/key_struct/key_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/key_struct/key_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/complex_nested_arrays.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/complex_nested_arrays.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/map_struct/map_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/map_struct/map_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/inheritance_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/inheritance_struct.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/sequence_struct/sequence_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/sequence_struct/sequence_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/enum_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/enum_struct.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/string_struct/string_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/string_struct/string_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/extensibility_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/extensibility_struct.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/struct_struct/struct_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/struct_struct/struct_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/float_bounded_sequence.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/float_bounded_sequence.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/hello_world.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/hello_world.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/key_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/key_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/map_bounded_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/map_bounded_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/map_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/map_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/multi_array_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/multi_array_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/nested_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/nested_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/numeric_array.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/numeric_array.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/string_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/string_struct.idl
COPYONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/types/idls/union_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/idls/union_struct.idl
${CMAKE_CURRENT_SOURCE_DIR}/types/union_struct/union_struct.idl
${CMAKE_CURRENT_BINARY_DIR}/types/union_struct/union_struct.idl
COPYONLY)

set(RESOURCEDYNTYPETOIDLTESTS_SOURCE
DynTypeIDLTests.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/xtypes/utils.cpp)

file(GLOB DATATYPE_SOURCES "types/gen/**/*.cxx")
file(GLOB DATATYPE_SOURCES "types/**/gen/*.cxx")

if(WIN32)
add_definitions(-D_WIN32_WINNT=0x0601)
Expand Down
4 changes: 2 additions & 2 deletions test/unittest/dds/xtypes/serializers/idl/DynTypeIDLTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ TEST_P(DynTypeIDLTests, to_idl)
test::register_type_object_representation(type);

// Read the IDL file as a string
const auto file_name = std::string("types/idls/") + type + ".idl";
const auto file_name = std::string("types/") + type + "/" + type + ".idl";

std::ifstream file(file_name);
ASSERT_TRUE(file.is_open());
Expand All @@ -103,7 +103,7 @@ TEST_P(DynTypeIDLTests, to_idl)

// Get Dynamic type
DynamicType::_ref_type dyn_type;
get_dynamic_type(type, dyn_type);
get_dynamic_type(snake_to_camel(type), dyn_type);

// Serialize DynamicType to IDL
std::stringstream idl_serialization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ typedef unsigned long MyLong;

typedef MyShort MyRecursiveShort;

struct alias_struct
struct AliasStruct
{
MyShort my_short;
MyLong my_long;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,33 @@ typedef uint32_t MyLong;
typedef MyShort MyRecursiveShort;

/*!
* @brief This class represents the structure alias_struct defined by the user in the IDL file.
* @brief This class represents the structure AliasStruct defined by the user in the IDL file.
* @ingroup alias_struct
*/
class alias_struct
class AliasStruct
{
public:

/*!
* @brief Default constructor.
*/
eProsima_user_DllExport alias_struct()
eProsima_user_DllExport AliasStruct()
{
}

/*!
* @brief Default destructor.
*/
eProsima_user_DllExport ~alias_struct()
eProsima_user_DllExport ~AliasStruct()
{
}

/*!
* @brief Copy constructor.
* @param x Reference to the object alias_struct that will be copied.
* @param x Reference to the object AliasStruct that will be copied.
*/
eProsima_user_DllExport alias_struct(
const alias_struct& x)
eProsima_user_DllExport AliasStruct(
const AliasStruct& x)
{
m_my_short = x.m_my_short;

Expand All @@ -94,10 +94,10 @@ class alias_struct

/*!
* @brief Move constructor.
* @param x Reference to the object alias_struct that will be copied.
* @param x Reference to the object AliasStruct that will be copied.
*/
eProsima_user_DllExport alias_struct(
alias_struct&& x) noexcept
eProsima_user_DllExport AliasStruct(
AliasStruct&& x) noexcept
{
m_my_short = x.m_my_short;
m_my_long = x.m_my_long;
Expand All @@ -106,10 +106,10 @@ class alias_struct

/*!
* @brief Copy assignment.
* @param x Reference to the object alias_struct that will be copied.
* @param x Reference to the object AliasStruct that will be copied.
*/
eProsima_user_DllExport alias_struct& operator =(
const alias_struct& x)
eProsima_user_DllExport AliasStruct& operator =(
const AliasStruct& x)
{

m_my_short = x.m_my_short;
Expand All @@ -123,10 +123,10 @@ class alias_struct

/*!
* @brief Move assignment.
* @param x Reference to the object alias_struct that will be copied.
* @param x Reference to the object AliasStruct that will be copied.
*/
eProsima_user_DllExport alias_struct& operator =(
alias_struct&& x) noexcept
eProsima_user_DllExport AliasStruct& operator =(
AliasStruct&& x) noexcept
{

m_my_short = x.m_my_short;
Expand All @@ -137,10 +137,10 @@ class alias_struct

/*!
* @brief Comparison operator.
* @param x alias_struct object to compare.
* @param x AliasStruct object to compare.
*/
eProsima_user_DllExport bool operator ==(
const alias_struct& x) const
const AliasStruct& x) const
{
return (m_my_short == x.m_my_short &&
m_my_long == x.m_my_long &&
Expand All @@ -149,10 +149,10 @@ class alias_struct

/*!
* @brief Comparison operator.
* @param x alias_struct object to compare.
* @param x AliasStruct object to compare.
*/
eProsima_user_DllExport bool operator !=(
const alias_struct& x) const
const AliasStruct& x) const
{
return !(*this == x);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#include "alias_struct.hpp"

constexpr uint32_t alias_struct_max_cdr_typesize {14UL};
constexpr uint32_t alias_struct_max_key_cdr_typesize {0UL};
constexpr uint32_t AliasStruct_max_cdr_typesize {14UL};
constexpr uint32_t AliasStruct_max_key_cdr_typesize {0UL};



Expand All @@ -39,7 +39,7 @@ class CdrSizeCalculator;

eProsima_user_DllExport void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const alias_struct& data);
const AliasStruct& data);


} // namespace fastcdr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace fastcdr {
template<>
eProsima_user_DllExport size_t calculate_serialized_size(
eprosima::fastcdr::CdrSizeCalculator& calculator,
const alias_struct& data,
const AliasStruct& data,
size_t& current_alignment)
{
static_cast<void>(data);
Expand Down Expand Up @@ -68,7 +68,7 @@ eProsima_user_DllExport size_t calculate_serialized_size(
template<>
eProsima_user_DllExport void serialize(
eprosima::fastcdr::Cdr& scdr,
const alias_struct& data)
const AliasStruct& data)
{
eprosima::fastcdr::Cdr::state current_state(scdr);
scdr.begin_serialize_type(current_state,
Expand All @@ -87,7 +87,7 @@ eProsima_user_DllExport void serialize(
template<>
eProsima_user_DllExport void deserialize(
eprosima::fastcdr::Cdr& cdr,
alias_struct& data)
AliasStruct& data)
{
cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ?
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
Expand Down Expand Up @@ -119,7 +119,7 @@ eProsima_user_DllExport void deserialize(

void serialize_key(
eprosima::fastcdr::Cdr& scdr,
const alias_struct& data)
const AliasStruct& data)
{
static_cast<void>(scdr);
static_cast<void>(data);
Expand Down
Loading

0 comments on commit 722ac43

Please sign in to comment.