|
| 1 | +// Copyright 2021 RT Corporation |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#include <memory> |
| 16 | + |
| 17 | +#include "gtest/gtest.h" |
| 18 | +#include "rt_manipulators_cpp/joint.hpp" |
| 19 | + |
| 20 | +class JointTestFixture : public ::testing::Test { |
| 21 | + protected: |
| 22 | + virtual void SetUp() { |
| 23 | + uint8_t id = 0; |
| 24 | + uint8_t operating_mode = 1; |
| 25 | + double min_position_limit = 2.0; |
| 26 | + double max_position_limit = 3.0; |
| 27 | + double current_limit_when_position_exceeds_limit = 4.0; |
| 28 | + test_joint = std::make_shared<joint::Joint>( |
| 29 | + id, operating_mode, max_position_limit, min_position_limit, |
| 30 | + current_limit_when_position_exceeds_limit); |
| 31 | + } |
| 32 | + |
| 33 | + virtual void TearDown() { |
| 34 | + test_joint.reset(); |
| 35 | + } |
| 36 | + |
| 37 | + std::shared_ptr<joint::Joint> test_joint; |
| 38 | +}; |
| 39 | + |
| 40 | +TEST_F(JointTestFixture, initialize_id) { |
| 41 | + EXPECT_EQ(test_joint->id(), 0); |
| 42 | +} |
| 43 | + |
| 44 | +TEST_F(JointTestFixture, initialize_operating_mode) { |
| 45 | + EXPECT_EQ(test_joint->operating_mode(), 1); |
| 46 | +} |
| 47 | + |
| 48 | +TEST_F(JointTestFixture, initialize_min_position_limit) { |
| 49 | + EXPECT_DOUBLE_EQ(test_joint->min_position_limit(), 2.0); |
| 50 | +} |
| 51 | + |
| 52 | +TEST_F(JointTestFixture, initialize_max_position_limit) { |
| 53 | + EXPECT_DOUBLE_EQ(test_joint->max_position_limit(), 3.0); |
| 54 | +} |
| 55 | + |
| 56 | +TEST_F(JointTestFixture, initialize_current_limit) { |
| 57 | + EXPECT_DOUBLE_EQ(test_joint->current_limit_when_position_exceeds_limit(), 4.0); |
| 58 | +} |
0 commit comments