mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-07-02 05:35:11 +00:00
Update sdv_packager (#6)
This commit is contained in:
41
tests/unit_tests/parameters/CMakeLists.txt
Normal file
41
tests/unit_tests/parameters/CMakeLists.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
#*******************************************************************************
|
||||
# Copyright (c) 2025-2026 Contributors to the Eclipse Foundation
|
||||
#
|
||||
# This program and the accompanying materials are made available under the
|
||||
# terms of the Apache License Version 2.0 which is available at
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Contributors:
|
||||
# Erik Verhoeven - initial API and implementation
|
||||
#*******************************************************************************
|
||||
|
||||
# Define project
|
||||
project(ParameterTests VERSION 1.0 LANGUAGES CXX)
|
||||
|
||||
# Define target
|
||||
add_executable(UnitTest_Parameters "param_access.cpp" "param_info.cpp" "main.cpp" "param_labels.cpp" "param_access_chain.cpp")
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_libraries(UnitTest_Parameters GTest::GTest)
|
||||
if (WIN32)
|
||||
target_link_libraries(UnitTest_Parameters Ws2_32 Winmm Rpcrt4.lib)
|
||||
else()
|
||||
target_link_libraries(UnitTest_Parameters ${CMAKE_DL_LIBS} rt)
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(UnitTest_Parameters GTest::GTest Rpcrt4.lib)
|
||||
endif()
|
||||
|
||||
# Add the test
|
||||
add_test(NAME UnitTest_Parameters COMMAND UnitTest_Parameters WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
# Execute the test
|
||||
add_custom_command(TARGET UnitTest_Parameters POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E env TEST_EXECUTION_MODE=CMake "$<TARGET_FILE:UnitTest_Parameters>" --gtest_output=xml:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/UnitTest_Parameters.xml
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# The unit-test project depends on a proper compilation of sdv idl files before
|
||||
add_dependencies(UnitTest_Parameters CompileCoreIDL)
|
||||
38
tests/unit_tests/parameters/main.cpp
Normal file
38
tests/unit_tests/parameters/main.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "../../../global/localmemmgr.h"
|
||||
#include "../../../global/process_watchdog.h"
|
||||
|
||||
#include <support/param_impl.h>
|
||||
|
||||
#if defined(_WIN32) && defined(_UNICODE)
|
||||
extern "C" int wmain(int argc, wchar_t* argv[])
|
||||
#else
|
||||
extern "C" int main(int argc, char* argv[])
|
||||
#endif
|
||||
{
|
||||
CProcessWatchdog watchdog;
|
||||
|
||||
// The memory manager registers itself into the system and needs to stay in scope.
|
||||
CLocalMemMgr memmgr;
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
auto iRet = RUN_ALL_TESTS();
|
||||
|
||||
// Clear the label map, deallocating the labels before the memory manager gets out of scope.
|
||||
sdv::internal::GetLabelMapHelper().Clear();
|
||||
|
||||
return iRet;
|
||||
}
|
||||
1702
tests/unit_tests/parameters/param_access.cpp
Normal file
1702
tests/unit_tests/parameters/param_access.cpp
Normal file
File diff suppressed because it is too large
Load Diff
854
tests/unit_tests/parameters/param_access_chain.cpp
Normal file
854
tests/unit_tests/parameters/param_access_chain.cpp
Normal file
@@ -0,0 +1,854 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "../../../global/localmemmgr.h"
|
||||
#include <support/param_impl.h>
|
||||
|
||||
class CSimpleParametersBase : public sdv::CSdvParamMap
|
||||
{
|
||||
public:
|
||||
BEGIN_SDV_PARAM_MAP()
|
||||
SDV_PARAM_ENTRY(m_i, "my_integer", 10, "int_unit", "My integer")
|
||||
SDV_PARAM_ENTRY(m_d, "my_double", 1234.5, "double_unit", "My double")
|
||||
END_SDV_PARAM_MAP()
|
||||
|
||||
private:
|
||||
int m_i;
|
||||
double m_d;
|
||||
};
|
||||
|
||||
class CSimpleParameters : public CSimpleParametersBase
|
||||
{
|
||||
public:
|
||||
CSimpleParameters()
|
||||
{
|
||||
InitParamMap();
|
||||
}
|
||||
|
||||
BEGIN_SDV_PARAM_MAP()
|
||||
SDV_PARAM_CHAIN_BASE(CSimpleParametersBase)
|
||||
SDV_PARAM_ENTRY(m_ss, "my_string", "string_value", "string_unit", "My string")
|
||||
END_SDV_PARAM_MAP()
|
||||
|
||||
private:
|
||||
std::string m_ss;
|
||||
};
|
||||
|
||||
TEST(ParameterTest, ChainBaseSimpleParamMapStaticInfo)
|
||||
{
|
||||
// Get parameter names
|
||||
auto vecParamMap = CSimpleParameters::GetParamMapInfoStatic();
|
||||
ASSERT_EQ(vecParamMap.size(), 3u);
|
||||
ASSERT_TRUE(vecParamMap[0]);
|
||||
ASSERT_TRUE(vecParamMap[1]);
|
||||
ASSERT_TRUE(vecParamMap[2]);
|
||||
|
||||
// Get parameter #0 global information
|
||||
auto ptrParamInfo = vecParamMap[0];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_integer");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "int_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My integer");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
ptrParamInfo = vecParamMap[1];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_double");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "double_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My double");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
ptrParamInfo = vecParamMap[2];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->String());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_string");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "string_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My string");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, ChainBaseSimpleParamMapObjectInfo)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParameters param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get parameter #0 information
|
||||
auto ptrParamInfo = param.FindParamObject(seqParams[0]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "int_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My integer");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
ptrParamInfo = param.FindParamObject(seqParams[1]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "double_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My double");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
ptrParamInfo = param.FindParamObject(seqParams[2]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->String());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "string_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My string");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, ChainBaseSimpleParamMapObjectInfoIndirect)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParameters param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get parameter #0 information
|
||||
sdv::CSdvParamInfo info(param.GetParamInfo(seqParams[0]));
|
||||
EXPECT_TRUE(info.Numeric());
|
||||
EXPECT_EQ(info.Unit(), "int_unit");
|
||||
EXPECT_EQ(info.Description(), "My integer");
|
||||
EXPECT_EQ(info.DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
info = param.GetParamInfo(seqParams[1]);
|
||||
EXPECT_TRUE(info.Numeric());
|
||||
EXPECT_EQ(info.Unit(), "double_unit");
|
||||
EXPECT_EQ(info.Description(), "My double");
|
||||
EXPECT_EQ(info.DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
info = param.GetParamInfo(seqParams[2]);
|
||||
EXPECT_TRUE(info.String());
|
||||
EXPECT_EQ(info.Unit(), "string_unit");
|
||||
EXPECT_EQ(info.Description(), "My string");
|
||||
EXPECT_EQ(info.DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, ChainBaseSimpleParamMapGetSet)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParameters param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get/set parameter #0 value
|
||||
auto anyVal = param.GetParam(seqParams[0]);
|
||||
EXPECT_EQ(anyVal, 10); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[0], 20));
|
||||
anyVal = param.GetParam(seqParams[0]);
|
||||
EXPECT_EQ(anyVal, 20); // New value
|
||||
|
||||
// Get/set parameter #1 value
|
||||
anyVal = param.GetParam(seqParams[1]);
|
||||
EXPECT_EQ(anyVal, 1234.5); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[1], 5432.1));
|
||||
anyVal = param.GetParam(seqParams[1]);
|
||||
EXPECT_EQ(anyVal, 5432.1); // New value
|
||||
|
||||
// Get/set parameter #2 value
|
||||
anyVal = param.GetParam(seqParams[2]);
|
||||
EXPECT_EQ(anyVal, "string_value"); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[2], "text_value"));
|
||||
anyVal = param.GetParam(seqParams[2]);
|
||||
EXPECT_EQ(anyVal, "text_value"); // New value
|
||||
}
|
||||
|
||||
class CSimpleParametersVirtualBase : virtual public sdv::CSdvParamMap
|
||||
{
|
||||
public:
|
||||
BEGIN_SDV_PARAM_MAP()
|
||||
SDV_PARAM_ENTRY(m_i, "my_integer", 10, "int_unit", "My integer")
|
||||
SDV_PARAM_ENTRY(m_d, "my_double", 1234.5, "double_unit", "My double")
|
||||
END_SDV_PARAM_MAP()
|
||||
|
||||
private:
|
||||
int m_i;
|
||||
double m_d;
|
||||
};
|
||||
|
||||
class CSimpleParametersVirtual : virtual public sdv::CSdvParamMap, public CSimpleParametersVirtualBase
|
||||
{
|
||||
public:
|
||||
CSimpleParametersVirtual()
|
||||
{
|
||||
InitParamMap();
|
||||
}
|
||||
|
||||
BEGIN_SDV_PARAM_MAP()
|
||||
SDV_PARAM_CHAIN_BASE(CSimpleParametersVirtualBase)
|
||||
SDV_PARAM_ENTRY(m_ss, "my_string", "string_value", "string_unit", "My string")
|
||||
END_SDV_PARAM_MAP()
|
||||
|
||||
private:
|
||||
std::string m_ss;
|
||||
};
|
||||
|
||||
TEST(ParameterTest, VirtualChainBaseSimpleParamMapStaticInfo)
|
||||
{
|
||||
// Get parameter names
|
||||
auto vecParamMap = CSimpleParametersVirtual::GetParamMapInfoStatic();
|
||||
ASSERT_EQ(vecParamMap.size(), 3u);
|
||||
ASSERT_TRUE(vecParamMap[0]);
|
||||
ASSERT_TRUE(vecParamMap[1]);
|
||||
ASSERT_TRUE(vecParamMap[2]);
|
||||
|
||||
// Get parameter #0 global information
|
||||
auto ptrParamInfo = vecParamMap[0];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_integer");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "int_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My integer");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
ptrParamInfo = vecParamMap[1];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_double");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "double_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My double");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
ptrParamInfo = vecParamMap[2];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->String());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_string");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "string_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My string");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, VirtualChainBaseSimpleParamMapObjectInfo)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersVirtual param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get parameter #0 information
|
||||
auto ptrParamInfo = param.FindParamObject(seqParams[0]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "int_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My integer");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
ptrParamInfo = param.FindParamObject(seqParams[1]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "double_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My double");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
ptrParamInfo = param.FindParamObject(seqParams[2]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->String());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "string_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My string");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, VirtualChainBaseSimpleParamMapObjectInfoIndirect)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersVirtual param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get parameter #0 information
|
||||
sdv::CSdvParamInfo info(param.GetParamInfo(seqParams[0]));
|
||||
EXPECT_TRUE(info.Numeric());
|
||||
EXPECT_EQ(info.Unit(), "int_unit");
|
||||
EXPECT_EQ(info.Description(), "My integer");
|
||||
EXPECT_EQ(info.DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
info = param.GetParamInfo(seqParams[1]);
|
||||
EXPECT_TRUE(info.Numeric());
|
||||
EXPECT_EQ(info.Unit(), "double_unit");
|
||||
EXPECT_EQ(info.Description(), "My double");
|
||||
EXPECT_EQ(info.DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
info = param.GetParamInfo(seqParams[2]);
|
||||
EXPECT_TRUE(info.String());
|
||||
EXPECT_EQ(info.Unit(), "string_unit");
|
||||
EXPECT_EQ(info.Description(), "My string");
|
||||
EXPECT_EQ(info.DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, VirtualChainBaseSimpleParamMapGetSet)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersVirtual param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get/set parameter #0 value
|
||||
auto anyVal = param.GetParam(seqParams[0]);
|
||||
EXPECT_EQ(anyVal, 10); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[0], 20));
|
||||
anyVal = param.GetParam(seqParams[0]);
|
||||
EXPECT_EQ(anyVal, 20); // New value
|
||||
|
||||
// Get/set parameter #1 value
|
||||
anyVal = param.GetParam(seqParams[1]);
|
||||
EXPECT_EQ(anyVal, 1234.5); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[1], 5432.1));
|
||||
anyVal = param.GetParam(seqParams[1]);
|
||||
EXPECT_EQ(anyVal, 5432.1); // New value
|
||||
|
||||
// Get/set parameter #2 value
|
||||
anyVal = param.GetParam(seqParams[2]);
|
||||
EXPECT_EQ(anyVal, "string_value"); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[2], "text_value"));
|
||||
anyVal = param.GetParam(seqParams[2]);
|
||||
EXPECT_EQ(anyVal, "text_value"); // New value
|
||||
}
|
||||
|
||||
class CSimpleParametersMember : public sdv::CSdvParamMap
|
||||
{
|
||||
public:
|
||||
BEGIN_SDV_PARAM_MAP()
|
||||
SDV_PARAM_ENTRY(m_i, "my_integer", 10, "int_unit", "My integer")
|
||||
SDV_PARAM_ENTRY(m_d, "my_double", 1234.5, "double_unit", "My double")
|
||||
END_SDV_PARAM_MAP()
|
||||
|
||||
private:
|
||||
int m_i;
|
||||
double m_d;
|
||||
};
|
||||
|
||||
class CSimpleParametersWithMember : public sdv::CSdvParamMap
|
||||
{
|
||||
public:
|
||||
CSimpleParametersWithMember()
|
||||
{
|
||||
InitParamMap();
|
||||
}
|
||||
|
||||
BEGIN_SDV_PARAM_MAP()
|
||||
SDV_PARAM_CHAIN_MEMBER(m_member)
|
||||
SDV_PARAM_ENTRY(m_ss, "my_string", "string_value", "string_unit", "My string")
|
||||
END_SDV_PARAM_MAP()
|
||||
|
||||
private:
|
||||
std::string m_ss;
|
||||
CSimpleParametersMember m_member;
|
||||
};
|
||||
|
||||
TEST(ParameterTest, MemberChainBaseSimpleParamMapStaticInfo)
|
||||
{
|
||||
// Get parameter names
|
||||
auto vecParamMap = CSimpleParametersWithMember::GetParamMapInfoStatic();
|
||||
ASSERT_EQ(vecParamMap.size(), 3u);
|
||||
ASSERT_TRUE(vecParamMap[0]);
|
||||
ASSERT_TRUE(vecParamMap[1]);
|
||||
ASSERT_TRUE(vecParamMap[2]);
|
||||
|
||||
// Get parameter #0 global information
|
||||
auto ptrParamInfo = vecParamMap[0];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_integer");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "int_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My integer");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
ptrParamInfo = vecParamMap[1];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_double");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "double_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My double");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
ptrParamInfo = vecParamMap[2];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->String());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_string");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "string_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My string");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, MemberChainBaseSimpleParamMapObjectInfo)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersWithMember param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get parameter #0 information
|
||||
auto ptrParamInfo = param.FindParamObject(seqParams[0]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "int_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My integer");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
ptrParamInfo = param.FindParamObject(seqParams[1]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "double_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My double");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
ptrParamInfo = param.FindParamObject(seqParams[2]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->String());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "string_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My string");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, MemberChainBaseSimpleParamMapObjectInfoIndirect)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersWithMember param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get parameter #0 information
|
||||
sdv::CSdvParamInfo info(param.GetParamInfo(seqParams[0]));
|
||||
EXPECT_TRUE(info.Numeric());
|
||||
EXPECT_EQ(info.Unit(), "int_unit");
|
||||
EXPECT_EQ(info.Description(), "My integer");
|
||||
EXPECT_EQ(info.DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
info = param.GetParamInfo(seqParams[1]);
|
||||
EXPECT_TRUE(info.Numeric());
|
||||
EXPECT_EQ(info.Unit(), "double_unit");
|
||||
EXPECT_EQ(info.Description(), "My double");
|
||||
EXPECT_EQ(info.DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
info = param.GetParamInfo(seqParams[2]);
|
||||
EXPECT_TRUE(info.String());
|
||||
EXPECT_EQ(info.Unit(), "string_unit");
|
||||
EXPECT_EQ(info.Description(), "My string");
|
||||
EXPECT_EQ(info.DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, MemberChainBaseSimpleParamMapGetSet)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersWithMember param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get/set parameter #0 value
|
||||
auto anyVal = param.GetParam(seqParams[0]);
|
||||
EXPECT_EQ(anyVal, 10); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[0], 20));
|
||||
anyVal = param.GetParam(seqParams[0]);
|
||||
EXPECT_EQ(anyVal, 20); // New value
|
||||
|
||||
// Get/set parameter #1 value
|
||||
anyVal = param.GetParam(seqParams[1]);
|
||||
EXPECT_EQ(anyVal, 1234.5); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[1], 5432.1));
|
||||
anyVal = param.GetParam(seqParams[1]);
|
||||
EXPECT_EQ(anyVal, 5432.1); // New value
|
||||
|
||||
// Get/set parameter #2 value
|
||||
anyVal = param.GetParam(seqParams[2]);
|
||||
EXPECT_EQ(anyVal, "string_value"); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[2], "text_value"));
|
||||
anyVal = param.GetParam(seqParams[2]);
|
||||
EXPECT_EQ(anyVal, "text_value"); // New value
|
||||
}
|
||||
|
||||
class CSimpleParametersWithMemberPointer : public sdv::CSdvParamMap
|
||||
{
|
||||
public:
|
||||
CSimpleParametersWithMemberPointer()
|
||||
{
|
||||
InitParamMap();
|
||||
}
|
||||
|
||||
BEGIN_SDV_PARAM_MAP()
|
||||
SDV_PARAM_CHAIN_MEMBER(m_pMember)
|
||||
SDV_PARAM_ENTRY(m_ss, "my_string", "string_value", "string_unit", "My string")
|
||||
END_SDV_PARAM_MAP()
|
||||
|
||||
private:
|
||||
std::string m_ss;
|
||||
CSimpleParametersMember m_member;
|
||||
CSimpleParametersMember* m_pMember = &m_member;
|
||||
};
|
||||
|
||||
TEST(ParameterTest, MemberPointerChainBaseSimpleParamMapStaticInfo)
|
||||
{
|
||||
// Get parameter names
|
||||
auto vecParamMap = CSimpleParametersWithMemberPointer::GetParamMapInfoStatic();
|
||||
ASSERT_EQ(vecParamMap.size(), 3u);
|
||||
ASSERT_TRUE(vecParamMap[0]);
|
||||
ASSERT_TRUE(vecParamMap[1]);
|
||||
ASSERT_TRUE(vecParamMap[2]);
|
||||
|
||||
// Get parameter #0 global information
|
||||
auto ptrParamInfo = vecParamMap[0];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_integer");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "int_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My integer");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
ptrParamInfo = vecParamMap[1];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_double");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "double_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My double");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
ptrParamInfo = vecParamMap[2];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->String());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_string");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "string_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My string");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, MemberPointerChainBaseSimpleParamMapObjectInfo)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersWithMemberPointer param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get parameter #0 information
|
||||
auto ptrParamInfo = param.FindParamObject(seqParams[0]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "int_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My integer");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
ptrParamInfo = param.FindParamObject(seqParams[1]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "double_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My double");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
ptrParamInfo = param.FindParamObject(seqParams[2]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->String());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "string_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My string");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, MemberPointerChainBaseSimpleParamMapObjectInfoIndirect)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersWithMemberPointer param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get parameter #0 information
|
||||
sdv::CSdvParamInfo info(param.GetParamInfo(seqParams[0]));
|
||||
EXPECT_TRUE(info.Numeric());
|
||||
EXPECT_EQ(info.Unit(), "int_unit");
|
||||
EXPECT_EQ(info.Description(), "My integer");
|
||||
EXPECT_EQ(info.DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
info = param.GetParamInfo(seqParams[1]);
|
||||
EXPECT_TRUE(info.Numeric());
|
||||
EXPECT_EQ(info.Unit(), "double_unit");
|
||||
EXPECT_EQ(info.Description(), "My double");
|
||||
EXPECT_EQ(info.DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
info = param.GetParamInfo(seqParams[2]);
|
||||
EXPECT_TRUE(info.String());
|
||||
EXPECT_EQ(info.Unit(), "string_unit");
|
||||
EXPECT_EQ(info.Description(), "My string");
|
||||
EXPECT_EQ(info.DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, MemberPointerChainBaseSimpleParamMapGetSet)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersWithMemberPointer param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get/set parameter #0 value
|
||||
auto anyVal = param.GetParam(seqParams[0]);
|
||||
EXPECT_EQ(anyVal, 10); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[0], 20));
|
||||
anyVal = param.GetParam(seqParams[0]);
|
||||
EXPECT_EQ(anyVal, 20); // New value
|
||||
|
||||
// Get/set parameter #1 value
|
||||
anyVal = param.GetParam(seqParams[1]);
|
||||
EXPECT_EQ(anyVal, 1234.5); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[1], 5432.1));
|
||||
anyVal = param.GetParam(seqParams[1]);
|
||||
EXPECT_EQ(anyVal, 5432.1); // New value
|
||||
|
||||
// Get/set parameter #2 value
|
||||
anyVal = param.GetParam(seqParams[2]);
|
||||
EXPECT_EQ(anyVal, "string_value"); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[2], "text_value"));
|
||||
anyVal = param.GetParam(seqParams[2]);
|
||||
EXPECT_EQ(anyVal, "text_value"); // New value
|
||||
}
|
||||
|
||||
class CSimpleParametersWithMemberSmartPointer : public sdv::CSdvParamMap
|
||||
{
|
||||
public:
|
||||
CSimpleParametersWithMemberSmartPointer()
|
||||
{
|
||||
InitParamMap();
|
||||
}
|
||||
|
||||
BEGIN_SDV_PARAM_MAP()
|
||||
SDV_PARAM_CHAIN_MEMBER(m_ptrMember)
|
||||
SDV_PARAM_ENTRY(m_ss, "my_string", "string_value", "string_unit", "My string")
|
||||
END_SDV_PARAM_MAP()
|
||||
|
||||
private:
|
||||
std::string m_ss;
|
||||
std::shared_ptr<CSimpleParametersMember> m_ptrMember = std::make_shared<CSimpleParametersMember>();
|
||||
};
|
||||
|
||||
TEST(ParameterTest, MemberSmartPointerChainBaseSimpleParamMapStaticInfo)
|
||||
{
|
||||
// Get parameter names
|
||||
auto vecParamMap = CSimpleParametersWithMemberSmartPointer::GetParamMapInfoStatic();
|
||||
ASSERT_EQ(vecParamMap.size(), 3u);
|
||||
ASSERT_TRUE(vecParamMap[0]);
|
||||
ASSERT_TRUE(vecParamMap[1]);
|
||||
ASSERT_TRUE(vecParamMap[2]);
|
||||
|
||||
// Get parameter #0 global information
|
||||
auto ptrParamInfo = vecParamMap[0];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_integer");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "int_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My integer");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
ptrParamInfo = vecParamMap[1];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_double");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "double_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My double");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
ptrParamInfo = vecParamMap[2];
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->String());
|
||||
EXPECT_EQ(ptrParamInfo->Name(), "my_string");
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "string_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My string");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, MemberSmartPointerChainBaseSimpleParamMapObjectInfo)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersWithMemberSmartPointer param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get parameter #0 information
|
||||
auto ptrParamInfo = param.FindParamObject(seqParams[0]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "int_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My integer");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
ptrParamInfo = param.FindParamObject(seqParams[1]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->Numeric());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "double_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My double");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
ptrParamInfo = param.FindParamObject(seqParams[2]);
|
||||
ASSERT_TRUE(ptrParamInfo);
|
||||
EXPECT_TRUE(ptrParamInfo->String());
|
||||
EXPECT_EQ(ptrParamInfo->Unit(), "string_unit");
|
||||
EXPECT_EQ(ptrParamInfo->Description(), "My string");
|
||||
EXPECT_EQ(ptrParamInfo->DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, MemberSmartPointerChainBaseSimpleParamMapObjectInfoIndirect)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersWithMemberSmartPointer param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get parameter #0 information
|
||||
sdv::CSdvParamInfo info(param.GetParamInfo(seqParams[0]));
|
||||
EXPECT_TRUE(info.Numeric());
|
||||
EXPECT_EQ(info.Unit(), "int_unit");
|
||||
EXPECT_EQ(info.Description(), "My integer");
|
||||
EXPECT_EQ(info.DefaultVal(), 10);
|
||||
|
||||
// Get parameter #1 global information
|
||||
info = param.GetParamInfo(seqParams[1]);
|
||||
EXPECT_TRUE(info.Numeric());
|
||||
EXPECT_EQ(info.Unit(), "double_unit");
|
||||
EXPECT_EQ(info.Description(), "My double");
|
||||
EXPECT_EQ(info.DefaultVal(), 1234.5);
|
||||
|
||||
// Get parameter #2 global information
|
||||
info = param.GetParamInfo(seqParams[2]);
|
||||
EXPECT_TRUE(info.String());
|
||||
EXPECT_EQ(info.Unit(), "string_unit");
|
||||
EXPECT_EQ(info.Description(), "My string");
|
||||
EXPECT_EQ(info.DefaultVal(), "string_value");
|
||||
}
|
||||
|
||||
TEST(ParameterTest, MemberSmartPointerChainBaseSimpleParamMapGetSet)
|
||||
{
|
||||
// Instantiation
|
||||
CSimpleParametersWithMemberSmartPointer param;
|
||||
|
||||
// Get parameter names
|
||||
auto seqParams = param.GetParamPaths();
|
||||
ASSERT_EQ(seqParams.size(), 3u);
|
||||
EXPECT_EQ(seqParams[0], "my_integer");
|
||||
EXPECT_EQ(seqParams[1], "my_double");
|
||||
EXPECT_EQ(seqParams[2], "my_string");
|
||||
|
||||
// Get/set parameter #0 value
|
||||
auto anyVal = param.GetParam(seqParams[0]);
|
||||
EXPECT_EQ(anyVal, 10); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[0], 20));
|
||||
anyVal = param.GetParam(seqParams[0]);
|
||||
EXPECT_EQ(anyVal, 20); // New value
|
||||
|
||||
// Get/set parameter #1 value
|
||||
anyVal = param.GetParam(seqParams[1]);
|
||||
EXPECT_EQ(anyVal, 1234.5); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[1], 5432.1));
|
||||
anyVal = param.GetParam(seqParams[1]);
|
||||
EXPECT_EQ(anyVal, 5432.1); // New value
|
||||
|
||||
// Get/set parameter #2 value
|
||||
anyVal = param.GetParam(seqParams[2]);
|
||||
EXPECT_EQ(anyVal, "string_value"); // Default value
|
||||
EXPECT_TRUE(param.SetParam(seqParams[2], "text_value"));
|
||||
anyVal = param.GetParam(seqParams[2]);
|
||||
EXPECT_EQ(anyVal, "text_value"); // New value
|
||||
}
|
||||
189
tests/unit_tests/parameters/param_info.cpp
Normal file
189
tests/unit_tests/parameters/param_info.cpp
Normal file
@@ -0,0 +1,189 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "../../../global/localmemmgr.h"
|
||||
#include <support/param_impl.h>
|
||||
|
||||
TEST(ParameterTest, AutoTypeInitializeBoolean)
|
||||
{
|
||||
bool b;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(b, "b", true, "", "", "", 0)->Boolean());
|
||||
}
|
||||
|
||||
TEST(ParameterTest, AutoTypeInitializeNumeric)
|
||||
{
|
||||
// Signed integer
|
||||
int8_t i8;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(i8, "i8", 1, "", "", "", 0)->Numeric());
|
||||
int16_t i16;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(i16, "i16", 2, "", "", "", 0)->Numeric());
|
||||
int32_t i32;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(i32, "i32", 3, "", "", "", 0)->Numeric());
|
||||
int64_t i64;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(i64, "i64", 4, "", "", "", 0)->Numeric());
|
||||
int i;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(i, "i", 5, "", "", "", 0)->Numeric());
|
||||
long l;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(l, "l", 6, "", "", "", 0)->Numeric());
|
||||
long long ll;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ll, "ll", 7, "", "", "", 0)->Numeric());
|
||||
|
||||
// Unsigned integer
|
||||
uint8_t ui8;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ui8, "ui8", 8, "", "", "", 0)->Numeric());
|
||||
uint16_t ui16;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ui16, "ui16", 9, "", "", "", 0)->Numeric());
|
||||
uint32_t ui32;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ui32, "ui32", 10, "", "", "", 0)->Numeric());
|
||||
uint32_t ui64;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ui64, "ui64", 11, "", "", "", 0)->Numeric());
|
||||
unsigned int ui;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ui, "ui", 12, "", "", "", 0)->Numeric());
|
||||
unsigned long ul;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ul, "ul", 13, "", "", "", 0)->Numeric());
|
||||
unsigned long long ull;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ull, "ull", 14, "", "", "", 0)->Numeric());
|
||||
|
||||
// Floating point
|
||||
float f;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(f, "f", 15.0, "", "", "", 0)->Numeric());
|
||||
double d;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(d, "d", 16.0, "", "", "", 0)->Numeric());
|
||||
long double ld;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ld, "ld", 17.0, "", "", "", 0)->Numeric());
|
||||
}
|
||||
|
||||
TEST(ParameterTest, AutoTypeInitializeString)
|
||||
{
|
||||
// STD string object
|
||||
std::string ss;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ss, "ss", "18", "", "", "", 0)->String());
|
||||
std::wstring ssw;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ssw, "ssw", L"19", "", "", "", 0)->String());
|
||||
std::u16string ss16;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ss16, "ss16", u"20", "", "", "", 0)->String());
|
||||
std::u32string ss32;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ss32, "ss32", U"21", "", "", "", 0)->String());
|
||||
|
||||
// SDV string object
|
||||
sdv::string ss_sdv;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ss_sdv, "ss_sdv", "22", "", "", "", 0)->String());
|
||||
sdv::u8string ss8_sdv;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ss8_sdv, "ss8_sdv", u8"23", "", "", "", 0)->String());
|
||||
sdv::wstring ssw_sdv;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ssw_sdv, "ssw_sdv", L"24", "", "", "", 0)->String());
|
||||
sdv::u16string ss16_sdv;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ss16_sdv, "ss16_sdv", u"25", "", "", "", 0)->String());
|
||||
sdv::u32string ss32_sdv;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ss32_sdv, "ss32_sdv", U"26", "", "", "", 0)->String());
|
||||
|
||||
// C character array
|
||||
char sz[] = "";
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(sz, "sz", "27", "", "", "", 0)->String());
|
||||
char16_t sz16[] = u"";
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(sz16, "sz16", u"28", "", "", "", 0)->String());
|
||||
char32_t sz32[] = U"";
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(sz32, "sz32", U"29", "", "", "", 0)->String());
|
||||
wchar_t wsz[] = L"";
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(wsz, "wsz", L"30", "", "", "", 0)->String());
|
||||
|
||||
// Pointer to a string
|
||||
char* psz = new char[2];
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(psz, "psz", "31", "", "", "", 0)->String());
|
||||
delete[] psz;
|
||||
char16_t* psz16 = new char16_t[2];
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(psz16, "psz16", u"32", "", "", "", 0)->String());
|
||||
delete[] psz16;
|
||||
char32_t* psz32 = new char32_t[2];
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(psz32, "psz32", U"33", "", "", "", 0)->String());
|
||||
delete[] psz32;
|
||||
wchar_t* pwsz = new wchar_t[2];
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(pwsz, "pwsz", L"34", "", "", "", 0)->String());
|
||||
delete[] pwsz;
|
||||
|
||||
// Pointer to a const string
|
||||
const char* pcsz = "";
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(pcsz, "pcsz", "35", "", "", "", 0)->String());
|
||||
const char16_t* pcsz16 = u"";
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(pcsz16, "pcsz16", u"36", "", "", "", 0)->String());
|
||||
const char32_t* pcsz32 = U"";
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(pcsz32, "pcsz32", U"37", "", "", "", 0)->String());
|
||||
const wchar_t* pcwsz = L"";
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(pcwsz, "pcwsz", L"38", "", "", "", 0)->String());
|
||||
}
|
||||
|
||||
TEST(ParameterTest, AutoTypeInitializeEnum)
|
||||
{
|
||||
// C-style enum
|
||||
enum ECStyle {one, two, three} eC;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(eC, "ECStyle", ECStyle::one, "", "", "", 0)->Enum());
|
||||
|
||||
// C++-style enum
|
||||
enum class ECppStyle : uint8_t {one, two, three} eCpp;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(eCpp, "ECppStyle", ECppStyle::two, "", "", "", 0)->Enum());
|
||||
}
|
||||
|
||||
TEST(ParameterTest, AutoTypeReadonly)
|
||||
{
|
||||
// Numeric read/write
|
||||
int32_t i32RW;
|
||||
EXPECT_FALSE(std::make_shared<sdv::CSdvParamInfo>(i32RW, "i32RW", 10, "", "", "", 0)->ReadOnly());
|
||||
uint32_t ui32RW;
|
||||
EXPECT_FALSE(std::make_shared<sdv::CSdvParamInfo>(ui32RW, "ui32RW", 20, "", "", "", 0)->ReadOnly());
|
||||
double dRW;
|
||||
EXPECT_FALSE(std::make_shared<sdv::CSdvParamInfo>(dRW, "dRW", 30, "", "", "", 0)->ReadOnly());
|
||||
|
||||
// Strings read/write
|
||||
// Remarks: the C-style string and the character pointer are both marked as read-only.
|
||||
std::string ssRW;
|
||||
EXPECT_FALSE(std::make_shared<sdv::CSdvParamInfo>(ssRW, "ssRW", "40", "", "", "", 0)->ReadOnly());
|
||||
sdv::string ss_sdvRW;
|
||||
EXPECT_FALSE(std::make_shared<sdv::CSdvParamInfo>(ss_sdvRW, "ss_sdvRW", "50", "", "", "", 0)->ReadOnly());
|
||||
|
||||
// Enums read/write
|
||||
enum ECStyle {one, two, three};
|
||||
enum class ECppStyle : uint8_t {one, two, three};
|
||||
ECStyle eCStyleRW;
|
||||
EXPECT_FALSE(std::make_shared<sdv::CSdvParamInfo>(eCStyleRW , "eCStyleRW", ECStyle ::one, "", "", "", 0)->ReadOnly());
|
||||
ECppStyle eCppStyleRW;
|
||||
EXPECT_FALSE(std::make_shared<sdv::CSdvParamInfo>(eCppStyleRW, "eCppStyleRW", ECppStyle::two, "", "", "", 0)->ReadOnly());
|
||||
|
||||
// Numeric read-only
|
||||
const int32_t i32R = 0;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(i32R, "i32R", 60, "", "", "", 0)->ReadOnly());
|
||||
const uint32_t ui32R = 0;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ui32R, "ui32R", 70, "", "", "", 0)->ReadOnly());
|
||||
const double dR = 0.0;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(dR, "dR", 80, "", "", "", 0)->ReadOnly());
|
||||
|
||||
// Strings read/write
|
||||
const std::string ssR;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ssR, "ssR", "90", "", "", "", 0)->ReadOnly());
|
||||
const sdv::string ss_sdvR;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(ss_sdvR, "ss_sdvR", "100", "", "", "", 0)->ReadOnly());
|
||||
char szR[] = "";
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(szR, "szR", "101", "", "", "", 0)->ReadOnly());
|
||||
char* pszR = new char[2];
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(pszR, "pszR", "102", "", "", "", 0)->ReadOnly());
|
||||
delete[] pszR;
|
||||
const char* pcszR = "";
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(pcszR, "pcszR", "103", "", "", "", 0)->ReadOnly());
|
||||
|
||||
// Enums read/write
|
||||
const ECStyle eCStyleR = ECStyle::one;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(eCStyleR, "eCStyleR", ECStyle::one, "", "", "", 0)->ReadOnly());
|
||||
const ECppStyle eCppStyleR = ECppStyle::one;
|
||||
EXPECT_TRUE(std::make_shared<sdv::CSdvParamInfo>(eCppStyleR, "eCppStyleR", ECppStyle::one, "", "", "", 0)->ReadOnly());
|
||||
}
|
||||
|
||||
233
tests/unit_tests/parameters/param_labels.cpp
Normal file
233
tests/unit_tests/parameters/param_labels.cpp
Normal file
@@ -0,0 +1,233 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "../../../global/localmemmgr.h"
|
||||
#include <support/param_impl.h>
|
||||
|
||||
enum class EEnumWithoutLabelMap
|
||||
{
|
||||
one,
|
||||
two,
|
||||
three
|
||||
};
|
||||
|
||||
enum class EEnumWithEmptyLabelMap
|
||||
{
|
||||
four,
|
||||
five,
|
||||
six
|
||||
};
|
||||
|
||||
BEGIN_SDV_LABEL_MAP(EEnumWithEmptyLabelMap)
|
||||
END_SDV_LABEL_MAP()
|
||||
|
||||
enum class EEnumWithLabelMap
|
||||
{
|
||||
seven,
|
||||
eight,
|
||||
nine
|
||||
};
|
||||
|
||||
BEGIN_SDV_LABEL_MAP(EEnumWithLabelMap)
|
||||
SDV_LABEL_ENTRY(EEnumWithLabelMap::seven, "seven")
|
||||
SDV_LABEL_ENTRY(EEnumWithLabelMap::eight, "eight")
|
||||
SDV_LABEL_ENTRY(EEnumWithLabelMap::nine, "nine")
|
||||
END_SDV_LABEL_MAP()
|
||||
|
||||
enum class EEnumWithLabelMapBehindFunction
|
||||
{
|
||||
ten,
|
||||
eleven,
|
||||
twelve
|
||||
};
|
||||
|
||||
sdv::sequence<sdv::SLabelInfo::SLabel> GetLabelMapForEnumBeforMapDefinition()
|
||||
{
|
||||
return sdv::internal::GetLabelMapHelper().GetLabelMap<EEnumWithLabelMapBehindFunction>();
|
||||
}
|
||||
|
||||
BEGIN_SDV_LABEL_MAP(EEnumWithLabelMapBehindFunction)
|
||||
SDV_LABEL_ENTRY(EEnumWithLabelMapBehindFunction::ten, "ten")
|
||||
SDV_LABEL_ENTRY(EEnumWithLabelMapBehindFunction::eleven, "eleven")
|
||||
SDV_LABEL_ENTRY(EEnumWithLabelMapBehindFunction::twelve, "twelve")
|
||||
END_SDV_LABEL_MAP()
|
||||
|
||||
namespace LabelMapTest
|
||||
{
|
||||
enum class EEnumInNamespaceWithLabelMap
|
||||
{
|
||||
thirteen,
|
||||
fourteen,
|
||||
fifteen
|
||||
};
|
||||
|
||||
BEGIN_SDV_LABEL_MAP(EEnumInNamespaceWithLabelMap)
|
||||
SDV_LABEL_ENTRY(EEnumInNamespaceWithLabelMap::thirteen, "thirteen")
|
||||
SDV_LABEL_ENTRY(EEnumInNamespaceWithLabelMap::fourteen, "fourteen")
|
||||
SDV_LABEL_ENTRY(EEnumInNamespaceWithLabelMap::fifteen, "fifteen")
|
||||
END_SDV_LABEL_MAP()
|
||||
|
||||
enum class EEnumInNamespaceWithLabelMapBehindFunction
|
||||
{
|
||||
sixteen,
|
||||
seventeen,
|
||||
eighteen
|
||||
};
|
||||
|
||||
sdv::sequence<sdv::SLabelInfo::SLabel> GetLabelMapForEnumBeforMapDefinition()
|
||||
{
|
||||
return sdv::internal::GetLabelMapHelper().GetLabelMap<EEnumInNamespaceWithLabelMapBehindFunction>();
|
||||
}
|
||||
|
||||
BEGIN_SDV_LABEL_MAP(EEnumInNamespaceWithLabelMapBehindFunction)
|
||||
SDV_LABEL_ENTRY(EEnumInNamespaceWithLabelMapBehindFunction::sixteen, "sixteen")
|
||||
SDV_LABEL_ENTRY(EEnumInNamespaceWithLabelMapBehindFunction::seventeen, "seventeen")
|
||||
SDV_LABEL_ENTRY(EEnumInNamespaceWithLabelMapBehindFunction::eighteen, "eighteen")
|
||||
END_SDV_LABEL_MAP()
|
||||
} // namespace LabelMapTest
|
||||
|
||||
class CLabelMapTest
|
||||
{
|
||||
public:
|
||||
enum class EEnumInClassWithLabelMap
|
||||
{
|
||||
nineteen,
|
||||
twenty,
|
||||
twenty_one
|
||||
};
|
||||
|
||||
BEGIN_SDV_LABEL_MAP(EEnumInClassWithLabelMap)
|
||||
SDV_LABEL_ENTRY(EEnumInClassWithLabelMap::nineteen, "nineteen")
|
||||
SDV_LABEL_ENTRY(EEnumInClassWithLabelMap::twenty, "twenty")
|
||||
SDV_LABEL_ENTRY(EEnumInClassWithLabelMap::twenty_one, "twenty_one")
|
||||
END_SDV_LABEL_MAP()
|
||||
|
||||
enum class EEnumInClassWithLabelMapBehindFunction
|
||||
{
|
||||
twenty_two,
|
||||
twenty_three,
|
||||
twenty_four
|
||||
};
|
||||
|
||||
static sdv::sequence<sdv::SLabelInfo::SLabel> GetLabelMapForEnumBeforMapDefinition()
|
||||
{
|
||||
return sdv::internal::GetLabelMapHelper().GetLabelMap<EEnumInClassWithLabelMapBehindFunction>();
|
||||
}
|
||||
|
||||
BEGIN_SDV_LABEL_MAP(EEnumInClassWithLabelMapBehindFunction)
|
||||
SDV_LABEL_ENTRY(EEnumInClassWithLabelMapBehindFunction::twenty_two, "twenty_two")
|
||||
SDV_LABEL_ENTRY(EEnumInClassWithLabelMapBehindFunction::twenty_three, "twenty_three")
|
||||
SDV_LABEL_ENTRY(EEnumInClassWithLabelMapBehindFunction::twenty_four, "twenty_four")
|
||||
END_SDV_LABEL_MAP()
|
||||
|
||||
enum class EEnumInClassWithLabelMapOutsideClass
|
||||
{
|
||||
twenty_five,
|
||||
twenty_six,
|
||||
twenty_seven
|
||||
};
|
||||
|
||||
enum class EEnumInClassWithLabelMapOutsideClassBehindFunction
|
||||
{
|
||||
twenty_eight,
|
||||
twenty_nine,
|
||||
thirty
|
||||
};
|
||||
};
|
||||
|
||||
BEGIN_SDV_LABEL_MAP(CLabelMapTest::EEnumInClassWithLabelMapOutsideClass)
|
||||
SDV_LABEL_ENTRY(CLabelMapTest::EEnumInClassWithLabelMapOutsideClass::twenty_five, "twenty_five")
|
||||
SDV_LABEL_ENTRY(CLabelMapTest::EEnumInClassWithLabelMapOutsideClass::twenty_six, "twenty_six")
|
||||
SDV_LABEL_ENTRY(CLabelMapTest::EEnumInClassWithLabelMapOutsideClass::twenty_seven, "twenty_seven")
|
||||
END_SDV_LABEL_MAP()
|
||||
|
||||
sdv::sequence<sdv::SLabelInfo::SLabel> GetLabelMapForEnumBeforMapDefinitionOutsideClass()
|
||||
{
|
||||
return sdv::internal::GetLabelMapHelper().GetLabelMap<CLabelMapTest::EEnumInClassWithLabelMapOutsideClassBehindFunction>();
|
||||
}
|
||||
|
||||
BEGIN_SDV_LABEL_MAP(CLabelMapTest::EEnumInClassWithLabelMapOutsideClassBehindFunction)
|
||||
SDV_LABEL_ENTRY(CLabelMapTest::EEnumInClassWithLabelMapOutsideClassBehindFunction::twenty_eight, "twenty_eight")
|
||||
SDV_LABEL_ENTRY(CLabelMapTest::EEnumInClassWithLabelMapOutsideClassBehindFunction::twenty_nine, "twenty_nine")
|
||||
SDV_LABEL_ENTRY(CLabelMapTest::EEnumInClassWithLabelMapOutsideClassBehindFunction::thirty, "thirty")
|
||||
END_SDV_LABEL_MAP()
|
||||
|
||||
TEST(ParameterTest, LabelMap)
|
||||
{
|
||||
// Enum without label map
|
||||
auto seqLabelMap = sdv::internal::GetLabelMapHelper().GetLabelMap<EEnumWithoutLabelMap>();
|
||||
EXPECT_TRUE(seqLabelMap.empty());
|
||||
|
||||
// Enum with empty label map
|
||||
seqLabelMap = sdv::internal::GetLabelMapHelper().GetLabelMap<EEnumWithEmptyLabelMap>();
|
||||
EXPECT_TRUE(seqLabelMap.empty());
|
||||
|
||||
// Enum with label map
|
||||
seqLabelMap = sdv::internal::GetLabelMapHelper().GetLabelMap<EEnumWithLabelMap>();
|
||||
ASSERT_EQ(seqLabelMap.size(), 3u);
|
||||
EXPECT_EQ(seqLabelMap[0].anyValue, static_cast<int>(EEnumWithLabelMap::seven));
|
||||
EXPECT_EQ(seqLabelMap[1].anyValue, static_cast<int>(EEnumWithLabelMap::eight));
|
||||
EXPECT_EQ(seqLabelMap[2].anyValue, static_cast<int>(EEnumWithLabelMap::nine));
|
||||
|
||||
// Enum with label map with access function defined before label map
|
||||
seqLabelMap = GetLabelMapForEnumBeforMapDefinition();
|
||||
ASSERT_EQ(seqLabelMap.size(), 3u);
|
||||
EXPECT_EQ(seqLabelMap[0].anyValue, static_cast<int>(EEnumWithLabelMapBehindFunction::ten));
|
||||
EXPECT_EQ(seqLabelMap[1].anyValue, static_cast<int>(EEnumWithLabelMapBehindFunction::eleven));
|
||||
EXPECT_EQ(seqLabelMap[2].anyValue, static_cast<int>(EEnumWithLabelMapBehindFunction::twelve));
|
||||
|
||||
// Enum in namespace with label map
|
||||
seqLabelMap = sdv::internal::GetLabelMapHelper().GetLabelMap<LabelMapTest::EEnumInNamespaceWithLabelMap>();
|
||||
ASSERT_EQ(seqLabelMap.size(), 3u);
|
||||
EXPECT_EQ(seqLabelMap[0].anyValue, static_cast<int>(LabelMapTest::EEnumInNamespaceWithLabelMap::thirteen));
|
||||
EXPECT_EQ(seqLabelMap[1].anyValue, static_cast<int>(LabelMapTest::EEnumInNamespaceWithLabelMap::fourteen));
|
||||
EXPECT_EQ(seqLabelMap[2].anyValue, static_cast<int>(LabelMapTest::EEnumInNamespaceWithLabelMap::fifteen));
|
||||
|
||||
// Enum in namespace with label map with access function defined before label map
|
||||
seqLabelMap = LabelMapTest::GetLabelMapForEnumBeforMapDefinition();
|
||||
ASSERT_EQ(seqLabelMap.size(), 3u);
|
||||
EXPECT_EQ(seqLabelMap[0].anyValue, static_cast<int>(LabelMapTest::EEnumInNamespaceWithLabelMapBehindFunction::sixteen));
|
||||
EXPECT_EQ(seqLabelMap[1].anyValue, static_cast<int>(LabelMapTest::EEnumInNamespaceWithLabelMapBehindFunction::seventeen));
|
||||
EXPECT_EQ(seqLabelMap[2].anyValue, static_cast<int>(LabelMapTest::EEnumInNamespaceWithLabelMapBehindFunction::eighteen));
|
||||
|
||||
// Enum in class with label map
|
||||
seqLabelMap = sdv::internal::GetLabelMapHelper().GetLabelMap<CLabelMapTest::EEnumInClassWithLabelMap>();
|
||||
ASSERT_EQ(seqLabelMap.size(), 3u);
|
||||
EXPECT_EQ(seqLabelMap[0].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMap::nineteen));
|
||||
EXPECT_EQ(seqLabelMap[1].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMap::twenty));
|
||||
EXPECT_EQ(seqLabelMap[2].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMap::twenty_one));
|
||||
|
||||
// Enum in class with label map with access function defined before label map
|
||||
seqLabelMap = CLabelMapTest::GetLabelMapForEnumBeforMapDefinition();
|
||||
ASSERT_EQ(seqLabelMap.size(), 3u);
|
||||
EXPECT_EQ(seqLabelMap[0].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMapBehindFunction::twenty_two));
|
||||
EXPECT_EQ(seqLabelMap[1].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMapBehindFunction::twenty_three));
|
||||
EXPECT_EQ(seqLabelMap[2].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMapBehindFunction::twenty_four));
|
||||
|
||||
// Enum in class with label map outside class
|
||||
seqLabelMap = sdv::internal::GetLabelMapHelper().GetLabelMap<CLabelMapTest::EEnumInClassWithLabelMapOutsideClass>();
|
||||
ASSERT_EQ(seqLabelMap.size(), 3u);
|
||||
EXPECT_EQ(seqLabelMap[0].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMapOutsideClass::twenty_five));
|
||||
EXPECT_EQ(seqLabelMap[1].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMapOutsideClass::twenty_six));
|
||||
EXPECT_EQ(seqLabelMap[2].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMapOutsideClass::twenty_seven));
|
||||
|
||||
// Enum in class with label map outside class behind access function
|
||||
seqLabelMap = GetLabelMapForEnumBeforMapDefinitionOutsideClass();
|
||||
ASSERT_EQ(seqLabelMap.size(), 3u);
|
||||
EXPECT_EQ(
|
||||
seqLabelMap[0].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMapOutsideClassBehindFunction::twenty_eight));
|
||||
EXPECT_EQ(
|
||||
seqLabelMap[1].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMapOutsideClassBehindFunction::twenty_nine));
|
||||
EXPECT_EQ(seqLabelMap[2].anyValue, static_cast<int>(CLabelMapTest::EEnumInClassWithLabelMapOutsideClassBehindFunction::thirty));
|
||||
};
|
||||
Reference in New Issue
Block a user