xref: /aosp_15_r20/external/cronet/base/files/file_error_or_unittest.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/files/file_error_or.h"
6 
7 #include "base/test/gmock_expected_support.h"
8 #include "base/types/expected.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 
11 namespace base {
12 namespace {
13 
TEST(FileErrorOrDeathTest,Error)14 TEST(FileErrorOrDeathTest, Error) {
15   FileErrorOr<int> error = unexpected(File::Error::FILE_ERROR_FAILED);
16   EXPECT_THAT(error, test::ErrorIs(File::Error::FILE_ERROR_FAILED));
17   EXPECT_DEATH_IF_SUPPORTED(error.value(), "");
18 }
19 
TEST(FileErrorOrDeathTest,Value)20 TEST(FileErrorOrDeathTest, Value) {
21   FileErrorOr<int> value = 42;
22   EXPECT_THAT(value, test::ValueIs(42));
23   EXPECT_DEATH_IF_SUPPORTED(value.error(), "");
24 }
25 
TEST(FileErrorOrDeathTest,ConstValue)26 TEST(FileErrorOrDeathTest, ConstValue) {
27   const FileErrorOr<int> const_value = 1234;
28   EXPECT_THAT(const_value, test::ValueIs(1234));
29   EXPECT_DEATH_IF_SUPPORTED(const_value.error(), "");
30 }
31 
32 }  // namespace
33 }  // namespace base
34