diff --git a/include/frg/array.hpp b/include/frg/array.hpp index 0184edf..be62337 100644 --- a/include/frg/array.hpp +++ b/include/frg/array.hpp @@ -88,6 +88,7 @@ struct array { } bool operator==(const array &other) const = default; + auto operator<=>(const array &other) const = default; }; namespace details { diff --git a/tests/tests.cpp b/tests/tests.cpp index c2b7cf4..1ca1ce7 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -319,3 +319,27 @@ TEST(bitset, count) { EXPECT_FALSE(a.all()); EXPECT_FALSE(a.none()); } + +#include + +TEST(array, compare) { + { + frg::array a = {1, 2, 3, 4}, + b = {1, 2, 3, 4}; + EXPECT_TRUE(a == b); + } + + { + frg::array a = {1, 2, 3, 4}, + b = {1, 2, 3, 5}; + EXPECT_TRUE(a != b); + EXPECT_TRUE(a < b); + } + + { + frg::array a = {1, 2, 3, 5}, + b = {1, 2, 3, 4}; + EXPECT_TRUE(a != b); + EXPECT_TRUE(a > b); + } +}