Skip to content
Snippets Groups Projects
Commit fa3924ee authored by Xiao Pan's avatar Xiao Pan
Browse files

feat: Add Vec2 data type

parent 214df604
No related branches found
No related tags found
1 merge request!112feat: Add Vec2 data type
Pipeline #29631 passed with stage
in 0 seconds
......@@ -33,3 +33,10 @@ cc_test(
srcs = ["test/interface_test.cpp"],
deps = [":test_utils"],
)
cc_test(
name = "commom_test",
timeout = "short",
srcs = glob(["test/MantleAPI/Common/*.h"])+glob(["test/MantleAPI/Common/*.cc"]),
deps = [":test_utils"],
)
/*******************************************************************************
* Copyright (c) 2021, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (C) 2023, ANSYS, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
......@@ -22,6 +23,13 @@
namespace mantle_api
{
template <typename T, class = typename std::enable_if_t<units::traits::is_unit_t<T>::value>>
struct Vec2
{
T x{0};
T y{0};
};
template <typename T, class = typename std::enable_if_t<units::traits::is_unit_t<T>::value>>
struct Vec3
{
......
......@@ -9,7 +9,7 @@
################################################################################
add_executable(CommonTest)
target_sources(CommonTest PUBLIC floating_point_helper_test.cc logger_test.cc log_utils_test.cc)
target_sources(CommonTest PUBLIC floating_point_helper_test.cc logger_test.cc log_utils_test.cc vector_test.cc)
target_include_directories(CommonTest PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/test>)
target_link_libraries(CommonTest PUBLIC MantleAPI::MantleAPI GTest::gmock_main)
......
/*******************************************************************************
* Copyright (C) 2023, ANSYS, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
#include "MantleAPI/Common/vector.h"
#include <gtest/gtest.h>
namespace
{
using units::literals::operator""_m;
TEST(Vector2Test, GivenVector2_WhenGetData_ThenTypical)
{
mantle_api::Vec2<units::length::meter_t> vec2{4.0_m, 10.0_m};
EXPECT_EQ(vec2.x, 4.0_m);
EXPECT_EQ(vec2.y, 10.0_m);
}
} // namespace
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment