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 --- .../strings/internal/str_format/checker_test.cc | 170 --------------------- 1 file changed, 170 deletions(-) delete mode 100644 third_party/abseil_cpp/absl/strings/internal/str_format/checker_test.cc (limited to 'third_party/abseil_cpp/absl/strings/internal/str_format/checker_test.cc') diff --git a/third_party/abseil_cpp/absl/strings/internal/str_format/checker_test.cc b/third_party/abseil_cpp/absl/strings/internal/str_format/checker_test.cc deleted file mode 100644 index 7c70f47d682a..000000000000 --- a/third_party/abseil_cpp/absl/strings/internal/str_format/checker_test.cc +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright 2020 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. - -#include - -#include "gmock/gmock.h" -#include "gtest/gtest.h" -#include "absl/strings/str_format.h" - -namespace absl { -ABSL_NAMESPACE_BEGIN -namespace str_format_internal { -namespace { - -std::string ConvToString(FormatConversionCharSet conv) { - std::string out; -#define CONV_SET_CASE(c) \ - if (Contains(conv, FormatConversionCharSetInternal::c)) { \ - out += #c; \ - } - ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(CONV_SET_CASE, ) -#undef CONV_SET_CASE - if (Contains(conv, FormatConversionCharSetInternal::kStar)) { - out += "*"; - } - return out; -} - -TEST(StrFormatChecker, ArgumentToConv) { - FormatConversionCharSet conv = ArgumentToConv(); - EXPECT_EQ(ConvToString(conv), "s"); - - conv = ArgumentToConv(); - EXPECT_EQ(ConvToString(conv), "sp"); - - conv = ArgumentToConv(); - EXPECT_EQ(ConvToString(conv), "fFeEgGaA"); - - conv = ArgumentToConv(); - EXPECT_EQ(ConvToString(conv), "cdiouxXfFeEgGaA*"); - - conv = ArgumentToConv(); - EXPECT_EQ(ConvToString(conv), "p"); -} - -#ifdef ABSL_INTERNAL_ENABLE_FORMAT_CHECKER - -struct Case { - bool result; - const char* format; -}; - -template -constexpr Case ValidFormat(const char* format) { - return {ValidFormatImpl()...>(format), format}; -} - -TEST(StrFormatChecker, ValidFormat) { - // We want to make sure these expressions are constexpr and they have the - // expected value. - // If they are not constexpr the attribute will just ignore them and not give - // a compile time error. - enum e {}; - enum class e2 {}; - constexpr Case trues[] = { - ValidFormat<>("abc"), // - - ValidFormat("%d"), // - ValidFormat("%d"), // - ValidFormat("%% %d"), // - ValidFormat("%ld"), // - ValidFormat("%lld"), // - ValidFormat("%s"), // - ValidFormat("%10s"), // - ValidFormat("%.10x"), // - ValidFormat("%*.3x"), // - ValidFormat("%1.d"), // - ValidFormat("%.d"), // - ValidFormat("%d %g"), // - ValidFormat("%*s"), // - ValidFormat("%.*f"), // - ValidFormat("%p %p"), // - ValidFormat( - "string_view=%s const char*=%s double=%f void*=%p)"), - - ValidFormat("%% %1$d"), // - ValidFormat("%1$ld"), // - ValidFormat("%1$lld"), // - ValidFormat("%1$s"), // - ValidFormat("%1$10s"), // - ValidFormat("%1$.10x"), // - ValidFormat("%1$*1$.*1$d"), // - ValidFormat("%1$*2$.3x"), // - ValidFormat("%1$1.d"), // - ValidFormat("%1$.d"), // - ValidFormat("%2$d %1$g"), // - ValidFormat("%2$*1$s"), // - ValidFormat("%2$.*1$f"), // - ValidFormat( - "string_view=%2$s const char*=%3$s double=%4$f void*=%1$p " - "repeat=%3$s)")}; - - for (Case c : trues) { - EXPECT_TRUE(c.result) << c.format; - } - - constexpr Case falses[] = { - ValidFormat(""), // - - ValidFormat("%s"), // - ValidFormat("%s"), // - ValidFormat<>("%s"), // - ValidFormat<>("%r"), // - ValidFormat("%s"), // - ValidFormat("%.1.d"), // - ValidFormat("%*1d"), // - ValidFormat("%1-d"), // - ValidFormat("%*s"), // - ValidFormat("%*d"), // - ValidFormat("%p"), // - ValidFormat("%d"), // - - ValidFormat<>("%3$d"), // - ValidFormat<>("%1$r"), // - ValidFormat("%1$s"), // - ValidFormat("%1$.1.d"), // - ValidFormat("%1$*2$1d"), // - ValidFormat("%1$1-d"), // - ValidFormat("%2$*1$s"), // - ValidFormat("%1$p"), - - ValidFormat("%d %2$d"), // - }; - - for (Case c : falses) { - EXPECT_FALSE(c.result) << c.format; - } -} - -TEST(StrFormatChecker, LongFormat) { -#define CHARS_X_40 "1234567890123456789012345678901234567890" -#define CHARS_X_400 \ - CHARS_X_40 CHARS_X_40 CHARS_X_40 CHARS_X_40 CHARS_X_40 CHARS_X_40 CHARS_X_40 \ - CHARS_X_40 CHARS_X_40 CHARS_X_40 -#define CHARS_X_4000 \ - CHARS_X_400 CHARS_X_400 CHARS_X_400 CHARS_X_400 CHARS_X_400 CHARS_X_400 \ - CHARS_X_400 CHARS_X_400 CHARS_X_400 CHARS_X_400 - constexpr char long_format[] = - CHARS_X_4000 "%d" CHARS_X_4000 "%s" CHARS_X_4000; - constexpr bool is_valid = ValidFormat(long_format).result; - EXPECT_TRUE(is_valid); -} - -#endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER - -} // namespace -} // namespace str_format_internal -ABSL_NAMESPACE_END -} // namespace absl -- cgit 1.4.1