tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_helpers.h (2323B)


      1 // Copyright 2022 The Abseil Authors.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //      https://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 //
     15 // -----------------------------------------------------------------------------
     16 // File: log/internal/test_helpers.h
     17 // -----------------------------------------------------------------------------
     18 //
     19 // This file declares testing helpers for the logging library.
     20 
     21 #ifndef ABSL_LOG_INTERNAL_TEST_HELPERS_H_
     22 #define ABSL_LOG_INTERNAL_TEST_HELPERS_H_
     23 
     24 #include "gtest/gtest.h"
     25 #include "absl/base/config.h"
     26 #include "absl/base/log_severity.h"
     27 #include "absl/log/globals.h"
     28 
     29 namespace absl {
     30 ABSL_NAMESPACE_BEGIN
     31 namespace log_internal {
     32 
     33 // `ABSL_MIN_LOG_LEVEL` can't be used directly since it is not always defined.
     34 constexpr auto kAbslMinLogLevel =
     35 #ifdef ABSL_MIN_LOG_LEVEL
     36    static_cast<absl::LogSeverityAtLeast>(ABSL_MIN_LOG_LEVEL);
     37 #else
     38    absl::LogSeverityAtLeast::kInfo;
     39 #endif
     40 
     41 // Returns false if the specified severity level is disabled by
     42 // `ABSL_MIN_LOG_LEVEL` or `absl::MinLogLevel()`.
     43 bool LoggingEnabledAt(absl::LogSeverity severity);
     44 
     45 // -----------------------------------------------------------------------------
     46 // Googletest Death Test Predicates
     47 // -----------------------------------------------------------------------------
     48 
     49 #if GTEST_HAS_DEATH_TEST
     50 
     51 bool DiedOfFatal(int exit_status);
     52 bool DiedOfQFatal(int exit_status);
     53 
     54 #endif
     55 
     56 // -----------------------------------------------------------------------------
     57 // Helper for Log initialization in test
     58 // -----------------------------------------------------------------------------
     59 
     60 class LogTestEnvironment : public ::testing::Environment {
     61 public:
     62  ~LogTestEnvironment() override = default;
     63 
     64  void SetUp() override;
     65 };
     66 
     67 }  // namespace log_internal
     68 ABSL_NAMESPACE_END
     69 }  // namespace absl
     70 
     71 #endif  // ABSL_LOG_INTERNAL_TEST_HELPERS_H_