llvm/llvm/unittests/ADT/STLExtrasTest.cpp

//===- STLExtrasTest.cpp - Unit tests for STL extras ----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

#include <array>
#include <climits>
#include <cstddef>
#include <initializer_list>
#include <iterator>
#include <list>
#include <tuple>
#include <type_traits>
#include <unordered_set>
#include <utility>
#include <vector>

usingnamespacellvm;

ElementsAre;
UnorderedElementsAre;

namespace {

int f(rank<0>) {}
int f(rank<1>) {}
int f(rank<2>) {}
int f(rank<4>) {}

TEST(STLExtrasTest, Rank) {}

TEST(STLExtrasTest, EnumerateLValue) {}

TEST(STLExtrasTest, EnumerateModifyLValue) {}

TEST(STLExtrasTest, EnumerateRValueRef) {}

TEST(STLExtrasTest, EnumerateModifyRValue) {}

TEST(STLExtrasTest, EnumerateTwoRanges) {}

TEST(STLExtrasTest, EnumerateThreeRanges) {}

TEST(STLExtrasTest, EnumerateTemporaries) {}

#if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG)
TEST(STLExtrasTest, EnumerateDifferentLengths) {
  std::vector<int> Ints = {0, 1};
  bool Bools[] = {true, false, true};
  std::string Chars = "abc";
  EXPECT_DEATH(llvm::enumerate(Ints, Bools, Chars),
               "Ranges have different length");
  EXPECT_DEATH(llvm::enumerate(Bools, Ints, Chars),
               "Ranges have different length");
  EXPECT_DEATH(llvm::enumerate(Bools, Chars, Ints),
               "Ranges have different length");
}
#endif

template <bool B> struct CanMove {};
template <> struct CanMove<false> {};

template <bool B> struct CanCopy {};
template <> struct CanCopy<false> {};

template <bool Moveable, bool Copyable>
class Counted : CanMove<Moveable>, CanCopy<Copyable> {};

template <bool Moveable, bool Copyable>
struct Range : Counted<Moveable, Copyable> {};

TEST(STLExtrasTest, EnumerateLifetimeSemanticsPRValue) {}

TEST(STLExtrasTest, EnumerateLifetimeSemanticsRValue) {}

TEST(STLExtrasTest, EnumerateLifetimeSemanticsLValue) {}

namespace some_namespace {
struct some_struct {};

std::vector<int>::const_iterator begin(const some_struct &s) {}

std::vector<int>::const_iterator end(const some_struct &s) {}

std::vector<int>::const_reverse_iterator rbegin(const some_struct &s) {}

std::vector<int>::const_reverse_iterator rend(const some_struct &s) {}

void swap(some_struct &lhs, some_struct &rhs) {}

struct requires_move {};
int *begin(requires_move &&) {}
int *end(requires_move &&) {}
} // namespace some_namespace

TEST(STLExtrasTest, EnumerateCustomBeginEnd) {}

TEST(STLExtrasTest, CountAdaptor) {}

TEST(STLExtrasTest, for_each) {}

TEST(STLExtrasTest, ToVector) {}

TEST(STLExtrasTest, ConcatRange) {}

TEST(STLExtrasTest, PartitionAdaptor) {}

TEST(STLExtrasTest, EraseIf) {}

TEST(STLExtrasTest, AppendRange) {}

TEST(STLExtrasTest, AppendValues) {}

TEST(STLExtrasTest, ADLTest) {}

TEST(STLExtrasTest, ADLTestTemporaryRange) {}

TEST(STLExtrasTest, ADLTestConstexpr) {}

struct FooWithMemberSize {};

namespace some_namespace {
struct FooWithFreeSize {};

size_t size(const FooWithFreeSize &) {}
} // namespace some_namespace

TEST(STLExtrasTest, ADLSizeTest) {}

TEST(STLExtrasTest, DropBeginTest) {}

TEST(STLExtrasTest, DropBeginDefaultTest) {}

TEST(STLExtrasTest, DropEndTest) {}

TEST(STLExtrasTest, DropEndDefaultTest) {}

TEST(STLExtrasTest, EarlyIncrementTest) {}

// A custom iterator that returns a pointer when dereferenced. This is used to
// test make_early_inc_range with iterators that do not return a reference on
// dereferencing.
struct CustomPointerIterator
    : public iterator_adaptor_base<CustomPointerIterator,
                                   std::list<int>::iterator,
                                   std::forward_iterator_tag> {};

// Make sure make_early_inc_range works with iterators that do not return a
// reference on dereferencing. The test is similar to EarlyIncrementTest, but
// uses CustomPointerIterator.
TEST(STLExtrasTest, EarlyIncrementTestCustomPointerIterator) {}

TEST(STLExtrasTest, AllEqual) {}

// Test to verify that all_equal works with a container that does not
// model the random access iterator concept.
TEST(STLExtrasTest, AllEqualNonRandomAccess) {}

TEST(STLExtrasTest, AllEqualInitializerList) {}

TEST(STLExtrasTest, to_address) {}

TEST(STLExtrasTest, partition_point) {}

TEST(STLExtrasTest, hasSingleElement) {}

TEST(STLExtrasTest, hasNItems) {}

TEST(STLExtras, hasNItemsOrMore) {}

TEST(STLExtras, hasNItemsOrLess) {}

TEST(STLExtras, MoveRange) {}

TEST(STLExtras, Unique) {}

TEST(STLExtras, UniqueNoPred) {}

TEST(STLExtrasTest, MakeVisitorOneCallable) {}

TEST(STLExtrasTest, MakeVisitorTwoCallables) {}

TEST(STLExtrasTest, MakeVisitorCallableMultipleOperands) {}

TEST(STLExtrasTest, MakeVisitorDefaultCase) {}

template <bool Moveable, bool Copyable>
struct Functor : Counted<Moveable, Copyable> {};

TEST(STLExtrasTest, MakeVisitorLifetimeSemanticsPRValue) {}

TEST(STLExtrasTest, MakeVisitorLifetimeSemanticsRValue) {}

TEST(STLExtrasTest, MakeVisitorLifetimeSemanticsLValue) {}

TEST(STLExtrasTest, AllOfZip) {}

TEST(STLExtrasTest, TypesAreDistinct) {}

TEST(STLExtrasTest, FirstIndexOfType) {}

TEST(STLExtrasTest, TypeAtIndex) {}

enum Doggos {};

struct WooferCmp {};

TEST(STLExtrasTest, IsContainedInitializerList) {}

TEST(STLExtrasTest, IsContainedMemberContains) {}

TEST(STLExtrasTest, IsContainedMemberFind) {}

TEST(STLExtrasTest, addEnumValues) {}

TEST(STLExtrasTest, LessFirst) {}

TEST(STLExtrasTest, LessSecond) {}

TEST(STLExtrasTest, Mismatch) {}

struct Foo;
struct Bar {};

static_assert;
static_assert;

} // namespace