2020-11-16 18:27:14 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-11-16 18:27:14 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <AK/TestSuite.h>
|
|
|
|
|
|
|
|
|
|
#include <AK/AllOf.h>
|
|
|
|
|
#include <AK/Array.h>
|
|
|
|
|
|
|
|
|
|
TEST_CASE(should_determine_if_predicate_applies_to_all_elements_in_container)
|
|
|
|
|
{
|
2021-02-25 21:10:47 +01:00
|
|
|
constexpr Array<int, 10> a {};
|
2020-11-16 18:27:14 -07:00
|
|
|
|
2021-02-25 21:10:47 +01:00
|
|
|
static_assert(all_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
|
|
|
|
|
static_assert(!all_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));
|
2020-11-16 18:27:14 -07:00
|
|
|
|
2021-02-25 21:10:47 +01:00
|
|
|
EXPECT(all_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
|
|
|
|
|
EXPECT(!all_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));
|
2020-11-16 18:27:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_MAIN(AllOf)
|