Verified Commit 21f8adee authored by nagayama15's avatar nagayama15

fix bug in function-reorder method

parent fd77caab
...@@ -26,7 +26,10 @@ namespace kyut { ...@@ -26,7 +26,10 @@ namespace kyut {
// Sort the chunk. // Sort the chunk.
std::sort(begin, end, less); std::sort(begin, end, less);
// TODO: Assume unique // Assume unique
end = safe_unique(begin, end, [&](const auto& a, const auto& b) {
return !less(a, b) && !less(a, b);
});
// Embed watermark. // Embed watermark.
const std::size_t count = std::distance(begin, end); const std::size_t count = std::distance(begin, end);
...@@ -90,7 +93,12 @@ namespace kyut { ...@@ -90,7 +93,12 @@ namespace kyut {
return less(*a, *b); return less(*a, *b);
}); });
// TODO: Assume unique // Assume unique
chunk.erase(
safe_unique(std::begin(chunk), std::end(chunk), [&](const auto& a, const auto& b) {
return !less(*a, *b) && !less(*a, *b);
}),
std::end(chunk));
const auto chunk_begin = std::begin(chunk); const auto chunk_begin = std::begin(chunk);
const auto chunk_end = std::end(chunk); const auto chunk_end = std::end(chunk);
......
...@@ -38,8 +38,8 @@ TEST(kyut_Reordering, embed_by_reordering) { ...@@ -38,8 +38,8 @@ TEST(kyut_Reordering, embed_by_reordering) {
check_embed("2314", "\x50"sv, 20, 4, "2314"); check_embed("2314", "\x50"sv, 20, 4, "2314");
check_embed("2314", "\x00"sv, 20, 4, "1234"); check_embed("2314", "\x00"sv, 20, 4, "1234");
// check_embed("1223", "\x00"sv, 20, 2, "1232"); check_embed("1223", "\x00"sv, 20, 2, "1232");
// check_embed("1223", "\x40"sv, 20, 2, "2132"); check_embed("1223", "\x40"sv, 20, 2, "2132");
} }
namespace { namespace {
...@@ -73,8 +73,8 @@ TEST(kyut_Reordering, extract_by_reordering) { ...@@ -73,8 +73,8 @@ TEST(kyut_Reordering, extract_by_reordering) {
check_extract("1324", 20, 4, "\x40"sv); check_extract("1324", 20, 4, "\x40"sv);
check_extract("2314", 20, 4, "\x50"sv); check_extract("2314", 20, 4, "\x50"sv);
// check_extract("1232", 20, 2, "\x00"sv); check_extract("1232", 20, 2, "\x00"sv);
// check_extract("2132", 20, 2, "\x40"sv); check_extract("2132", 20, 2, "\x40"sv);
} }
namespace { namespace {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment