Commit 8db6cfd1 by Abseil Team Committed by misterg

Changes imported from Abseil "staging" branch:

  - 8bcd472c6f1a7c8a3a7aac07d7e5e3f90685fe5e Create an exception-safety testing framework for Abseil by Jon Cohen <cohenjon@google.com>
  - 17cc4bb19ba86e2bc45e9381bd07450c06134903 Fix typo. by Abseil Team <absl-team@google.com>

GitOrigin-RevId: 8bcd472c6f1a7c8a3a7aac07d7e5e3f90685fe5e
Change-Id: Ia1f4f12d25c375e0af34fea052a4a82dc964eeff
parent c8bd28c5
......@@ -226,6 +226,37 @@ cc_library(
],
)
cc_library(
name = "pretty_function",
hdrs = ["internal/pretty_function.h"],
)
cc_library(
name = "exception_safety_testing",
testonly = 1,
srcs = ["internal/exception_safety_testing.cc"],
hdrs = ["internal/exception_safety_testing.h"],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
deps = [
":config",
":pretty_function",
"//absl/meta:type_traits",
"//absl/strings",
"@com_google_googletest//:gtest",
],
)
cc_test(
name = "exception_safety_testing_test",
srcs = ["exception_safety_testing_test.cc"],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
deps = [
":exception_safety_testing",
"//absl/memory",
"@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "invoke_test",
size = "small",
......
......@@ -260,7 +260,7 @@
// ABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED
//
// Tells the UndefinedSanitizer to ignore a given function. Useful for cases
// where certain behavior (eg. devision by zero) is being used intentionally.
// where certain behavior (eg. division by zero) is being used intentionally.
// NOTE: GCC supports UndefinedBehaviorSanitizer(ubsan) since 4.9.
// https://gcc.gnu.org/gcc-4.9/changes.html
#if defined(__GNUC__) && \
......
#include "absl/base/internal/exception_safety_testing.h"
#include "gtest/gtest.h"
#include "absl/meta/type_traits.h"
namespace absl {
namespace exceptions_internal {
int countdown = -1;
void MaybeThrow(absl::string_view msg) {
if (countdown-- == 0) throw TestException(msg);
}
testing::AssertionResult FailureMessage(const TestException& e,
int countdown) noexcept {
return testing::AssertionFailure()
<< "Exception number " << countdown + 1 << " thrown from " << e.what();
}
} // namespace exceptions_internal
} // namespace absl
#ifndef ABSL_BASE_INTERNAL_PRETTY_FUNCTION_H_
#define ABSL_BASE_INTERNAL_PRETTY_FUNCTION_H_
// ABSL_PRETTY_FUNCTION
//
// In C++11, __func__ gives the undecorated name of the current function. That
// is, "main", not "int main()". Various compilers give extra macros to get the
// decorated function name, including return type and arguments, to
// differentiate between overload sets. ABSL_PRETTY_FUNCTION is a portable
// version of these macros which forwards to the correct macro on each compiler.
#if defined(_MSC_VER)
#define ABSL_PRETTY_FUNCTION __FUNCSIG__
#elif defined(__GNUC__)
#define ABSL_PRETTY_FUNCTION __PRETTY_FUNCTION__
#else
#error "Unsupported compiler"
#endif
#endif // ABSL_BASE_INTERNAL_PRETTY_FUNCTION_H_
// 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
//
// http://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.
#ifndef ABSL_STRINGS_ASCII_CTYPE_H_
#define ABSL_STRINGS_ASCII_CTYPE_H_
#include "absl/strings/ascii.h"
inline bool ascii_isalpha(unsigned char c) {
return absl::ascii_isalpha(c);
}
inline bool ascii_isalnum(unsigned char c) {
return absl::ascii_isalnum(c);
}
inline bool ascii_isspace(unsigned char c) {
return absl::ascii_isspace(c);
}
inline bool ascii_ispunct(unsigned char c) {
return absl::ascii_ispunct(c);
}
inline bool ascii_isblank(unsigned char c) {
return absl::ascii_isblank(c);
}
inline bool ascii_iscntrl(unsigned char c) {
return absl::ascii_iscntrl(c);
}
inline bool ascii_isxdigit(unsigned char c) {
return absl::ascii_isxdigit(c);
}
inline bool ascii_isdigit(unsigned char c) {
return absl::ascii_isdigit(c);
}
inline bool ascii_isprint(unsigned char c) {
return absl::ascii_isprint(c);
}
inline bool ascii_isgraph(unsigned char c) {
return absl::ascii_isgraph(c);
}
inline bool ascii_isupper(unsigned char c) {
return absl::ascii_isupper(c);
}
inline bool ascii_islower(unsigned char c) {
return absl::ascii_islower(c);
}
inline bool ascii_isascii(unsigned char c) {
return absl::ascii_isascii(c);
}
inline char ascii_tolower(unsigned char c) {
return absl::ascii_tolower(c);
}
inline char ascii_toupper(unsigned char c) {
return absl::ascii_toupper(c);
}
#endif // ABSL_STRINGS_ASCII_CTYPE_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment