Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "absl/base/config.h"
00016
00017 #include <cstdint>
00018
00019 #include "gtest/gtest.h"
00020 #include "absl/synchronization/internal/thread_pool.h"
00021
00022 namespace {
00023
00024 TEST(ConfigTest, Endianness) {
00025 union {
00026 uint32_t value;
00027 uint8_t data[sizeof(uint32_t)];
00028 } number;
00029 number.data[0] = 0x00;
00030 number.data[1] = 0x01;
00031 number.data[2] = 0x02;
00032 number.data[3] = 0x03;
00033 #if defined(ABSL_IS_LITTLE_ENDIAN) && defined(ABSL_IS_BIG_ENDIAN)
00034 #error Both ABSL_IS_LITTLE_ENDIAN and ABSL_IS_BIG_ENDIAN are defined
00035 #elif defined(ABSL_IS_LITTLE_ENDIAN)
00036 EXPECT_EQ(UINT32_C(0x03020100), number.value);
00037 #elif defined(ABSL_IS_BIG_ENDIAN)
00038 EXPECT_EQ(UINT32_C(0x00010203), number.value);
00039 #else
00040 #error Unknown endianness
00041 #endif
00042 }
00043
00044 #if defined(ABSL_HAVE_THREAD_LOCAL)
00045 TEST(ConfigTest, ThreadLocal) {
00046 static thread_local int mine_mine_mine = 16;
00047 EXPECT_EQ(16, mine_mine_mine);
00048 {
00049 absl::synchronization_internal::ThreadPool pool(1);
00050 pool.Schedule([&] {
00051 EXPECT_EQ(16, mine_mine_mine);
00052 mine_mine_mine = 32;
00053 EXPECT_EQ(32, mine_mine_mine);
00054 });
00055 }
00056 EXPECT_EQ(16, mine_mine_mine);
00057 }
00058 #endif
00059
00060 }