chromium/base/types/optional_ref_unittest.cc

// Copyright 2022 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/types/optional_ref.h"

#include <cstddef>
#include <optional>
#include <type_traits>
#include <utility>

#include "base/test/gtest_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {

namespace {

// Construction from `std::nullptr_t` is disallowed; `std::nullopt` must be
// used to construct an empty `optional_ref`.
static_assert;

// No-compile asserts for various const -> mutable conversions.
static_assert;
static_assert;
static_assert;
static_assert;
static_assert;
static_assert;

// No-compile asserts for implicit conversions.
static_assert;
static_assert;
static_assert;
static_assert;
static_assert;

class ImplicitInt {};

static_assert;
static_assert;
static_assert;
static_assert;
static_assert;

class TestClass {};

TEST(OptionalRefTest, FromNullopt) {}

TEST(OptionalRefTest, FromConstEmptyOptional) {}

TEST(OptionalRefTest, FromMutableEmptyOptional) {}

TEST(OptionalRefTest, FromConstOptional) {}

TEST(OptionalRefTest, FromMutableOptional) {}

// The From*NullPointer tests intentionally avoid passing nullptr directly,
// which is explicitly disallowed to reduce ambiguity when constructing an empty
// `optional_ref`.
TEST(OptionalRefTest, FromConstNullPointer) {}

TEST(OptionalRefTest, FromMutableNullPointer) {}

TEST(OptionalRefTest, FromConstPointer) {}

TEST(OptionalRefTest, FromPointer) {}

TEST(OptionalRefTest, FromConstRef) {}

TEST(OptionalRefTest, FromMutableRef) {}

TEST(OptionalRefTest, FromConstValue) {}

TEST(OptionalRefTest, FromMutableValue) {}

TEST(OptionalRefTest, FromMutableEmptyOptionalRefTest) {}

TEST(OptionalRefTest, FromMutableOptionalRefTest) {}

TEST(OptionalRefTest, FromCopyConstructorConst) {}

TEST(OptionalRefTest, FromCopyConstructorMutable) {}

TEST(OptionalRefTest, Arrow) {}

TEST(OptionalRefTest, Star) {}

TEST(OptionalRefTest, BoolConversion) {}

TEST(OptionalRefTest, Value) {}

TEST(OptionalRefTest, AsPtr) {}

TEST(OptionalRefTest, CopyAsOptional) {}

TEST(OptionalRefTest, EqualityComparisonWithNullOpt) {}

TEST(OptionalRefTest, CompatibilityWithOptionalMatcher) {}

TEST(OptionalRefDeathTest, ArrowOnEmpty) {}

TEST(OptionalRefDeathTest, StarOnEmpty) {}

TEST(OptionalRefDeathTest, ValueOnEmpty) {}

TEST(OptionalRefTest, ClassTemplateArgumentDeduction) {}

}  // namespace

}  // namespace base