Skip to content

Commit

Permalink
add "validate_custom_names" test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibault Poignonec committed Dec 16, 2024
1 parent e3b99d3 commit 2e2798f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions controller_interface/test/test_led_rgb_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,22 @@ TEST_F(LedDeviceTest, validate_all)
led_device_->release_interfaces();
ASSERT_EQ(led_device_->command_interfaces_.size(), 0);
}

TEST_F(LedDeviceTest, validate_custom_names)
{
std::string interface_name_r = "led/custom_r";
std::string interface_name_g = "led/custom_g";
std::string interface_name_b = "led/custom_b";
// Create device
led_device_ =
std::make_unique<TestableLedDevice>(interface_name_r, interface_name_g, interface_name_b);
EXPECT_EQ(led_device_->name_, "");

EXPECT_EQ(led_device_->interface_names_.size(), size_);
EXPECT_EQ(led_device_->command_interfaces_.capacity(), size_);

// Validate custom interface_names_
EXPECT_EQ(led_device_->interface_names_[0], interface_name_r);
EXPECT_EQ(led_device_->interface_names_[1], interface_name_g);
EXPECT_EQ(led_device_->interface_names_[2], interface_name_b);
}
8 changes: 8 additions & 0 deletions controller_interface/test/test_led_rgb_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@
class TestableLedDevice : public semantic_components::LEDRgbDevice
{
FRIEND_TEST(LedDeviceTest, validate_all);
FRIEND_TEST(LedDeviceTest, validate_custom_names);

public:
// Use default command interface names
explicit TestableLedDevice(const std::string & name) : LEDRgbDevice{name} {}

TestableLedDevice(
const std::string & interface_r, const std::string & interface_g,
const std::string & interface_b)
: LEDRgbDevice{interface_r, interface_g, interface_b}
{
}

virtual ~TestableLedDevice() = default;
};

Expand Down

0 comments on commit 2e2798f

Please sign in to comment.