mirror of
https://github.com/zebrajr/ladybird.git
synced 2026-01-15 12:15:15 +00:00
AK: Add first_is_equal_to_all_of()
This method returns true if all arguments are equal.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
97e917bdf5
commit
040dca0223
@@ -41,6 +41,12 @@ template<typename T, typename... Ts>
|
|||||||
return (... || (forward<T>(to_compare) >= forward<Ts>(valid_values)));
|
return (... || (forward<T>(to_compare) >= forward<Ts>(valid_values)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, typename... Ts>
|
||||||
|
[[nodiscard]] constexpr bool first_is_equal_to_all_of(T&& to_compare, Ts&&... valid_values)
|
||||||
|
{
|
||||||
|
return (... && (forward<T>(to_compare) == forward<Ts>(valid_values)));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, typename... Ts>
|
template<typename T, typename... Ts>
|
||||||
[[nodiscard]] constexpr bool first_is_smaller_than_all_of(T&& to_compare, Ts&&... valid_values)
|
[[nodiscard]] constexpr bool first_is_smaller_than_all_of(T&& to_compare, Ts&&... valid_values)
|
||||||
{
|
{
|
||||||
@@ -67,6 +73,7 @@ template<typename T, typename... Ts>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if USING_AK_GLOBALLY
|
#if USING_AK_GLOBALLY
|
||||||
|
using AK::first_is_equal_to_all_of;
|
||||||
using AK::first_is_larger_or_equal_than_all_of;
|
using AK::first_is_larger_or_equal_than_all_of;
|
||||||
using AK::first_is_larger_or_equal_than_one_of;
|
using AK::first_is_larger_or_equal_than_one_of;
|
||||||
using AK::first_is_larger_than_all_of;
|
using AK::first_is_larger_than_all_of;
|
||||||
|
|||||||
@@ -203,6 +203,27 @@ TEST_CASE(first_is_larger_than_one_of)
|
|||||||
EXPECT(!first_is_larger_than_one_of(10));
|
EXPECT(!first_is_larger_than_one_of(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE(first_is_equal_to_all_of)
|
||||||
|
{
|
||||||
|
static_assert(first_is_equal_to_all_of(1));
|
||||||
|
EXPECT(first_is_equal_to_all_of(1));
|
||||||
|
|
||||||
|
static_assert(first_is_equal_to_all_of(1, 1));
|
||||||
|
EXPECT(first_is_equal_to_all_of(1, 1));
|
||||||
|
|
||||||
|
static_assert(!first_is_equal_to_all_of(1, 2));
|
||||||
|
EXPECT(!first_is_equal_to_all_of(1, 2));
|
||||||
|
|
||||||
|
static_assert(!first_is_equal_to_all_of(1, 1, 2));
|
||||||
|
EXPECT(!first_is_equal_to_all_of(1, 1, 2));
|
||||||
|
|
||||||
|
static_assert(!first_is_equal_to_all_of(2, 1, 1));
|
||||||
|
EXPECT(!first_is_equal_to_all_of(2, 1, 1));
|
||||||
|
|
||||||
|
static_assert(!first_is_equal_to_all_of(2, 2, 1));
|
||||||
|
EXPECT(!first_is_equal_to_all_of(2, 2, 1));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE(first_is_larger_or_equal_than_all_of)
|
TEST_CASE(first_is_larger_or_equal_than_all_of)
|
||||||
{
|
{
|
||||||
// Finds larger than all items
|
// Finds larger than all items
|
||||||
|
|||||||
Reference in New Issue
Block a user