Skip to content

Commit

Permalink
array: Add defaulted operator<=> and test
Browse files Browse the repository at this point in the history
  • Loading branch information
qookei committed Feb 9, 2024
1 parent a24e99e commit 1e053d7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/frg/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct array {
}

bool operator==(const array &other) const = default;
auto operator<=>(const array &other) const = default;
};

namespace details {
Expand Down
24 changes: 24 additions & 0 deletions tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,27 @@ TEST(bitset, count) {
EXPECT_FALSE(a.all());
EXPECT_FALSE(a.none());
}

#include <frg/array.hpp>

TEST(array, compare) {
{
frg::array<int, 4> a = {1, 2, 3, 4},
b = {1, 2, 3, 4};
EXPECT_TRUE(a == b);
}

{
frg::array<int, 4> a = {1, 2, 3, 4},
b = {1, 2, 3, 5};
EXPECT_TRUE(a != b);
EXPECT_TRUE(a < b);
}

{
frg::array<int, 4> a = {1, 2, 3, 5},
b = {1, 2, 3, 4};
EXPECT_TRUE(a != b);
EXPECT_TRUE(a > b);
}
}

0 comments on commit 1e053d7

Please sign in to comment.