Skip to content

Commit

Permalink
FIX: unit test false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Aug 21, 2024
1 parent c110e1b commit 7d7fb02
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions doc/source/doxygen-docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
\page changelog Change Log

# Version 2.13.7: UNRELEASED
- BUG FIXES:
- Fix incorrect check in mrpt-io unit tests leading to potential false positives.


# Version 2.13.6: Released Aug 14th, 2024
- Build system:
- This main MRPT repository is no longer directly built as a ROS package. Please, use the wrappers for better modularity:
Expand Down
22 changes: 21 additions & 1 deletion libs/io/src/CFileGZStreams_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@
#include <test_mrpt_common.h>

#include <algorithm> // std::equal
#include <cstdint>
#include <iomanip>
#include <sstream>
#include <string>

namespace
{
std::string to_hex_string(const uint8_t* buf, size_t len)
{
std::ostringstream oss;
for (size_t i = 0; i < len; ++i)
{
oss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(buf[i]);
}
return oss.str();
}
} // namespace

const size_t tst_data_len = 1000U;

Expand Down Expand Up @@ -112,7 +129,10 @@ TEST(CFileGZStreams, readwriteTmpFileCompressed)
const size_t rd_count = fil_in.Read(rd_buf, tst_data_len / 4);
EXPECT_EQ(rd_count, tst_data_len / 4);

EXPECT_TRUE(std::equal(std::begin(tst_data), std::end(tst_data), std::begin(rd_buf)));
EXPECT_TRUE(std::equal(std::begin(rd_buf), std::end(rd_buf), std::begin(tst_data)))
<< " compress_level: " << compress_level << "\n"
<< " test_data: " << to_hex_string(tst_data.data(), tst_data.size()) << "\n"
<< " read_data: " << to_hex_string(rd_buf, sizeof(rd_buf)) << "\n";

// next I should find an EOF:
const auto rdEof = fil_in.Read(rd_buf, 1);
Expand Down

0 comments on commit 7d7fb02

Please sign in to comment.