Skip to content

Commit

Permalink
Fix warning for older compilers and pair comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianFeldmann committed Dec 19, 2024
1 parent 0b9f935 commit 7e81f70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions YUViewLib/src/common/EnumMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ struct EnumMapper : public std::array<std::pair<ValueType, std::string_view>, N>

constexpr std::array<ValueType, N> getValues() const
{
std::array<ValueType, N> values;
std::array<ValueType, N> values{};
for (std::size_t i = 0; i < N; ++i)
values[i] = this->at(i).first;
return values;
}

constexpr std::array<std::string_view, N> getNames() const
{
std::array<std::string_view, N> names;
std::array<std::string_view, N> names{};
for (std::size_t i = 0; i < N; ++i)
names[i] = this->at(i).second;
return names;
Expand Down
8 changes: 5 additions & 3 deletions YUViewUnitTest/common/EnumMapperTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#include <common/EnumMapper.h>

using namespace std::string_view_literals;

namespace
{

Expand Down Expand Up @@ -115,9 +117,9 @@ TEST(EnumMapperTest, testIndexOf)

TEST(EnumMapperTest, testAt)
{
EXPECT_EQ(TestEnumMapper.at(0), std::make_pair(TestEnum::ValueOne, "ValueOne"));
EXPECT_EQ(TestEnumMapper.at(1), std::make_pair(TestEnum::ValueTwo, "ValueTwo"));
EXPECT_EQ(TestEnumMapper.at(2), std::make_pair(TestEnum::ValueThree, "ValueThree"));
EXPECT_EQ(TestEnumMapper.at(0), std::make_pair(TestEnum::ValueOne, "ValueOne"sv));
EXPECT_EQ(TestEnumMapper.at(1), std::make_pair(TestEnum::ValueTwo, "ValueTwo"sv));
EXPECT_EQ(TestEnumMapper.at(2), std::make_pair(TestEnum::ValueThree, "ValueThree"sv));

EXPECT_THROW(TestEnumMapper.at(3), std::out_of_range);
EXPECT_THROW(TestEnumMapper.at(4), std::out_of_range);
Expand Down

0 comments on commit 7e81f70

Please sign in to comment.