tvl-depot/absl/base/internal/exception_safety_testing.cc
Abseil Team 4132ce2595 Changes imported from Abseil "staging" branch:
- 0a519d9a4507158267cc515e0c7c83959d94fc78 Fix missing header include when compiling with _GLIBCXX_D... by Alex Strelnikov <strel@google.com>
  - d089af70781d92af9a5de2d84c417ddf2c87689a Internal change by Gennadiy Rozental <rogeeff@google.com>
  - 0d3afc89d3907923ede964d58c6bcca579e8ad65 Test absl::any for exception safety.  This test is tempor... by Jon Cohen <cohenjon@google.com>
  - 29af424b8a3174a7b3e657e478aa30a8a425aee2 Tweak the ABSL type trait library and expand its tests. by Abseil Team <absl-team@google.com>
  - 99ab42b2ebbe466cc3730fb6b16b5fad848f95af Rollback GLIBCXX_DEBUG fix due to internal breakage. by Alex Strelnikov <strel@google.com>
  - 1a5bcb93ee16d4dd2170254e54c4b62b38fbf17b Internal change. by Abseil Team <absl-team@google.com>
  - 46de7d09c7d4aef5b7b5389ce9b4f96b654aac02 absl::string_view::rfind: doc fix. by Abseil Team <absl-team@google.com>
  - edda4c7ddd2d76fbb5b3fd5226b95082083c57d9 Fix string_view_test with c++17/clang/libc++ to address by Xiaoyi Zhang <zhangxy@google.com>

GitOrigin-RevId: 0a519d9a4507158267cc515e0c7c83959d94fc78
Change-Id: Ie27de1be3e79bba011f05e924d34e8fcc62d8de5
2018-01-08 10:38:50 -05:00

38 lines
1.3 KiB
C++

// 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.
#include "absl/base/internal/exception_safety_testing.h"
#include "gtest/gtest.h"
#include "absl/meta/type_traits.h"
namespace absl {
exceptions_internal::NoThrowTag no_throw_ctor;
namespace exceptions_internal {
int countdown = -1;
void MaybeThrow(absl::string_view msg, bool throw_bad_alloc) {
if (countdown-- == 0) {
if (throw_bad_alloc) throw TestBadAllocException(msg);
throw TestException(msg);
}
}
testing::AssertionResult FailureMessage(const TestException& e,
int countdown) noexcept {
return testing::AssertionFailure() << "Exception thrown from " << e.what();
}
} // namespace exceptions_internal
} // namespace absl