Skip to content

Commit

Permalink
Added missing tests in test_lpp_rosprintf.cc + refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
4c3y committed Sep 7, 2023
1 parent 3187ad8 commit 06e1921
Showing 1 changed file with 39 additions and 29 deletions.
68 changes: 39 additions & 29 deletions test/lpp/test_lpp_rosprintf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,72 @@

using namespace lpp::testing;

TEST(lpp_rosprintf, ros_info) {
TEST(lpp_rosprintf, ros_debug) {
LOG_INIT(*test_argv);

std::string output = LPP_CAPTURE_STDOUT(ROS_DEBUG(ERROR_MESSAGE, 3.3, 5.5));
ASSERT_EQ(output, "DEBUG " + EXPECTED_ERROR_MESSAGE);
}

TEST(lpp_rosprintf, ros_debug_once) {
LOG_INIT(*test_argv);

testing::internal::CaptureStdout();
ROS_INFO(ERROR_MESSAGE, 3.3, 5.5);
std::string c = testing::internal::GetCapturedStdout();
std::string output = LPP_CAPTURE_STDOUT(ROS_DEBUG_ONCE(ERROR_MESSAGE, 3.3, 5.5));
ASSERT_EQ(output, "DEBUG " + EXPECTED_ERROR_MESSAGE);
}

ASSERT_EQ(c, "INFO " + EXPECTED_ERROR_MESSAGE);
TEST(lpp_rosprintf, ros_info) {
LOG_INIT(*test_argv);

std::string output = LPP_CAPTURE_STDOUT(ROS_INFO(ERROR_MESSAGE, 3.3, 5.5));
ASSERT_EQ(output, "INFO " + EXPECTED_ERROR_MESSAGE);
}

TEST(lpp_rosprintf, ros_info_once) {
LOG_INIT(*test_argv);

testing::internal::CaptureStdout();
ROS_INFO_ONCE(ERROR_MESSAGE, 3.3, 5.5);
std::string c = testing::internal::GetCapturedStdout();

ASSERT_EQ(c, "INFO " + EXPECTED_ERROR_MESSAGE);
std::string output = LPP_CAPTURE_STDOUT(ROS_INFO_ONCE(ERROR_MESSAGE, 3.3, 5.5));
ASSERT_EQ(output, "INFO " + EXPECTED_ERROR_MESSAGE);
}

TEST(lpp_rosprintf, ros_warn) {
LOG_INIT(*test_argv);

testing::internal::CaptureStdout();
ROS_WARN(ERROR_MESSAGE, 3.3, 5.5);
std::string c = testing::internal::GetCapturedStdout();

ASSERT_EQ(c, "WARN " + EXPECTED_ERROR_MESSAGE);
std::string output = LPP_CAPTURE_STDOUT(ROS_WARN(ERROR_MESSAGE, 3.3, 5.5));
ASSERT_EQ(output, "WARN " + EXPECTED_ERROR_MESSAGE);
}

TEST(lpp_rosprintf, ros_warn_once) {
LOG_INIT(*test_argv);

testing::internal::CaptureStdout();
ROS_WARN_ONCE(ERROR_MESSAGE, 3.3, 5.5);
std::string c = testing::internal::GetCapturedStdout();

ASSERT_EQ(c, "WARN " + EXPECTED_ERROR_MESSAGE);
std::string output = LPP_CAPTURE_STDOUT(ROS_WARN_ONCE(ERROR_MESSAGE, 3.3, 5.5));
ASSERT_EQ(output, "WARN " + EXPECTED_ERROR_MESSAGE);
}

TEST(lpp_rosprintf, ros_error) {
LOG_INIT(*test_argv);

testing::internal::CaptureStdout();
ROS_ERROR(ERROR_MESSAGE, 3.3, 5.5);
std::string c = testing::internal::GetCapturedStdout();

ASSERT_EQ(c, "ERROR " + EXPECTED_ERROR_MESSAGE);
std::string output = LPP_CAPTURE_STDOUT(ROS_ERROR(ERROR_MESSAGE, 3.3, 5.5));
ASSERT_EQ(output, "ERROR " + EXPECTED_ERROR_MESSAGE);
}

TEST(lpp_rosprintf, ros_error_once) {
LOG_INIT(*test_argv);

testing::internal::CaptureStdout();
ROS_ERROR_ONCE(ERROR_MESSAGE, 3.3, 5.5);
std::string c = testing::internal::GetCapturedStdout();
std::string output = LPP_CAPTURE_STDOUT(ROS_ERROR_ONCE(ERROR_MESSAGE, 3.3, 5.5));
ASSERT_EQ(output, "ERROR " + EXPECTED_ERROR_MESSAGE);
}

TEST(lpp_rosprintf, ros_fatal) {
LOG_INIT(*test_argv);

std::string output = LPP_CAPTURE_STDOUT(ROS_FATAL(ERROR_MESSAGE, 3.3, 5.5));
ASSERT_EQ(output, "FATAL " + EXPECTED_ERROR_MESSAGE);
}

TEST(lpp_rosprintf, ros_fatal_once) {
LOG_INIT(*test_argv);

ASSERT_EQ(c, "ERROR " + EXPECTED_ERROR_MESSAGE);
std::string output = LPP_CAPTURE_STDOUT(ROS_FATAL_ONCE(ERROR_MESSAGE, 3.3, 5.5));
ASSERT_EQ(output, "FATAL " + EXPECTED_ERROR_MESSAGE);
}

0 comments on commit 06e1921

Please sign in to comment.