chromium/base/types/expected_macros_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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "base/types/expected_macros.h"

#include <memory>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>

#include "base/test/gmock_expected_support.h"
#include "base/types/expected.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {
namespace {

expected<void, std::string> ReturnOk() {}

expected<int, std::string> ReturnValue(int v) {}

expected<int, std::string> ReturnError(std::string_view msg) {}

template <class... Args>
expected<std::tuple<Args...>, std::string> ReturnTupleValue(Args&&... v) {}

template <class... Args>
expected<std::tuple<Args...>, std::string> ReturnTupleError(
    std::string_view msg) {}

expected<std::unique_ptr<int>, std::string> ReturnPtrValue(int v) {}

expected<std::string, std::unique_ptr<int>> ReturnPtrError(int v) {}

TEST(ReturnIfError, Works) {}

TEST(ReturnIfError, WorksWithExpectedReturn) {}

TEST(ReturnIfError, WorksWithLambda) {}

TEST(ReturnIfError, WorksWithMoveOnlyType) {}

TEST(ReturnIfError, WorksWithMoveOnlyTypeAndExpectedReturn) {}

TEST(ReturnIfError, WorksWithAdaptorFunc) {}

TEST(ReturnIfError, WorksWithAdaptorFuncAndExpectedReturn) {}

TEST(ReturnIfError, WorksWithAdaptorFuncAndMoveOnlyType) {}

TEST(ReturnIfError, WorksWithAdaptorFuncAndMoveOnlyTypeAndExpectedReturn) {}

TEST(ReturnIfError, WorksWithVoidReturnAdaptor) {}

TEST(AssignOrReturn, Works) {}

TEST(AssignOrReturn, WorksWithExpectedReturn) {}

TEST(AssignOrReturn, WorksWithLambda) {}

TEST(AssignOrReturn, WorksWithMoveOnlyType) {}

TEST(AssignOrReturn, WorksWithMoveOnlyTypeAndExpectedReturn) {}

TEST(AssignOrReturn, WorksWithCommasInType) {}

TEST(AssignOrReturn, WorksWithStructuredBindings) {}

TEST(AssignOrReturn, WorksWithParenthesesAndDereference) {}

TEST(AssignOrReturn, WorksWithAdaptorFunc) {}

TEST(AssignOrReturn, WorksWithAdaptorFuncAndExpectedReturn) {}

TEST(AssignOrReturn, WorksWithAdaptorFuncAndMoveOnlyType) {}

TEST(AssignOrReturn, WorksWithAdaptorFuncAndMoveOnlyTypeAndExpectedReturn) {}

TEST(AssignOrReturn, WorksWithVoidReturnAdaptor) {}

TEST(AssignOrReturn, WorksWithThirdArgumentAndCommas) {}

TEST(AssignOrReturn, WorksWithAppendIncludingLocals) {}

TEST(AssignOrReturn, WorksForExistingVariable) {}

TEST(AssignOrReturn, UniquePtrWorks) {}

TEST(AssignOrReturn, UniquePtrWorksForExistingVariable) {}

}  // namespace
}  // namespace base