chromium/components/performance_manager/resource_attribution/type_helpers_unittest.cc

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

#include "components/performance_manager/public/resource_attribution/type_helpers.h"

#include <optional>
#include <type_traits>
#include <vector>

#include "base/types/optional_ref.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/variant.h"

namespace resource_attribution::internal {

namespace {

// gtest EXPECT macros interpret spaces as parameter breaks, so won't compile
// with parameters like "IsVariantAlternative<T, V>". This class wraps functions
// in type_helpers.h in methods that take only a single template param.
template <typename V>
class VariantTester {};

template <typename T>
::testing::AssertionResult TestOptionalConstRef(base::optional_ref<T> opt_ref,
                                                auto expected_value) {}

TEST(ResourceAttrTypeHelpersTest, IsVariantAlternativeEmptyVariant) {}

TEST(ResourceAttrTypeHelpersTest, IsVariantAlternativeSingleAlternative) {}

TEST(ResourceAttrTypeHelpersTest, IsVariantAlternativeManyAlternatives) {}

TEST(ResourceAttrTypeHelpersTest, IsVariantAlternativeWithMonostate) {}

// Can't test GetAsOptional() with absl::variant<> because it can't be
// instantiated.

TEST(ResourceAttrTypeHelpersTest, GetAsOptionalSingleAlternative) {}

TEST(ResourceAttrTypeHelpersTest, GetAsOptionalManyAlternatives) {}

TEST(ResourceAttrTypeHelpersTest, GetAsOptionalWithMonostate) {}

// Note: GetFromVariantVector returns `base::optional_ref`, which doesn't define
// all comparators, so need to match against the contained values.

TEST(ResourceAttrTypeHelpersTest, VariantVectorSingleAlternative) {}

TEST(ResourceAttrTypeHelpersTest, VariantVectorManyAlternatives) {}

TEST(ResourceAttrTypeHelpersTest, VariantVectorWithMonostate) {}

TEST(ResourceAttrTypeHelpersTest, VariantVectorConst) {}

// Can't test comparators with absl::variant<> because it can't be
// instantiated.

TEST(ResourceAttrTypeHelpersTest, VariantComparatorsSingleAlternative) {}

TEST(ResourceAttrTypeHelpersTest, VariantComparatorsManyAlternatives) {}

}  // namespace

}  // namespace resource_attribution::internal