grpc
third_party
abseil-cpp
absl
container
internal
node_slot_policy_test.cc
Go to the documentation of this file.
1
// Copyright 2018 The Abseil Authors.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include "
absl/container/internal/node_slot_policy.h
"
16
17
#include <memory>
18
19
#include "gmock/gmock.h"
20
#include "gtest/gtest.h"
21
#include "absl/container/internal/hash_policy_traits.h"
22
23
namespace
absl
{
24
ABSL_NAMESPACE_BEGIN
25
namespace
container_internal {
26
namespace
{
27
28
using ::testing::Pointee
;
29
30
struct
Policy : node_slot_policy<int&, Policy> {
31
using
key_type
=
int
;
32
using
init_type =
int
;
33
34
template
<
class
Alloc>
35
static
int
* new_element(
Alloc
*
alloc
,
int
value
) {
36
return
new
int
(
value
);
37
}
38
39
template
<
class
Alloc>
40
static
void
delete_element(
Alloc
*
alloc
,
int
*
elem
) {
41
delete
elem
;
42
}
43
};
44
45
using
NodePolicy = hash_policy_traits<Policy>;
46
47
struct
NodeTest :
::testing::Test
{
48
std::allocator<int>
alloc
;
49
int
n
= 53;
50
int
*
a
= &
n
;
51
};
52
53
TEST_F
(NodeTest, ConstructDestroy) {
54
NodePolicy::construct
(&
alloc
, &
a
, 42);
55
EXPECT_THAT
(
a
,
Pointee
(42));
56
NodePolicy::destroy
(&
alloc
, &
a
);
57
}
58
59
TEST_F
(NodeTest,
transfer
) {
60
int
s
= 42;
61
int
*
b
= &
s
;
62
NodePolicy::transfer
(&
alloc
, &a, &
b
);
63
EXPECT_EQ
(&s, a);
64
}
65
66
}
// namespace
67
}
// namespace container_internal
68
ABSL_NAMESPACE_END
69
}
// namespace absl
alloc
std::allocator< int > alloc
Definition:
node_slot_policy_test.cc:48
testing::Pointee
internal::PointeeMatcher< InnerMatcher > Pointee(const InnerMatcher &inner_matcher)
Definition:
cares/cares/test/gmock-1.8.0/gmock/gmock.h:8691
EXPECT_THAT
#define EXPECT_THAT(value, matcher)
elem
Timer elem
Definition:
event_engine/iomgr_event_engine/timer_heap_test.cc:109
absl::FormatConversionChar::s
@ s
a
int a
Definition:
abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
ABSL_NAMESPACE_END
#define ABSL_NAMESPACE_END
Definition:
third_party/abseil-cpp/absl/base/config.h:171
testing::Test
Definition:
bloaty/third_party/googletest/googletest/include/gtest/gtest.h:402
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition:
iomgr/time_averaged_stats_test.cc:27
ABSL_NAMESPACE_BEGIN
#define ABSL_NAMESPACE_BEGIN
Definition:
third_party/abseil-cpp/absl/base/config.h:170
xds_interop_client.int
int
Definition:
xds_interop_client.py:113
absl::flags_internal::Alloc
void * Alloc(FlagOpFn op)
Definition:
abseil-cpp/absl/flags/internal/flag.h:102
b
uint64_t b
Definition:
abseil-cpp/absl/container/internal/layout_test.cc:53
transfer
static std::function< void(void *, Slot *, Slot *)> transfer
Definition:
abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:58
n
int n
Definition:
abseil-cpp/absl/container/btree_test.cc:1080
value
const char * value
Definition:
hpack_parser_table.cc:165
construct
static std::function< void(void *, Slot *, Slot)> construct
Definition:
abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:41
node_slot_policy.h
absl
Definition:
abseil-cpp/absl/algorithm/algorithm.h:31
key_type
upb_fieldtype_t key_type
Definition:
bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1071
destroy
static std::function< void(void *, Slot *)> destroy
Definition:
abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:42
TEST_F
#define TEST_F(test_fixture, test_name)
Definition:
bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2367
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:32