chromium/base/containers/span_unittest.cc

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

#include "base/containers/span.h"

#include <stdint.h>

#include <algorithm>
#include <concepts>
#include <iterator>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <vector>

#include "base/compiler_specific.h"
#include "base/containers/adapters.h"
#include "base/containers/checked_iterators.h"
#include "base/debug/alias.h"
#include "base/memory/raw_span.h"
#include "base/numerics/byte_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/test/gtest_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

ElementsAre;
ElementsAreArray;
Eq;
Pointwise;

namespace base {

namespace {

// Tests for span(It, StrictNumeric<size_t>) deduction guide. These tests use a
// helper function to wrap the static_asserts, as most STL containers don't work
// well in a constexpr context. std::array<T, N> does, but base::span has
// specific overloads for std::array<T, n>, so that ends up being less helpful
// than it would initially appear.
//
// Another alternative would be to use std::declval, but that would be fairly
// verbose.
[[maybe_unused]] void TestDeductionGuides() {}

}  // namespace

TEST(SpanTest, DefaultConstructor) {}

TEST(SpanTest, ConstructFromDataAndSize) {}

TEST(SpanTest, ConstructFromDataAndZeroSize) {}

TEST(SpanTest, ConstructFromIterAndSize) {}

TEST(SpanTest, ConstructFromIterPair) {}

TEST(SpanTest, AllowedConversionsFromStdArray) {}

TEST(SpanTest, DisallowedConstructionsFromStdArray) {}

TEST(SpanTest, ConstructFromConstexprArray) {}

TEST(SpanTest, ConstructFromArray) {}

TEST(SpanTest, ConstructFromVolatileArray) {}

TEST(SpanTest, ConstructFromStdArray) {}

TEST(SpanTest, ConstructFromInitializerList) {}

TEST(SpanTest, ConstructFromStdString) {}

TEST(SpanTest, ConstructFromConstContainer) {}

TEST(SpanTest, ConstructFromContainer) {}

TEST(SpanTest, ConstructFromRange) {}

TEST(SpanTest, FromRefOfMutableStackVariable) {}

TEST(SpanTest, FromRefOfConstStackVariable) {}

TEST(SpanTest, FromCString) {}

TEST(SpanTest, FromCStringEmpty) {}

TEST(SpanTest, FromCStringEmbeddedNul) {}

TEST(SpanTest, FromCStringOtherTypes) {}

TEST(SpanTest, ConvertNonConstIntegralToConst) {}

TEST(SpanTest, ConvertNonConstPointerToConst) {}

TEST(SpanTest, ConvertBetweenEquivalentTypes) {}

TEST(SpanTest, TemplatedFirst) {}

TEST(SpanTest, TemplatedLast) {}

TEST(SpanTest, TemplatedSubspan) {}

TEST(SpanTest, SubscriptedBeginIterator) {}

TEST(SpanTest, TemplatedFirstOnDynamicSpan) {}

TEST(SpanTest, TemplatedLastOnDynamicSpan) {}

TEST(SpanTest, TemplatedSubspanFromDynamicSpan) {}

TEST(SpanTest, First) {}

TEST(SpanTest, Last) {}

TEST(SpanTest, Subspan) {}

TEST(SpanTest, ToFixedExtent) {}

TEST(SpanTest, Size) {}

TEST(SpanTest, SizeBytes) {}

TEST(SpanTest, Empty) {}

TEST(SpanTest, OperatorAt) {}

TEST(SpanTest, Front) {}

TEST(SpanTest, Back) {}

TEST(SpanTest, Iterator) {}

TEST(SpanTest, ConstexprIterator) {}

TEST(SpanTest, ReverseIterator) {}

TEST(SpanTest, AsBytes) {}

TEST(SpanTest, AsWritableBytes) {}

TEST(SpanTest, AsChars) {}

TEST(SpanTest, AsWritableChars) {}

TEST(SpanTest, AsByteSpan) {}

TEST(SpanTest, AsWritableByteSpan) {}

TEST(SpanTest, AsStringView) {}

TEST(SpanTest, MakeSpanFromDataAndSize) {}

TEST(SpanTest, MakeSpanFromPointerPair) {}

TEST(SpanTest, MakeSpanFromConstexprArray) {}

TEST(SpanTest, MakeSpanFromStdArray) {}

TEST(SpanTest, MakeSpanFromConstContainer) {}

TEST(SpanTest, MakeSpanFromContainer) {}

TEST(SpanTest, MakeSpanFromRValueContainer) {}

TEST(SpanTest, MakeSpanFromDynamicSpan) {}

TEST(SpanTest, MakeSpanFromStaticSpan) {}

TEST(SpanTest, EnsureConstexprGoodness) {}

TEST(SpanTest, OutOfBoundsDeath) {}

TEST(SpanTest, IteratorIsRangeMoveSafe) {}

TEST(SpanTest, Sort) {}

TEST(SpanTest, SpanExtentConversions) {}

TEST(SpanTest, IteratorConversions) {}

TEST(SpanTest, ExtentMacro) {}

TEST(SpanTest, CopyFrom) {}

TEST(SpanTest, CopyFromNonoverlapping) {}

TEST(SpanTest, CopyFromConversion) {}

TEST(SpanTest, CopyPrefixFrom) {}

TEST(SpanTest, SplitAt) {}

TEST(SpanTest, CompareEquality) {}

TEST(SpanTest, CompareOrdered) {}

TEST(SpanTest, GMockMacroCompatibility) {}

TEST(SpanTest, GTestMacroCompatibility) {}

// These are all examples from //docs/unsafe_buffers.md, copied here to ensure
// they compile.
TEST(SpanTest, Example_UnsafeBuffersPatterns) {}

TEST(SpanTest, Printing) {}

}  // namespace base

// Test for compatibility with std::span<>, in case some third-party
// API decides to use it. The size() and data() convention should mean
// that everyone's spans are compatible with each other.
TEST(SpanTest, FromStdSpan) {}

TEST(SpanTest, ToStdSpan) {}