LCOV - code coverage report
Current view: top level - include/llvm/Testing/Support - SupportHelpers.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 13 13 100.0 %
Date: 2017-09-14 15:23:50 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- Testing/Support/SupportHelpers.h -----------------------------------===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #ifndef LLVM_TESTING_SUPPORT_SUPPORTHELPERS_H
      11             : #define LLVM_TESTING_SUPPORT_SUPPORTHELPERS_H
      12             : 
      13             : #include "llvm/ADT/StringRef.h"
      14             : #include "llvm/Support/Error.h"
      15             : #include "gtest/gtest-printers.h"
      16             : 
      17             : namespace llvm {
      18             : namespace detail {
      19        2349 : struct ErrorHolder {
      20             :   bool Success;
      21             :   std::string Message;
      22             : };
      23             : 
      24         405 : template <typename T> struct ExpectedHolder : public ErrorHolder {
      25             :   Optional<T *> Value;
      26             : };
      27             : 
      28         892 : inline void PrintTo(const ErrorHolder &Err, std::ostream *Out) {
      29         892 :   *Out << (Err.Success ? "succeeded" : "failed");
      30         892 :   if (!Err.Success) {
      31         396 :     *Out << "  (" << StringRef(Err.Message).trim().str() << ")";
      32             :   }
      33         892 : }
      34             : 
      35             : template <typename T>
      36          81 : void PrintTo(const ExpectedHolder<T> &Item, std::ostream *Out) {
      37          81 :   if (Item.Success) {
      38         240 :     *Out << "succeeded with value \"" << ::testing::PrintToString(**Item.Value)
      39         320 :          << "\"";
      40             :   } else {
      41           1 :     PrintTo(static_cast<const ErrorHolder &>(Item), Out);
      42             :   }
      43          81 : }
      44             : } // namespace detail
      45             : } // namespace llvm
      46             : 
      47             : #endif

Generated by: LCOV version 1.13