Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
style(pre-commit): autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Feb 14, 2024
1 parent cfdfc3d commit 8b0ddb8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion autoware_utils/include/autoware_utils/ros/uuid_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ inline unique_identifier_msgs::msg::UUID toUUIDMsg(const boost::uuids::uuid & id

} // namespace autoware_utils

#endif // AUTOWARE_UTILS__ROS__UUID_HELPER_HPP_
#endif // AUTOWARE_UTILS__ROS__UUID_HELPER_HPP_
50 changes: 25 additions & 25 deletions autoware_utils/test/src/ros/test_uuid_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,54 @@
// See the License for the specific language governing permissions and
// limitations under the License.


#include "autoware_utils/ros/uuid_helper.hpp"

#include <boost/uuid/uuid_generators.hpp>
#include <gtest/gtest.h>
#include <boost/uuid/uuid_generators.hpp>

#include <gtest/gtest.h>

TEST(UUIDHelperTest, GenerateUUID)
{
// Generate two UUIDs and ensure they are all different
// Generate two UUIDs and ensure they are all different

unique_identifier_msgs::msg::UUID uuid1 = autoware_utils::generateUUID();
unique_identifier_msgs::msg::UUID uuid2 = autoware_utils::generateUUID();
unique_identifier_msgs::msg::UUID uuid1 = autoware_utils::generateUUID();
unique_identifier_msgs::msg::UUID uuid2 = autoware_utils::generateUUID();

EXPECT_FALSE(uuid1 == uuid2) << "Duplicate UUID generated: " << autoware_utils::toHexString(uuid2);
EXPECT_FALSE(uuid1 == uuid2) << "Duplicate UUID generated: "
<< autoware_utils::toHexString(uuid2);
}

TEST(UUIDHelperTest, ToHexString)
{
unique_identifier_msgs::msg::UUID uuid;
// Populate the UUID with some values
std::fill(uuid.uuid.begin(), uuid.uuid.end(), 0x42);
unique_identifier_msgs::msg::UUID uuid;
// Populate the UUID with some values
std::fill(uuid.uuid.begin(), uuid.uuid.end(), 0x42);

std::string hexString = autoware_utils::toHexString(uuid);
std::string hexString = autoware_utils::toHexString(uuid);

// Check if the generated hex string is correct
EXPECT_EQ(hexString, "42424242424242424242424242424242");
// Check if the generated hex string is correct
EXPECT_EQ(hexString, "42424242424242424242424242424242");
}

TEST(UUIDHelperTest, ToBoostUUID)
{
unique_identifier_msgs::msg::UUID uuid;
// Populate the UUID with some values
std::fill(uuid.uuid.begin(), uuid.uuid.end(), 0x42);
unique_identifier_msgs::msg::UUID uuid;
// Populate the UUID with some values
std::fill(uuid.uuid.begin(), uuid.uuid.end(), 0x42);

boost::uuids::uuid boostUUID;
std::fill(boostUUID.begin(), boostUUID.end(), 0x42);
boost::uuids::uuid boostUUID;
std::fill(boostUUID.begin(), boostUUID.end(), 0x42);

// Check if the conversion from ROS UUID to Boost UUID is correct
EXPECT_TRUE(boostUUID == autoware_utils::toBoostUUID(uuid));
// Check if the conversion from ROS UUID to Boost UUID is correct
EXPECT_TRUE(boostUUID == autoware_utils::toBoostUUID(uuid));
}

TEST(UUIDHelperTest, ToUUIDMsg)
{
boost::uuids::random_generator generator;
boost::uuids::uuid boostUUID = generator();
unique_identifier_msgs::msg::UUID rosUUID = autoware_utils::toUUIDMsg(boostUUID);
boost::uuids::random_generator generator;
boost::uuids::uuid boostUUID = generator();
unique_identifier_msgs::msg::UUID rosUUID = autoware_utils::toUUIDMsg(boostUUID);

// Check if the conversion from Boost UUID to ROS UUID is correct
EXPECT_TRUE(std::equal(boostUUID.begin(), boostUUID.end(), rosUUID.uuid.begin()));
// Check if the conversion from Boost UUID to ROS UUID is correct
EXPECT_TRUE(std::equal(boostUUID.begin(), boostUUID.end(), rosUUID.uuid.begin()));
}

0 comments on commit 8b0ddb8

Please sign in to comment.