grpc
third_party
abseil-cpp
absl
base
abseil-cpp/absl/base/config_test.cc
Go to the documentation of this file.
1
// Copyright 2017 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/base/config.h"
16
17
#include <cstdint>
18
19
#include "gtest/gtest.h"
20
#include "absl/synchronization/internal/thread_pool.h"
21
22
namespace
{
23
24
TEST
(ConfigTest, Endianness) {
25
union
{
26
uint32_t
value
;
27
uint8_t
data
[
sizeof
(
uint32_t
)];
28
}
number
;
29
number
.data[0] = 0x00;
30
number
.data[1] = 0x01;
31
number
.data[2] = 0x02;
32
number
.data[3] = 0x03;
33
#if defined(ABSL_IS_LITTLE_ENDIAN) && defined(ABSL_IS_BIG_ENDIAN)
34
#error Both ABSL_IS_LITTLE_ENDIAN and ABSL_IS_BIG_ENDIAN are defined
35
#elif defined(ABSL_IS_LITTLE_ENDIAN)
36
EXPECT_EQ
(
UINT32_C
(0x03020100),
number
.value);
37
#elif defined(ABSL_IS_BIG_ENDIAN)
38
EXPECT_EQ
(
UINT32_C
(0x00010203),
number
.value);
39
#else
40
#error Unknown endianness
41
#endif
42
}
43
44
#if defined(ABSL_HAVE_THREAD_LOCAL)
45
TEST
(ConfigTest, ThreadLocal) {
46
static
thread_local
int
mine_mine_mine = 16;
47
EXPECT_EQ
(16, mine_mine_mine);
48
{
49
absl::synchronization_internal::ThreadPool
pool
(1);
50
pool
.Schedule([&] {
51
EXPECT_EQ
(16, mine_mine_mine);
52
mine_mine_mine = 32;
53
EXPECT_EQ
(32, mine_mine_mine);
54
});
55
}
56
EXPECT_EQ
(16, mine_mine_mine);
57
}
58
#endif
59
60
}
// namespace
absl::synchronization_internal::ThreadPool
Definition:
third_party/abseil-cpp/absl/synchronization/internal/thread_pool.h:33
uint8_t
unsigned char uint8_t
Definition:
stdint-msvc2008.h:78
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition:
iomgr/time_averaged_stats_test.cc:27
uint32_t
unsigned int uint32_t
Definition:
stdint-msvc2008.h:80
TEST
#define TEST(name, init_size,...)
Definition:
arena_test.cc:75
number
int32_t number
Definition:
bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:850
data
char data[kBufferLength]
Definition:
abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
value
const char * value
Definition:
hpack_parser_table.cc:165
UINT32_C
#define UINT32_C(val)
Definition:
stdint-msvc2008.h:237
pool
InternalDescriptorPool * pool
Definition:
bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:807
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:00