Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-09 09:40:44

0001 // Copyright 2017 The Abseil Authors.
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 //      https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 
0015 // Testing utilities for ABSL types which throw exceptions.
0016 
0017 #ifndef ABSL_BASE_INTERNAL_EXCEPTION_TESTING_H_
0018 #define ABSL_BASE_INTERNAL_EXCEPTION_TESTING_H_
0019 
0020 #include "gtest/gtest.h"
0021 #include "absl/base/config.h"
0022 
0023 // ABSL_BASE_INTERNAL_EXPECT_FAIL tests either for a specified thrown exception
0024 // if exceptions are enabled, or for death with a specified text in the error
0025 // message
0026 #ifdef ABSL_HAVE_EXCEPTIONS
0027 
0028 #define ABSL_BASE_INTERNAL_EXPECT_FAIL(expr, exception_t, text) \
0029   EXPECT_THROW(expr, exception_t)
0030 
0031 #elif defined(__ANDROID__)
0032 // Android asserts do not log anywhere that gtest can currently inspect.
0033 // So we expect exit, but cannot match the message.
0034 #define ABSL_BASE_INTERNAL_EXPECT_FAIL(expr, exception_t, text) \
0035   EXPECT_DEATH(expr, ".*")
0036 #else
0037 #define ABSL_BASE_INTERNAL_EXPECT_FAIL(expr, exception_t, text) \
0038   EXPECT_DEATH_IF_SUPPORTED(expr, text)
0039 
0040 #endif
0041 
0042 #endif  // ABSL_BASE_INTERNAL_EXCEPTION_TESTING_H_