Modernize std::equal with ranges

This commit is contained in:
mitaclaw 2024-09-21 23:46:43 -07:00
parent 4cc5e1972a
commit 249defa72b
3 changed files with 6 additions and 8 deletions

View File

@ -191,8 +191,7 @@ void FIFOAnalyzer::UpdateTree()
// We shouldn't end on a Command (it should end with an EFB copy)
ASSERT(part_start == frame_info.parts.size());
// The counts we computed should match the frame's counts
ASSERT(std::equal(frame_info.part_type_counts.begin(), frame_info.part_type_counts.end(),
part_counts.begin()));
ASSERT(std::ranges::equal(frame_info.part_type_counts, part_counts));
}
}

View File

@ -53,8 +53,7 @@ struct TwoPointCalibration
}
else
{
return std::equal(std::begin(max.data), std::end(max.data), std::begin(zero.data),
std::not_equal_to<>());
return std::ranges::equal(max.data, zero.data, std::ranges::not_equal_to{});
}
}

View File

@ -47,7 +47,7 @@ TEST(SettingsHandlerTest, EncryptSingleSetting)
handler.AddSetting("key", "val");
Common::SettingsHandler::Buffer buffer = handler.GetBytes();
EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), BUFFER_A.begin(), BUFFER_A.end()));
EXPECT_TRUE(std::ranges::equal(buffer, BUFFER_A));
}
TEST(SettingsHandlerTest, DecryptSingleSetting)
@ -64,7 +64,7 @@ TEST(SettingsHandlerTest, EncryptMultipleSettings)
handler.AddSetting("foo", "bar");
Common::SettingsHandler::Buffer buffer = handler.GetBytes();
EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), BUFFER_B.begin(), BUFFER_B.end()));
EXPECT_TRUE(std::ranges::equal(buffer, BUFFER_B));
}
TEST(SettingsHandlerTest, DecryptMultipleSettings)
@ -88,7 +88,7 @@ TEST(SettingsHandlerTest, EncryptAddsLFOnNullChar)
handler.AddSetting("\xFA", "a");
Common::SettingsHandler::Buffer buffer = handler.GetBytes();
EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), BUFFER_C.begin(), BUFFER_C.end()));
EXPECT_TRUE(std::ranges::equal(buffer, BUFFER_C));
}
TEST(SettingsHandlerTest, EncryptAddsLFOnNullCharTwice)
@ -97,7 +97,7 @@ TEST(SettingsHandlerTest, EncryptAddsLFOnNullCharTwice)
handler.AddSetting("\xFA\xE9", "a");
Common::SettingsHandler::Buffer buffer = handler.GetBytes();
EXPECT_TRUE(std::equal(buffer.begin(), buffer.end(), BUFFER_D.begin(), BUFFER_D.end()));
EXPECT_TRUE(std::ranges::equal(buffer, BUFFER_D));
}
TEST(SettingsHandlerTest, DecryptSingleAddedLF)