chromium/third_party/abseil-cpp/absl/container/internal/layout_test.cc

// Copyright 2018 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "absl/container/internal/layout.h"

// We need ::max_align_t because some libstdc++ versions don't provide
// std::max_align_t
#include <stddef.h>

#include <cstdint>
#include <cstring>
#include <initializer_list>
#include <memory>
#include <ostream>
#include <string>
#include <tuple>
#include <type_traits>

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/base/config.h"
#include "absl/log/check.h"
#include "absl/types/span.h"
#include "absl/utility/utility.h"

namespace absl {
ABSL_NAMESPACE_BEGIN
namespace container_internal {
namespace {

Span;
ElementsAre;

size_t Distance(const void* from, const void* to) {}

template <class Expected, class Actual>
Expected Type(Actual val) {}

// Helper classes to test different size and alignments.
struct alignas(8) Int128 {};

// int64_t is *not* 8-byte aligned on all platforms!
struct alignas(8) Int64 {};

// Properties of types that this test relies on.
static_assert;
static_assert;
static_assert;
static_assert;
static_assert;
static_assert;
static_assert;
static_assert;
static_assert;
static_assert;

template <class Expected, class Actual>
void SameType() {}

TEST(Layout, ElementType) {}

TEST(Layout, ElementTypes) {}

TEST(Layout, OffsetByIndex) {}

TEST(Layout, OffsetByType) {}

TEST(Layout, Offsets) {}

TEST(Layout, StaticOffsets) {}

TEST(Layout, AllocSize) {}

TEST(Layout, StaticAllocSize) {}

TEST(Layout, SizeByIndex) {}

TEST(Layout, SizeByType) {}

TEST(Layout, Sizes) {}

TEST(Layout, StaticSize) {}

TEST(Layout, PointerByIndex) {}

TEST(Layout, PointerByType) {}

TEST(Layout, MutablePointerByIndex) {}

TEST(Layout, MutablePointerByType) {}

TEST(Layout, Pointers) {}

TEST(Layout, MutablePointers) {}

TEST(Layout, StaticPointers) {}

TEST(Layout, SliceByIndexSize) {}

TEST(Layout, SliceByTypeSize) {}
TEST(Layout, MutableSliceByIndexSize) {}

TEST(Layout, MutableSliceByTypeSize) {}

TEST(Layout, StaticSliceSize) {}

TEST(Layout, SliceByIndexData) {}

TEST(Layout, SliceByTypeData) {}

TEST(Layout, MutableSliceByIndexData) {}

TEST(Layout, MutableSliceByTypeData) {}

TEST(Layout, StaticSliceData) {}

MATCHER_P(IsSameSlice, slice, "") {}

template <typename... M>
class TupleMatcher {};

template <typename... M>
testing::PolymorphicMatcher<TupleMatcher<M...>> Tuple(M... matchers) {}

TEST(Layout, Slices) {}

TEST(Layout, MutableSlices) {}

TEST(Layout, StaticSlices) {}

TEST(Layout, UnalignedTypes) {}

TEST(Layout, CustomAlignment) {}

TEST(Layout, OverAligned) {}

TEST(Layout, Alignment) {}

TEST(Layout, StaticAlignment) {}

TEST(Layout, ConstexprPartial) {}

TEST(Layout, StaticConstexpr) {}

// [from, to)
struct Region {};

void ExpectRegionPoisoned(const unsigned char* p, size_t n, bool poisoned) {}

template <size_t N>
void ExpectPoisoned(const unsigned char (&buf)[N],
                    std::initializer_list<Region> reg) {}

TEST(Layout, PoisonPadding) {}

TEST(Layout, StaticPoisonPadding) {}

TEST(Layout, DebugString) {}

TEST(Layout, StaticDebugString) {}

TEST(Layout, CharTypes) {}

TEST(Layout, ConstElementType) {}

namespace example {

// Immutable move-only string with sizeof equal to sizeof(void*). The string
// size and the characters are kept in the same heap allocation.
class CompactString {};

TEST(CompactString, Works) {}

// Same as the previous CompactString example, except we set the first array
// size to 1 statically, since we know it is always 1. This allows us to compute
// the offset of the character array at compile time.
class StaticCompactString {};

TEST(StaticCompactString, Works) {}

}  // namespace example

}  // namespace
}  // namespace container_internal
ABSL_NAMESPACE_END
}  // namespace absl