2 * Copyright (c) Meta Platforms, Inc. and affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <folly/portability/GTest.h>
18 #include <thrift/lib/cpp2/BoxedValuePtr.h>
20 using namespace apache::thrift::detail
;
22 TEST(BoxedValuePtrTest
, DefaultConstructor
) {
23 boxed_value_ptr
<int> a
;
24 EXPECT_FALSE(static_cast<bool>(a
));
27 TEST(BoxedValuePtrTest
, Constructor
) {
28 boxed_value_ptr
<int> a(5);
32 TEST(BoxedValuePtrTest
, CopyConstructor
) {
33 boxed_value_ptr
<int> a(5);
34 boxed_value_ptr
<int> b(a
);
39 TEST(BoxedValuePtrTest
, CopyAssignment
) {
40 boxed_value_ptr
<int> a(5);
41 boxed_value_ptr
<int> b
;
47 TEST(BoxedValuePtrTest
, MoveConstructor
) {
48 boxed_value_ptr
<int> a(5);
49 boxed_value_ptr
<int> b(std::move(a
));
53 TEST(BoxedValuePtrTest
, MoveAssignment
) {
54 boxed_value_ptr
<int> a(5);
55 boxed_value_ptr
<int> b
;
60 TEST(BoxedValuePtrTest
, EmptyAssignment
) {
61 boxed_value_ptr
<int> a
;
62 boxed_value_ptr
<int> b(5);
65 EXPECT_FALSE(static_cast<bool>(b
));
68 TEST(BoxedValuePtrTest
, Emplace
) {
69 boxed_value_ptr
<int> a
;
76 TEST(LazyPtrRest
, Reset
) {
77 boxed_value_ptr
<int> a(6);
79 EXPECT_FALSE(static_cast<bool>(a
));
82 TEST(BoxedValuePtrTest
, Assignment
) {
83 boxed_value_ptr
<int> a
;
88 TEST(BoxedValuePtrTest
, MoveOnlyType
) {
89 boxed_value_ptr
<std::unique_ptr
<int>> a
;
90 a
= std::make_unique
<int>(5);
92 boxed_value_ptr
<std::unique_ptr
<int>> b(std::move(a
));
96 TEST(BoxedValuePtrTest
, Swap
) {
97 boxed_value_ptr
<int> a(5);
98 boxed_value_ptr
<int> b(7);
104 TEST(BoxedValuePtrTest
, Equal
) {
105 boxed_value_ptr
<int> a
;
106 boxed_value_ptr
<int> b
;
109 EXPECT_FALSE(a
== b
);
111 EXPECT_FALSE(a
== b
);
113 EXPECT_FALSE(a
== b
);