chromium/base/ranges/algorithm_unittest.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "base/ranges/algorithm.h"

#include <algorithm>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <random>
#include <ranges>
#include <utility>

#include "base/ranges/functional.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

ElementsAre;
Field;
Ge;
Gt;
Le;
Lt;
Pair;

namespace base {

namespace {

// A macro to work around the fact that lambdas are not constexpr in C++14.
// This will define an unnamed struct with a constexpr call operator, similarly
// to how lambdas behave in C++17+.
// Note that this does not support capture groups, so all lambdas defined like
// this must be stateless.
// Example Usage: `CONSTEXPR_LAMBDA((int i, int j) { return i + j; }) lambda;`
// TODO(crbug.com/40533712): Remove once we have constexpr lambdas for real.
#define CONSTEXPR_LAMBDA(fun)

struct Int {};

constexpr bool operator==(Int lhs, Int rhs) {}

constexpr bool operator<(Int lhs, Int rhs) {}

constexpr bool operator>(Int lhs, Int rhs) {}

constexpr bool operator<=(Int lhs, Int rhs) {}

constexpr bool operator>=(Int lhs, Int rhs) {}

// Move-only int that clears `value` when moving out.
struct MoveOnlyInt {};

constexpr bool is_even(int i) {}

bool is_odd(int i) {}

template <typename Iter>
auto make_vector(Iter begin, Iter end) {}

}  // namespace

TEST(RangesTest, AllOf) {}

TEST(RangesTest, AnyOf) {}

TEST(RangesTest, NoneOf) {}

TEST(RangesTest, ForEach) {}

TEST(RangesTest, ForEachN) {}

TEST(RangesTest, Find) {}

TEST(RangesTest, FindIf) {}

TEST(RangesTest, FindIfNot) {}

TEST(RangesTest, FindEnd) {}

TEST(RangesTest, FindFirstOf) {}

TEST(RangesTest, AdjacentFind) {}

TEST(RangesTest, Count) {}

TEST(RangesTest, CountIf) {}

TEST(RangesTest, Mismatch) {}

TEST(RangesTest, Equal) {}

TEST(RangesTest, IsPermutation) {}

TEST(RangesTest, Search) {}

TEST(RangesTest, SearchN) {}

TEST(RangesTest, Copy) {}

TEST(RangesTest, CopyN) {}

TEST(RangesTest, CopyIf) {}

TEST(RangesTest, CopyBackward) {}

TEST(RangesTest, Move) {}

TEST(RangesTest, MoveBackward) {}

TEST(RangesTest, SwapRanges) {}

TEST(RangesTest, UnaryTransform) {}

TEST(RangesTest, BinaryTransform) {}

TEST(RangesTest, Replace) {}

TEST(RangesTest, ReplaceIf) {}

TEST(RangesTest, ReplaceCopy) {}

TEST(RangesTest, ReplaceCopyIf) {}

TEST(RangesTest, Fill) {}

TEST(RangesTest, FillN) {}

TEST(RangesTest, Generate) {}

TEST(RangesTest, GenerateN) {}

TEST(RangesTest, Remove) {}

TEST(RangesTest, RemoveIf) {}

TEST(RangesTest, RemoveCopy) {}

TEST(RangesTest, RemovCopyIf) {}

TEST(RangesTest, Unique) {}

TEST(RangesTest, UniqueCopy) {}

TEST(RangesTest, Reverse) {}

TEST(RangesTest, ReverseCopy) {}

TEST(RangesTest, Rotate) {}

TEST(RangesTest, RotateCopy) {}

TEST(RangesTest, Shuffle) {}

TEST(RangesTest, Sort) {}

TEST(RangesTest, StableSort) {}

TEST(RangesTest, PartialSort) {}

TEST(RangesTest, PartialSortCopy) {}

TEST(RangesTest, IsSorted) {}

TEST(RangesTest, IsSortedUntil) {}

TEST(RangesTest, NthElement) {}

TEST(RangesTest, LowerBound) {}

TEST(RangesTest, UpperBound) {}

TEST(RangesTest, EqualRange) {}

TEST(RangesTest, BinarySearch) {}

TEST(RangesTest, IsPartitioned) {}

TEST(RangesTest, Partition) {}

TEST(RangesTest, StablePartition) {}

TEST(RangesTest, PartitionCopy) {}

TEST(RangesTest, PartitionPoint) {}

TEST(RangesTest, Merge) {}

TEST(RangesTest, InplaceMerge) {}

TEST(RangesTest, Includes) {}

TEST(RangesTest, SetUnion) {}

TEST(RangesTest, SetIntersection) {}

TEST(RangesTest, SetDifference) {}

TEST(RangesTest, SetSymmetricDifference) {}

TEST(RangesTest, PushHeap) {}

TEST(RangesTest, PopHeap) {}

TEST(RangesTest, MakeHeap) {}

TEST(RangesTest, SortHeap) {}

TEST(RangesTest, IsHeap) {}

TEST(RangesTest, IsHeapUntil) {}

TEST(RangesTest, Min) {}

TEST(RangesTest, Max) {}

TEST(RangesTest, Minmax) {}

TEST(RangesTest, MinElement) {}

TEST(RangesTest, MaxElement) {}

TEST(RangesTest, MinmaxElement) {}

TEST(RangesTest, Clamp) {}

TEST(RangesTest, LexicographicalCompare) {}

TEST(RangesTest, NextPermutation) {}

TEST(RangesTest, PrevPermutation) {}

namespace internal {
struct TestPair {};
}  // namespace internal

}  // namespace base