From 5aa5d282eac56a21e74611c1cdbaa97bb5db2dca Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 8 Feb 2022 02:05:36 +0300 Subject: chore(3p/abseil_cpp): unvendor abseil_cpp we weren't actually using these sources anymore, okay? Change-Id: If701571d9716de308d3512e1eb22c35db0877a66 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5248 Tested-by: BuildkiteCI Reviewed-by: grfn Autosubmit: tazjin --- third_party/abseil_cpp/absl/base/bit_cast_test.cc | 109 ---------------------- 1 file changed, 109 deletions(-) delete mode 100644 third_party/abseil_cpp/absl/base/bit_cast_test.cc (limited to 'third_party/abseil_cpp/absl/base/bit_cast_test.cc') diff --git a/third_party/abseil_cpp/absl/base/bit_cast_test.cc b/third_party/abseil_cpp/absl/base/bit_cast_test.cc deleted file mode 100644 index 8a3a41ea0231..000000000000 --- a/third_party/abseil_cpp/absl/base/bit_cast_test.cc +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Unit test for bit_cast template. - -#include -#include - -#include "gtest/gtest.h" -#include "absl/base/casts.h" -#include "absl/base/macros.h" - -namespace absl { -ABSL_NAMESPACE_BEGIN -namespace { - -template -struct marshall { char buf[N]; }; - -template -void TestMarshall(const T values[], int num_values) { - for (int i = 0; i < num_values; ++i) { - T t0 = values[i]; - marshall m0 = absl::bit_cast >(t0); - T t1 = absl::bit_cast(m0); - marshall m1 = absl::bit_cast >(t1); - ASSERT_EQ(0, memcmp(&t0, &t1, sizeof(T))); - ASSERT_EQ(0, memcmp(&m0, &m1, sizeof(T))); - } -} - -// Convert back and forth to an integral type. The C++ standard does -// not guarantee this will work, but we test that this works on all the -// platforms we support. -// -// Likewise, we below make assumptions about sizeof(float) and -// sizeof(double) which the standard does not guarantee, but which hold on the -// platforms we support. - -template -void TestIntegral(const T values[], int num_values) { - for (int i = 0; i < num_values; ++i) { - T t0 = values[i]; - I i0 = absl::bit_cast(t0); - T t1 = absl::bit_cast(i0); - I i1 = absl::bit_cast(t1); - ASSERT_EQ(0, memcmp(&t0, &t1, sizeof(T))); - ASSERT_EQ(i0, i1); - } -} - -TEST(BitCast, Bool) { - static const bool bool_list[] = { false, true }; - TestMarshall(bool_list, ABSL_ARRAYSIZE(bool_list)); -} - -TEST(BitCast, Int32) { - static const int32_t int_list[] = - { 0, 1, 100, 2147483647, -1, -100, -2147483647, -2147483647-1 }; - TestMarshall(int_list, ABSL_ARRAYSIZE(int_list)); -} - -TEST(BitCast, Int64) { - static const int64_t int64_list[] = - { 0, 1, 1LL << 40, -1, -(1LL<<40) }; - TestMarshall(int64_list, ABSL_ARRAYSIZE(int64_list)); -} - -TEST(BitCast, Uint64) { - static const uint64_t uint64_list[] = - { 0, 1, 1LLU << 40, 1LLU << 63 }; - TestMarshall(uint64_list, ABSL_ARRAYSIZE(uint64_list)); -} - -TEST(BitCast, Float) { - static const float float_list[] = - { 0.0f, 1.0f, -1.0f, 10.0f, -10.0f, - 1e10f, 1e20f, 1e-10f, 1e-20f, - 2.71828f, 3.14159f }; - TestMarshall(float_list, ABSL_ARRAYSIZE(float_list)); - TestIntegral(float_list, ABSL_ARRAYSIZE(float_list)); - TestIntegral(float_list, ABSL_ARRAYSIZE(float_list)); -} - -TEST(BitCast, Double) { - static const double double_list[] = - { 0.0, 1.0, -1.0, 10.0, -10.0, - 1e10, 1e100, 1e-10, 1e-100, - 2.718281828459045, - 3.141592653589793238462643383279502884197169399375105820974944 }; - TestMarshall(double_list, ABSL_ARRAYSIZE(double_list)); - TestIntegral(double_list, ABSL_ARRAYSIZE(double_list)); - TestIntegral(double_list, ABSL_ARRAYSIZE(double_list)); -} - -} // namespace -ABSL_NAMESPACE_END -} // namespace absl -- cgit 1.4.1