Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
gtest-test-part.cc
Go to the documentation of this file.
1// Copyright 2008, 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// Author: mheule@google.com (Markus Heule)
31//
32// The Google C++ Testing and Mocking Framework (Google Test)
33
36
37namespace testing {
38
40
41// Gets the summary of the failure message by omitting the stack trace
42// in it.
43std::string TestPartResult::ExtractSummary(const char* message) {
44 const char* const stack_trace = strstr(message, internal::kStackTraceMarker);
45 return stack_trace == NULL ? message :
46 std::string(message, stack_trace);
47}
48
49// Prints a TestPartResult object.
50std::ostream& operator<<(std::ostream& os, const TestPartResult& result) {
51 return os
52 << result.file_name() << ":" << result.line_number() << ": "
53 << (result.type() == TestPartResult::kSuccess ? "Success" :
54 result.type() == TestPartResult::kFatalFailure ? "Fatal failure" :
55 "Non-fatal failure") << ":\n"
56 << result.message() << std::endl;
57}
58
59// Appends a TestPartResult to the array.
61 array_.push_back(result);
62}
63
64// Returns the TestPartResult at the given index (0-based).
66 if (index < 0 || index >= size()) {
67 printf("\nInvalid index (%d) into TestPartResultArray.\n", index);
69 }
70
71 return array_[index];
72}
73
74// Returns the number of TestPartResult objects in the array.
76 return static_cast<int>(array_.size());
77}
78
79namespace internal {
80
82 : has_new_fatal_failure_(false),
83 original_reporter_(GetUnitTestImpl()->
84 GetTestPartResultReporterForCurrentThread()) {
86}
87
92
94 const TestPartResult& result) {
95 if (result.fatally_failed())
96 has_new_fatal_failure_ = true;
97 original_reporter_->ReportTestPartResult(result);
98}
99
100} // namespace internal
101
102} // namespace testing
const char * message() const
Definition gtest.h:314
void Append(const TestPartResult &result)
const TestPartResult & GetTestPartResult(int index) const
const char * message() const
virtual void ReportTestPartResult(const TestPartResult &result)=0
virtual void ReportTestPartResult(const TestPartResult &result)
void SetTestPartResultReporterForCurrentThread(TestPartResultReporterInterface *reporter)
Definition gtest.cc:738
os_t os
class UnitTestImpl * GetUnitTestImpl()
GTEST_API_ const char kStackTraceMarker[]
Definition gtest.cc:179
std::ostream & operator<<(std::ostream &os, const Matcher< T > &matcher)