Coverage Report

Created: 2020-06-26 05:44

/home/arjun/llvm-project/llvm/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2015, Google Inc.
2
// All rights reserved.
3
//
4
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions are
6
// met:
7
//
8
//     * Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
//     * Redistributions in binary form must reproduce the above
11
// copyright notice, this list of conditions and the following disclaimer
12
// in the documentation and/or other materials provided with the
13
// distribution.
14
//     * Neither the name of Google Inc. nor the names of its
15
// contributors may be used to endorse or promote products derived from
16
// this software without specific prior written permission.
17
//
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
//
30
// This file provides an injection point for custom printers in a local
31
// installation of gTest.
32
// It will be included from gtest-printers.h and the overrides in this file
33
// will be visible to everyone.
34
// See documentation at gtest/gtest-printers.h for details on how to define a
35
// custom printer.
36
//
37
// ** Custom implementation starts here **
38
39
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
40
#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
41
42
#if !GTEST_NO_LLVM_SUPPORT
43
#include "llvm/ADT/SmallString.h"
44
#include "llvm/ADT/StringRef.h"
45
#include <ostream>
46
// Printing of llvm String types.
47
// gtest sees these as containers of char (they have nested iterator types),
48
// so their operator<< is never considered unless we provide PrintTo().
49
// PrintStringTo provides quotes and escaping, at the cost of a copy.
50
namespace llvm {
51
0
inline void PrintTo(llvm::StringRef S, std::ostream *OS) {
52
0
  *OS << ::testing::PrintToString(S.str());
53
0
}
54
// We need both SmallString<N> and SmallVectorImpl<char> overloads:
55
//  - the SmallString<N> template is needed as overload resolution will
56
//    instantiate generic PrintTo<T> rather than do derived-to-base conversion
57
//  - but SmallVectorImpl<char> is sometimes the actual static type, in code
58
//    that erases the small size
59
template <unsigned N>
60
inline void PrintTo(const SmallString<N> &S, std::ostream *OS) {
61
  *OS << ::testing::PrintToString(std::string(S.data(), S.size()));
62
}
63
0
inline void PrintTo(const SmallVectorImpl<char> &S, std::ostream *OS) {
64
0
  *OS << ::testing::PrintToString(std::string(S.data(), S.size()));
65
0
}
66
} // namespace llvm
67
#endif // !GTEST_NO_LLVM_SUPPORT
68
69
#endif  // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_