Skip to content

Commit

Permalink
chore: replace deprecated rcpputils filesystem with std::filesystem (#…
Browse files Browse the repository at this point in the history
…467)

Signed-off-by: wep21 <[email protected]>
  • Loading branch information
wep21 authored Jul 29, 2024
1 parent 7d2a64d commit a681667
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions grid_map_ros/test/GridMapRosTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#include <nav_msgs/msg/occupancy_grid.hpp>
#include <nav2_msgs/msg/costmap.hpp>
#include <sensor_msgs/image_encodings.hpp>
#include <rcpputils/filesystem_helper.hpp>

// STD
#include <filesystem>
#include <string>
#include <vector>
#include <iterator>
Expand Down Expand Up @@ -77,9 +77,9 @@ TEST(RosbagHandling, saveLoad)
EXPECT_FALSE(gridMapOut.exists(layer));

// Cleaning in case the previous bag was not removed
rcpputils::fs::path dir(pathToBag);
EXPECT_TRUE(!dir.exists() || rcpputils::fs::remove_all(dir));
EXPECT_TRUE(!dir.exists() || rcpputils::fs::create_directories(dir));
std::filesystem::path dir(pathToBag);
EXPECT_TRUE(!std::filesystem::exists(dir) || std::filesystem::remove_all(dir));
EXPECT_TRUE(!std::filesystem::exists(dir) || std::filesystem::create_directories(dir));

EXPECT_TRUE(GridMapRosConverter::saveToBag(gridMapIn, pathToBag, topic));
EXPECT_TRUE(GridMapRosConverter::loadFromBag(pathToBag, topic, gridMapOut));
Expand All @@ -90,7 +90,7 @@ TEST(RosbagHandling, saveLoad)
}

// Removing the created bag
rcpputils::fs::remove_all(dir);
std::filesystem::remove_all(dir);
}

TEST(RosbagHandling, saveLoadWithTime)
Expand All @@ -115,9 +115,9 @@ TEST(RosbagHandling, saveLoadWithTime)
gridMapIn.setTimestamp(clock.now().nanoseconds());

// Cleaning in case the previous bag was not removed
rcpputils::fs::path dir(pathToBag);
EXPECT_TRUE(!dir.exists() || rcpputils::fs::remove_all(dir));
EXPECT_TRUE(!dir.exists() || rcpputils::fs::create_directories(dir));
std::filesystem::path dir(pathToBag);
EXPECT_TRUE(!std::filesystem::exists(dir) || std::filesystem::remove_all(dir));
EXPECT_TRUE(!std::filesystem::exists(dir) || std::filesystem::create_directories(dir));

EXPECT_TRUE(GridMapRosConverter::saveToBag(gridMapIn, pathToBag, topic));
EXPECT_TRUE(GridMapRosConverter::loadFromBag(pathToBag, topic, gridMapOut));
Expand All @@ -129,7 +129,7 @@ TEST(RosbagHandling, saveLoadWithTime)
}

// Removing the created bag
rcpputils::fs::remove_all(dir);
std::filesystem::remove_all(dir);
}

TEST(RosbagHandling, wrongTopicType)
Expand All @@ -140,7 +140,7 @@ TEST(RosbagHandling, wrongTopicType)
std::string pathToBag = "double_chatter";
string topic = "/chatter1";
GridMap gridMapOut;
rcpputils::fs::path dir(pathToBag);
std::filesystem::path dir(pathToBag);

EXPECT_FALSE(GridMapRosConverter::loadFromBag(pathToBag, topic, gridMapOut));
}
Expand All @@ -155,7 +155,7 @@ TEST(RosbagHandling, checkTopicTypes)
string topic_correct = "/grid_map";
string topic_non_existing = "/grid_map_non_existing";
GridMap gridMapOut;
rcpputils::fs::path dir(pathToBag);
std::filesystem::path dir(pathToBag);

EXPECT_FALSE(GridMapRosConverter::loadFromBag(pathToBag, topic_wrong, gridMapOut));
EXPECT_TRUE(GridMapRosConverter::loadFromBag(pathToBag, topic_correct, gridMapOut));
Expand Down

0 comments on commit a681667

Please sign in to comment.