2021-01-14 15:36:23 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-01-14 15:36:23 -07:00
|
|
|
*/
|
|
|
|
|
|
2021-04-24 23:53:23 -06:00
|
|
|
#include <LibTest/TestCase.h>
|
2021-01-14 15:36:23 -07:00
|
|
|
|
|
|
|
|
#include <AK/AnyOf.h>
|
|
|
|
|
#include <AK/Array.h>
|
|
|
|
|
|
|
|
|
|
TEST_CASE(should_determine_if_predicate_applies_to_any_element_in_container)
|
|
|
|
|
{
|
2021-02-25 21:10:47 +01:00
|
|
|
constexpr Array<int, 10> a { 1 };
|
2021-01-14 15:36:23 -07:00
|
|
|
|
2021-02-25 21:10:47 +01:00
|
|
|
static_assert(any_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
|
|
|
|
|
static_assert(any_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));
|
|
|
|
|
static_assert(!any_of(a.begin(), a.end(), [](auto elem) { return elem == 2; }));
|
2021-01-14 15:36:23 -07:00
|
|
|
|
2021-02-25 21:10:47 +01:00
|
|
|
EXPECT(any_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
|
|
|
|
|
EXPECT(any_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));
|
|
|
|
|
EXPECT(!any_of(a.begin(), a.end(), [](auto elem) { return elem == 2; }));
|
2021-01-14 15:36:23 -07:00
|
|
|
}
|