boringssl-with-bazel/src/third_party/googletest/src/gtest.cc
Go to the documentation of this file.
1 // Copyright 2005, 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 //
31 // The Google C++ Testing and Mocking Framework (Google Test)
32 
33 #include "gtest/gtest.h"
34 #include "gtest/internal/custom/gtest.h"
35 #include "gtest/gtest-spi.h"
36 
37 #include <ctype.h>
38 #include <stdarg.h>
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <time.h>
42 #include <wchar.h>
43 #include <wctype.h>
44 
45 #include <algorithm>
46 #include <chrono> // NOLINT
47 #include <cmath>
48 #include <cstdint>
49 #include <iomanip>
50 #include <limits>
51 #include <list>
52 #include <map>
53 #include <ostream> // NOLINT
54 #include <sstream>
55 #include <vector>
56 
57 #if GTEST_OS_LINUX
58 
59 # include <fcntl.h> // NOLINT
60 # include <limits.h> // NOLINT
61 # include <sched.h> // NOLINT
62 // Declares vsnprintf(). This header is not available on Windows.
63 # include <strings.h> // NOLINT
64 # include <sys/mman.h> // NOLINT
65 # include <sys/time.h> // NOLINT
66 # include <unistd.h> // NOLINT
67 # include <string>
68 
69 #elif GTEST_OS_ZOS
70 # include <sys/time.h> // NOLINT
71 
72 // On z/OS we additionally need strings.h for strcasecmp.
73 # include <strings.h> // NOLINT
74 
75 #elif GTEST_OS_WINDOWS_MOBILE // We are on Windows CE.
76 
77 # include <windows.h> // NOLINT
78 # undef min
79 
80 #elif GTEST_OS_WINDOWS // We are on Windows proper.
81 
82 # include <windows.h> // NOLINT
83 # undef min
84 
85 #ifdef _MSC_VER
86 # include <crtdbg.h> // NOLINT
87 #endif
88 
89 # include <io.h> // NOLINT
90 # include <sys/timeb.h> // NOLINT
91 # include <sys/types.h> // NOLINT
92 # include <sys/stat.h> // NOLINT
93 
94 # if GTEST_OS_WINDOWS_MINGW
95 # include <sys/time.h> // NOLINT
96 # endif // GTEST_OS_WINDOWS_MINGW
97 
98 #else
99 
100 // cpplint thinks that the header is already included, so we want to
101 // silence it.
102 # include <sys/time.h> // NOLINT
103 # include <unistd.h> // NOLINT
104 
105 #endif // GTEST_OS_LINUX
106 
107 #if GTEST_HAS_EXCEPTIONS
108 # include <stdexcept>
109 #endif
110 
111 #if GTEST_CAN_STREAM_RESULTS_
112 # include <arpa/inet.h> // NOLINT
113 # include <netdb.h> // NOLINT
114 # include <sys/socket.h> // NOLINT
115 # include <sys/types.h> // NOLINT
116 #endif
117 
118 #include "src/gtest-internal-inl.h"
119 
120 #if GTEST_OS_WINDOWS
121 # define vsnprintf _vsnprintf
122 #endif // GTEST_OS_WINDOWS
123 
124 #if GTEST_OS_MAC
125 #ifndef GTEST_OS_IOS
126 #include <crt_externs.h>
127 #endif
128 #endif
129 
130 #if GTEST_HAS_ABSL
131 #include "absl/debugging/failure_signal_handler.h"
132 #include "absl/debugging/stacktrace.h"
133 #include "absl/debugging/symbolize.h"
134 #include "absl/strings/str_cat.h"
135 #endif // GTEST_HAS_ABSL
136 
137 namespace testing {
138 
139 using internal::CountIf;
140 using internal::ForEach;
142 using internal::Shuffle;
143 
144 // Constants.
145 
146 // A test whose test suite name or test name matches this filter is
147 // disabled and not run.
148 static const char kDisableTestFilter[] = "DISABLED_*:*/DISABLED_*";
149 
150 // A test suite whose name matches this filter is considered a death
151 // test suite and will be run before test suites whose name doesn't
152 // match this filter.
153 static const char kDeathTestSuiteFilter[] = "*DeathTest:*DeathTest/*";
154 
155 // A test filter that matches everything.
156 static const char kUniversalFilter[] = "*";
157 
158 // The default output format.
159 static const char kDefaultOutputFormat[] = "xml";
160 // The default output file.
161 static const char kDefaultOutputFile[] = "test_detail";
162 
163 // The environment variable name for the test shard index.
164 static const char kTestShardIndex[] = "GTEST_SHARD_INDEX";
165 // The environment variable name for the total number of test shards.
166 static const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS";
167 // The environment variable name for the test shard status file.
168 static const char kTestShardStatusFile[] = "GTEST_SHARD_STATUS_FILE";
169 
170 namespace internal {
171 
172 // The text used in failure messages to indicate the start of the
173 // stack trace.
174 const char kStackTraceMarker[] = "\nStack trace:\n";
175 
176 // g_help_flag is true if and only if the --help flag or an equivalent form
177 // is specified on the command line.
178 bool g_help_flag = false;
179 
180 // Utilty function to Open File for Writing
181 static FILE* OpenFileForWriting(const std::string& output_file) {
182  FILE* fileout = nullptr;
183  FilePath output_file_path(output_file);
184  FilePath output_dir(output_file_path.RemoveFileName());
185 
186  if (output_dir.CreateDirectoriesRecursively()) {
187  fileout = posix::FOpen(output_file.c_str(), "w");
188  }
189  if (fileout == nullptr) {
190  GTEST_LOG_(FATAL) << "Unable to open file \"" << output_file << "\"";
191  }
192  return fileout;
193 }
194 
195 } // namespace internal
196 
197 // Bazel passes in the argument to '--test_filter' via the TESTBRIDGE_TEST_ONLY
198 // environment variable.
199 static const char* GetDefaultFilter() {
200  const char* const testbridge_test_only =
201  internal::posix::GetEnv("TESTBRIDGE_TEST_ONLY");
202  if (testbridge_test_only != nullptr) {
203  return testbridge_test_only;
204  }
205  return kUniversalFilter;
206 }
207 
208 // Bazel passes in the argument to '--test_runner_fail_fast' via the
209 // TESTBRIDGE_TEST_RUNNER_FAIL_FAST environment variable.
210 static bool GetDefaultFailFast() {
211  const char* const testbridge_test_runner_fail_fast =
212  internal::posix::GetEnv("TESTBRIDGE_TEST_RUNNER_FAIL_FAST");
213  if (testbridge_test_runner_fail_fast != nullptr) {
214  return strcmp(testbridge_test_runner_fail_fast, "1") == 0;
215  }
216  return false;
217 }
218 
220  fail_fast, internal::BoolFromGTestEnv("fail_fast", GetDefaultFailFast()),
221  "True if and only if a test failure should stop further test execution.");
222 
224  also_run_disabled_tests,
225  internal::BoolFromGTestEnv("also_run_disabled_tests", false),
226  "Run disabled tests too, in addition to the tests normally being run.");
227 
229  break_on_failure, internal::BoolFromGTestEnv("break_on_failure", false),
230  "True if and only if a failed assertion should be a debugger "
231  "break-point.");
232 
233 GTEST_DEFINE_bool_(catch_exceptions,
234  internal::BoolFromGTestEnv("catch_exceptions", true),
235  "True if and only if " GTEST_NAME_
236  " should catch exceptions and treat them as test failures.");
237 
239  color,
240  internal::StringFromGTestEnv("color", "auto"),
241  "Whether to use colors in the output. Valid values: yes, no, "
242  "and auto. 'auto' means to use colors if the output is "
243  "being sent to a terminal and the TERM environment variable "
244  "is set to a terminal type that supports colors.");
245 
247  filter,
249  "A colon-separated list of glob (not regex) patterns "
250  "for filtering the tests to run, optionally followed by a "
251  "'-' and a : separated list of negative patterns (tests to "
252  "exclude). A test is run if it matches one of the positive "
253  "patterns and does not match any of the negative patterns.");
254 
256  install_failure_signal_handler,
257  internal::BoolFromGTestEnv("install_failure_signal_handler", false),
258  "If true and supported on the current platform, " GTEST_NAME_ " should "
259  "install a signal handler that dumps debugging information when fatal "
260  "signals are raised.");
261 
262 GTEST_DEFINE_bool_(list_tests, false,
263  "List all tests without running them.");
264 
265 // The net priority order after flag processing is thus:
266 // --gtest_output command line flag
267 // GTEST_OUTPUT environment variable
268 // XML_OUTPUT_FILE environment variable
269 // ''
271  output,
274  "A format (defaults to \"xml\" but can be specified to be \"json\"), "
275  "optionally followed by a colon and an output file name or directory. "
276  "A directory is indicated by a trailing pathname separator. "
277  "Examples: \"xml:filename.xml\", \"xml::directoryname/\". "
278  "If a directory is specified, output files will be created "
279  "within that directory, with file-names based on the test "
280  "executable's name and, if necessary, made unique by adding "
281  "digits.");
282 
284  brief, internal::BoolFromGTestEnv("brief", false),
285  "True if only test failures should be displayed in text output.");
286 
287 GTEST_DEFINE_bool_(print_time, internal::BoolFromGTestEnv("print_time", true),
288  "True if and only if " GTEST_NAME_
289  " should display elapsed time in text output.");
290 
291 GTEST_DEFINE_bool_(print_utf8, internal::BoolFromGTestEnv("print_utf8", true),
292  "True if and only if " GTEST_NAME_
293  " prints UTF8 characters as text.");
294 
296  random_seed,
297  internal::Int32FromGTestEnv("random_seed", 0),
298  "Random number seed to use when shuffling test orders. Must be in range "
299  "[1, 99999], or 0 to use a seed based on the current time.");
300 
302  repeat,
303  internal::Int32FromGTestEnv("repeat", 1),
304  "How many times to repeat each test. Specify a negative number "
305  "for repeating forever. Useful for shaking out flaky tests.");
306 
307 GTEST_DEFINE_bool_(show_internal_stack_frames, false,
308  "True if and only if " GTEST_NAME_
309  " should include internal stack frames when "
310  "printing test failure stack traces.");
311 
312 GTEST_DEFINE_bool_(shuffle, internal::BoolFromGTestEnv("shuffle", false),
313  "True if and only if " GTEST_NAME_
314  " should randomize tests' order on every run.");
315 
317  stack_trace_depth,
318  internal::Int32FromGTestEnv("stack_trace_depth", kMaxStackTraceDepth),
319  "The maximum number of stack frames to print when an "
320  "assertion fails. The valid range is 0 through 100, inclusive.");
321 
323  stream_result_to,
324  internal::StringFromGTestEnv("stream_result_to", ""),
325  "This flag specifies the host name and the port number on which to stream "
326  "test results. Example: \"localhost:555\". The flag is effective only on "
327  "Linux.");
328 
330  throw_on_failure,
331  internal::BoolFromGTestEnv("throw_on_failure", false),
332  "When this flag is specified, a failed assertion will throw an exception "
333  "if exceptions are enabled or exit the program with a non-zero code "
334  "otherwise. For use with an external test framework.");
335 
336 #if GTEST_USE_OWN_FLAGFILE_FLAG_
338  flagfile,
339  internal::StringFromGTestEnv("flagfile", ""),
340  "This flag specifies the flagfile to read command-line flags from.");
341 #endif // GTEST_USE_OWN_FLAGFILE_FLAG_
342 
343 namespace internal {
344 
345 // Generates a random number from [0, range), using a Linear
346 // Congruential Generator (LCG). Crashes if 'range' is 0 or greater
347 // than kMaxRange.
349  // These constants are the same as are used in glibc's rand(3).
350  // Use wider types than necessary to prevent unsigned overflow diagnostics.
351  state_ = static_cast<uint32_t>(1103515245ULL*state_ + 12345U) % kMaxRange;
352 
353  GTEST_CHECK_(range > 0)
354  << "Cannot generate a number in the range [0, 0).";
356  << "Generation of a number in [0, " << range << ") was requested, "
357  << "but this can only generate numbers in [0, " << kMaxRange << ").";
358 
359  // Converting via modulus introduces a bit of downward bias, but
360  // it's simple, and a linear congruential generator isn't too good
361  // to begin with.
362  return state_ % range;
363 }
364 
365 // GTestIsInitialized() returns true if and only if the user has initialized
366 // Google Test. Useful for catching the user mistake of not initializing
367 // Google Test before calling RUN_ALL_TESTS().
368 static bool GTestIsInitialized() { return GetArgvs().size() > 0; }
369 
370 // Iterates over a vector of TestSuites, keeping a running sum of the
371 // results of calling a given int-returning method on each.
372 // Returns the sum.
373 static int SumOverTestSuiteList(const std::vector<TestSuite*>& case_list,
374  int (TestSuite::*method)() const) {
375  int sum = 0;
376  for (size_t i = 0; i < case_list.size(); i++) {
377  sum += (case_list[i]->*method)();
378  }
379  return sum;
380 }
381 
382 // Returns true if and only if the test suite passed.
383 static bool TestSuitePassed(const TestSuite* test_suite) {
384  return test_suite->should_run() && test_suite->Passed();
385 }
386 
387 // Returns true if and only if the test suite failed.
388 static bool TestSuiteFailed(const TestSuite* test_suite) {
389  return test_suite->should_run() && test_suite->Failed();
390 }
391 
392 // Returns true if and only if test_suite contains at least one test that
393 // should run.
395  return test_suite->should_run();
396 }
397 
398 // AssertHelper constructor.
400  const char* file,
401  int line,
402  const char* message)
403  : data_(new AssertHelperData(type, file, line, message)) {
404 }
405 
406 AssertHelper::~AssertHelper() {
407  delete data_;
408 }
409 
410 // Message assignment, for assertion streaming support.
411 void AssertHelper::operator=(const Message& message) const {
413  AddTestPartResult(data_->type, data_->file, data_->line,
414  AppendUserMessage(data_->message, message),
417  // Skips the stack frame for this function itself.
418  ); // NOLINT
419 }
420 
421 namespace {
422 
423 // When TEST_P is found without a matching INSTANTIATE_TEST_SUITE_P
424 // to creates test cases for it, a syntetic test case is
425 // inserted to report ether an error or a log message.
426 //
427 // This configuration bit will likely be removed at some point.
428 constexpr bool kErrorOnUninstantiatedParameterizedTest = true;
429 constexpr bool kErrorOnUninstantiatedTypeParameterizedTest = true;
430 
431 // A test that fails at a given file/line location with a given message.
432 class FailureTest : public Test {
433  public:
434  explicit FailureTest(const CodeLocation& loc, std::string error_message,
435  bool as_error)
436  : loc_(loc),
437  error_message_(std::move(error_message)),
438  as_error_(as_error) {}
439 
440  void TestBody() override {
441  if (as_error_) {
442  AssertHelper(TestPartResult::kNonFatalFailure, loc_.file.c_str(),
443  loc_.line, "") = Message() << error_message_;
444  } else {
445  std::cout << error_message_ << std::endl;
446  }
447  }
448 
449  private:
450  const CodeLocation loc_;
452  const bool as_error_;
453 };
454 
455 
456 } // namespace
457 
458 std::set<std::string>* GetIgnoredParameterizedTestSuites() {
460 }
461 
462 // Add a given test_suit to the list of them allow to go un-instantiated.
463 MarkAsIgnored::MarkAsIgnored(const char* test_suite) {
465 }
466 
467 // If this parameterized test suite has no instantiations (and that
468 // has not been marked as okay), emit a test case reporting that.
470  bool has_test_p) {
471  const auto& ignored = *GetIgnoredParameterizedTestSuites();
472  if (ignored.find(name) != ignored.end()) return;
473 
474  const char kMissingInstantiation[] = //
475  " is defined via TEST_P, but never instantiated. None of the test cases "
476  "will run. Either no INSTANTIATE_TEST_SUITE_P is provided or the only "
477  "ones provided expand to nothing."
478  "\n\n"
479  "Ideally, TEST_P definitions should only ever be included as part of "
480  "binaries that intend to use them. (As opposed to, for example, being "
481  "placed in a library that may be linked in to get other utilities.)";
482 
483  const char kMissingTestCase[] = //
484  " is instantiated via INSTANTIATE_TEST_SUITE_P, but no tests are "
485  "defined via TEST_P . No test cases will run."
486  "\n\n"
487  "Ideally, INSTANTIATE_TEST_SUITE_P should only ever be invoked from "
488  "code that always depend on code that provides TEST_P. Failing to do "
489  "so is often an indication of dead code, e.g. the last TEST_P was "
490  "removed but the rest got left behind.";
491 
493  "Parameterized test suite " + name +
494  (has_test_p ? kMissingInstantiation : kMissingTestCase) +
495  "\n\n"
496  "To suppress this error for this test suite, insert the following line "
497  "(in a non-header) in the namespace it is defined in:"
498  "\n\n"
499  "GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(" + name + ");";
500 
501  std::string full_name = "UninstantiatedParameterizedTestSuite<" + name + ">";
502  RegisterTest( //
503  "GoogleTestVerification", full_name.c_str(),
504  nullptr, // No type parameter.
505  nullptr, // No value parameter.
506  location.file.c_str(), location.line, [message, location] {
507  return new FailureTest(location, message,
508  kErrorOnUninstantiatedParameterizedTest);
509  });
510 }
511 
512 void RegisterTypeParameterizedTestSuite(const char* test_suite_name,
513  CodeLocation code_location) {
515  test_suite_name, code_location);
516 }
517 
521  .RegisterInstantiation(case_name);
522 }
523 
524 void TypeParameterizedTestSuiteRegistry::RegisterTestSuite(
525  const char* test_suite_name, CodeLocation code_location) {
526  suites_.emplace(std::string(test_suite_name),
527  TypeParameterizedTestSuiteInfo(code_location));
528 }
529 
530 void TypeParameterizedTestSuiteRegistry::RegisterInstantiation(
531  const char* test_suite_name) {
532  auto it = suites_.find(std::string(test_suite_name));
533  if (it != suites_.end()) {
534  it->second.instantiated = true;
535  } else {
536  GTEST_LOG_(ERROR) << "Unknown type parameterized test suit '"
537  << test_suite_name << "'";
538  }
539 }
540 
541 void TypeParameterizedTestSuiteRegistry::CheckForInstantiations() {
542  const auto& ignored = *GetIgnoredParameterizedTestSuites();
543  for (const auto& testcase : suites_) {
544  if (testcase.second.instantiated) continue;
545  if (ignored.find(testcase.first) != ignored.end()) continue;
546 
548  "Type parameterized test suite " + testcase.first +
549  " is defined via REGISTER_TYPED_TEST_SUITE_P, but never instantiated "
550  "via INSTANTIATE_TYPED_TEST_SUITE_P. None of the test cases will run."
551  "\n\n"
552  "Ideally, TYPED_TEST_P definitions should only ever be included as "
553  "part of binaries that intend to use them. (As opposed to, for "
554  "example, being placed in a library that may be linked in to get other "
555  "utilities.)"
556  "\n\n"
557  "To suppress this error for this test suite, insert the following line "
558  "(in a non-header) in the namespace it is defined in:"
559  "\n\n"
560  "GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(" +
561  testcase.first + ");";
562 
563  std::string full_name =
564  "UninstantiatedTypeParameterizedTestSuite<" + testcase.first + ">";
565  RegisterTest( //
566  "GoogleTestVerification", full_name.c_str(),
567  nullptr, // No type parameter.
568  nullptr, // No value parameter.
569  testcase.second.code_location.file.c_str(),
570  testcase.second.code_location.line, [message, testcase] {
571  return new FailureTest(testcase.second.code_location, message,
572  kErrorOnUninstantiatedTypeParameterizedTest);
573  });
574  }
575 }
576 
577 // A copy of all command line arguments. Set by InitGoogleTest().
578 static ::std::vector<std::string> g_argvs;
579 
580 ::std::vector<std::string> GetArgvs() {
581 #if defined(GTEST_CUSTOM_GET_ARGVS_)
582  // GTEST_CUSTOM_GET_ARGVS_() may return a container of std::string or
583  // ::string. This code converts it to the appropriate type.
584  const auto& custom = GTEST_CUSTOM_GET_ARGVS_();
585  return ::std::vector<std::string>(custom.begin(), custom.end());
586 #else // defined(GTEST_CUSTOM_GET_ARGVS_)
587  return g_argvs;
588 #endif // defined(GTEST_CUSTOM_GET_ARGVS_)
589 }
590 
591 // Returns the current application's name, removing directory path if that
592 // is present.
595 
596 #if GTEST_OS_WINDOWS || GTEST_OS_OS2
597  result.Set(FilePath(GetArgvs()[0]).RemoveExtension("exe"));
598 #else
599  result.Set(FilePath(GetArgvs()[0]));
600 #endif // GTEST_OS_WINDOWS
601 
602  return result.RemoveDirectoryName();
603 }
604 
605 // Functions for processing the gtest_output flag.
606 
607 // Returns the output format, or "" for normal printed output.
608 std::string UnitTestOptions::GetOutputFormat() {
609  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
610  const char* const colon = strchr(gtest_output_flag, ':');
611  return (colon == nullptr)
612  ? std::string(gtest_output_flag)
613  : std::string(gtest_output_flag,
614  static_cast<size_t>(colon - gtest_output_flag));
615 }
616 
617 // Returns the name of the requested output file, or the default if none
618 // was explicitly specified.
619 std::string UnitTestOptions::GetAbsolutePathToOutputFile() {
620  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
621 
622  std::string format = GetOutputFormat();
623  if (format.empty())
625 
626  const char* const colon = strchr(gtest_output_flag, ':');
627  if (colon == nullptr)
630  UnitTest::GetInstance()->original_working_dir()),
632  format.c_str()).string();
633 
634  internal::FilePath output_name(colon + 1);
635  if (!output_name.IsAbsolutePath())
636  output_name = internal::FilePath::ConcatPaths(
637  internal::FilePath(UnitTest::GetInstance()->original_working_dir()),
638  internal::FilePath(colon + 1));
639 
640  if (!output_name.IsDirectory())
641  return output_name.string();
642 
644  output_name, internal::GetCurrentExecutableName(),
645  GetOutputFormat().c_str()));
646  return result.string();
647 }
648 
649 // Returns true if and only if the wildcard pattern matches the string.
650 // The first ':' or '\0' character in pattern marks the end of it.
651 //
652 // This recursive algorithm isn't very efficient, but is clear and
653 // works well enough for matching test names, which are short.
655  const char *str) {
656  switch (*pattern) {
657  case '\0':
658  case ':': // Either ':' or '\0' marks the end of the pattern.
659  return *str == '\0';
660  case '?': // Matches any single character.
661  return *str != '\0' && PatternMatchesString(pattern + 1, str + 1);
662  case '*': // Matches any string (possibly empty) of characters.
663  return (*str != '\0' && PatternMatchesString(pattern, str + 1)) ||
665  default: // Non-special character. Matches itself.
666  return *pattern == *str &&
667  PatternMatchesString(pattern + 1, str + 1);
668  }
669 }
670 
671 bool UnitTestOptions::MatchesFilter(
672  const std::string& name, const char* filter) {
673  const char *cur_pattern = filter;
674  for (;;) {
675  if (PatternMatchesString(cur_pattern, name.c_str())) {
676  return true;
677  }
678 
679  // Finds the next pattern in the filter.
680  cur_pattern = strchr(cur_pattern, ':');
681 
682  // Returns if no more pattern can be found.
683  if (cur_pattern == nullptr) {
684  return false;
685  }
686 
687  // Skips the pattern separater (the ':' character).
688  cur_pattern++;
689  }
690 }
691 
692 // Returns true if and only if the user-specified filter matches the test
693 // suite name and the test name.
694 bool UnitTestOptions::FilterMatchesTest(const std::string& test_suite_name,
695  const std::string& test_name) {
696  const std::string& full_name = test_suite_name + "." + test_name.c_str();
697 
698  // Split --gtest_filter at '-', if there is one, to separate into
699  // positive filter and negative filter portions
700  const char* const p = GTEST_FLAG(filter).c_str();
701  const char* const dash = strchr(p, '-');
702  std::string positive;
704  if (dash == nullptr) {
705  positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter
706  negative = "";
707  } else {
708  positive = std::string(p, dash); // Everything up to the dash
709  negative = std::string(dash + 1); // Everything after the dash
710  if (positive.empty()) {
711  // Treat '-test1' as the same as '*-test1'
712  positive = kUniversalFilter;
713  }
714  }
715 
716  // A filter is a colon-separated list of patterns. It matches a
717  // test if any pattern in it matches the test.
718  return (MatchesFilter(full_name, positive.c_str()) &&
719  !MatchesFilter(full_name, negative.c_str()));
720 }
721 
722 #if GTEST_HAS_SEH
723 // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
724 // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
725 // This function is useful as an __except condition.
726 int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {
727  // Google Test should handle a SEH exception if:
728  // 1. the user wants it to, AND
729  // 2. this is not a breakpoint exception, AND
730  // 3. this is not a C++ exception (VC++ implements them via SEH,
731  // apparently).
732  //
733  // SEH exception code for C++ exceptions.
734  // (see http://support.microsoft.com/kb/185294 for more information).
735  const DWORD kCxxExceptionCode = 0xe06d7363;
736 
737  bool should_handle = true;
738 
739  if (!GTEST_FLAG(catch_exceptions))
740  should_handle = false;
741  else if (exception_code == EXCEPTION_BREAKPOINT)
742  should_handle = false;
743  else if (exception_code == kCxxExceptionCode)
744  should_handle = false;
745 
746  return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
747 }
748 #endif // GTEST_HAS_SEH
749 
750 } // namespace internal
751 
752 // The c'tor sets this object as the test part result reporter used by
753 // Google Test. The 'result' parameter specifies where to report the
754 // results. Intercepts only failures from the current thread.
755 ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(
756  TestPartResultArray* result)
757  : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD),
758  result_(result) {
759  Init();
760 }
761 
762 // The c'tor sets this object as the test part result reporter used by
763 // Google Test. The 'result' parameter specifies where to report the
764 // results.
766  InterceptMode intercept_mode, TestPartResultArray* result)
767  : intercept_mode_(intercept_mode),
768  result_(result) {
769  Init();
770 }
771 
773  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
774  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
775  old_reporter_ = impl->GetGlobalTestPartResultReporter();
776  impl->SetGlobalTestPartResultReporter(this);
777  } else {
778  old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();
779  impl->SetTestPartResultReporterForCurrentThread(this);
780  }
781 }
782 
783 // The d'tor restores the test part result reporter used by Google Test
784 // before.
786  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
787  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
788  impl->SetGlobalTestPartResultReporter(old_reporter_);
789  } else {
790  impl->SetTestPartResultReporterForCurrentThread(old_reporter_);
791  }
792 }
793 
794 // Increments the test part result count and remembers the result.
795 // This method is from the TestPartResultReporterInterface interface.
797  const TestPartResult& result) {
798  result_->Append(result);
799 }
800 
801 namespace internal {
802 
803 // Returns the type ID of ::testing::Test. We should always call this
804 // instead of GetTypeId< ::testing::Test>() to get the type ID of
805 // testing::Test. This is to work around a suspected linker bug when
806 // using Google Test as a framework on Mac OS X. The bug causes
807 // GetTypeId< ::testing::Test>() to return different values depending
808 // on whether the call is from the Google Test framework itself or
809 // from user test code. GetTestTypeId() is guaranteed to always
810 // return the same value, as it always calls GetTypeId<>() from the
811 // gtest.cc, which is within the Google Test framework.
813  return GetTypeId<Test>();
814 }
815 
816 // The value of GetTestTypeId() as seen from within the Google Test
817 // library. This is solely for testing GetTestTypeId().
819 
820 // This predicate-formatter checks that 'results' contains a test part
821 // failure of the given type and that the failure message contains the
822 // given substring.
823 static AssertionResult HasOneFailure(const char* /* results_expr */,
824  const char* /* type_expr */,
825  const char* /* substr_expr */,
828  const std::string& substr) {
830  "1 fatal failure" :
831  "1 non-fatal failure");
832  Message msg;
833  if (results.size() != 1) {
834  msg << "Expected: " << expected << "\n"
835  << " Actual: " << results.size() << " failures";
836  for (int i = 0; i < results.size(); i++) {
837  msg << "\n" << results.GetTestPartResult(i);
838  }
839  return AssertionFailure() << msg;
840  }
841 
842  const TestPartResult& r = results.GetTestPartResult(0);
843  if (r.type() != type) {
844  return AssertionFailure() << "Expected: " << expected << "\n"
845  << " Actual:\n"
846  << r;
847  }
848 
849  if (strstr(r.message(), substr.c_str()) == nullptr) {
850  return AssertionFailure() << "Expected: " << expected << " containing \""
851  << substr << "\"\n"
852  << " Actual:\n"
853  << r;
854  }
855 
856  return AssertionSuccess();
857 }
858 
859 // The constructor of SingleFailureChecker remembers where to look up
860 // test part results, what type of failure we expect, and what
861 // substring the failure message should contain.
864  const std::string& substr)
865  : results_(results), type_(type), substr_(substr) {}
866 
867 // The destructor of SingleFailureChecker verifies that the given
868 // TestPartResultArray contains exactly one failure that has the given
869 // type and contains the given substring. If that's not the case, a
870 // non-fatal failure will be generated.
871 SingleFailureChecker::~SingleFailureChecker() {
872  EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_);
873 }
874 
875 DefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter(
876  UnitTestImpl* unit_test) : unit_test_(unit_test) {}
877 
878 void DefaultGlobalTestPartResultReporter::ReportTestPartResult(
879  const TestPartResult& result) {
880  unit_test_->current_test_result()->AddTestPartResult(result);
881  unit_test_->listeners()->repeater()->OnTestPartResult(result);
882 }
883 
884 DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(
885  UnitTestImpl* unit_test) : unit_test_(unit_test) {}
886 
887 void DefaultPerThreadTestPartResultReporter::ReportTestPartResult(
888  const TestPartResult& result) {
889  unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result);
890 }
891 
892 // Returns the global test part result reporter.
893 TestPartResultReporterInterface*
894 UnitTestImpl::GetGlobalTestPartResultReporter() {
895  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
896  return global_test_part_result_repoter_;
897 }
898 
899 // Sets the global test part result reporter.
900 void UnitTestImpl::SetGlobalTestPartResultReporter(
901  TestPartResultReporterInterface* reporter) {
902  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
903  global_test_part_result_repoter_ = reporter;
904 }
905 
906 // Returns the test part result reporter for the current thread.
907 TestPartResultReporterInterface*
908 UnitTestImpl::GetTestPartResultReporterForCurrentThread() {
909  return per_thread_test_part_result_reporter_.get();
910 }
911 
912 // Sets the test part result reporter for the current thread.
913 void UnitTestImpl::SetTestPartResultReporterForCurrentThread(
914  TestPartResultReporterInterface* reporter) {
915  per_thread_test_part_result_reporter_.set(reporter);
916 }
917 
918 // Gets the number of successful test suites.
919 int UnitTestImpl::successful_test_suite_count() const {
920  return CountIf(test_suites_, TestSuitePassed);
921 }
922 
923 // Gets the number of failed test suites.
924 int UnitTestImpl::failed_test_suite_count() const {
925  return CountIf(test_suites_, TestSuiteFailed);
926 }
927 
928 // Gets the number of all test suites.
929 int UnitTestImpl::total_test_suite_count() const {
930  return static_cast<int>(test_suites_.size());
931 }
932 
933 // Gets the number of all test suites that contain at least one test
934 // that should run.
935 int UnitTestImpl::test_suite_to_run_count() const {
936  return CountIf(test_suites_, ShouldRunTestSuite);
937 }
938 
939 // Gets the number of successful tests.
940 int UnitTestImpl::successful_test_count() const {
942 }
943 
944 // Gets the number of skipped tests.
945 int UnitTestImpl::skipped_test_count() const {
947 }
948 
949 // Gets the number of failed tests.
950 int UnitTestImpl::failed_test_count() const {
951  return SumOverTestSuiteList(test_suites_, &TestSuite::failed_test_count);
952 }
953 
954 // Gets the number of disabled tests that will be reported in the XML report.
955 int UnitTestImpl::reportable_disabled_test_count() const {
956  return SumOverTestSuiteList(test_suites_,
958 }
959 
960 // Gets the number of disabled tests.
961 int UnitTestImpl::disabled_test_count() const {
963 }
964 
965 // Gets the number of tests to be printed in the XML report.
966 int UnitTestImpl::reportable_test_count() const {
968 }
969 
970 // Gets the number of all tests.
971 int UnitTestImpl::total_test_count() const {
972  return SumOverTestSuiteList(test_suites_, &TestSuite::total_test_count);
973 }
974 
975 // Gets the number of tests that should run.
976 int UnitTestImpl::test_to_run_count() const {
977  return SumOverTestSuiteList(test_suites_, &TestSuite::test_to_run_count);
978 }
979 
980 // Returns the current OS stack trace as an std::string.
981 //
982 // The maximum number of stack frames to be included is specified by
983 // the gtest_stack_trace_depth flag. The skip_count parameter
984 // specifies the number of top frames to be skipped, which doesn't
985 // count against the number of frames to be included.
986 //
987 // For example, if Foo() calls Bar(), which in turn calls
988 // CurrentOsStackTraceExceptTop(1), Foo() will be included in the
989 // trace but Bar() and CurrentOsStackTraceExceptTop() won't.
990 std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
991  return os_stack_trace_getter()->CurrentStackTrace(
992  static_cast<int>(GTEST_FLAG(stack_trace_depth)),
993  skip_count + 1
994  // Skips the user-specified number of frames plus this function
995  // itself.
996  ); // NOLINT
997 }
998 
999 // Returns the current time in milliseconds.
1001  return std::chrono::duration_cast<std::chrono::milliseconds>(
1003  std::chrono::system_clock::from_time_t(0))
1004  .count();
1005 }
1006 
1007 // Utilities
1008 
1009 // class String.
1010 
1011 #if GTEST_OS_WINDOWS_MOBILE
1012 // Creates a UTF-16 wide string from the given ANSI string, allocating
1013 // memory using new. The caller is responsible for deleting the return
1014 // value using delete[]. Returns the wide string, or NULL if the
1015 // input is NULL.
1016 LPCWSTR String::AnsiToUtf16(const char* ansi) {
1017  if (!ansi) return nullptr;
1018  const int length = strlen(ansi);
1019  const int unicode_length =
1020  MultiByteToWideChar(CP_ACP, 0, ansi, length, nullptr, 0);
1021  WCHAR* unicode = new WCHAR[unicode_length + 1];
1022  MultiByteToWideChar(CP_ACP, 0, ansi, length,
1023  unicode, unicode_length);
1024  unicode[unicode_length] = 0;
1025  return unicode;
1026 }
1027 
1028 // Creates an ANSI string from the given wide string, allocating
1029 // memory using new. The caller is responsible for deleting the return
1030 // value using delete[]. Returns the ANSI string, or NULL if the
1031 // input is NULL.
1032 const char* String::Utf16ToAnsi(LPCWSTR utf16_str) {
1033  if (!utf16_str) return nullptr;
1034  const int ansi_length = WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, nullptr,
1035  0, nullptr, nullptr);
1036  char* ansi = new char[ansi_length + 1];
1037  WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, ansi, ansi_length, nullptr,
1038  nullptr);
1039  ansi[ansi_length] = 0;
1040  return ansi;
1041 }
1042 
1043 #endif // GTEST_OS_WINDOWS_MOBILE
1044 
1045 // Compares two C strings. Returns true if and only if they have the same
1046 // content.
1047 //
1048 // Unlike strcmp(), this function can handle NULL argument(s). A NULL
1049 // C string is considered different to any non-NULL C string,
1050 // including the empty string.
1051 bool String::CStringEquals(const char * lhs, const char * rhs) {
1052  if (lhs == nullptr) return rhs == nullptr;
1053 
1054  if (rhs == nullptr) return false;
1055 
1056  return strcmp(lhs, rhs) == 0;
1057 }
1058 
1059 #if GTEST_HAS_STD_WSTRING
1060 
1061 // Converts an array of wide chars to a narrow string using the UTF-8
1062 // encoding, and streams the result to the given Message object.
1063 static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length,
1064  Message* msg) {
1065  for (size_t i = 0; i != length; ) { // NOLINT
1066  if (wstr[i] != L'\0') {
1067  *msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));
1068  while (i != length && wstr[i] != L'\0')
1069  i++;
1070  } else {
1071  *msg << '\0';
1072  i++;
1073  }
1074  }
1075 }
1076 
1077 #endif // GTEST_HAS_STD_WSTRING
1078 
1079 void SplitString(const ::std::string& str, char delimiter,
1080  ::std::vector< ::std::string>* dest) {
1081  ::std::vector< ::std::string> parsed;
1082  ::std::string::size_type pos = 0;
1083  while (::testing::internal::AlwaysTrue()) {
1084  const ::std::string::size_type colon = str.find(delimiter, pos);
1085  if (colon == ::std::string::npos) {
1086  parsed.push_back(str.substr(pos));
1087  break;
1088  } else {
1089  parsed.push_back(str.substr(pos, colon - pos));
1090  pos = colon + 1;
1091  }
1092  }
1093  dest->swap(parsed);
1094 }
1095 
1096 } // namespace internal
1097 
1098 // Constructs an empty Message.
1099 // We allocate the stringstream separately because otherwise each use of
1100 // ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
1101 // stack frame leading to huge stack frames in some cases; gcc does not reuse
1102 // the stack space.
1103 Message::Message() : ss_(new ::std::stringstream) {
1104  // By default, we want there to be enough precision when printing
1105  // a double to a Message.
1106  *ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);
1107 }
1108 
1109 // These two overloads allow streaming a wide C string to a Message
1110 // using the UTF-8 encoding.
1111 Message& Message::operator <<(const wchar_t* wide_c_str) {
1112  return *this << internal::String::ShowWideCString(wide_c_str);
1113 }
1114 Message& Message::operator <<(wchar_t* wide_c_str) {
1115  return *this << internal::String::ShowWideCString(wide_c_str);
1116 }
1117 
1118 #if GTEST_HAS_STD_WSTRING
1119 // Converts the given wide string to a narrow string using the UTF-8
1120 // encoding, and streams the result to this Message object.
1122  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);
1123  return *this;
1124 }
1125 #endif // GTEST_HAS_STD_WSTRING
1126 
1127 // Gets the text streamed to this object so far as an std::string.
1128 // Each '\0' character in the buffer is replaced with "\\0".
1130  return internal::StringStreamToString(ss_.get());
1131 }
1132 
1133 // AssertionResult constructors.
1134 // Used in EXPECT_TRUE/FALSE(assertion_result).
1135 AssertionResult::AssertionResult(const AssertionResult& other)
1136  : success_(other.success_),
1137  message_(other.message_.get() != nullptr
1138  ? new ::std::string(*other.message_)
1139  : static_cast< ::std::string*>(nullptr)) {}
1140 
1141 // Swaps two AssertionResults.
1142 void AssertionResult::swap(AssertionResult& other) {
1143  using std::swap;
1144  swap(success_, other.success_);
1145  swap(message_, other.message_);
1146 }
1147 
1148 // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
1149 AssertionResult AssertionResult::operator!() const {
1150  AssertionResult negation(!success_);
1151  if (message_.get() != nullptr) negation << *message_;
1152  return negation;
1153 }
1154 
1155 // Makes a successful assertion result.
1156 AssertionResult AssertionSuccess() {
1157  return AssertionResult(true);
1158 }
1159 
1160 // Makes a failed assertion result.
1161 AssertionResult AssertionFailure() {
1162  return AssertionResult(false);
1163 }
1164 
1165 // Makes a failed assertion result with the given failure message.
1166 // Deprecated; use AssertionFailure() << message.
1167 AssertionResult AssertionFailure(const Message& message) {
1168  return AssertionFailure() << message;
1169 }
1170 
1171 namespace internal {
1172 
1173 namespace edit_distance {
1174 std::vector<EditType> CalculateOptimalEdits(const std::vector<size_t>& left,
1175  const std::vector<size_t>& right) {
1176  std::vector<std::vector<double> > costs(
1177  left.size() + 1, std::vector<double>(right.size() + 1));
1178  std::vector<std::vector<EditType> > best_move(
1179  left.size() + 1, std::vector<EditType>(right.size() + 1));
1180 
1181  // Populate for empty right.
1182  for (size_t l_i = 0; l_i < costs.size(); ++l_i) {
1183  costs[l_i][0] = static_cast<double>(l_i);
1184  best_move[l_i][0] = kRemove;
1185  }
1186  // Populate for empty left.
1187  for (size_t r_i = 1; r_i < costs[0].size(); ++r_i) {
1188  costs[0][r_i] = static_cast<double>(r_i);
1189  best_move[0][r_i] = kAdd;
1190  }
1191 
1192  for (size_t l_i = 0; l_i < left.size(); ++l_i) {
1193  for (size_t r_i = 0; r_i < right.size(); ++r_i) {
1194  if (left[l_i] == right[r_i]) {
1195  // Found a match. Consume it.
1196  costs[l_i + 1][r_i + 1] = costs[l_i][r_i];
1197  best_move[l_i + 1][r_i + 1] = kMatch;
1198  continue;
1199  }
1200 
1201  const double add = costs[l_i + 1][r_i];
1202  const double remove = costs[l_i][r_i + 1];
1203  const double replace = costs[l_i][r_i];
1204  if (add < remove && add < replace) {
1205  costs[l_i + 1][r_i + 1] = add + 1;
1206  best_move[l_i + 1][r_i + 1] = kAdd;
1207  } else if (remove < add && remove < replace) {
1208  costs[l_i + 1][r_i + 1] = remove + 1;
1209  best_move[l_i + 1][r_i + 1] = kRemove;
1210  } else {
1211  // We make replace a little more expensive than add/remove to lower
1212  // their priority.
1213  costs[l_i + 1][r_i + 1] = replace + 1.00001;
1214  best_move[l_i + 1][r_i + 1] = kReplace;
1215  }
1216  }
1217  }
1218 
1219  // Reconstruct the best path. We do it in reverse order.
1220  std::vector<EditType> best_path;
1221  for (size_t l_i = left.size(), r_i = right.size(); l_i > 0 || r_i > 0;) {
1222  EditType move = best_move[l_i][r_i];
1223  best_path.push_back(move);
1224  l_i -= move != kAdd;
1225  r_i -= move != kRemove;
1226  }
1227  std::reverse(best_path.begin(), best_path.end());
1228  return best_path;
1229 }
1230 
1231 namespace {
1232 
1233 // Helper class to convert string into ids with deduplication.
1234 class InternalStrings {
1235  public:
1236  size_t GetId(const std::string& str) {
1237  IdMap::iterator it = ids_.find(str);
1238  if (it != ids_.end()) return it->second;
1239  size_t id = ids_.size();
1240  return ids_[str] = id;
1241  }
1242 
1243  private:
1244  typedef std::map<std::string, size_t> IdMap;
1246 };
1247 
1248 } // namespace
1249 
1250 std::vector<EditType> CalculateOptimalEdits(
1251  const std::vector<std::string>& left,
1252  const std::vector<std::string>& right) {
1253  std::vector<size_t> left_ids, right_ids;
1254  {
1255  InternalStrings intern_table;
1256  for (size_t i = 0; i < left.size(); ++i) {
1257  left_ids.push_back(intern_table.GetId(left[i]));
1258  }
1259  for (size_t i = 0; i < right.size(); ++i) {
1260  right_ids.push_back(intern_table.GetId(right[i]));
1261  }
1262  }
1263  return CalculateOptimalEdits(left_ids, right_ids);
1264 }
1265 
1266 namespace {
1267 
1268 // Helper class that holds the state for one hunk and prints it out to the
1269 // stream.
1270 // It reorders adds/removes when possible to group all removes before all
1271 // adds. It also adds the hunk header before printint into the stream.
1272 class Hunk {
1273  public:
1274  Hunk(size_t left_start, size_t right_start)
1275  : left_start_(left_start),
1276  right_start_(right_start),
1277  adds_(),
1278  removes_(),
1279  common_() {}
1280 
1281  void PushLine(char edit, const char* line) {
1282  switch (edit) {
1283  case ' ':
1284  ++common_;
1285  FlushEdits();
1286  hunk_.push_back(std::make_pair(' ', line));
1287  break;
1288  case '-':
1289  ++removes_;
1290  hunk_removes_.push_back(std::make_pair('-', line));
1291  break;
1292  case '+':
1293  ++adds_;
1294  hunk_adds_.push_back(std::make_pair('+', line));
1295  break;
1296  }
1297  }
1298 
1299  void PrintTo(std::ostream* os) {
1300  PrintHeader(os);
1301  FlushEdits();
1302  for (std::list<std::pair<char, const char*> >::const_iterator it =
1303  hunk_.begin();
1304  it != hunk_.end(); ++it) {
1305  *os << it->first << it->second << "\n";
1306  }
1307  }
1308 
1309  bool has_edits() const { return adds_ || removes_; }
1310 
1311  private:
1312  void FlushEdits() {
1313  hunk_.splice(hunk_.end(), hunk_removes_);
1314  hunk_.splice(hunk_.end(), hunk_adds_);
1315  }
1316 
1317  // Print a unified diff header for one hunk.
1318  // The format is
1319  // "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@"
1320  // where the left/right parts are omitted if unnecessary.
1321  void PrintHeader(std::ostream* ss) const {
1322  *ss << "@@ ";
1323  if (removes_) {
1324  *ss << "-" << left_start_ << "," << (removes_ + common_);
1325  }
1326  if (removes_ && adds_) {
1327  *ss << " ";
1328  }
1329  if (adds_) {
1330  *ss << "+" << right_start_ << "," << (adds_ + common_);
1331  }
1332  *ss << " @@\n";
1333  }
1334 
1337  std::list<std::pair<char, const char*> > hunk_, hunk_adds_, hunk_removes_;
1338 };
1339 
1340 } // namespace
1341 
1342 // Create a list of diff hunks in Unified diff format.
1343 // Each hunk has a header generated by PrintHeader above plus a body with
1344 // lines prefixed with ' ' for no change, '-' for deletion and '+' for
1345 // addition.
1346 // 'context' represents the desired unchanged prefix/suffix around the diff.
1347 // If two hunks are close enough that their contexts overlap, then they are
1348 // joined into one hunk.
1349 std::string CreateUnifiedDiff(const std::vector<std::string>& left,
1350  const std::vector<std::string>& right,
1351  size_t context) {
1352  const std::vector<EditType> edits = CalculateOptimalEdits(left, right);
1353 
1354  size_t l_i = 0, r_i = 0, edit_i = 0;
1355  std::stringstream ss;
1356  while (edit_i < edits.size()) {
1357  // Find first edit.
1358  while (edit_i < edits.size() && edits[edit_i] == kMatch) {
1359  ++l_i;
1360  ++r_i;
1361  ++edit_i;
1362  }
1363 
1364  // Find the first line to include in the hunk.
1365  const size_t prefix_context = std::min(l_i, context);
1366  Hunk hunk(l_i - prefix_context + 1, r_i - prefix_context + 1);
1367  for (size_t i = prefix_context; i > 0; --i) {
1368  hunk.PushLine(' ', left[l_i - i].c_str());
1369  }
1370 
1371  // Iterate the edits until we found enough suffix for the hunk or the input
1372  // is over.
1373  size_t n_suffix = 0;
1374  for (; edit_i < edits.size(); ++edit_i) {
1375  if (n_suffix >= context) {
1376  // Continue only if the next hunk is very close.
1377  auto it = edits.begin() + static_cast<int>(edit_i);
1378  while (it != edits.end() && *it == kMatch) ++it;
1379  if (it == edits.end() ||
1380  static_cast<size_t>(it - edits.begin()) - edit_i >= context) {
1381  // There is no next edit or it is too far away.
1382  break;
1383  }
1384  }
1385 
1386  EditType edit = edits[edit_i];
1387  // Reset count when a non match is found.
1388  n_suffix = edit == kMatch ? n_suffix + 1 : 0;
1389 
1390  if (edit == kMatch || edit == kRemove || edit == kReplace) {
1391  hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str());
1392  }
1393  if (edit == kAdd || edit == kReplace) {
1394  hunk.PushLine('+', right[r_i].c_str());
1395  }
1396 
1397  // Advance indices, depending on edit type.
1398  l_i += edit != kAdd;
1399  r_i += edit != kRemove;
1400  }
1401 
1402  if (!hunk.has_edits()) {
1403  // We are done. We don't want this hunk.
1404  break;
1405  }
1406 
1407  hunk.PrintTo(&ss);
1408  }
1409  return ss.str();
1410 }
1411 
1412 } // namespace edit_distance
1413 
1414 namespace {
1415 
1416 // The string representation of the values received in EqFailure() are already
1417 // escaped. Split them on escaped '\n' boundaries. Leave all other escaped
1418 // characters the same.
1419 std::vector<std::string> SplitEscapedString(const std::string& str) {
1420  std::vector<std::string> lines;
1421  size_t start = 0, end = str.size();
1422  if (end > 2 && str[0] == '"' && str[end - 1] == '"') {
1423  ++start;
1424  --end;
1425  }
1426  bool escaped = false;
1427  for (size_t i = start; i + 1 < end; ++i) {
1428  if (escaped) {
1429  escaped = false;
1430  if (str[i] == 'n') {
1431  lines.push_back(str.substr(start, i - start - 1));
1432  start = i + 1;
1433  }
1434  } else {
1435  escaped = str[i] == '\\';
1436  }
1437  }
1438  lines.push_back(str.substr(start, end - start));
1439  return lines;
1440 }
1441 
1442 } // namespace
1443 
1444 // Constructs and returns the message for an equality assertion
1445 // (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
1446 //
1447 // The first four parameters are the expressions used in the assertion
1448 // and their values, as strings. For example, for ASSERT_EQ(foo, bar)
1449 // where foo is 5 and bar is 6, we have:
1450 //
1451 // lhs_expression: "foo"
1452 // rhs_expression: "bar"
1453 // lhs_value: "5"
1454 // rhs_value: "6"
1455 //
1456 // The ignoring_case parameter is true if and only if the assertion is a
1457 // *_STRCASEEQ*. When it's true, the string "Ignoring case" will
1458 // be inserted into the message.
1459 AssertionResult EqFailure(const char* lhs_expression,
1460  const char* rhs_expression,
1461  const std::string& lhs_value,
1462  const std::string& rhs_value,
1463  bool ignoring_case) {
1464  Message msg;
1465  msg << "Expected equality of these values:";
1466  msg << "\n " << lhs_expression;
1467  if (lhs_value != lhs_expression) {
1468  msg << "\n Which is: " << lhs_value;
1469  }
1470  msg << "\n " << rhs_expression;
1471  if (rhs_value != rhs_expression) {
1472  msg << "\n Which is: " << rhs_value;
1473  }
1474 
1475  if (ignoring_case) {
1476  msg << "\nIgnoring case";
1477  }
1478 
1479  if (!lhs_value.empty() && !rhs_value.empty()) {
1480  const std::vector<std::string> lhs_lines =
1481  SplitEscapedString(lhs_value);
1482  const std::vector<std::string> rhs_lines =
1483  SplitEscapedString(rhs_value);
1484  if (lhs_lines.size() > 1 || rhs_lines.size() > 1) {
1485  msg << "\nWith diff:\n"
1486  << edit_distance::CreateUnifiedDiff(lhs_lines, rhs_lines);
1487  }
1488  }
1489 
1490  return AssertionFailure() << msg;
1491 }
1492 
1493 // Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
1495  const AssertionResult& assertion_result,
1496  const char* expression_text,
1497  const char* actual_predicate_value,
1498  const char* expected_predicate_value) {
1499  const char* actual_message = assertion_result.message();
1500  Message msg;
1501  msg << "Value of: " << expression_text
1502  << "\n Actual: " << actual_predicate_value;
1503  if (actual_message[0] != '\0')
1504  msg << " (" << actual_message << ")";
1505  msg << "\nExpected: " << expected_predicate_value;
1506  return msg.GetString();
1507 }
1508 
1509 // Helper function for implementing ASSERT_NEAR.
1510 AssertionResult DoubleNearPredFormat(const char* expr1,
1511  const char* expr2,
1512  const char* abs_error_expr,
1513  double val1,
1514  double val2,
1515  double abs_error) {
1516  const double diff = fabs(val1 - val2);
1517  if (diff <= abs_error) return AssertionSuccess();
1518 
1519  // Find the value which is closest to zero.
1520  const double min_abs = std::min(fabs(val1), fabs(val2));
1521  // Find the distance to the next double from that value.
1522  const double epsilon =
1523  nextafter(min_abs, std::numeric_limits<double>::infinity()) - min_abs;
1524  // Detect the case where abs_error is so small that EXPECT_NEAR is
1525  // effectively the same as EXPECT_EQUAL, and give an informative error
1526  // message so that the situation can be more easily understood without
1527  // requiring exotic floating-point knowledge.
1528  // Don't do an epsilon check if abs_error is zero because that implies
1529  // that an equality check was actually intended.
1530  if (!(std::isnan)(val1) && !(std::isnan)(val2) && abs_error > 0 &&
1531  abs_error < epsilon) {
1532  return AssertionFailure()
1533  << "The difference between " << expr1 << " and " << expr2 << " is "
1534  << diff << ", where\n"
1535  << expr1 << " evaluates to " << val1 << ",\n"
1536  << expr2 << " evaluates to " << val2 << ".\nThe abs_error parameter "
1537  << abs_error_expr << " evaluates to " << abs_error
1538  << " which is smaller than the minimum distance between doubles for "
1539  "numbers of this magnitude which is "
1540  << epsilon
1541  << ", thus making this EXPECT_NEAR check equivalent to "
1542  "EXPECT_EQUAL. Consider using EXPECT_DOUBLE_EQ instead.";
1543  }
1544  return AssertionFailure()
1545  << "The difference between " << expr1 << " and " << expr2
1546  << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n"
1547  << expr1 << " evaluates to " << val1 << ",\n"
1548  << expr2 << " evaluates to " << val2 << ", and\n"
1549  << abs_error_expr << " evaluates to " << abs_error << ".";
1550 }
1551 
1552 
1553 // Helper template for implementing FloatLE() and DoubleLE().
1554 template <typename RawType>
1555 AssertionResult FloatingPointLE(const char* expr1,
1556  const char* expr2,
1557  RawType val1,
1558  RawType val2) {
1559  // Returns success if val1 is less than val2,
1560  if (val1 < val2) {
1561  return AssertionSuccess();
1562  }
1563 
1564  // or if val1 is almost equal to val2.
1565  const FloatingPoint<RawType> lhs(val1), rhs(val2);
1566  if (lhs.AlmostEquals(rhs)) {
1567  return AssertionSuccess();
1568  }
1569 
1570  // Note that the above two checks will both fail if either val1 or
1571  // val2 is NaN, as the IEEE floating-point standard requires that
1572  // any predicate involving a NaN must return false.
1573 
1574  ::std::stringstream val1_ss;
1575  val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
1576  << val1;
1577 
1578  ::std::stringstream val2_ss;
1579  val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
1580  << val2;
1581 
1582  return AssertionFailure()
1583  << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n"
1584  << " Actual: " << StringStreamToString(&val1_ss) << " vs "
1585  << StringStreamToString(&val2_ss);
1586 }
1587 
1588 } // namespace internal
1589 
1590 // Asserts that val1 is less than, or almost equal to, val2. Fails
1591 // otherwise. In particular, it fails if either val1 or val2 is NaN.
1592 AssertionResult FloatLE(const char* expr1, const char* expr2,
1593  float val1, float val2) {
1594  return internal::FloatingPointLE<float>(expr1, expr2, val1, val2);
1595 }
1596 
1597 // Asserts that val1 is less than, or almost equal to, val2. Fails
1598 // otherwise. In particular, it fails if either val1 or val2 is NaN.
1599 AssertionResult DoubleLE(const char* expr1, const char* expr2,
1600  double val1, double val2) {
1601  return internal::FloatingPointLE<double>(expr1, expr2, val1, val2);
1602 }
1603 
1604 namespace internal {
1605 
1606 // The helper function for {ASSERT|EXPECT}_EQ with int or enum
1607 // arguments.
1608 AssertionResult CmpHelperEQ(const char* lhs_expression,
1609  const char* rhs_expression,
1610  BiggestInt lhs,
1611  BiggestInt rhs) {
1612  if (lhs == rhs) {
1613  return AssertionSuccess();
1614  }
1615 
1616  return EqFailure(lhs_expression,
1617  rhs_expression,
1620  false);
1621 }
1622 
1623 // A macro for implementing the helper functions needed to implement
1624 // ASSERT_?? and EXPECT_?? with integer or enum arguments. It is here
1625 // just to avoid copy-and-paste of similar code.
1626 #define GTEST_IMPL_CMP_HELPER_(op_name, op)\
1627 AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
1628  BiggestInt val1, BiggestInt val2) {\
1629  if (val1 op val2) {\
1630  return AssertionSuccess();\
1631  } else {\
1632  return AssertionFailure() \
1633  << "Expected: (" << expr1 << ") " #op " (" << expr2\
1634  << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\
1635  << " vs " << FormatForComparisonFailureMessage(val2, val1);\
1636  }\
1637 }
1638 
1639 // Implements the helper function for {ASSERT|EXPECT}_NE with int or
1640 // enum arguments.
1641 GTEST_IMPL_CMP_HELPER_(NE, !=)
1642 // Implements the helper function for {ASSERT|EXPECT}_LE with int or
1643 // enum arguments.
1644 GTEST_IMPL_CMP_HELPER_(LE, <=)
1645 // Implements the helper function for {ASSERT|EXPECT}_LT with int or
1646 // enum arguments.
1647 GTEST_IMPL_CMP_HELPER_(LT, < )
1648 // Implements the helper function for {ASSERT|EXPECT}_GE with int or
1649 // enum arguments.
1650 GTEST_IMPL_CMP_HELPER_(GE, >=)
1651 // Implements the helper function for {ASSERT|EXPECT}_GT with int or
1652 // enum arguments.
1653 GTEST_IMPL_CMP_HELPER_(GT, > )
1654 
1655 #undef GTEST_IMPL_CMP_HELPER_
1656 
1657 // The helper function for {ASSERT|EXPECT}_STREQ.
1658 AssertionResult CmpHelperSTREQ(const char* lhs_expression,
1659  const char* rhs_expression,
1660  const char* lhs,
1661  const char* rhs) {
1662  if (String::CStringEquals(lhs, rhs)) {
1663  return AssertionSuccess();
1664  }
1665 
1666  return EqFailure(lhs_expression,
1667  rhs_expression,
1668  PrintToString(lhs),
1669  PrintToString(rhs),
1670  false);
1671 }
1672 
1673 // The helper function for {ASSERT|EXPECT}_STRCASEEQ.
1674 AssertionResult CmpHelperSTRCASEEQ(const char* lhs_expression,
1675  const char* rhs_expression,
1676  const char* lhs,
1677  const char* rhs) {
1678  if (String::CaseInsensitiveCStringEquals(lhs, rhs)) {
1679  return AssertionSuccess();
1680  }
1681 
1682  return EqFailure(lhs_expression,
1683  rhs_expression,
1684  PrintToString(lhs),
1685  PrintToString(rhs),
1686  true);
1687 }
1688 
1689 // The helper function for {ASSERT|EXPECT}_STRNE.
1690 AssertionResult CmpHelperSTRNE(const char* s1_expression,
1691  const char* s2_expression,
1692  const char* s1,
1693  const char* s2) {
1694  if (!String::CStringEquals(s1, s2)) {
1695  return AssertionSuccess();
1696  } else {
1697  return AssertionFailure() << "Expected: (" << s1_expression << ") != ("
1698  << s2_expression << "), actual: \""
1699  << s1 << "\" vs \"" << s2 << "\"";
1700  }
1701 }
1702 
1703 // The helper function for {ASSERT|EXPECT}_STRCASENE.
1704 AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
1705  const char* s2_expression,
1706  const char* s1,
1707  const char* s2) {
1708  if (!String::CaseInsensitiveCStringEquals(s1, s2)) {
1709  return AssertionSuccess();
1710  } else {
1711  return AssertionFailure()
1712  << "Expected: (" << s1_expression << ") != ("
1713  << s2_expression << ") (ignoring case), actual: \""
1714  << s1 << "\" vs \"" << s2 << "\"";
1715  }
1716 }
1717 
1718 } // namespace internal
1719 
1720 namespace {
1721 
1722 // Helper functions for implementing IsSubString() and IsNotSubstring().
1723 
1724 // This group of overloaded functions return true if and only if needle
1725 // is a substring of haystack. NULL is considered a substring of
1726 // itself only.
1727 
1728 bool IsSubstringPred(const char* needle, const char* haystack) {
1729  if (needle == nullptr || haystack == nullptr) return needle == haystack;
1730 
1731  return strstr(haystack, needle) != nullptr;
1732 }
1733 
1734 bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) {
1735  if (needle == nullptr || haystack == nullptr) return needle == haystack;
1736 
1737  return wcsstr(haystack, needle) != nullptr;
1738 }
1739 
1740 // StringType here can be either ::std::string or ::std::wstring.
1741 template <typename StringType>
1742 bool IsSubstringPred(const StringType& needle,
1743  const StringType& haystack) {
1744  return haystack.find(needle) != StringType::npos;
1745 }
1746 
1747 // This function implements either IsSubstring() or IsNotSubstring(),
1748 // depending on the value of the expected_to_be_substring parameter.
1749 // StringType here can be const char*, const wchar_t*, ::std::string,
1750 // or ::std::wstring.
1751 template <typename StringType>
1752 AssertionResult IsSubstringImpl(
1753  bool expected_to_be_substring,
1754  const char* needle_expr, const char* haystack_expr,
1755  const StringType& needle, const StringType& haystack) {
1756  if (IsSubstringPred(needle, haystack) == expected_to_be_substring)
1757  return AssertionSuccess();
1758 
1759  const bool is_wide_string = sizeof(needle[0]) > 1;
1760  const char* const begin_string_quote = is_wide_string ? "L\"" : "\"";
1761  return AssertionFailure()
1762  << "Value of: " << needle_expr << "\n"
1763  << " Actual: " << begin_string_quote << needle << "\"\n"
1764  << "Expected: " << (expected_to_be_substring ? "" : "not ")
1765  << "a substring of " << haystack_expr << "\n"
1766  << "Which is: " << begin_string_quote << haystack << "\"";
1767 }
1768 
1769 } // namespace
1770 
1771 // IsSubstring() and IsNotSubstring() check whether needle is a
1772 // substring of haystack (NULL is considered a substring of itself
1773 // only), and return an appropriate error message when they fail.
1774 
1775 AssertionResult IsSubstring(
1776  const char* needle_expr, const char* haystack_expr,
1777  const char* needle, const char* haystack) {
1778  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
1779 }
1780 
1781 AssertionResult IsSubstring(
1782  const char* needle_expr, const char* haystack_expr,
1783  const wchar_t* needle, const wchar_t* haystack) {
1784  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
1785 }
1786 
1787 AssertionResult IsNotSubstring(
1788  const char* needle_expr, const char* haystack_expr,
1789  const char* needle, const char* haystack) {
1790  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
1791 }
1792 
1793 AssertionResult IsNotSubstring(
1794  const char* needle_expr, const char* haystack_expr,
1795  const wchar_t* needle, const wchar_t* haystack) {
1796  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
1797 }
1798 
1799 AssertionResult IsSubstring(
1800  const char* needle_expr, const char* haystack_expr,
1801  const ::std::string& needle, const ::std::string& haystack) {
1802  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
1803 }
1804 
1805 AssertionResult IsNotSubstring(
1806  const char* needle_expr, const char* haystack_expr,
1807  const ::std::string& needle, const ::std::string& haystack) {
1808  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
1809 }
1810 
1811 #if GTEST_HAS_STD_WSTRING
1812 AssertionResult IsSubstring(
1813  const char* needle_expr, const char* haystack_expr,
1814  const ::std::wstring& needle, const ::std::wstring& haystack) {
1815  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
1816 }
1817 
1818 AssertionResult IsNotSubstring(
1819  const char* needle_expr, const char* haystack_expr,
1820  const ::std::wstring& needle, const ::std::wstring& haystack) {
1821  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
1822 }
1823 #endif // GTEST_HAS_STD_WSTRING
1824 
1825 namespace internal {
1826 
1827 #if GTEST_OS_WINDOWS
1828 
1829 namespace {
1830 
1831 // Helper function for IsHRESULT{SuccessFailure} predicates
1832 AssertionResult HRESULTFailureHelper(const char* expr,
1833  const char* expected,
1834  long hr) { // NOLINT
1835 # if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_TV_TITLE
1836 
1837  // Windows CE doesn't support FormatMessage.
1838  const char error_text[] = "";
1839 
1840 # else
1841 
1842  // Looks up the human-readable system message for the HRESULT code
1843  // and since we're not passing any params to FormatMessage, we don't
1844  // want inserts expanded.
1845  const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |
1846  FORMAT_MESSAGE_IGNORE_INSERTS;
1847  const DWORD kBufSize = 4096;
1848  // Gets the system's human readable message string for this HRESULT.
1849  char error_text[kBufSize] = { '\0' };
1850  DWORD message_length = ::FormatMessageA(kFlags,
1851  0, // no source, we're asking system
1852  static_cast<DWORD>(hr), // the error
1853  0, // no line width restrictions
1854  error_text, // output buffer
1855  kBufSize, // buf size
1856  nullptr); // no arguments for inserts
1857  // Trims tailing white space (FormatMessage leaves a trailing CR-LF)
1858  for (; message_length && IsSpace(error_text[message_length - 1]);
1859  --message_length) {
1860  error_text[message_length - 1] = '\0';
1861  }
1862 
1863 # endif // GTEST_OS_WINDOWS_MOBILE
1864 
1865  const std::string error_hex("0x" + String::FormatHexInt(hr));
1867  << "Expected: " << expr << " " << expected << ".\n"
1868  << " Actual: " << error_hex << " " << error_text << "\n";
1869 }
1870 
1871 } // namespace
1872 
1873 AssertionResult IsHRESULTSuccess(const char* expr, long hr) { // NOLINT
1874  if (SUCCEEDED(hr)) {
1875  return AssertionSuccess();
1876  }
1877  return HRESULTFailureHelper(expr, "succeeds", hr);
1878 }
1879 
1880 AssertionResult IsHRESULTFailure(const char* expr, long hr) { // NOLINT
1881  if (FAILED(hr)) {
1882  return AssertionSuccess();
1883  }
1884  return HRESULTFailureHelper(expr, "fails", hr);
1885 }
1886 
1887 #endif // GTEST_OS_WINDOWS
1888 
1889 // Utility functions for encoding Unicode text (wide strings) in
1890 // UTF-8.
1891 
1892 // A Unicode code-point can have up to 21 bits, and is encoded in UTF-8
1893 // like this:
1894 //
1895 // Code-point length Encoding
1896 // 0 - 7 bits 0xxxxxxx
1897 // 8 - 11 bits 110xxxxx 10xxxxxx
1898 // 12 - 16 bits 1110xxxx 10xxxxxx 10xxxxxx
1899 // 17 - 21 bits 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
1900 
1901 // The maximum code-point a one-byte UTF-8 sequence can represent.
1902 constexpr uint32_t kMaxCodePoint1 = (static_cast<uint32_t>(1) << 7) - 1;
1903 
1904 // The maximum code-point a two-byte UTF-8 sequence can represent.
1905 constexpr uint32_t kMaxCodePoint2 = (static_cast<uint32_t>(1) << (5 + 6)) - 1;
1906 
1907 // The maximum code-point a three-byte UTF-8 sequence can represent.
1908 constexpr uint32_t kMaxCodePoint3 = (static_cast<uint32_t>(1) << (4 + 2*6)) - 1;
1909 
1910 // The maximum code-point a four-byte UTF-8 sequence can represent.
1911 constexpr uint32_t kMaxCodePoint4 = (static_cast<uint32_t>(1) << (3 + 3*6)) - 1;
1912 
1913 // Chops off the n lowest bits from a bit pattern. Returns the n
1914 // lowest bits. As a side effect, the original bit pattern will be
1915 // shifted to the right by n bits.
1917  const uint32_t low_bits = *bits & ((static_cast<uint32_t>(1) << n) - 1);
1918  *bits >>= n;
1919  return low_bits;
1920 }
1921 
1922 // Converts a Unicode code point to a narrow string in UTF-8 encoding.
1923 // code_point parameter is of type uint32_t because wchar_t may not be
1924 // wide enough to contain a code point.
1925 // If the code_point is not a valid Unicode code point
1926 // (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted
1927 // to "(Invalid Unicode 0xXXXXXXXX)".
1929  if (code_point > kMaxCodePoint4) {
1930  return "(Invalid Unicode 0x" + String::FormatHexUInt32(code_point) + ")";
1931  }
1932 
1933  char str[5]; // Big enough for the largest valid code point.
1934  if (code_point <= kMaxCodePoint1) {
1935  str[1] = '\0';
1936  str[0] = static_cast<char>(code_point); // 0xxxxxxx
1937  } else if (code_point <= kMaxCodePoint2) {
1938  str[2] = '\0';
1939  str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
1940  str[0] = static_cast<char>(0xC0 | code_point); // 110xxxxx
1941  } else if (code_point <= kMaxCodePoint3) {
1942  str[3] = '\0';
1943  str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
1944  str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
1945  str[0] = static_cast<char>(0xE0 | code_point); // 1110xxxx
1946  } else { // code_point <= kMaxCodePoint4
1947  str[4] = '\0';
1948  str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
1949  str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
1950  str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
1951  str[0] = static_cast<char>(0xF0 | code_point); // 11110xxx
1952  }
1953  return str;
1954 }
1955 
1956 // The following two functions only make sense if the system
1957 // uses UTF-16 for wide string encoding. All supported systems
1958 // with 16 bit wchar_t (Windows, Cygwin) do use UTF-16.
1959 
1960 // Determines if the arguments constitute UTF-16 surrogate pair
1961 // and thus should be combined into a single Unicode code point
1962 // using CreateCodePointFromUtf16SurrogatePair.
1963 inline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) {
1964  return sizeof(wchar_t) == 2 &&
1965  (first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00;
1966 }
1967 
1968 // Creates a Unicode code point from UTF16 surrogate pair.
1970  wchar_t second) {
1971  const auto first_u = static_cast<uint32_t>(first);
1972  const auto second_u = static_cast<uint32_t>(second);
1973  const uint32_t mask = (1 << 10) - 1;
1974  return (sizeof(wchar_t) == 2)
1975  ? (((first_u & mask) << 10) | (second_u & mask)) + 0x10000
1976  :
1977  // This function should not be called when the condition is
1978  // false, but we provide a sensible default in case it is.
1979  first_u;
1980 }
1981 
1982 // Converts a wide string to a narrow string in UTF-8 encoding.
1983 // The wide string is assumed to have the following encoding:
1984 // UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin)
1985 // UTF-32 if sizeof(wchar_t) == 4 (on Linux)
1986 // Parameter str points to a null-terminated wide string.
1987 // Parameter num_chars may additionally limit the number
1988 // of wchar_t characters processed. -1 is used when the entire string
1989 // should be processed.
1990 // If the string contains code points that are not valid Unicode code points
1991 // (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output
1992 // as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding
1993 // and contains invalid UTF-16 surrogate pairs, values in those pairs
1994 // will be encoded as individual Unicode characters from Basic Normal Plane.
1995 std::string WideStringToUtf8(const wchar_t* str, int num_chars) {
1996  if (num_chars == -1)
1997  num_chars = static_cast<int>(wcslen(str));
1998 
1999  ::std::stringstream stream;
2000  for (int i = 0; i < num_chars; ++i) {
2001  uint32_t unicode_code_point;
2002 
2003  if (str[i] == L'\0') {
2004  break;
2005  } else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {
2006  unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],
2007  str[i + 1]);
2008  i++;
2009  } else {
2010  unicode_code_point = static_cast<uint32_t>(str[i]);
2011  }
2012 
2013  stream << CodePointToUtf8(unicode_code_point);
2014  }
2015  return StringStreamToString(&stream);
2016 }
2017 
2018 // Converts a wide C string to an std::string using the UTF-8 encoding.
2019 // NULL will be converted to "(null)".
2020 std::string String::ShowWideCString(const wchar_t * wide_c_str) {
2021  if (wide_c_str == nullptr) return "(null)";
2022 
2023  return internal::WideStringToUtf8(wide_c_str, -1);
2024 }
2025 
2026 // Compares two wide C strings. Returns true if and only if they have the
2027 // same content.
2028 //
2029 // Unlike wcscmp(), this function can handle NULL argument(s). A NULL
2030 // C string is considered different to any non-NULL C string,
2031 // including the empty string.
2032 bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) {
2033  if (lhs == nullptr) return rhs == nullptr;
2034 
2035  if (rhs == nullptr) return false;
2036 
2037  return wcscmp(lhs, rhs) == 0;
2038 }
2039 
2040 // Helper function for *_STREQ on wide strings.
2041 AssertionResult CmpHelperSTREQ(const char* lhs_expression,
2042  const char* rhs_expression,
2043  const wchar_t* lhs,
2044  const wchar_t* rhs) {
2045  if (String::WideCStringEquals(lhs, rhs)) {
2046  return AssertionSuccess();
2047  }
2048 
2049  return EqFailure(lhs_expression,
2050  rhs_expression,
2051  PrintToString(lhs),
2052  PrintToString(rhs),
2053  false);
2054 }
2055 
2056 // Helper function for *_STRNE on wide strings.
2057 AssertionResult CmpHelperSTRNE(const char* s1_expression,
2058  const char* s2_expression,
2059  const wchar_t* s1,
2060  const wchar_t* s2) {
2061  if (!String::WideCStringEquals(s1, s2)) {
2062  return AssertionSuccess();
2063  }
2064 
2065  return AssertionFailure() << "Expected: (" << s1_expression << ") != ("
2066  << s2_expression << "), actual: "
2067  << PrintToString(s1)
2068  << " vs " << PrintToString(s2);
2069 }
2070 
2071 // Compares two C strings, ignoring case. Returns true if and only if they have
2072 // the same content.
2073 //
2074 // Unlike strcasecmp(), this function can handle NULL argument(s). A
2075 // NULL C string is considered different to any non-NULL C string,
2076 // including the empty string.
2077 bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
2078  if (lhs == nullptr) return rhs == nullptr;
2079  if (rhs == nullptr) return false;
2080  return posix::StrCaseCmp(lhs, rhs) == 0;
2081 }
2082 
2083 // Compares two wide C strings, ignoring case. Returns true if and only if they
2084 // have the same content.
2085 //
2086 // Unlike wcscasecmp(), this function can handle NULL argument(s).
2087 // A NULL C string is considered different to any non-NULL wide C string,
2088 // including the empty string.
2089 // NB: The implementations on different platforms slightly differ.
2090 // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
2091 // environment variable. On GNU platform this method uses wcscasecmp
2092 // which compares according to LC_CTYPE category of the current locale.
2093 // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
2094 // current locale.
2095 bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
2096  const wchar_t* rhs) {
2097  if (lhs == nullptr) return rhs == nullptr;
2098 
2099  if (rhs == nullptr) return false;
2100 
2101 #if GTEST_OS_WINDOWS
2102  return _wcsicmp(lhs, rhs) == 0;
2103 #elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID
2104  return wcscasecmp(lhs, rhs) == 0;
2105 #else
2106  // Android, Mac OS X and Cygwin don't define wcscasecmp.
2107  // Other unknown OSes may not define it either.
2108  wint_t left, right;
2109  do {
2110  left = towlower(static_cast<wint_t>(*lhs++));
2111  right = towlower(static_cast<wint_t>(*rhs++));
2112  } while (left && left == right);
2113  return left == right;
2114 #endif // OS selector
2115 }
2116 
2117 // Returns true if and only if str ends with the given suffix, ignoring case.
2118 // Any string is considered to end with an empty suffix.
2120  const std::string& str, const std::string& suffix) {
2121  const size_t str_len = str.length();
2122  const size_t suffix_len = suffix.length();
2123  return (str_len >= suffix_len) &&
2124  CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len,
2125  suffix.c_str());
2126 }
2127 
2128 // Formats an int value as "%02d".
2130  return FormatIntWidthN(value, 2);
2131 }
2132 
2133 // Formats an int value to given width with leading zeros.
2135  std::stringstream ss;
2136  ss << std::setfill('0') << std::setw(width) << value;
2137  return ss.str();
2138 }
2139 
2140 // Formats an int value as "%X".
2142  std::stringstream ss;
2143  ss << std::hex << std::uppercase << value;
2144  return ss.str();
2145 }
2146 
2147 // Formats an int value as "%X".
2149  return FormatHexUInt32(static_cast<uint32_t>(value));
2150 }
2151 
2152 // Formats a byte as "%02X".
2153 std::string String::FormatByte(unsigned char value) {
2154  std::stringstream ss;
2155  ss << std::setfill('0') << std::setw(2) << std::hex << std::uppercase
2156  << static_cast<unsigned int>(value);
2157  return ss.str();
2158 }
2159 
2160 // Converts the buffer in a stringstream to an std::string, converting NUL
2161 // bytes to "\\0" along the way.
2162 std::string StringStreamToString(::std::stringstream* ss) {
2163  const ::std::string& str = ss->str();
2164  const char* const start = str.c_str();
2165  const char* const end = start + str.length();
2166 
2168  result.reserve(static_cast<size_t>(2 * (end - start)));
2169  for (const char* ch = start; ch != end; ++ch) {
2170  if (*ch == '\0') {
2171  result += "\\0"; // Replaces NUL with "\\0";
2172  } else {
2173  result += *ch;
2174  }
2175  }
2176 
2177  return result;
2178 }
2179 
2180 // Appends the user-supplied message to the Google-Test-generated message.
2181 std::string AppendUserMessage(const std::string& gtest_msg,
2182  const Message& user_msg) {
2183  // Appends the user message if it's non-empty.
2184  const std::string user_msg_string = user_msg.GetString();
2185  if (user_msg_string.empty()) {
2186  return gtest_msg;
2187  }
2188  if (gtest_msg.empty()) {
2189  return user_msg_string;
2190  }
2191  return gtest_msg + "\n" + user_msg_string;
2192 }
2193 
2194 } // namespace internal
2195 
2196 // class TestResult
2197 
2198 // Creates an empty TestResult.
2200  : death_test_count_(0), start_timestamp_(0), elapsed_time_(0) {}
2201 
2202 // D'tor.
2204 }
2205 
2206 // Returns the i-th test part result among all the results. i can
2207 // range from 0 to total_part_count() - 1. If i is not in that range,
2208 // aborts the program.
2209 const TestPartResult& TestResult::GetTestPartResult(int i) const {
2210  if (i < 0 || i >= total_part_count())
2212  return test_part_results_.at(static_cast<size_t>(i));
2213 }
2214 
2215 // Returns the i-th test property. i can range from 0 to
2216 // test_property_count() - 1. If i is not in that range, aborts the
2217 // program.
2218 const TestProperty& TestResult::GetTestProperty(int i) const {
2219  if (i < 0 || i >= test_property_count())
2221  return test_properties_.at(static_cast<size_t>(i));
2222 }
2223 
2224 // Clears the test part results.
2226  test_part_results_.clear();
2227 }
2228 
2229 // Adds a test part result to the list.
2230 void TestResult::AddTestPartResult(const TestPartResult& test_part_result) {
2231  test_part_results_.push_back(test_part_result);
2232 }
2233 
2234 // Adds a test property to the list. If a property with the same key as the
2235 // supplied property is already represented, the value of this test_property
2236 // replaces the old value for that key.
2237 void TestResult::RecordProperty(const std::string& xml_element,
2238  const TestProperty& test_property) {
2239  if (!ValidateTestProperty(xml_element, test_property)) {
2240  return;
2241  }
2242  internal::MutexLock lock(&test_properites_mutex_);
2243  const std::vector<TestProperty>::iterator property_with_matching_key =
2244  std::find_if(test_properties_.begin(), test_properties_.end(),
2245  internal::TestPropertyKeyIs(test_property.key()));
2246  if (property_with_matching_key == test_properties_.end()) {
2247  test_properties_.push_back(test_property);
2248  return;
2249  }
2250  property_with_matching_key->SetValue(test_property.value());
2251 }
2252 
2253 // The list of reserved attributes used in the <testsuites> element of XML
2254 // output.
2255 static const char* const kReservedTestSuitesAttributes[] = {
2256  "disabled",
2257  "errors",
2258  "failures",
2259  "name",
2260  "random_seed",
2261  "tests",
2262  "time",
2263  "timestamp"
2264 };
2265 
2266 // The list of reserved attributes used in the <testsuite> element of XML
2267 // output.
2268 static const char* const kReservedTestSuiteAttributes[] = {
2269  "disabled", "errors", "failures", "name",
2270  "tests", "time", "timestamp", "skipped"};
2271 
2272 // The list of reserved attributes used in the <testcase> element of XML output.
2273 static const char* const kReservedTestCaseAttributes[] = {
2274  "classname", "name", "status", "time", "type_param",
2275  "value_param", "file", "line"};
2276 
2277 // Use a slightly different set for allowed output to ensure existing tests can
2278 // still RecordProperty("result") or "RecordProperty(timestamp")
2279 static const char* const kReservedOutputTestCaseAttributes[] = {
2280  "classname", "name", "status", "time", "type_param",
2281  "value_param", "file", "line", "result", "timestamp"};
2282 
2283 template <size_t kSize>
2284 std::vector<std::string> ArrayAsVector(const char* const (&array)[kSize]) {
2285  return std::vector<std::string>(array, array + kSize);
2286 }
2287 
2288 static std::vector<std::string> GetReservedAttributesForElement(
2289  const std::string& xml_element) {
2290  if (xml_element == "testsuites") {
2292  } else if (xml_element == "testsuite") {
2294  } else if (xml_element == "testcase") {
2296  } else {
2297  GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element;
2298  }
2299  // This code is unreachable but some compilers may not realizes that.
2300  return std::vector<std::string>();
2301 }
2302 
2303 // TODO(jdesprez): Merge the two getReserved attributes once skip is improved
2304 static std::vector<std::string> GetReservedOutputAttributesForElement(
2305  const std::string& xml_element) {
2306  if (xml_element == "testsuites") {
2308  } else if (xml_element == "testsuite") {
2310  } else if (xml_element == "testcase") {
2312  } else {
2313  GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element;
2314  }
2315  // This code is unreachable but some compilers may not realizes that.
2316  return std::vector<std::string>();
2317 }
2318 
2319 static std::string FormatWordList(const std::vector<std::string>& words) {
2320  Message word_list;
2321  for (size_t i = 0; i < words.size(); ++i) {
2322  if (i > 0 && words.size() > 2) {
2323  word_list << ", ";
2324  }
2325  if (i == words.size() - 1) {
2326  word_list << "and ";
2327  }
2328  word_list << "'" << words[i] << "'";
2329  }
2330  return word_list.GetString();
2331 }
2332 
2334  const std::string& property_name,
2335  const std::vector<std::string>& reserved_names) {
2336  if (std::find(reserved_names.begin(), reserved_names.end(), property_name) !=
2337  reserved_names.end()) {
2338  ADD_FAILURE() << "Reserved key used in RecordProperty(): " << property_name
2339  << " (" << FormatWordList(reserved_names)
2340  << " are reserved by " << GTEST_NAME_ << ")";
2341  return false;
2342  }
2343  return true;
2344 }
2345 
2346 // Adds a failure if the key is a reserved attribute of the element named
2347 // xml_element. Returns true if the property is valid.
2348 bool TestResult::ValidateTestProperty(const std::string& xml_element,
2349  const TestProperty& test_property) {
2350  return ValidateTestPropertyName(test_property.key(),
2351  GetReservedAttributesForElement(xml_element));
2352 }
2353 
2354 // Clears the object.
2355 void TestResult::Clear() {
2356  test_part_results_.clear();
2357  test_properties_.clear();
2358  death_test_count_ = 0;
2359  elapsed_time_ = 0;
2360 }
2361 
2362 // Returns true off the test part was skipped.
2364  return result.skipped();
2365 }
2366 
2367 // Returns true if and only if the test was skipped.
2368 bool TestResult::Skipped() const {
2369  return !Failed() && CountIf(test_part_results_, TestPartSkipped) > 0;
2370 }
2371 
2372 // Returns true if and only if the test failed.
2373 bool TestResult::Failed() const {
2374  for (int i = 0; i < total_part_count(); ++i) {
2375  if (GetTestPartResult(i).failed())
2376  return true;
2377  }
2378  return false;
2379 }
2380 
2381 // Returns true if and only if the test part fatally failed.
2383  return result.fatally_failed();
2384 }
2385 
2386 // Returns true if and only if the test fatally failed.
2387 bool TestResult::HasFatalFailure() const {
2388  return CountIf(test_part_results_, TestPartFatallyFailed) > 0;
2389 }
2390 
2391 // Returns true if and only if the test part non-fatally failed.
2393  return result.nonfatally_failed();
2394 }
2395 
2396 // Returns true if and only if the test has a non-fatal failure.
2397 bool TestResult::HasNonfatalFailure() const {
2398  return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0;
2399 }
2400 
2401 // Gets the number of all test parts. This is the sum of the number
2402 // of successful test parts and the number of failed test parts.
2403 int TestResult::total_part_count() const {
2404  return static_cast<int>(test_part_results_.size());
2405 }
2406 
2407 // Returns the number of the test properties.
2408 int TestResult::test_property_count() const {
2409  return static_cast<int>(test_properties_.size());
2410 }
2411 
2412 // class Test
2413 
2414 // Creates a Test object.
2415 
2416 // The c'tor saves the states of all flags.
2417 Test::Test()
2418  : gtest_flag_saver_(new GTEST_FLAG_SAVER_) {
2419 }
2420 
2421 // The d'tor restores the states of all flags. The actual work is
2422 // done by the d'tor of the gtest_flag_saver_ field, and thus not
2423 // visible here.
2424 Test::~Test() {
2425 }
2426 
2427 // Sets up the test fixture.
2428 //
2429 // A sub-class may override this.
2430 void Test::SetUp() {
2431 }
2432 
2433 // Tears down the test fixture.
2434 //
2435 // A sub-class may override this.
2436 void Test::TearDown() {
2437 }
2438 
2439 // Allows user supplied key value pairs to be recorded for later output.
2440 void Test::RecordProperty(const std::string& key, const std::string& value) {
2441  UnitTest::GetInstance()->RecordProperty(key, value);
2442 }
2443 
2444 // Allows user supplied key value pairs to be recorded for later output.
2445 void Test::RecordProperty(const std::string& key, int value) {
2446  Message value_message;
2447  value_message << value;
2448  RecordProperty(key, value_message.GetString().c_str());
2449 }
2450 
2451 namespace internal {
2452 
2454  const std::string& message) {
2455  // This function is a friend of UnitTest and as such has access to
2456  // AddTestPartResult.
2457  UnitTest::GetInstance()->AddTestPartResult(
2458  result_type,
2459  nullptr, // No info about the source file where the exception occurred.
2460  -1, // We have no info on which line caused the exception.
2461  message,
2462  ""); // No stack trace, either.
2463 }
2464 
2465 } // namespace internal
2466 
2467 // Google Test requires all tests in the same test suite to use the same test
2468 // fixture class. This function checks if the current test has the
2469 // same fixture class as the first test in the current test suite. If
2470 // yes, it returns true; otherwise it generates a Google Test failure and
2471 // returns false.
2472 bool Test::HasSameFixtureClass() {
2473  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
2474  const TestSuite* const test_suite = impl->current_test_suite();
2475 
2476  // Info about the first test in the current test suite.
2477  const TestInfo* const first_test_info = test_suite->test_info_list()[0];
2478  const internal::TypeId first_fixture_id = first_test_info->fixture_class_id_;
2479  const char* const first_test_name = first_test_info->name();
2480 
2481  // Info about the current test.
2482  const TestInfo* const this_test_info = impl->current_test_info();
2483  const internal::TypeId this_fixture_id = this_test_info->fixture_class_id_;
2484  const char* const this_test_name = this_test_info->name();
2485 
2486  if (this_fixture_id != first_fixture_id) {
2487  // Is the first test defined using TEST?
2488  const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId();
2489  // Is this test defined using TEST?
2490  const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId();
2491 
2492  if (first_is_TEST || this_is_TEST) {
2493  // Both TEST and TEST_F appear in same test suite, which is incorrect.
2494  // Tell the user how to fix this.
2495 
2496  // Gets the name of the TEST and the name of the TEST_F. Note
2497  // that first_is_TEST and this_is_TEST cannot both be true, as
2498  // the fixture IDs are different for the two tests.
2499  const char* const TEST_name =
2500  first_is_TEST ? first_test_name : this_test_name;
2501  const char* const TEST_F_name =
2502  first_is_TEST ? this_test_name : first_test_name;
2503 
2504  ADD_FAILURE()
2505  << "All tests in the same test suite must use the same test fixture\n"
2506  << "class, so mixing TEST_F and TEST in the same test suite is\n"
2507  << "illegal. In test suite " << this_test_info->test_suite_name()
2508  << ",\n"
2509  << "test " << TEST_F_name << " is defined using TEST_F but\n"
2510  << "test " << TEST_name << " is defined using TEST. You probably\n"
2511  << "want to change the TEST to TEST_F or move it to another test\n"
2512  << "case.";
2513  } else {
2514  // Two fixture classes with the same name appear in two different
2515  // namespaces, which is not allowed. Tell the user how to fix this.
2516  ADD_FAILURE()
2517  << "All tests in the same test suite must use the same test fixture\n"
2518  << "class. However, in test suite "
2519  << this_test_info->test_suite_name() << ",\n"
2520  << "you defined test " << first_test_name << " and test "
2521  << this_test_name << "\n"
2522  << "using two different test fixture classes. This can happen if\n"
2523  << "the two classes are from different namespaces or translation\n"
2524  << "units and have the same name. You should probably rename one\n"
2525  << "of the classes to put the tests into different test suites.";
2526  }
2527  return false;
2528  }
2529 
2530  return true;
2531 }
2532 
2533 #if GTEST_HAS_SEH
2534 
2535 // Adds an "exception thrown" fatal failure to the current test. This
2536 // function returns its result via an output parameter pointer because VC++
2537 // prohibits creation of objects with destructors on stack in functions
2538 // using __try (see error C2712).
2539 static std::string* FormatSehExceptionMessage(DWORD exception_code,
2540  const char* location) {
2541  Message message;
2542  message << "SEH exception with code 0x" << std::setbase(16) <<
2543  exception_code << std::setbase(10) << " thrown in " << location << ".";
2544 
2545  return new std::string(message.GetString());
2546 }
2547 
2548 #endif // GTEST_HAS_SEH
2549 
2550 namespace internal {
2551 
2552 #if GTEST_HAS_EXCEPTIONS
2553 
2554 // Adds an "exception thrown" fatal failure to the current test.
2555 static std::string FormatCxxExceptionMessage(const char* description,
2556  const char* location) {
2557  Message message;
2558  if (description != nullptr) {
2559  message << "C++ exception with description \"" << description << "\"";
2560  } else {
2561  message << "Unknown C++ exception";
2562  }
2563  message << " thrown in " << location << ".";
2564 
2565  return message.GetString();
2566 }
2567 
2569  const TestPartResult& test_part_result);
2570 
2571 GoogleTestFailureException::GoogleTestFailureException(
2572  const TestPartResult& failure)
2573  : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}
2574 
2575 #endif // GTEST_HAS_EXCEPTIONS
2576 
2577 // We put these helper functions in the internal namespace as IBM's xlC
2578 // compiler rejects the code if they were declared static.
2579 
2580 // Runs the given method and handles SEH exceptions it throws, when
2581 // SEH is supported; returns the 0-value for type Result in case of an
2582 // SEH exception. (Microsoft compilers cannot handle SEH and C++
2583 // exceptions in the same function. Therefore, we provide a separate
2584 // wrapper function for handling SEH exceptions.)
2585 template <class T, typename Result>
2587  T* object, Result (T::*method)(), const char* location) {
2588 #if GTEST_HAS_SEH
2589  __try {
2590  return (object->*method)();
2591  } __except (internal::UnitTestOptions::GTestShouldProcessSEH( // NOLINT
2592  GetExceptionCode())) {
2593  // We create the exception message on the heap because VC++ prohibits
2594  // creation of objects with destructors on stack in functions using __try
2595  // (see error C2712).
2596  std::string* exception_message = FormatSehExceptionMessage(
2597  GetExceptionCode(), location);
2598  internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,
2599  *exception_message);
2600  delete exception_message;
2601  return static_cast<Result>(0);
2602  }
2603 #else
2604  (void)location;
2605  return (object->*method)();
2606 #endif // GTEST_HAS_SEH
2607 }
2608 
2609 // Runs the given method and catches and reports C++ and/or SEH-style
2610 // exceptions, if they are supported; returns the 0-value for type
2611 // Result in case of an SEH exception.
2612 template <class T, typename Result>
2614  T* object, Result (T::*method)(), const char* location) {
2615  // NOTE: The user code can affect the way in which Google Test handles
2616  // exceptions by setting GTEST_FLAG(catch_exceptions), but only before
2617  // RUN_ALL_TESTS() starts. It is technically possible to check the flag
2618  // after the exception is caught and either report or re-throw the
2619  // exception based on the flag's value:
2620  //
2621  // try {
2622  // // Perform the test method.
2623  // } catch (...) {
2624  // if (GTEST_FLAG(catch_exceptions))
2625  // // Report the exception as failure.
2626  // else
2627  // throw; // Re-throws the original exception.
2628  // }
2629  //
2630  // However, the purpose of this flag is to allow the program to drop into
2631  // the debugger when the exception is thrown. On most platforms, once the
2632  // control enters the catch block, the exception origin information is
2633  // lost and the debugger will stop the program at the point of the
2634  // re-throw in this function -- instead of at the point of the original
2635  // throw statement in the code under test. For this reason, we perform
2636  // the check early, sacrificing the ability to affect Google Test's
2637  // exception handling in the method where the exception is thrown.
2638  if (internal::GetUnitTestImpl()->catch_exceptions()) {
2639 #if GTEST_HAS_EXCEPTIONS
2640  try {
2641  return HandleSehExceptionsInMethodIfSupported(object, method, location);
2642  } catch (const AssertionException&) { // NOLINT
2643  // This failure was reported already.
2644  } catch (const internal::GoogleTestFailureException&) { // NOLINT
2645  // This exception type can only be thrown by a failed Google
2646  // Test assertion with the intention of letting another testing
2647  // framework catch it. Therefore we just re-throw it.
2648  throw;
2649  } catch (const std::exception& e) { // NOLINT
2651  TestPartResult::kFatalFailure,
2652  FormatCxxExceptionMessage(e.what(), location));
2653  } catch (...) { // NOLINT
2655  TestPartResult::kFatalFailure,
2656  FormatCxxExceptionMessage(nullptr, location));
2657  }
2658  return static_cast<Result>(0);
2659 #else
2660  return HandleSehExceptionsInMethodIfSupported(object, method, location);
2661 #endif // GTEST_HAS_EXCEPTIONS
2662  } else {
2663  return (object->*method)();
2664  }
2665 }
2666 
2667 } // namespace internal
2668 
2669 // Runs the test and updates the test result.
2670 void Test::Run() {
2671  if (!HasSameFixtureClass()) return;
2672 
2673  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
2674  impl->os_stack_trace_getter()->UponLeavingGTest();
2675  internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()");
2676  // We will run the test only if SetUp() was successful and didn't call
2677  // GTEST_SKIP().
2678  if (!HasFatalFailure() && !IsSkipped()) {
2679  impl->os_stack_trace_getter()->UponLeavingGTest();
2681  this, &Test::TestBody, "the test body");
2682  }
2683 
2684  // However, we want to clean up as much as possible. Hence we will
2685  // always call TearDown(), even if SetUp() or the test body has
2686  // failed.
2687  impl->os_stack_trace_getter()->UponLeavingGTest();
2689  this, &Test::TearDown, "TearDown()");
2690 }
2691 
2692 // Returns true if and only if the current test has a fatal failure.
2693 bool Test::HasFatalFailure() {
2695 }
2696 
2697 // Returns true if and only if the current test has a non-fatal failure.
2698 bool Test::HasNonfatalFailure() {
2700  HasNonfatalFailure();
2701 }
2702 
2703 // Returns true if and only if the current test was skipped.
2704 bool Test::IsSkipped() {
2706 }
2707 
2708 // class TestInfo
2709 
2710 // Constructs a TestInfo object. It assumes ownership of the test factory
2711 // object.
2712 TestInfo::TestInfo(const std::string& a_test_suite_name,
2713  const std::string& a_name, const char* a_type_param,
2714  const char* a_value_param,
2715  internal::CodeLocation a_code_location,
2716  internal::TypeId fixture_class_id,
2717  internal::TestFactoryBase* factory)
2718  : test_suite_name_(a_test_suite_name),
2719  name_(a_name),
2720  type_param_(a_type_param ? new std::string(a_type_param) : nullptr),
2721  value_param_(a_value_param ? new std::string(a_value_param) : nullptr),
2722  location_(a_code_location),
2723  fixture_class_id_(fixture_class_id),
2724  should_run_(false),
2725  is_disabled_(false),
2726  matches_filter_(false),
2727  is_in_another_shard_(false),
2728  factory_(factory),
2729  result_() {}
2730 
2731 // Destructs a TestInfo object.
2732 TestInfo::~TestInfo() { delete factory_; }
2733 
2734 namespace internal {
2735 
2736 // Creates a new TestInfo object and registers it with Google Test;
2737 // returns the created object.
2738 //
2739 // Arguments:
2740 //
2741 // test_suite_name: name of the test suite
2742 // name: name of the test
2743 // type_param: the name of the test's type parameter, or NULL if
2744 // this is not a typed or a type-parameterized test.
2745 // value_param: text representation of the test's value parameter,
2746 // or NULL if this is not a value-parameterized test.
2747 // code_location: code location where the test is defined
2748 // fixture_class_id: ID of the test fixture class
2749 // set_up_tc: pointer to the function that sets up the test suite
2750 // tear_down_tc: pointer to the function that tears down the test suite
2751 // factory: pointer to the factory that creates a test object.
2752 // The newly created TestInfo instance will assume
2753 // ownership of the factory object.
2754 TestInfo* MakeAndRegisterTestInfo(
2755  const char* test_suite_name, const char* name, const char* type_param,
2756  const char* value_param, CodeLocation code_location,
2757  TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
2758  TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory) {
2759  TestInfo* const test_info =
2760  new TestInfo(test_suite_name, name, type_param, value_param,
2761  code_location, fixture_class_id, factory);
2762  GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);
2763  return test_info;
2764 }
2765 
2766 void ReportInvalidTestSuiteType(const char* test_suite_name,
2767  CodeLocation code_location) {
2768  Message errors;
2769  errors
2770  << "Attempted redefinition of test suite " << test_suite_name << ".\n"
2771  << "All tests in the same test suite must use the same test fixture\n"
2772  << "class. However, in test suite " << test_suite_name << ", you tried\n"
2773  << "to define a test using a fixture class different from the one\n"
2774  << "used earlier. This can happen if the two fixture classes are\n"
2775  << "from different namespaces and have the same name. You should\n"
2776  << "probably rename one of the classes to put the tests into different\n"
2777  << "test suites.";
2778 
2779  GTEST_LOG_(ERROR) << FormatFileLocation(code_location.file.c_str(),
2780  code_location.line)
2781  << " " << errors.GetString();
2782 }
2783 } // namespace internal
2784 
2785 namespace {
2786 
2787 // A predicate that checks the test name of a TestInfo against a known
2788 // value.
2789 //
2790 // This is used for implementation of the TestSuite class only. We put
2791 // it in the anonymous namespace to prevent polluting the outer
2792 // namespace.
2793 //
2794 // TestNameIs is copyable.
2795 class TestNameIs {
2796  public:
2797  // Constructor.
2798  //
2799  // TestNameIs has NO default constructor.
2800  explicit TestNameIs(const char* name)
2801  : name_(name) {}
2802 
2803  // Returns true if and only if the test name of test_info matches name_.
2804  bool operator()(const TestInfo * test_info) const {
2805  return test_info && test_info->name() == name_;
2806  }
2807 
2808  private:
2810 };
2811 
2812 } // namespace
2813 
2814 namespace internal {
2815 
2816 // This method expands all parameterized tests registered with macros TEST_P
2817 // and INSTANTIATE_TEST_SUITE_P into regular tests and registers those.
2818 // This will be done just once during the program runtime.
2819 void UnitTestImpl::RegisterParameterizedTests() {
2820  if (!parameterized_tests_registered_) {
2821  parameterized_test_registry_.RegisterTests();
2822  type_parameterized_test_registry_.CheckForInstantiations();
2823  parameterized_tests_registered_ = true;
2824  }
2825 }
2826 
2827 } // namespace internal
2828 
2829 // Creates the test object, runs it, records its result, and then
2830 // deletes it.
2831 void TestInfo::Run() {
2832  if (!should_run_) return;
2833 
2834  // Tells UnitTest where to store test result.
2835  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
2836  impl->set_current_test_info(this);
2837 
2838  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
2839 
2840  // Notifies the unit test event listeners that a test is about to start.
2841  repeater->OnTestStart(*this);
2842 
2844 
2845  impl->os_stack_trace_getter()->UponLeavingGTest();
2846 
2847  // Creates the test object.
2849  factory_, &internal::TestFactoryBase::CreateTest,
2850  "the test fixture's constructor");
2851 
2852  // Runs the test if the constructor didn't generate a fatal failure or invoke
2853  // GTEST_SKIP().
2854  // Note that the object will not be null
2855  if (!Test::HasFatalFailure() && !Test::IsSkipped()) {
2856  // This doesn't throw as all user code that can throw are wrapped into
2857  // exception handling code.
2858  test->Run();
2859  }
2860 
2861  if (test != nullptr) {
2862  // Deletes the test object.
2863  impl->os_stack_trace_getter()->UponLeavingGTest();
2865  test, &Test::DeleteSelf_, "the test fixture's destructor");
2866  }
2867 
2868  result_.set_start_timestamp(start);
2869  result_.set_elapsed_time(internal::GetTimeInMillis() - start);
2870 
2871  // Notifies the unit test event listener that a test has just finished.
2872  repeater->OnTestEnd(*this);
2873 
2874  // Tells UnitTest to stop associating assertion results to this
2875  // test.
2876  impl->set_current_test_info(nullptr);
2877 }
2878 
2879 // Skip and records a skipped test result for this object.
2881  if (!should_run_) return;
2882 
2884  impl->set_current_test_info(this);
2885 
2886  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
2887 
2888  // Notifies the unit test event listeners that a test is about to start.
2889  repeater->OnTestStart(*this);
2890 
2891  const TestPartResult test_part_result =
2892  TestPartResult(TestPartResult::kSkip, this->file(), this->line(), "");
2894  test_part_result);
2895 
2896  // Notifies the unit test event listener that a test has just finished.
2897  repeater->OnTestEnd(*this);
2898  impl->set_current_test_info(nullptr);
2899 }
2900 
2901 // class TestSuite
2902 
2903 // Gets the number of successful tests in this test suite.
2904 int TestSuite::successful_test_count() const {
2905  return CountIf(test_info_list_, TestPassed);
2906 }
2907 
2908 // Gets the number of successful tests in this test suite.
2909 int TestSuite::skipped_test_count() const {
2910  return CountIf(test_info_list_, TestSkipped);
2911 }
2912 
2913 // Gets the number of failed tests in this test suite.
2914 int TestSuite::failed_test_count() const {
2915  return CountIf(test_info_list_, TestFailed);
2916 }
2917 
2918 // Gets the number of disabled tests that will be reported in the XML report.
2919 int TestSuite::reportable_disabled_test_count() const {
2920  return CountIf(test_info_list_, TestReportableDisabled);
2921 }
2922 
2923 // Gets the number of disabled tests in this test suite.
2924 int TestSuite::disabled_test_count() const {
2925  return CountIf(test_info_list_, TestDisabled);
2926 }
2927 
2928 // Gets the number of tests to be printed in the XML report.
2929 int TestSuite::reportable_test_count() const {
2930  return CountIf(test_info_list_, TestReportable);
2931 }
2932 
2933 // Get the number of tests in this test suite that should run.
2934 int TestSuite::test_to_run_count() const {
2935  return CountIf(test_info_list_, ShouldRunTest);
2936 }
2937 
2938 // Gets the number of all tests.
2939 int TestSuite::total_test_count() const {
2940  return static_cast<int>(test_info_list_.size());
2941 }
2942 
2943 // Creates a TestSuite with the given name.
2944 //
2945 // Arguments:
2946 //
2947 // a_name: name of the test suite
2948 // a_type_param: the name of the test suite's type parameter, or NULL if
2949 // this is not a typed or a type-parameterized test suite.
2950 // set_up_tc: pointer to the function that sets up the test suite
2951 // tear_down_tc: pointer to the function that tears down the test suite
2952 TestSuite::TestSuite(const char* a_name, const char* a_type_param,
2953  internal::SetUpTestSuiteFunc set_up_tc,
2954  internal::TearDownTestSuiteFunc tear_down_tc)
2955  : name_(a_name),
2956  type_param_(a_type_param ? new std::string(a_type_param) : nullptr),
2957  set_up_tc_(set_up_tc),
2958  tear_down_tc_(tear_down_tc),
2959  should_run_(false),
2960  start_timestamp_(0),
2961  elapsed_time_(0) {}
2962 
2963 // Destructor of TestSuite.
2965  // Deletes every Test in the collection.
2966  ForEach(test_info_list_, internal::Delete<TestInfo>);
2967 }
2968 
2969 // Returns the i-th test among all the tests. i can range from 0 to
2970 // total_test_count() - 1. If i is not in that range, returns NULL.
2971 const TestInfo* TestSuite::GetTestInfo(int i) const {
2972  const int index = GetElementOr(test_indices_, i, -1);
2973  return index < 0 ? nullptr : test_info_list_[static_cast<size_t>(index)];
2974 }
2975 
2976 // Returns the i-th test among all the tests. i can range from 0 to
2977 // total_test_count() - 1. If i is not in that range, returns NULL.
2978 TestInfo* TestSuite::GetMutableTestInfo(int i) {
2979  const int index = GetElementOr(test_indices_, i, -1);
2980  return index < 0 ? nullptr : test_info_list_[static_cast<size_t>(index)];
2981 }
2982 
2983 // Adds a test to this test suite. Will delete the test upon
2984 // destruction of the TestSuite object.
2985 void TestSuite::AddTestInfo(TestInfo* test_info) {
2986  test_info_list_.push_back(test_info);
2987  test_indices_.push_back(static_cast<int>(test_indices_.size()));
2988 }
2989 
2990 // Runs every test in this TestSuite.
2991 void TestSuite::Run() {
2992  if (!should_run_) return;
2993 
2995  impl->set_current_test_suite(this);
2996 
2997  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
2998 
2999  // Call both legacy and the new API
3000  repeater->OnTestSuiteStart(*this);
3001 // Legacy API is deprecated but still available
3002 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3003  repeater->OnTestCaseStart(*this);
3004 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3005 
3006  impl->os_stack_trace_getter()->UponLeavingGTest();
3008  this, &TestSuite::RunSetUpTestSuite, "SetUpTestSuite()");
3009 
3011  for (int i = 0; i < total_test_count(); i++) {
3012  GetMutableTestInfo(i)->Run();
3013  if (GTEST_FLAG(fail_fast) && GetMutableTestInfo(i)->result()->Failed()) {
3014  for (int j = i + 1; j < total_test_count(); j++) {
3015  GetMutableTestInfo(j)->Skip();
3016  }
3017  break;
3018  }
3019  }
3021 
3022  impl->os_stack_trace_getter()->UponLeavingGTest();
3024  this, &TestSuite::RunTearDownTestSuite, "TearDownTestSuite()");
3025 
3026  // Call both legacy and the new API
3027  repeater->OnTestSuiteEnd(*this);
3028 // Legacy API is deprecated but still available
3029 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3030  repeater->OnTestCaseEnd(*this);
3031 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3032 
3033  impl->set_current_test_suite(nullptr);
3034 }
3035 
3036 // Skips all tests under this TestSuite.
3038  if (!should_run_) return;
3039 
3041  impl->set_current_test_suite(this);
3042 
3044 
3045  // Call both legacy and the new API
3046  repeater->OnTestSuiteStart(*this);
3047 // Legacy API is deprecated but still available
3048 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3049  repeater->OnTestCaseStart(*this);
3050 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3051 
3052  for (int i = 0; i < total_test_count(); i++) {
3054  }
3055 
3056  // Call both legacy and the new API
3057  repeater->OnTestSuiteEnd(*this);
3058  // Legacy API is deprecated but still available
3059 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3060  repeater->OnTestCaseEnd(*this);
3061 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3062 
3063  impl->set_current_test_suite(nullptr);
3064 }
3065 
3066 // Clears the results of all tests in this test suite.
3067 void TestSuite::ClearResult() {
3070 }
3071 
3072 // Shuffles the tests in this test suite.
3074  Shuffle(random, &test_indices_);
3075 }
3076 
3077 // Restores the test order to before the first shuffle.
3079  for (size_t i = 0; i < test_indices_.size(); i++) {
3080  test_indices_[i] = static_cast<int>(i);
3081  }
3082 }
3083 
3084 // Formats a countable noun. Depending on its quantity, either the
3085 // singular form or the plural form is used. e.g.
3086 //
3087 // FormatCountableNoun(1, "formula", "formuli") returns "1 formula".
3088 // FormatCountableNoun(5, "book", "books") returns "5 books".
3090  const char * singular_form,
3091  const char * plural_form) {
3092  return internal::StreamableToString(count) + " " +
3093  (count == 1 ? singular_form : plural_form);
3094 }
3095 
3096 // Formats the count of tests.
3098  return FormatCountableNoun(test_count, "test", "tests");
3099 }
3100 
3101 // Formats the count of test suites.
3102 static std::string FormatTestSuiteCount(int test_suite_count) {
3103  return FormatCountableNoun(test_suite_count, "test suite", "test suites");
3104 }
3105 
3106 // Converts a TestPartResult::Type enum to human-friendly string
3107 // representation. Both kNonFatalFailure and kFatalFailure are translated
3108 // to "Failure", as the user usually doesn't care about the difference
3109 // between the two when viewing the test result.
3111  switch (type) {
3112  case TestPartResult::kSkip:
3113  return "Skipped\n";
3115  return "Success";
3116 
3119 #ifdef _MSC_VER
3120  return "error: ";
3121 #else
3122  return "Failure\n";
3123 #endif
3124  default:
3125  return "Unknown result type";
3126  }
3127 }
3128 
3129 namespace internal {
3130 namespace {
3131 enum class GTestColor { kDefault, kRed, kGreen, kYellow };
3132 } // namespace
3133 
3134 // Prints a TestPartResult to an std::string.
3136  const TestPartResult& test_part_result) {
3137  return (Message()
3138  << internal::FormatFileLocation(test_part_result.file_name(),
3139  test_part_result.line_number())
3140  << " " << TestPartResultTypeToString(test_part_result.type())
3141  << test_part_result.message()).GetString();
3142 }
3143 
3144 // Prints a TestPartResult.
3145 static void PrintTestPartResult(const TestPartResult& test_part_result) {
3146  const std::string& result =
3147  PrintTestPartResultToString(test_part_result);
3148  printf("%s\n", result.c_str());
3149  fflush(stdout);
3150  // If the test program runs in Visual Studio or a debugger, the
3151  // following statements add the test part result message to the Output
3152  // window such that the user can double-click on it to jump to the
3153  // corresponding source code location; otherwise they do nothing.
3154 #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
3155  // We don't call OutputDebugString*() on Windows Mobile, as printing
3156  // to stdout is done by OutputDebugString() there already - we don't
3157  // want the same message printed twice.
3158  ::OutputDebugStringA(result.c_str());
3159  ::OutputDebugStringA("\n");
3160 #endif
3161 }
3162 
3163 // class PrettyUnitTestResultPrinter
3164 #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \
3165  !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
3166 
3167 // Returns the character attribute for the given color.
3168 static WORD GetColorAttribute(GTestColor color) {
3169  switch (color) {
3170  case GTestColor::kRed:
3171  return FOREGROUND_RED;
3172  case GTestColor::kGreen:
3173  return FOREGROUND_GREEN;
3174  case GTestColor::kYellow:
3175  return FOREGROUND_RED | FOREGROUND_GREEN;
3176  default: return 0;
3177  }
3178 }
3179 
3180 static int GetBitOffset(WORD color_mask) {
3181  if (color_mask == 0) return 0;
3182 
3183  int bitOffset = 0;
3184  while ((color_mask & 1) == 0) {
3185  color_mask >>= 1;
3186  ++bitOffset;
3187  }
3188  return bitOffset;
3189 }
3190 
3191 static WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
3192  // Let's reuse the BG
3193  static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN |
3194  BACKGROUND_RED | BACKGROUND_INTENSITY;
3195  static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN |
3196  FOREGROUND_RED | FOREGROUND_INTENSITY;
3197  const WORD existing_bg = old_color_attrs & background_mask;
3198 
3199  WORD new_color =
3200  GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY;
3201  static const int bg_bitOffset = GetBitOffset(background_mask);
3202  static const int fg_bitOffset = GetBitOffset(foreground_mask);
3203 
3204  if (((new_color & background_mask) >> bg_bitOffset) ==
3205  ((new_color & foreground_mask) >> fg_bitOffset)) {
3206  new_color ^= FOREGROUND_INTENSITY; // invert intensity
3207  }
3208  return new_color;
3209 }
3210 
3211 #else
3212 
3213 // Returns the ANSI color code for the given color. GTestColor::kDefault is
3214 // an invalid input.
3215 static const char* GetAnsiColorCode(GTestColor color) {
3216  switch (color) {
3217  case GTestColor::kRed:
3218  return "1";
3219  case GTestColor::kGreen:
3220  return "2";
3221  case GTestColor::kYellow:
3222  return "3";
3223  default:
3224  return nullptr;
3225  }
3226 }
3227 
3228 #endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
3229 
3230 // Returns true if and only if Google Test should use colors in the output.
3231 bool ShouldUseColor(bool stdout_is_tty) {
3232  const char* const gtest_color = GTEST_FLAG(color).c_str();
3233 
3234  if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) {
3235 #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
3236  // On Windows the TERM variable is usually not set, but the
3237  // console there does support colors.
3238  return stdout_is_tty;
3239 #else
3240  // On non-Windows platforms, we rely on the TERM variable.
3241  const char* const term = posix::GetEnv("TERM");
3242  const bool term_supports_color =
3243  String::CStringEquals(term, "xterm") ||
3244  String::CStringEquals(term, "xterm-color") ||
3245  String::CStringEquals(term, "xterm-256color") ||
3246  String::CStringEquals(term, "screen") ||
3247  String::CStringEquals(term, "screen-256color") ||
3248  String::CStringEquals(term, "tmux") ||
3249  String::CStringEquals(term, "tmux-256color") ||
3250  String::CStringEquals(term, "rxvt-unicode") ||
3251  String::CStringEquals(term, "rxvt-unicode-256color") ||
3252  String::CStringEquals(term, "linux") ||
3253  String::CStringEquals(term, "cygwin");
3254  return stdout_is_tty && term_supports_color;
3255 #endif // GTEST_OS_WINDOWS
3256  }
3257 
3258  return String::CaseInsensitiveCStringEquals(gtest_color, "yes") ||
3259  String::CaseInsensitiveCStringEquals(gtest_color, "true") ||
3260  String::CaseInsensitiveCStringEquals(gtest_color, "t") ||
3261  String::CStringEquals(gtest_color, "1");
3262  // We take "yes", "true", "t", and "1" as meaning "yes". If the
3263  // value is neither one of these nor "auto", we treat it as "no" to
3264  // be conservative.
3265 }
3266 
3267 // Helpers for printing colored strings to stdout. Note that on Windows, we
3268 // cannot simply emit special characters and have the terminal change colors.
3269 // This routine must actually emit the characters rather than return a string
3270 // that would be colored when printed, as can be done on Linux.
3271 
3273 static void ColoredPrintf(GTestColor color, const char *fmt, ...) {
3274  va_list args;
3275  va_start(args, fmt);
3276 
3277 #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS || GTEST_OS_IOS || \
3278  GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT || defined(ESP_PLATFORM)
3279  const bool use_color = AlwaysFalse();
3280 #else
3281  static const bool in_color_mode =
3283  const bool use_color = in_color_mode && (color != GTestColor::kDefault);
3284 #endif // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS
3285 
3286  if (!use_color) {
3287  vprintf(fmt, args);
3288  va_end(args);
3289  return;
3290  }
3291 
3292 #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \
3293  !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
3294  const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
3295 
3296  // Gets the current text color.
3297  CONSOLE_SCREEN_BUFFER_INFO buffer_info;
3298  GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
3299  const WORD old_color_attrs = buffer_info.wAttributes;
3300  const WORD new_color = GetNewColor(color, old_color_attrs);
3301 
3302  // We need to flush the stream buffers into the console before each
3303  // SetConsoleTextAttribute call lest it affect the text that is already
3304  // printed but has not yet reached the console.
3305  fflush(stdout);
3306  SetConsoleTextAttribute(stdout_handle, new_color);
3307 
3308  vprintf(fmt, args);
3309 
3310  fflush(stdout);
3311  // Restores the text color.
3312  SetConsoleTextAttribute(stdout_handle, old_color_attrs);
3313 #else
3314  printf("\033[0;3%sm", GetAnsiColorCode(color));
3315  vprintf(fmt, args);
3316  printf("\033[m"); // Resets the terminal to default.
3317 #endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
3318  va_end(args);
3319 }
3320 
3321 // Text printed in Google Test's text output and --gtest_list_tests
3322 // output to label the type parameter and value parameter for a test.
3323 static const char kTypeParamLabel[] = "TypeParam";
3324 static const char kValueParamLabel[] = "GetParam()";
3325 
3326 static void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
3327  const char* const type_param = test_info.type_param();
3328  const char* const value_param = test_info.value_param();
3329 
3330  if (type_param != nullptr || value_param != nullptr) {
3331  printf(", where ");
3332  if (type_param != nullptr) {
3333  printf("%s = %s", kTypeParamLabel, type_param);
3334  if (value_param != nullptr) printf(" and ");
3335  }
3336  if (value_param != nullptr) {
3337  printf("%s = %s", kValueParamLabel, value_param);
3338  }
3339  }
3340 }
3341 
3342 // This class implements the TestEventListener interface.
3343 //
3344 // Class PrettyUnitTestResultPrinter is copyable.
3345 class PrettyUnitTestResultPrinter : public TestEventListener {
3346  public:
3348  static void PrintTestName(const char* test_suite, const char* test) {
3349  printf("%s.%s", test_suite, test);
3350  }
3351 
3352  // The following methods override what's in the TestEventListener class.
3353  void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}
3354  void OnTestIterationStart(const UnitTest& unit_test, int iteration) override;
3355  void OnEnvironmentsSetUpStart(const UnitTest& unit_test) override;
3356  void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}
3357 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3358  void OnTestCaseStart(const TestCase& test_case) override;
3359 #else
3360  void OnTestSuiteStart(const TestSuite& test_suite) override;
3361 #endif // OnTestCaseStart
3362 
3363  void OnTestStart(const TestInfo& test_info) override;
3364 
3365  void OnTestPartResult(const TestPartResult& result) override;
3366  void OnTestEnd(const TestInfo& test_info) override;
3367 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3368  void OnTestCaseEnd(const TestCase& test_case) override;
3369 #else
3370  void OnTestSuiteEnd(const TestSuite& test_suite) override;
3371 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3372 
3373  void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override;
3374  void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}
3375  void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
3376  void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}
3377 
3378  private:
3379  static void PrintFailedTests(const UnitTest& unit_test);
3380  static void PrintFailedTestSuites(const UnitTest& unit_test);
3381  static void PrintSkippedTests(const UnitTest& unit_test);
3382 };
3383 
3384  // Fired before each iteration of tests starts.
3386  const UnitTest& unit_test, int iteration) {
3387  if (GTEST_FLAG(repeat) != 1)
3388  printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1);
3389 
3390  const char* const filter = GTEST_FLAG(filter).c_str();
3391 
3392  // Prints the filter if it's not *. This reminds the user that some
3393  // tests may be skipped.
3394  if (!String::CStringEquals(filter, kUniversalFilter)) {
3395  ColoredPrintf(GTestColor::kYellow, "Note: %s filter = %s\n", GTEST_NAME_,
3396  filter);
3397  }
3398 
3400  const int32_t shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
3401  ColoredPrintf(GTestColor::kYellow, "Note: This is test shard %d of %s.\n",
3402  static_cast<int>(shard_index) + 1,
3404  }
3405 
3406  if (GTEST_FLAG(shuffle)) {
3407  ColoredPrintf(GTestColor::kYellow,
3408  "Note: Randomizing tests' orders with a seed of %d .\n",
3409  unit_test.random_seed());
3410  }
3411 
3412  ColoredPrintf(GTestColor::kGreen, "[==========] ");
3413  printf("Running %s from %s.\n",
3414  FormatTestCount(unit_test.test_to_run_count()).c_str(),
3415  FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
3416  fflush(stdout);
3417 }
3418 
3420  const UnitTest& /*unit_test*/) {
3421  ColoredPrintf(GTestColor::kGreen, "[----------] ");
3422  printf("Global test environment set-up.\n");
3423  fflush(stdout);
3424 }
3425 
3426 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3428  const std::string counts =
3429  FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
3430  ColoredPrintf(GTestColor::kGreen, "[----------] ");
3431  printf("%s from %s", counts.c_str(), test_case.name());
3432  if (test_case.type_param() == nullptr) {
3433  printf("\n");
3434  } else {
3435  printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param());
3436  }
3437  fflush(stdout);
3438 }
3439 #else
3441  const TestSuite& test_suite) {
3442  const std::string counts =
3443  FormatCountableNoun(test_suite.test_to_run_count(), "test", "tests");
3444  ColoredPrintf(GTestColor::kGreen, "[----------] ");
3445  printf("%s from %s", counts.c_str(), test_suite.name());
3446  if (test_suite.type_param() == nullptr) {
3447  printf("\n");
3448  } else {
3449  printf(", where %s = %s\n", kTypeParamLabel, test_suite.type_param());
3450  }
3451  fflush(stdout);
3452 }
3453 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3454 
3455 void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {
3456  ColoredPrintf(GTestColor::kGreen, "[ RUN ] ");
3457  PrintTestName(test_info.test_suite_name(), test_info.name());
3458  printf("\n");
3459  fflush(stdout);
3460 }
3461 
3462 // Called after an assertion failure.
3464  const TestPartResult& result) {
3465  switch (result.type()) {
3466  // If the test part succeeded, we don't need to do anything.
3468  return;
3469  default:
3470  // Print failure message from the assertion
3471  // (e.g. expected this and got that).
3473  fflush(stdout);
3474  }
3475 }
3476 
3477 void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {
3478  if (test_info.result()->Passed()) {
3479  ColoredPrintf(GTestColor::kGreen, "[ OK ] ");
3480  } else if (test_info.result()->Skipped()) {
3481  ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
3482  } else {
3483  ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
3484  }
3485  PrintTestName(test_info.test_suite_name(), test_info.name());
3486  if (test_info.result()->Failed())
3487  PrintFullTestCommentIfPresent(test_info);
3488 
3489  if (GTEST_FLAG(print_time)) {
3490  printf(" (%s ms)\n", internal::StreamableToString(
3491  test_info.result()->elapsed_time()).c_str());
3492  } else {
3493  printf("\n");
3494  }
3495  fflush(stdout);
3496 }
3497 
3498 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3500  if (!GTEST_FLAG(print_time)) return;
3501 
3502  const std::string counts =
3503  FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
3504  ColoredPrintf(GTestColor::kGreen, "[----------] ");
3505  printf("%s from %s (%s ms total)\n\n", counts.c_str(), test_case.name(),
3506  internal::StreamableToString(test_case.elapsed_time()).c_str());
3507  fflush(stdout);
3508 }
3509 #else
3511  if (!GTEST_FLAG(print_time)) return;
3512 
3513  const std::string counts =
3514  FormatCountableNoun(test_suite.test_to_run_count(), "test", "tests");
3515  ColoredPrintf(GTestColor::kGreen, "[----------] ");
3516  printf("%s from %s (%s ms total)\n\n", counts.c_str(), test_suite.name(),
3517  internal::StreamableToString(test_suite.elapsed_time()).c_str());
3518  fflush(stdout);
3519 }
3520 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3521 
3523  const UnitTest& /*unit_test*/) {
3524  ColoredPrintf(GTestColor::kGreen, "[----------] ");
3525  printf("Global test environment tear-down\n");
3526  fflush(stdout);
3527 }
3528 
3529 // Internal helper for printing the list of failed tests.
3530 void PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) {
3531  const int failed_test_count = unit_test.failed_test_count();
3532  ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
3533  printf("%s, listed below:\n", FormatTestCount(failed_test_count).c_str());
3534 
3535  for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
3536  const TestSuite& test_suite = *unit_test.GetTestSuite(i);
3537  if (!test_suite.should_run() || (test_suite.failed_test_count() == 0)) {
3538  continue;
3539  }
3540  for (int j = 0; j < test_suite.total_test_count(); ++j) {
3541  const TestInfo& test_info = *test_suite.GetTestInfo(j);
3542  if (!test_info.should_run() || !test_info.result()->Failed()) {
3543  continue;
3544  }
3545  ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
3546  printf("%s.%s", test_suite.name(), test_info.name());
3547  PrintFullTestCommentIfPresent(test_info);
3548  printf("\n");
3549  }
3550  }
3551  printf("\n%2d FAILED %s\n", failed_test_count,
3552  failed_test_count == 1 ? "TEST" : "TESTS");
3553 }
3554 
3555 // Internal helper for printing the list of test suite failures not covered by
3556 // PrintFailedTests.
3558  const UnitTest& unit_test) {
3559  int suite_failure_count = 0;
3560  for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
3561  const TestSuite& test_suite = *unit_test.GetTestSuite(i);
3562  if (!test_suite.should_run()) {
3563  continue;
3564  }
3565  if (test_suite.ad_hoc_test_result().Failed()) {
3566  ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
3567  printf("%s: SetUpTestSuite or TearDownTestSuite\n", test_suite.name());
3568  ++suite_failure_count;
3569  }
3570  }
3571  if (suite_failure_count > 0) {
3572  printf("\n%2d FAILED TEST %s\n", suite_failure_count,
3573  suite_failure_count == 1 ? "SUITE" : "SUITES");
3574  }
3575 }
3576 
3577 // Internal helper for printing the list of skipped tests.
3579  const int skipped_test_count = unit_test.skipped_test_count();
3580  if (skipped_test_count == 0) {
3581  return;
3582  }
3583 
3584  for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
3585  const TestSuite& test_suite = *unit_test.GetTestSuite(i);
3586  if (!test_suite.should_run() || (test_suite.skipped_test_count() == 0)) {
3587  continue;
3588  }
3589  for (int j = 0; j < test_suite.total_test_count(); ++j) {
3590  const TestInfo& test_info = *test_suite.GetTestInfo(j);
3591  if (!test_info.should_run() || !test_info.result()->Skipped()) {
3592  continue;
3593  }
3594  ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
3595  printf("%s.%s", test_suite.name(), test_info.name());
3596  printf("\n");
3597  }
3598  }
3599 }
3600 
3601 void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
3602  int /*iteration*/) {
3603  ColoredPrintf(GTestColor::kGreen, "[==========] ");
3604  printf("%s from %s ran.",
3605  FormatTestCount(unit_test.test_to_run_count()).c_str(),
3606  FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
3607  if (GTEST_FLAG(print_time)) {
3608  printf(" (%s ms total)",
3609  internal::StreamableToString(unit_test.elapsed_time()).c_str());
3610  }
3611  printf("\n");
3612  ColoredPrintf(GTestColor::kGreen, "[ PASSED ] ");
3613  printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str());
3614 
3615  const int skipped_test_count = unit_test.skipped_test_count();
3616  if (skipped_test_count > 0) {
3617  ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
3618  printf("%s, listed below:\n", FormatTestCount(skipped_test_count).c_str());
3619  PrintSkippedTests(unit_test);
3620  }
3621 
3622  if (!unit_test.Passed()) {
3623  PrintFailedTests(unit_test);
3624  PrintFailedTestSuites(unit_test);
3625  }
3626 
3627  int num_disabled = unit_test.reportable_disabled_test_count();
3628  if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
3629  if (unit_test.Passed()) {
3630  printf("\n"); // Add a spacer if no FAILURE banner is displayed.
3631  }
3632  ColoredPrintf(GTestColor::kYellow, " YOU HAVE %d DISABLED %s\n\n",
3633  num_disabled, num_disabled == 1 ? "TEST" : "TESTS");
3634  }
3635  // Ensure that Google Test output is printed before, e.g., heapchecker output.
3636  fflush(stdout);
3637 }
3638 
3639 // End PrettyUnitTestResultPrinter
3640 
3641 // This class implements the TestEventListener interface.
3642 //
3643 // Class BriefUnitTestResultPrinter is copyable.
3645  public:
3647  static void PrintTestName(const char* test_suite, const char* test) {
3648  printf("%s.%s", test_suite, test);
3649  }
3650 
3651  // The following methods override what's in the TestEventListener class.
3652  void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}
3653  void OnTestIterationStart(const UnitTest& /*unit_test*/,
3654  int /*iteration*/) override {}
3655  void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {}
3656  void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}
3657 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3658  void OnTestCaseStart(const TestCase& /*test_case*/) override {}
3659 #else
3660  void OnTestSuiteStart(const TestSuite& /*test_suite*/) override {}
3661 #endif // OnTestCaseStart
3662 
3663  void OnTestStart(const TestInfo& /*test_info*/) override {}
3664 
3665  void OnTestPartResult(const TestPartResult& result) override;
3666  void OnTestEnd(const TestInfo& test_info) override;
3667 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3668  void OnTestCaseEnd(const TestCase& /*test_case*/) override {}
3669 #else
3670  void OnTestSuiteEnd(const TestSuite& /*test_suite*/) override {}
3671 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3672 
3673  void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {}
3674  void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}
3675  void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
3676  void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}
3677 };
3678 
3679 // Called after an assertion failure.
3681  const TestPartResult& result) {
3682  switch (result.type()) {
3683  // If the test part succeeded, we don't need to do anything.
3685  return;
3686  default:
3687  // Print failure message from the assertion
3688  // (e.g. expected this and got that).
3690  fflush(stdout);
3691  }
3692 }
3693 
3695  if (test_info.result()->Failed()) {
3696  ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
3697  PrintTestName(test_info.test_suite_name(), test_info.name());
3698  PrintFullTestCommentIfPresent(test_info);
3699 
3700  if (GTEST_FLAG(print_time)) {
3701  printf(" (%s ms)\n",
3703  .c_str());
3704  } else {
3705  printf("\n");
3706  }
3707  fflush(stdout);
3708  }
3709 }
3710 
3712  int /*iteration*/) {
3713  ColoredPrintf(GTestColor::kGreen, "[==========] ");
3714  printf("%s from %s ran.",
3715  FormatTestCount(unit_test.test_to_run_count()).c_str(),
3716  FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
3717  if (GTEST_FLAG(print_time)) {
3718  printf(" (%s ms total)",
3719  internal::StreamableToString(unit_test.elapsed_time()).c_str());
3720  }
3721  printf("\n");
3722  ColoredPrintf(GTestColor::kGreen, "[ PASSED ] ");
3723  printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str());
3724 
3725  const int skipped_test_count = unit_test.skipped_test_count();
3726  if (skipped_test_count > 0) {
3727  ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
3728  printf("%s.\n", FormatTestCount(skipped_test_count).c_str());
3729  }
3730 
3731  int num_disabled = unit_test.reportable_disabled_test_count();
3732  if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
3733  if (unit_test.Passed()) {
3734  printf("\n"); // Add a spacer if no FAILURE banner is displayed.
3735  }
3736  ColoredPrintf(GTestColor::kYellow, " YOU HAVE %d DISABLED %s\n\n",
3737  num_disabled, num_disabled == 1 ? "TEST" : "TESTS");
3738  }
3739  // Ensure that Google Test output is printed before, e.g., heapchecker output.
3740  fflush(stdout);
3741 }
3742 
3743 // End BriefUnitTestResultPrinter
3744 
3745 // class TestEventRepeater
3746 //
3747 // This class forwards events to other event listeners.
3748 class TestEventRepeater : public TestEventListener {
3749  public:
3751  ~TestEventRepeater() override;
3752  void Append(TestEventListener *listener);
3754 
3755  // Controls whether events will be forwarded to listeners_. Set to false
3756  // in death test child processes.
3757  bool forwarding_enabled() const { return forwarding_enabled_; }
3758  void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }
3759 
3760  void OnTestProgramStart(const UnitTest& unit_test) override;
3761  void OnTestIterationStart(const UnitTest& unit_test, int iteration) override;
3762  void OnEnvironmentsSetUpStart(const UnitTest& unit_test) override;
3763  void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) override;
3764 // Legacy API is deprecated but still available
3765 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3766  void OnTestCaseStart(const TestSuite& parameter) override;
3767 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3768  void OnTestSuiteStart(const TestSuite& parameter) override;
3769  void OnTestStart(const TestInfo& test_info) override;
3770  void OnTestPartResult(const TestPartResult& result) override;
3771  void OnTestEnd(const TestInfo& test_info) override;
3772 // Legacy API is deprecated but still available
3773 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3774  void OnTestCaseEnd(const TestCase& parameter) override;
3775 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3776  void OnTestSuiteEnd(const TestSuite& parameter) override;
3777  void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override;
3778  void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) override;
3779  void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
3780  void OnTestProgramEnd(const UnitTest& unit_test) override;
3781 
3782  private:
3783  // Controls whether events will be forwarded to listeners_. Set to false
3784  // in death test child processes.
3785  bool forwarding_enabled_;
3786  // The list of listeners that receive events.
3787  std::vector<TestEventListener*> listeners_;
3788 
3790 };
3791 
3793  ForEach(listeners_, Delete<TestEventListener>);
3794 }
3795 
3796 void TestEventRepeater::Append(TestEventListener *listener) {
3797  listeners_.push_back(listener);
3798 }
3799 
3800 TestEventListener* TestEventRepeater::Release(TestEventListener *listener) {
3801  for (size_t i = 0; i < listeners_.size(); ++i) {
3802  if (listeners_[i] == listener) {
3803  listeners_.erase(listeners_.begin() + static_cast<int>(i));
3804  return listener;
3805  }
3806  }
3807 
3808  return nullptr;
3809 }
3810 
3811 // Since most methods are very similar, use macros to reduce boilerplate.
3812 // This defines a member that forwards the call to all listeners.
3813 #define GTEST_REPEATER_METHOD_(Name, Type) \
3814 void TestEventRepeater::Name(const Type& parameter) { \
3815  if (forwarding_enabled_) { \
3816  for (size_t i = 0; i < listeners_.size(); i++) { \
3817  listeners_[i]->Name(parameter); \
3818  } \
3819  } \
3820 }
3821 // This defines a member that forwards the call to all listeners in reverse
3822 // order.
3823 #define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \
3824  void TestEventRepeater::Name(const Type& parameter) { \
3825  if (forwarding_enabled_) { \
3826  for (size_t i = listeners_.size(); i != 0; i--) { \
3827  listeners_[i - 1]->Name(parameter); \
3828  } \
3829  } \
3830  }
3831 
3832 GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest)
3833 GTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest)
3834 // Legacy API is deprecated but still available
3835 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3836 GTEST_REPEATER_METHOD_(OnTestCaseStart, TestSuite)
3837 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3838 GTEST_REPEATER_METHOD_(OnTestSuiteStart, TestSuite)
3839 GTEST_REPEATER_METHOD_(OnTestStart, TestInfo)
3840 GTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult)
3841 GTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest)
3842 GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest)
3843 GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest)
3844 GTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo)
3845 // Legacy API is deprecated but still available
3846 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3848 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
3850 GTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest)
3851 
3852 #undef GTEST_REPEATER_METHOD_
3853 #undef GTEST_REVERSE_REPEATER_METHOD_
3854 
3855 void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,
3856  int iteration) {
3857  if (forwarding_enabled_) {
3858  for (size_t i = 0; i < listeners_.size(); i++) {
3859  listeners_[i]->OnTestIterationStart(unit_test, iteration);
3860  }
3861  }
3862 }
3863 
3864 void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test,
3865  int iteration) {
3866  if (forwarding_enabled_) {
3867  for (size_t i = listeners_.size(); i > 0; i--) {
3868  listeners_[i - 1]->OnTestIterationEnd(unit_test, iteration);
3869  }
3870  }
3871 }
3872 
3873 // End TestEventRepeater
3874 
3875 // This class generates an XML output file.
3876 class XmlUnitTestResultPrinter : public EmptyTestEventListener {
3877  public:
3878  explicit XmlUnitTestResultPrinter(const char* output_file);
3879 
3880  void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
3881  void ListTestsMatchingFilter(const std::vector<TestSuite*>& test_suites);
3882 
3883  // Prints an XML summary of all unit tests.
3884  static void PrintXmlTestsList(std::ostream* stream,
3885  const std::vector<TestSuite*>& test_suites);
3886 
3887  private:
3888  // Is c a whitespace character that is normalized to a space character
3889  // when it appears in an XML attribute value?
3890  static bool IsNormalizableWhitespace(char c) {
3891  return c == 0x9 || c == 0xA || c == 0xD;
3892  }
3893 
3894  // May c appear in a well-formed XML document?
3895  static bool IsValidXmlCharacter(char c) {
3896  return IsNormalizableWhitespace(c) || c >= 0x20;
3897  }
3898 
3899  // Returns an XML-escaped copy of the input string str. If
3900  // is_attribute is true, the text is meant to appear as an attribute
3901  // value, and normalizable whitespace is preserved by replacing it
3902  // with character references.
3903  static std::string EscapeXml(const std::string& str, bool is_attribute);
3904 
3905  // Returns the given string with all characters invalid in XML removed.
3907 
3908  // Convenience wrapper around EscapeXml when str is an attribute value.
3910  return EscapeXml(str, true);
3911  }
3912 
3913  // Convenience wrapper around EscapeXml when str is not an attribute value.
3914  static std::string EscapeXmlText(const char* str) {
3915  return EscapeXml(str, false);
3916  }
3917 
3918  // Verifies that the given attribute belongs to the given element and
3919  // streams the attribute as XML.
3920  static void OutputXmlAttribute(std::ostream* stream,
3921  const std::string& element_name,
3922  const std::string& name,
3923  const std::string& value);
3924 
3925  // Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
3926  static void OutputXmlCDataSection(::std::ostream* stream, const char* data);
3927 
3928  // Streams an XML representation of a TestInfo object.
3929  static void OutputXmlTestInfo(::std::ostream* stream,
3930  const char* test_suite_name,
3931  const TestInfo& test_info);
3932 
3933  // Prints an XML representation of a TestSuite object
3934  static void PrintXmlTestSuite(::std::ostream* stream,
3935  const TestSuite& test_suite);
3936 
3937  // Prints an XML summary of unit_test to output stream out.
3938  static void PrintXmlUnitTest(::std::ostream* stream,
3939  const UnitTest& unit_test);
3940 
3941  // Produces a string representing the test properties in a result as space
3942  // delimited XML attributes based on the property key="value" pairs.
3943  // When the std::string is not empty, it includes a space at the beginning,
3944  // to delimit this attribute from prior attributes.
3946 
3947  // Streams an XML representation of the test properties of a TestResult
3948  // object.
3949  static void OutputXmlTestProperties(std::ostream* stream,
3950  const TestResult& result);
3951 
3952  // The output file.
3953  const std::string output_file_;
3954 
3956 };
3957 
3958 // Creates a new XmlUnitTestResultPrinter.
3960  : output_file_(output_file) {
3961  if (output_file_.empty()) {
3962  GTEST_LOG_(FATAL) << "XML output file may not be null";
3963  }
3964 }
3965 
3966 // Called after the unit test ends.
3967 void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
3968  int /*iteration*/) {
3970  std::stringstream stream;
3971  PrintXmlUnitTest(&stream, unit_test);
3972  fprintf(xmlout, "%s", StringStreamToString(&stream).c_str());
3973  fclose(xmlout);
3974 }
3975 
3977  const std::vector<TestSuite*>& test_suites) {
3979  std::stringstream stream;
3980  PrintXmlTestsList(&stream, test_suites);
3981  fprintf(xmlout, "%s", StringStreamToString(&stream).c_str());
3982  fclose(xmlout);
3983 }
3984 
3985 // Returns an XML-escaped copy of the input string str. If is_attribute
3986 // is true, the text is meant to appear as an attribute value, and
3987 // normalizable whitespace is preserved by replacing it with character
3988 // references.
3989 //
3990 // Invalid XML characters in str, if any, are stripped from the output.
3991 // It is expected that most, if not all, of the text processed by this
3992 // module will consist of ordinary English text.
3993 // If this module is ever modified to produce version 1.1 XML output,
3994 // most invalid characters can be retained using character references.
3996  const std::string& str, bool is_attribute) {
3997  Message m;
3998 
3999  for (size_t i = 0; i < str.size(); ++i) {
4000  const char ch = str[i];
4001  switch (ch) {
4002  case '<':
4003  m << "&lt;";
4004  break;
4005  case '>':
4006  m << "&gt;";
4007  break;
4008  case '&':
4009  m << "&amp;";
4010  break;
4011  case '\'':
4012  if (is_attribute)
4013  m << "&apos;";
4014  else
4015  m << '\'';
4016  break;
4017  case '"':
4018  if (is_attribute)
4019  m << "&quot;";
4020  else
4021  m << '"';
4022  break;
4023  default:
4024  if (IsValidXmlCharacter(ch)) {
4025  if (is_attribute && IsNormalizableWhitespace(ch))
4026  m << "&#x" << String::FormatByte(static_cast<unsigned char>(ch))
4027  << ";";
4028  else
4029  m << ch;
4030  }
4031  break;
4032  }
4033  }
4034 
4035  return m.GetString();
4036 }
4037 
4038 // Returns the given string with all characters invalid in XML removed.
4039 // Currently invalid characters are dropped from the string. An
4040 // alternative is to replace them with certain characters such as . or ?.
4042  const std::string& str) {
4044  output.reserve(str.size());
4045  for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
4046  if (IsValidXmlCharacter(*it))
4047  output.push_back(*it);
4048 
4049  return output;
4050 }
4051 
4052 // The following routines generate an XML representation of a UnitTest
4053 // object.
4054 // GOOGLETEST_CM0009 DO NOT DELETE
4055 //
4056 // This is how Google Test concepts map to the DTD:
4057 //
4058 // <testsuites name="AllTests"> <-- corresponds to a UnitTest object
4059 // <testsuite name="testcase-name"> <-- corresponds to a TestSuite object
4060 // <testcase name="test-name"> <-- corresponds to a TestInfo object
4061 // <failure message="...">...</failure>
4062 // <failure message="...">...</failure>
4063 // <failure message="...">...</failure>
4064 // <-- individual assertion failures
4065 // </testcase>
4066 // </testsuite>
4067 // </testsuites>
4068 
4069 // Formats the given time in milliseconds as seconds.
4071  ::std::stringstream ss;
4072  ss << (static_cast<double>(ms) * 1e-3);
4073  return ss.str();
4074 }
4075 
4076 static bool PortableLocaltime(time_t seconds, struct tm* out) {
4077 #if defined(_MSC_VER)
4078  return localtime_s(out, &seconds) == 0;
4079 #elif defined(__MINGW32__) || defined(__MINGW64__)
4080  // MINGW <time.h> provides neither localtime_r nor localtime_s, but uses
4081  // Windows' localtime(), which has a thread-local tm buffer.
4082  struct tm* tm_ptr = localtime(&seconds); // NOLINT
4083  if (tm_ptr == nullptr) return false;
4084  *out = *tm_ptr;
4085  return true;
4086 #else
4087  return localtime_r(&seconds, out) != nullptr;
4088 #endif
4089 }
4090 
4091 // Converts the given epoch time in milliseconds to a date string in the ISO
4092 // 8601 format, without the timezone information.
4094  struct tm time_struct;
4095  if (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct))
4096  return "";
4097  // YYYY-MM-DDThh:mm:ss.sss
4098  return StreamableToString(time_struct.tm_year + 1900) + "-" +
4099  String::FormatIntWidth2(time_struct.tm_mon + 1) + "-" +
4100  String::FormatIntWidth2(time_struct.tm_mday) + "T" +
4101  String::FormatIntWidth2(time_struct.tm_hour) + ":" +
4102  String::FormatIntWidth2(time_struct.tm_min) + ":" +
4103  String::FormatIntWidth2(time_struct.tm_sec) + "." +
4104  String::FormatIntWidthN(static_cast<int>(ms % 1000), 3);
4105 }
4106 
4107 // Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
4109  const char* data) {
4110  const char* segment = data;
4111  *stream << "<![CDATA[";
4112  for (;;) {
4113  const char* const next_segment = strstr(segment, "]]>");
4114  if (next_segment != nullptr) {
4115  stream->write(
4116  segment, static_cast<std::streamsize>(next_segment - segment));
4117  *stream << "]]>]]&gt;<![CDATA[";
4118  segment = next_segment + strlen("]]>");
4119  } else {
4120  *stream << segment;
4121  break;
4122  }
4123  }
4124  *stream << "]]>";
4125 }
4126 
4128  std::ostream* stream,
4129  const std::string& element_name,
4130  const std::string& name,
4131  const std::string& value) {
4132  const std::vector<std::string>& allowed_names =
4134 
4135  GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=
4136  allowed_names.end())
4137  << "Attribute " << name << " is not allowed for element <" << element_name
4138  << ">.";
4139 
4140  *stream << " " << name << "=\"" << EscapeXmlAttribute(value) << "\"";
4141 }
4142 
4143 // Prints an XML representation of a TestInfo object.
4145  const char* test_suite_name,
4146  const TestInfo& test_info) {
4147  const TestResult& result = *test_info.result();
4148  const std::string kTestsuite = "testcase";
4149 
4150  if (test_info.is_in_another_shard()) {
4151  return;
4152  }
4153 
4154  *stream << " <testcase";
4155  OutputXmlAttribute(stream, kTestsuite, "name", test_info.name());
4156 
4157  if (test_info.value_param() != nullptr) {
4158  OutputXmlAttribute(stream, kTestsuite, "value_param",
4159  test_info.value_param());
4160  }
4161  if (test_info.type_param() != nullptr) {
4162  OutputXmlAttribute(stream, kTestsuite, "type_param",
4163  test_info.type_param());
4164  }
4165  if (GTEST_FLAG(list_tests)) {
4166  OutputXmlAttribute(stream, kTestsuite, "file", test_info.file());
4167  OutputXmlAttribute(stream, kTestsuite, "line",
4168  StreamableToString(test_info.line()));
4169  *stream << " />\n";
4170  return;
4171  }
4172 
4173  OutputXmlAttribute(stream, kTestsuite, "status",
4174  test_info.should_run() ? "run" : "notrun");
4175  OutputXmlAttribute(stream, kTestsuite, "result",
4176  test_info.should_run()
4177  ? (result.Skipped() ? "skipped" : "completed")
4178  : "suppressed");
4179  OutputXmlAttribute(stream, kTestsuite, "time",
4180  FormatTimeInMillisAsSeconds(result.elapsed_time()));
4182  stream, kTestsuite, "timestamp",
4183  FormatEpochTimeInMillisAsIso8601(result.start_timestamp()));
4184  OutputXmlAttribute(stream, kTestsuite, "classname", test_suite_name);
4185 
4186  int failures = 0;
4187  int skips = 0;
4188  for (int i = 0; i < result.total_part_count(); ++i) {
4189  const TestPartResult& part = result.GetTestPartResult(i);
4190  if (part.failed()) {
4191  if (++failures == 1 && skips == 0) {
4192  *stream << ">\n";
4193  }
4194  const std::string location =
4196  part.line_number());
4197  const std::string summary = location + "\n" + part.summary();
4198  *stream << " <failure message=\""
4200  << "\" type=\"\">";
4201  const std::string detail = location + "\n" + part.message();
4203  *stream << "</failure>\n";
4204  } else if (part.skipped()) {
4205  if (++skips == 1 && failures == 0) {
4206  *stream << ">\n";
4207  }
4208  const std::string location =
4210  part.line_number());
4211  const std::string summary = location + "\n" + part.summary();
4212  *stream << " <skipped message=\""
4213  << EscapeXmlAttribute(summary.c_str()) << "\">";
4214  const std::string detail = location + "\n" + part.message();
4216  *stream << "</skipped>\n";
4217  }
4218  }
4219 
4220  if (failures == 0 && skips == 0 && result.test_property_count() == 0) {
4221  *stream << " />\n";
4222  } else {
4223  if (failures == 0 && skips == 0) {
4224  *stream << ">\n";
4225  }
4227  *stream << " </testcase>\n";
4228  }
4229 }
4230 
4231 // Prints an XML representation of a TestSuite object
4233  const TestSuite& test_suite) {
4234  const std::string kTestsuite = "testsuite";
4235  *stream << " <" << kTestsuite;
4236  OutputXmlAttribute(stream, kTestsuite, "name", test_suite.name());
4237  OutputXmlAttribute(stream, kTestsuite, "tests",
4238  StreamableToString(test_suite.reportable_test_count()));
4239  if (!GTEST_FLAG(list_tests)) {
4240  OutputXmlAttribute(stream, kTestsuite, "failures",
4241  StreamableToString(test_suite.failed_test_count()));
4243  stream, kTestsuite, "disabled",
4244  StreamableToString(test_suite.reportable_disabled_test_count()));
4245  OutputXmlAttribute(stream, kTestsuite, "skipped",
4246  StreamableToString(test_suite.skipped_test_count()));
4247 
4248  OutputXmlAttribute(stream, kTestsuite, "errors", "0");
4249 
4250  OutputXmlAttribute(stream, kTestsuite, "time",
4251  FormatTimeInMillisAsSeconds(test_suite.elapsed_time()));
4253  stream, kTestsuite, "timestamp",
4254  FormatEpochTimeInMillisAsIso8601(test_suite.start_timestamp()));
4255  *stream << TestPropertiesAsXmlAttributes(test_suite.ad_hoc_test_result());
4256  }
4257  *stream << ">\n";
4258  for (int i = 0; i < test_suite.total_test_count(); ++i) {
4259  if (test_suite.GetTestInfo(i)->is_reportable())
4260  OutputXmlTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));
4261  }
4262  *stream << " </" << kTestsuite << ">\n";
4263 }
4264 
4265 // Prints an XML summary of unit_test to output stream out.
4267  const UnitTest& unit_test) {
4268  const std::string kTestsuites = "testsuites";
4269 
4270  *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
4271  *stream << "<" << kTestsuites;
4272 
4273  OutputXmlAttribute(stream, kTestsuites, "tests",
4274  StreamableToString(unit_test.reportable_test_count()));
4275  OutputXmlAttribute(stream, kTestsuites, "failures",
4276  StreamableToString(unit_test.failed_test_count()));
4278  stream, kTestsuites, "disabled",
4279  StreamableToString(unit_test.reportable_disabled_test_count()));
4280  OutputXmlAttribute(stream, kTestsuites, "errors", "0");
4281  OutputXmlAttribute(stream, kTestsuites, "time",
4282  FormatTimeInMillisAsSeconds(unit_test.elapsed_time()));
4284  stream, kTestsuites, "timestamp",
4285  FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));
4286 
4287  if (GTEST_FLAG(shuffle)) {
4288  OutputXmlAttribute(stream, kTestsuites, "random_seed",
4289  StreamableToString(unit_test.random_seed()));
4290  }
4291  *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());
4292 
4293  OutputXmlAttribute(stream, kTestsuites, "name", "AllTests");
4294  *stream << ">\n";
4295 
4296  for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
4297  if (unit_test.GetTestSuite(i)->reportable_test_count() > 0)
4298  PrintXmlTestSuite(stream, *unit_test.GetTestSuite(i));
4299  }
4300  *stream << "</" << kTestsuites << ">\n";
4301 }
4302 
4304  std::ostream* stream, const std::vector<TestSuite*>& test_suites) {
4305  const std::string kTestsuites = "testsuites";
4306 
4307  *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
4308  *stream << "<" << kTestsuites;
4309 
4310  int total_tests = 0;
4311  for (auto test_suite : test_suites) {
4312  total_tests += test_suite->total_test_count();
4313  }
4314  OutputXmlAttribute(stream, kTestsuites, "tests",
4315  StreamableToString(total_tests));
4316  OutputXmlAttribute(stream, kTestsuites, "name", "AllTests");
4317  *stream << ">\n";
4318 
4319  for (auto test_suite : test_suites) {
4321  }
4322  *stream << "</" << kTestsuites << ">\n";
4323 }
4324 
4325 // Produces a string representing the test properties in a result as space
4326 // delimited XML attributes based on the property key="value" pairs.
4328  const TestResult& result) {
4329  Message attributes;
4330  for (int i = 0; i < result.test_property_count(); ++i) {
4331  const TestProperty& property = result.GetTestProperty(i);
4332  attributes << " " << property.key() << "="
4333  << "\"" << EscapeXmlAttribute(property.value()) << "\"";
4334  }
4335  return attributes.GetString();
4336 }
4337 
4339  std::ostream* stream, const TestResult& result) {
4340  const std::string kProperties = "properties";
4341  const std::string kProperty = "property";
4342 
4343  if (result.test_property_count() <= 0) {
4344  return;
4345  }
4346 
4347  *stream << "<" << kProperties << ">\n";
4348  for (int i = 0; i < result.test_property_count(); ++i) {
4349  const TestProperty& property = result.GetTestProperty(i);
4350  *stream << "<" << kProperty;
4351  *stream << " name=\"" << EscapeXmlAttribute(property.key()) << "\"";
4352  *stream << " value=\"" << EscapeXmlAttribute(property.value()) << "\"";
4353  *stream << "/>\n";
4354  }
4355  *stream << "</" << kProperties << ">\n";
4356 }
4357 
4358 // End XmlUnitTestResultPrinter
4359 
4360 // This class generates an JSON output file.
4361 class JsonUnitTestResultPrinter : public EmptyTestEventListener {
4362  public:
4363  explicit JsonUnitTestResultPrinter(const char* output_file);
4364 
4365  void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
4366 
4367  // Prints an JSON summary of all unit tests.
4368  static void PrintJsonTestList(::std::ostream* stream,
4369  const std::vector<TestSuite*>& test_suites);
4370 
4371  private:
4372  // Returns an JSON-escaped copy of the input string str.
4373  static std::string EscapeJson(const std::string& str);
4374 
4377  static void OutputJsonKey(std::ostream* stream,
4378  const std::string& element_name,
4379  const std::string& name,
4380  const std::string& value,
4381  const std::string& indent,
4382  bool comma = true);
4383  static void OutputJsonKey(std::ostream* stream,
4384  const std::string& element_name,
4385  const std::string& name,
4386  int value,
4387  const std::string& indent,
4388  bool comma = true);
4389 
4390  // Streams a JSON representation of a TestInfo object.
4391  static void OutputJsonTestInfo(::std::ostream* stream,
4392  const char* test_suite_name,
4393  const TestInfo& test_info);
4394 
4395  // Prints a JSON representation of a TestSuite object
4396  static void PrintJsonTestSuite(::std::ostream* stream,
4397  const TestSuite& test_suite);
4398 
4399  // Prints a JSON summary of unit_test to output stream out.
4400  static void PrintJsonUnitTest(::std::ostream* stream,
4401  const UnitTest& unit_test);
4402 
4403  // Produces a string representing the test properties in a result as
4404  // a JSON dictionary.
4405  static std::string TestPropertiesAsJson(const TestResult& result,
4406  const std::string& indent);
4407 
4408  // The output file.
4409  const std::string output_file_;
4410 
4412 };
4413 
4414 // Creates a new JsonUnitTestResultPrinter.
4416  : output_file_(output_file) {
4417  if (output_file_.empty()) {
4418  GTEST_LOG_(FATAL) << "JSON output file may not be null";
4419  }
4420 }
4421 
4422 void JsonUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
4423  int /*iteration*/) {
4424  FILE* jsonout = OpenFileForWriting(output_file_);
4425  std::stringstream stream;
4426  PrintJsonUnitTest(&stream, unit_test);
4427  fprintf(jsonout, "%s", StringStreamToString(&stream).c_str());
4428  fclose(jsonout);
4429 }
4430 
4431 // Returns an JSON-escaped copy of the input string str.
4432 std::string JsonUnitTestResultPrinter::EscapeJson(const std::string& str) {
4433  Message m;
4434 
4435  for (size_t i = 0; i < str.size(); ++i) {
4436  const char ch = str[i];
4437  switch (ch) {
4438  case '\\':
4439  case '"':
4440  case '/':
4441  m << '\\' << ch;
4442  break;
4443  case '\b':
4444  m << "\\b";
4445  break;
4446  case '\t':
4447  m << "\\t";
4448  break;
4449  case '\n':
4450  m << "\\n";
4451  break;
4452  case '\f':
4453  m << "\\f";
4454  break;
4455  case '\r':
4456  m << "\\r";
4457  break;
4458  default:
4459  if (ch < ' ') {
4460  m << "\\u00" << String::FormatByte(static_cast<unsigned char>(ch));
4461  } else {
4462  m << ch;
4463  }
4464  break;
4465  }
4466  }
4467 
4468  return m.GetString();
4469 }
4470 
4471 // The following routines generate an JSON representation of a UnitTest
4472 // object.
4473 
4474 // Formats the given time in milliseconds as seconds.
4476  ::std::stringstream ss;
4477  ss << (static_cast<double>(ms) * 1e-3) << "s";
4478  return ss.str();
4479 }
4480 
4481 // Converts the given epoch time in milliseconds to a date string in the
4482 // RFC3339 format, without the timezone information.
4484  struct tm time_struct;
4485  if (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct))
4486  return "";
4487  // YYYY-MM-DDThh:mm:ss
4488  return StreamableToString(time_struct.tm_year + 1900) + "-" +
4489  String::FormatIntWidth2(time_struct.tm_mon + 1) + "-" +
4490  String::FormatIntWidth2(time_struct.tm_mday) + "T" +
4491  String::FormatIntWidth2(time_struct.tm_hour) + ":" +
4492  String::FormatIntWidth2(time_struct.tm_min) + ":" +
4493  String::FormatIntWidth2(time_struct.tm_sec) + "Z";
4494 }
4495 
4496 static inline std::string Indent(size_t width) {
4497  return std::string(width, ' ');
4498 }
4499 
4500 void JsonUnitTestResultPrinter::OutputJsonKey(
4501  std::ostream* stream,
4502  const std::string& element_name,
4503  const std::string& name,
4504  const std::string& value,
4505  const std::string& indent,
4506  bool comma) {
4507  const std::vector<std::string>& allowed_names =
4509 
4510  GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=
4511  allowed_names.end())
4512  << "Key \"" << name << "\" is not allowed for value \"" << element_name
4513  << "\".";
4514 
4515  *stream << indent << "\"" << name << "\": \"" << EscapeJson(value) << "\"";
4516  if (comma)
4517  *stream << ",\n";
4518 }
4519 
4520 void JsonUnitTestResultPrinter::OutputJsonKey(
4521  std::ostream* stream,
4522  const std::string& element_name,
4523  const std::string& name,
4524  int value,
4525  const std::string& indent,
4526  bool comma) {
4527  const std::vector<std::string>& allowed_names =
4529 
4530  GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=
4531  allowed_names.end())
4532  << "Key \"" << name << "\" is not allowed for value \"" << element_name
4533  << "\".";
4534 
4535  *stream << indent << "\"" << name << "\": " << StreamableToString(value);
4536  if (comma)
4537  *stream << ",\n";
4538 }
4539 
4540 // Prints a JSON representation of a TestInfo object.
4541 void JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream,
4542  const char* test_suite_name,
4543  const TestInfo& test_info) {
4544  const TestResult& result = *test_info.result();
4545  const std::string kTestsuite = "testcase";
4546  const std::string kIndent = Indent(10);
4547 
4548  *stream << Indent(8) << "{\n";
4549  OutputJsonKey(stream, kTestsuite, "name", test_info.name(), kIndent);
4550 
4551  if (test_info.value_param() != nullptr) {
4552  OutputJsonKey(stream, kTestsuite, "value_param", test_info.value_param(),
4553  kIndent);
4554  }
4555  if (test_info.type_param() != nullptr) {
4556  OutputJsonKey(stream, kTestsuite, "type_param", test_info.type_param(),
4557  kIndent);
4558  }
4559  if (GTEST_FLAG(list_tests)) {
4560  OutputJsonKey(stream, kTestsuite, "file", test_info.file(), kIndent);
4561  OutputJsonKey(stream, kTestsuite, "line", test_info.line(), kIndent, false);
4562  *stream << "\n" << Indent(8) << "}";
4563  return;
4564  }
4565 
4566  OutputJsonKey(stream, kTestsuite, "status",
4567  test_info.should_run() ? "RUN" : "NOTRUN", kIndent);
4568  OutputJsonKey(stream, kTestsuite, "result",
4569  test_info.should_run()
4570  ? (result.Skipped() ? "SKIPPED" : "COMPLETED")
4571  : "SUPPRESSED",
4572  kIndent);
4573  OutputJsonKey(stream, kTestsuite, "timestamp",
4574  FormatEpochTimeInMillisAsRFC3339(result.start_timestamp()),
4575  kIndent);
4576  OutputJsonKey(stream, kTestsuite, "time",
4577  FormatTimeInMillisAsDuration(result.elapsed_time()), kIndent);
4578  OutputJsonKey(stream, kTestsuite, "classname", test_suite_name, kIndent,
4579  false);
4580  *stream << TestPropertiesAsJson(result, kIndent);
4581 
4582  int failures = 0;
4583  for (int i = 0; i < result.total_part_count(); ++i) {
4584  const TestPartResult& part = result.GetTestPartResult(i);
4585  if (part.failed()) {
4586  *stream << ",\n";
4587  if (++failures == 1) {
4588  *stream << kIndent << "\"" << "failures" << "\": [\n";
4589  }
4590  const std::string location =
4592  part.line_number());
4593  const std::string message = EscapeJson(location + "\n" + part.message());
4594  *stream << kIndent << " {\n"
4595  << kIndent << " \"failure\": \"" << message << "\",\n"
4596  << kIndent << " \"type\": \"\"\n"
4597  << kIndent << " }";
4598  }
4599  }
4600 
4601  if (failures > 0)
4602  *stream << "\n" << kIndent << "]";
4603  *stream << "\n" << Indent(8) << "}";
4604 }
4605 
4606 // Prints an JSON representation of a TestSuite object
4607 void JsonUnitTestResultPrinter::PrintJsonTestSuite(
4608  std::ostream* stream, const TestSuite& test_suite) {
4609  const std::string kTestsuite = "testsuite";
4610  const std::string kIndent = Indent(6);
4611 
4612  *stream << Indent(4) << "{\n";
4613  OutputJsonKey(stream, kTestsuite, "name", test_suite.name(), kIndent);
4614  OutputJsonKey(stream, kTestsuite, "tests", test_suite.reportable_test_count(),
4615  kIndent);
4616  if (!GTEST_FLAG(list_tests)) {
4617  OutputJsonKey(stream, kTestsuite, "failures",
4618  test_suite.failed_test_count(), kIndent);
4619  OutputJsonKey(stream, kTestsuite, "disabled",
4620  test_suite.reportable_disabled_test_count(), kIndent);
4621  OutputJsonKey(stream, kTestsuite, "errors", 0, kIndent);
4622  OutputJsonKey(
4623  stream, kTestsuite, "timestamp",
4624  FormatEpochTimeInMillisAsRFC3339(test_suite.start_timestamp()),
4625  kIndent);
4626  OutputJsonKey(stream, kTestsuite, "time",
4627  FormatTimeInMillisAsDuration(test_suite.elapsed_time()),
4628  kIndent, false);
4629  *stream << TestPropertiesAsJson(test_suite.ad_hoc_test_result(), kIndent)
4630  << ",\n";
4631  }
4632 
4633  *stream << kIndent << "\"" << kTestsuite << "\": [\n";
4634 
4635  bool comma = false;
4636  for (int i = 0; i < test_suite.total_test_count(); ++i) {
4637  if (test_suite.GetTestInfo(i)->is_reportable()) {
4638  if (comma) {
4639  *stream << ",\n";
4640  } else {
4641  comma = true;
4642  }
4643  OutputJsonTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));
4644  }
4645  }
4646  *stream << "\n" << kIndent << "]\n" << Indent(4) << "}";
4647 }
4648 
4649 // Prints a JSON summary of unit_test to output stream out.
4650 void JsonUnitTestResultPrinter::PrintJsonUnitTest(std::ostream* stream,
4651  const UnitTest& unit_test) {
4652  const std::string kTestsuites = "testsuites";
4653  const std::string kIndent = Indent(2);
4654  *stream << "{\n";
4655 
4656  OutputJsonKey(stream, kTestsuites, "tests", unit_test.reportable_test_count(),
4657  kIndent);
4658  OutputJsonKey(stream, kTestsuites, "failures", unit_test.failed_test_count(),
4659  kIndent);
4660  OutputJsonKey(stream, kTestsuites, "disabled",
4661  unit_test.reportable_disabled_test_count(), kIndent);
4662  OutputJsonKey(stream, kTestsuites, "errors", 0, kIndent);
4663  if (GTEST_FLAG(shuffle)) {
4664  OutputJsonKey(stream, kTestsuites, "random_seed", unit_test.random_seed(),
4665  kIndent);
4666  }
4667  OutputJsonKey(stream, kTestsuites, "timestamp",
4668  FormatEpochTimeInMillisAsRFC3339(unit_test.start_timestamp()),
4669  kIndent);
4670  OutputJsonKey(stream, kTestsuites, "time",
4671  FormatTimeInMillisAsDuration(unit_test.elapsed_time()), kIndent,
4672  false);
4673 
4674  *stream << TestPropertiesAsJson(unit_test.ad_hoc_test_result(), kIndent)
4675  << ",\n";
4676 
4677  OutputJsonKey(stream, kTestsuites, "name", "AllTests", kIndent);
4678  *stream << kIndent << "\"" << kTestsuites << "\": [\n";
4679 
4680  bool comma = false;
4681  for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
4682  if (unit_test.GetTestSuite(i)->reportable_test_count() > 0) {
4683  if (comma) {
4684  *stream << ",\n";
4685  } else {
4686  comma = true;
4687  }
4688  PrintJsonTestSuite(stream, *unit_test.GetTestSuite(i));
4689  }
4690  }
4691 
4692  *stream << "\n" << kIndent << "]\n" << "}\n";
4693 }
4694 
4695 void JsonUnitTestResultPrinter::PrintJsonTestList(
4696  std::ostream* stream, const std::vector<TestSuite*>& test_suites) {
4697  const std::string kTestsuites = "testsuites";
4698  const std::string kIndent = Indent(2);
4699  *stream << "{\n";
4700  int total_tests = 0;
4701  for (auto test_suite : test_suites) {
4702  total_tests += test_suite->total_test_count();
4703  }
4704  OutputJsonKey(stream, kTestsuites, "tests", total_tests, kIndent);
4705 
4706  OutputJsonKey(stream, kTestsuites, "name", "AllTests", kIndent);
4707  *stream << kIndent << "\"" << kTestsuites << "\": [\n";
4708 
4709  for (size_t i = 0; i < test_suites.size(); ++i) {
4710  if (i != 0) {
4711  *stream << ",\n";
4712  }
4713  PrintJsonTestSuite(stream, *test_suites[i]);
4714  }
4715 
4716  *stream << "\n"
4717  << kIndent << "]\n"
4718  << "}\n";
4719 }
4720 // Produces a string representing the test properties in a result as
4721 // a JSON dictionary.
4722 std::string JsonUnitTestResultPrinter::TestPropertiesAsJson(
4723  const TestResult& result, const std::string& indent) {
4724  Message attributes;
4725  for (int i = 0; i < result.test_property_count(); ++i) {
4726  const TestProperty& property = result.GetTestProperty(i);
4727  attributes << ",\n" << indent << "\"" << property.key() << "\": "
4728  << "\"" << EscapeJson(property.value()) << "\"";
4729  }
4730  return attributes.GetString();
4731 }
4732 
4733 // End JsonUnitTestResultPrinter
4734 
4735 #if GTEST_CAN_STREAM_RESULTS_
4736 
4737 // Checks if str contains '=', '&', '%' or '\n' characters. If yes,
4738 // replaces them by "%xx" where xx is their hexadecimal value. For
4739 // example, replaces "=" with "%3D". This algorithm is O(strlen(str))
4740 // in both time and space -- important as the input str may contain an
4741 // arbitrarily long test failure message and stack trace.
4742 std::string StreamingListener::UrlEncode(const char* str) {
4744  result.reserve(strlen(str) + 1);
4745  for (char ch = *str; ch != '\0'; ch = *++str) {
4746  switch (ch) {
4747  case '%':
4748  case '=':
4749  case '&':
4750  case '\n':
4751  result.append("%" + String::FormatByte(static_cast<unsigned char>(ch)));
4752  break;
4753  default:
4754  result.push_back(ch);
4755  break;
4756  }
4757  }
4758  return result;
4759 }
4760 
4761 void StreamingListener::SocketWriter::MakeConnection() {
4762  GTEST_CHECK_(sockfd_ == -1)
4763  << "MakeConnection() can't be called when there is already a connection.";
4764 
4765  addrinfo hints;
4766  memset(&hints, 0, sizeof(hints));
4767  hints.ai_family = AF_UNSPEC; // To allow both IPv4 and IPv6 addresses.
4768  hints.ai_socktype = SOCK_STREAM;
4769  addrinfo* servinfo = nullptr;
4770 
4771  // Use the getaddrinfo() to get a linked list of IP addresses for
4772  // the given host name.
4773  const int error_num = getaddrinfo(
4774  host_name_.c_str(), port_num_.c_str(), &hints, &servinfo);
4775  if (error_num != 0) {
4776  GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: "
4777  << gai_strerror(error_num);
4778  }
4779 
4780  // Loop through all the results and connect to the first we can.
4781  for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != nullptr;
4782  cur_addr = cur_addr->ai_next) {
4783  sockfd_ = socket(
4784  cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);
4785  if (sockfd_ != -1) {
4786  // Connect the client socket to the server socket.
4787  if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
4788  close(sockfd_);
4789  sockfd_ = -1;
4790  }
4791  }
4792  }
4793 
4794  freeaddrinfo(servinfo); // all done with this structure
4795 
4796  if (sockfd_ == -1) {
4797  GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to "
4798  << host_name_ << ":" << port_num_;
4799  }
4800 }
4801 
4802 // End of class Streaming Listener
4803 #endif // GTEST_CAN_STREAM_RESULTS__
4804 
4805 // class OsStackTraceGetter
4806 
4807 const char* const OsStackTraceGetterInterface::kElidedFramesMarker =
4808  "... " GTEST_NAME_ " internal frames ...";
4809 
4810 std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count)
4812 #if GTEST_HAS_ABSL
4814 
4815  if (max_depth <= 0) {
4816  return result;
4817  }
4818 
4819  max_depth = std::min(max_depth, kMaxStackTraceDepth);
4820 
4821  std::vector<void*> raw_stack(max_depth);
4822  // Skips the frames requested by the caller, plus this function.
4823  const int raw_stack_size =
4824  absl::GetStackTrace(&raw_stack[0], max_depth, skip_count + 1);
4825 
4826  void* caller_frame = nullptr;
4827  {
4828  MutexLock lock(&mutex_);
4829  caller_frame = caller_frame_;
4830  }
4831 
4832  for (int i = 0; i < raw_stack_size; ++i) {
4833  if (raw_stack[i] == caller_frame &&
4834  !GTEST_FLAG(show_internal_stack_frames)) {
4835  // Add a marker to the trace and stop adding frames.
4836  absl::StrAppend(&result, kElidedFramesMarker, "\n");
4837  break;
4838  }
4839 
4840  char tmp[1024];
4841  const char* symbol = "(unknown)";
4842  if (absl::Symbolize(raw_stack[i], tmp, sizeof(tmp))) {
4843  symbol = tmp;
4844  }
4845 
4846  char line[1024];
4847  snprintf(line, sizeof(line), " %p: %s\n", raw_stack[i], symbol);
4848  result += line;
4849  }
4850 
4851  return result;
4852 
4853 #else // !GTEST_HAS_ABSL
4854  static_cast<void>(max_depth);
4855  static_cast<void>(skip_count);
4856  return "";
4857 #endif // GTEST_HAS_ABSL
4858 }
4859 
4860 void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) {
4861 #if GTEST_HAS_ABSL
4862  void* caller_frame = nullptr;
4863  if (absl::GetStackTrace(&caller_frame, 1, 3) <= 0) {
4864  caller_frame = nullptr;
4865  }
4866 
4867  MutexLock lock(&mutex_);
4868  caller_frame_ = caller_frame;
4869 #endif // GTEST_HAS_ABSL
4870 }
4871 
4872 // A helper class that creates the premature-exit file in its
4873 // constructor and deletes the file in its destructor.
4874 class ScopedPrematureExitFile {
4875  public:
4876  explicit ScopedPrematureExitFile(const char* premature_exit_filepath)
4877  : premature_exit_filepath_(premature_exit_filepath ?
4878  premature_exit_filepath : "") {
4879  // If a path to the premature-exit file is specified...
4880  if (!premature_exit_filepath_.empty()) {
4881  // create the file with a single "0" character in it. I/O
4882  // errors are ignored as there's nothing better we can do and we
4883  // don't want to fail the test because of this.
4884  FILE* pfile = posix::FOpen(premature_exit_filepath, "w");
4885  fwrite("0", 1, 1, pfile);
4886  fclose(pfile);
4887  }
4888  }
4889 
4891 #if !defined GTEST_OS_ESP8266
4892  if (!premature_exit_filepath_.empty()) {
4893  int retval = remove(premature_exit_filepath_.c_str());
4894  if (retval) {
4895  GTEST_LOG_(ERROR) << "Failed to remove premature exit filepath \""
4896  << premature_exit_filepath_ << "\" with error "
4897  << retval;
4898  }
4899  }
4900 #endif
4901  }
4902 
4903  private:
4904  const std::string premature_exit_filepath_;
4905 
4907 };
4908 
4909 } // namespace internal
4910 
4911 // class TestEventListeners
4912 
4913 TestEventListeners::TestEventListeners()
4914  : repeater_(new internal::TestEventRepeater()),
4915  default_result_printer_(nullptr),
4916  default_xml_generator_(nullptr) {}
4917 
4918 TestEventListeners::~TestEventListeners() { delete repeater_; }
4919 
4920 // Returns the standard listener responsible for the default console
4921 // output. Can be removed from the listeners list to shut down default
4922 // console output. Note that removing this object from the listener list
4923 // with Release transfers its ownership to the user.
4924 void TestEventListeners::Append(TestEventListener* listener) {
4925  repeater_->Append(listener);
4926 }
4927 
4928 // Removes the given event listener from the list and returns it. It then
4929 // becomes the caller's responsibility to delete the listener. Returns
4930 // NULL if the listener is not found in the list.
4931 TestEventListener* TestEventListeners::Release(TestEventListener* listener) {
4932  if (listener == default_result_printer_)
4933  default_result_printer_ = nullptr;
4934  else if (listener == default_xml_generator_)
4935  default_xml_generator_ = nullptr;
4936  return repeater_->Release(listener);
4937 }
4938 
4939 // Returns repeater that broadcasts the TestEventListener events to all
4940 // subscribers.
4941 TestEventListener* TestEventListeners::repeater() { return repeater_; }
4942 
4943 // Sets the default_result_printer attribute to the provided listener.
4944 // The listener is also added to the listener list and previous
4945 // default_result_printer is removed from it and deleted. The listener can
4946 // also be NULL in which case it will not be added to the list. Does
4947 // nothing if the previous and the current listener objects are the same.
4948 void TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) {
4949  if (default_result_printer_ != listener) {
4950  // It is an error to pass this method a listener that is already in the
4951  // list.
4952  delete Release(default_result_printer_);
4953  default_result_printer_ = listener;
4954  if (listener != nullptr) Append(listener);
4955  }
4956 }
4957 
4958 // Sets the default_xml_generator attribute to the provided listener. The
4959 // listener is also added to the listener list and previous
4960 // default_xml_generator is removed from it and deleted. The listener can
4961 // also be NULL in which case it will not be added to the list. Does
4962 // nothing if the previous and the current listener objects are the same.
4963 void TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) {
4964  if (default_xml_generator_ != listener) {
4965  // It is an error to pass this method a listener that is already in the
4966  // list.
4967  delete Release(default_xml_generator_);
4968  default_xml_generator_ = listener;
4969  if (listener != nullptr) Append(listener);
4970  }
4971 }
4972 
4973 // Controls whether events will be forwarded by the repeater to the
4974 // listeners in the list.
4976  return repeater_->forwarding_enabled();
4977 }
4978 
4980  repeater_->set_forwarding_enabled(false);
4981 }
4982 
4983 // class UnitTest
4984 
4985 // Gets the singleton UnitTest object. The first time this method is
4986 // called, a UnitTest object is constructed and returned. Consecutive
4987 // calls will return the same object.
4988 //
4989 // We don't protect this under mutex_ as a user is not supposed to
4990 // call this before main() starts, from which point on the return
4991 // value will never change.
4992 UnitTest* UnitTest::GetInstance() {
4993  // CodeGear C++Builder insists on a public destructor for the
4994  // default implementation. Use this implementation to keep good OO
4995  // design with private destructor.
4996 
4997 #if defined(__BORLANDC__)
4998  static UnitTest* const instance = new UnitTest;
4999  return instance;
5000 #else
5001  static UnitTest instance;
5002  return &instance;
5003 #endif // defined(__BORLANDC__)
5004 }
5005 
5006 // Gets the number of successful test suites.
5008  return impl()->successful_test_suite_count();
5009 }
5010 
5011 // Gets the number of failed test suites.
5013  return impl()->failed_test_suite_count();
5014 }
5015 
5016 // Gets the number of all test suites.
5018  return impl()->total_test_suite_count();
5019 }
5020 
5021 // Gets the number of all test suites that contain at least one test
5022 // that should run.
5024  return impl()->test_suite_to_run_count();
5025 }
5026 
5027 // Legacy API is deprecated but still available
5028 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
5030  return impl()->successful_test_suite_count();
5031 }
5033  return impl()->failed_test_suite_count();
5034 }
5035 int UnitTest::total_test_case_count() const {
5036  return impl()->total_test_suite_count();
5037 }
5039  return impl()->test_suite_to_run_count();
5040 }
5041 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
5042 
5043 // Gets the number of successful tests.
5044 int UnitTest::successful_test_count() const {
5045  return impl()->successful_test_count();
5046 }
5047 
5048 // Gets the number of skipped tests.
5049 int UnitTest::skipped_test_count() const {
5050  return impl()->skipped_test_count();
5051 }
5052 
5053 // Gets the number of failed tests.
5054 int UnitTest::failed_test_count() const { return impl()->failed_test_count(); }
5055 
5056 // Gets the number of disabled tests that will be reported in the XML report.
5058  return impl()->reportable_disabled_test_count();
5059 }
5060 
5061 // Gets the number of disabled tests.
5062 int UnitTest::disabled_test_count() const {
5063  return impl()->disabled_test_count();
5064 }
5065 
5066 // Gets the number of tests to be printed in the XML report.
5067 int UnitTest::reportable_test_count() const {
5068  return impl()->reportable_test_count();
5069 }
5070 
5071 // Gets the number of all tests.
5072 int UnitTest::total_test_count() const { return impl()->total_test_count(); }
5073 
5074 // Gets the number of tests that should run.
5075 int UnitTest::test_to_run_count() const { return impl()->test_to_run_count(); }
5076 
5077 // Gets the time of the test program start, in ms from the start of the
5078 // UNIX epoch.
5080  return impl()->start_timestamp();
5081 }
5082 
5083 // Gets the elapsed time, in milliseconds.
5085  return impl()->elapsed_time();
5086 }
5087 
5088 // Returns true if and only if the unit test passed (i.e. all test suites
5089 // passed).
5090 bool UnitTest::Passed() const { return impl()->Passed(); }
5091 
5092 // Returns true if and only if the unit test failed (i.e. some test suite
5093 // failed or something outside of all tests failed).
5094 bool UnitTest::Failed() const { return impl()->Failed(); }
5095 
5096 // Gets the i-th test suite among all the test suites. i can range from 0 to
5097 // total_test_suite_count() - 1. If i is not in that range, returns NULL.
5098 const TestSuite* UnitTest::GetTestSuite(int i) const {
5099  return impl()->GetTestSuite(i);
5100 }
5101 
5102 // Legacy API is deprecated but still available
5103 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
5104 const TestCase* UnitTest::GetTestCase(int i) const {
5105  return impl()->GetTestCase(i);
5106 }
5107 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
5108 
5109 // Returns the TestResult containing information on test failures and
5110 // properties logged outside of individual test suites.
5111 const TestResult& UnitTest::ad_hoc_test_result() const {
5112  return *impl()->ad_hoc_test_result();
5113 }
5114 
5115 // Gets the i-th test suite among all the test suites. i can range from 0 to
5116 // total_test_suite_count() - 1. If i is not in that range, returns NULL.
5118  return impl()->GetMutableSuiteCase(i);
5119 }
5120 
5121 // Returns the list of event listeners that can be used to track events
5122 // inside Google Test.
5123 TestEventListeners& UnitTest::listeners() {
5124  return *impl()->listeners();
5125 }
5126 
5127 // Registers and returns a global test environment. When a test
5128 // program is run, all global test environments will be set-up in the
5129 // order they were registered. After all tests in the program have
5130 // finished, all global test environments will be torn-down in the
5131 // *reverse* order they were registered.
5132 //
5133 // The UnitTest object takes ownership of the given environment.
5134 //
5135 // We don't protect this under mutex_, as we only support calling it
5136 // from the main thread.
5137 Environment* UnitTest::AddEnvironment(Environment* env) {
5138  if (env == nullptr) {
5139  return nullptr;
5140  }
5141 
5142  impl_->environments().push_back(env);
5143  return env;
5144 }
5145 
5146 // Adds a TestPartResult to the current TestResult object. All Google Test
5147 // assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call
5148 // this to report their results. The user code should use the
5149 // assertion macros instead of calling this directly.
5152  const char* file_name,
5153  int line_number,
5154  const std::string& message,
5155  const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_) {
5156  Message msg;
5157  msg << message;
5158 
5159  internal::MutexLock lock(&mutex_);
5160  if (impl_->gtest_trace_stack().size() > 0) {
5161  msg << "\n" << GTEST_NAME_ << " trace:";
5162 
5163  for (size_t i = impl_->gtest_trace_stack().size(); i > 0; --i) {
5164  const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];
5165  msg << "\n" << internal::FormatFileLocation(trace.file, trace.line)
5166  << " " << trace.message;
5167  }
5168  }
5169 
5170  if (os_stack_trace.c_str() != nullptr && !os_stack_trace.empty()) {
5171  msg << internal::kStackTraceMarker << os_stack_trace;
5172  }
5173 
5174  const TestPartResult result = TestPartResult(
5175  result_type, file_name, line_number, msg.GetString().c_str());
5176  impl_->GetTestPartResultReporterForCurrentThread()->
5177  ReportTestPartResult(result);
5178 
5180  result_type != TestPartResult::kSkip) {
5181  // gtest_break_on_failure takes precedence over
5182  // gtest_throw_on_failure. This allows a user to set the latter
5183  // in the code (perhaps in order to use Google Test assertions
5184  // with another testing framework) and specify the former on the
5185  // command line for debugging.
5186  if (GTEST_FLAG(break_on_failure)) {
5187 #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
5188  // Using DebugBreak on Windows allows gtest to still break into a debugger
5189  // when a failure happens and both the --gtest_break_on_failure and
5190  // the --gtest_catch_exceptions flags are specified.
5191  DebugBreak();
5192 #elif (!defined(__native_client__)) && \
5193  ((defined(__clang__) || defined(__GNUC__)) && \
5194  (defined(__x86_64__) || defined(__i386__)))
5195  // with clang/gcc we can achieve the same effect on x86 by invoking int3
5196  asm("int3");
5197 #else
5198  // Dereference nullptr through a volatile pointer to prevent the compiler
5199  // from removing. We use this rather than abort() or __builtin_trap() for
5200  // portability: some debuggers don't correctly trap abort().
5201  *static_cast<volatile int*>(nullptr) = 1;
5202 #endif // GTEST_OS_WINDOWS
5203  } else if (GTEST_FLAG(throw_on_failure)) {
5204 #if GTEST_HAS_EXCEPTIONS
5205  throw internal::GoogleTestFailureException(result);
5206 #else
5207  // We cannot call abort() as it generates a pop-up in debug mode
5208  // that cannot be suppressed in VC 7.1 or below.
5209  exit(1);
5210 #endif
5211  }
5212  }
5213 }
5214 
5215 // Adds a TestProperty to the current TestResult object when invoked from
5216 // inside a test, to current TestSuite's ad_hoc_test_result_ when invoked
5217 // from SetUpTestSuite or TearDownTestSuite, or to the global property set
5218 // when invoked elsewhere. If the result already contains a property with
5219 // the same key, the value will be updated.
5221  const std::string& value) {
5222  impl_->RecordProperty(TestProperty(key, value));
5223 }
5224 
5225 // Runs all tests in this UnitTest object and prints the result.
5226 // Returns 0 if successful, or 1 otherwise.
5227 //
5228 // We don't protect this under mutex_, as we only support calling it
5229 // from the main thread.
5230 int UnitTest::Run() {
5231  const bool in_death_test_child_process =
5232  internal::GTEST_FLAG(internal_run_death_test).length() > 0;
5233 
5234  // Google Test implements this protocol for catching that a test
5235  // program exits before returning control to Google Test:
5236  //
5237  // 1. Upon start, Google Test creates a file whose absolute path
5238  // is specified by the environment variable
5239  // TEST_PREMATURE_EXIT_FILE.
5240  // 2. When Google Test has finished its work, it deletes the file.
5241  //
5242  // This allows a test runner to set TEST_PREMATURE_EXIT_FILE before
5243  // running a Google-Test-based test program and check the existence
5244  // of the file at the end of the test execution to see if it has
5245  // exited prematurely.
5246 
5247  // If we are in the child process of a death test, don't
5248  // create/delete the premature exit file, as doing so is unnecessary
5249  // and will confuse the parent process. Otherwise, create/delete
5250  // the file upon entering/leaving this function. If the program
5251  // somehow exits before this function has a chance to return, the
5252  // premature-exit file will be left undeleted, causing a test runner
5253  // that understands the premature-exit-file protocol to report the
5254  // test as having failed.
5255  const internal::ScopedPrematureExitFile premature_exit_file(
5256  in_death_test_child_process
5257  ? nullptr
5258  : internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE"));
5259 
5260  // Captures the value of GTEST_FLAG(catch_exceptions). This value will be
5261  // used for the duration of the program.
5262  impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions));
5263 
5264 #if GTEST_OS_WINDOWS
5265  // Either the user wants Google Test to catch exceptions thrown by the
5266  // tests or this is executing in the context of death test child
5267  // process. In either case the user does not want to see pop-up dialogs
5268  // about crashes - they are expected.
5269  if (impl()->catch_exceptions() || in_death_test_child_process) {
5270 # if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
5271  // SetErrorMode doesn't exist on CE.
5272  SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
5273  SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
5274 # endif // !GTEST_OS_WINDOWS_MOBILE
5275 
5276 # if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE
5277  // Death test children can be terminated with _abort(). On Windows,
5278  // _abort() can show a dialog with a warning message. This forces the
5279  // abort message to go to stderr instead.
5280  _set_error_mode(_OUT_TO_STDERR);
5281 # endif
5282 
5283 # if defined(_MSC_VER) && !GTEST_OS_WINDOWS_MOBILE
5284  // In the debug version, Visual Studio pops up a separate dialog
5285  // offering a choice to debug the aborted program. We need to suppress
5286  // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
5287  // executed. Google Test will notify the user of any unexpected
5288  // failure via stderr.
5289  if (!GTEST_FLAG(break_on_failure))
5290  _set_abort_behavior(
5291  0x0, // Clear the following flags:
5292  _WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump.
5293 
5294  // In debug mode, the Windows CRT can crash with an assertion over invalid
5295  // input (e.g. passing an invalid file descriptor). The default handling
5296  // for these assertions is to pop up a dialog and wait for user input.
5297  // Instead ask the CRT to dump such assertions to stderr non-interactively.
5298  if (!IsDebuggerPresent()) {
5299  (void)_CrtSetReportMode(_CRT_ASSERT,
5300  _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
5301  (void)_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
5302  }
5303 # endif
5304  }
5305 #endif // GTEST_OS_WINDOWS
5306 
5308  impl(),
5310  "auxiliary test code (environments or event listeners)") ? 0 : 1;
5311 }
5312 
5313 // Returns the working directory when the first TEST() or TEST_F() was
5314 // executed.
5315 const char* UnitTest::original_working_dir() const {
5316  return impl_->original_working_dir_.c_str();
5317 }
5318 
5319 // Returns the TestSuite object for the test that's currently running,
5320 // or NULL if no test is running.
5323  internal::MutexLock lock(&mutex_);
5324  return impl_->current_test_suite();
5325 }
5326 
5327 // Legacy API is still available but deprecated
5328 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
5331  internal::MutexLock lock(&mutex_);
5332  return impl_->current_test_suite();
5333 }
5334 #endif
5335 
5336 // Returns the TestInfo object for the test that's currently running,
5337 // or NULL if no test is running.
5338 const TestInfo* UnitTest::current_test_info() const
5340  internal::MutexLock lock(&mutex_);
5341  return impl_->current_test_info();
5342 }
5343 
5344 // Returns the random seed used at the start of the current test run.
5345 int UnitTest::random_seed() const { return impl_->random_seed(); }
5346 
5347 // Returns ParameterizedTestSuiteRegistry object used to keep track of
5348 // value-parameterized tests and instantiate and register them.
5349 internal::ParameterizedTestSuiteRegistry&
5351  return impl_->parameterized_test_registry();
5352 }
5353 
5354 // Creates an empty UnitTest.
5356  impl_ = new internal::UnitTestImpl(this);
5357 }
5358 
5359 // Destructor of UnitTest.
5361  delete impl_;
5362 }
5363 
5364 // Pushes a trace defined by SCOPED_TRACE() on to the per-thread
5365 // Google Test trace stack.
5366 void UnitTest::PushGTestTrace(const internal::TraceInfo& trace)
5368  internal::MutexLock lock(&mutex_);
5369  impl_->gtest_trace_stack().push_back(trace);
5370 }
5371 
5372 // Pops a trace from the per-thread Google Test trace stack.
5375  internal::MutexLock lock(&mutex_);
5376  impl_->gtest_trace_stack().pop_back();
5377 }
5378 
5379 namespace internal {
5380 
5381 UnitTestImpl::UnitTestImpl(UnitTest* parent)
5382  : parent_(parent),
5383  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4355 /* using this in initializer */)
5384  default_global_test_part_result_reporter_(this),
5385  default_per_thread_test_part_result_reporter_(this),
5386  GTEST_DISABLE_MSC_WARNINGS_POP_() global_test_part_result_repoter_(
5387  &default_global_test_part_result_reporter_),
5388  per_thread_test_part_result_reporter_(
5389  &default_per_thread_test_part_result_reporter_),
5390  parameterized_test_registry_(),
5391  parameterized_tests_registered_(false),
5392  last_death_test_suite_(-1),
5393  current_test_suite_(nullptr),
5394  current_test_info_(nullptr),
5395  ad_hoc_test_result_(),
5396  os_stack_trace_getter_(nullptr),
5397  post_flag_parse_init_performed_(false),
5398  random_seed_(0), // Will be overridden by the flag before first use.
5399  random_(0), // Will be reseeded before first use.
5400  start_timestamp_(0),
5401  elapsed_time_(0),
5402 #if GTEST_HAS_DEATH_TEST
5403  death_test_factory_(new DefaultDeathTestFactory),
5404 #endif
5405  // Will be overridden by the flag before first use.
5406  catch_exceptions_(false) {
5407  listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter);
5408 }
5409 
5411  // Deletes every TestSuite.
5412  ForEach(test_suites_, internal::Delete<TestSuite>);
5413 
5414  // Deletes every Environment.
5415  ForEach(environments_, internal::Delete<Environment>);
5416 
5417  delete os_stack_trace_getter_;
5418 }
5419 
5420 // Adds a TestProperty to the current TestResult object when invoked in a
5421 // context of a test, to current test suite's ad_hoc_test_result when invoke
5422 // from SetUpTestSuite/TearDownTestSuite, or to the global property set
5423 // otherwise. If the result already contains a property with the same key,
5424 // the value will be updated.
5425 void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
5426  std::string xml_element;
5427  TestResult* test_result; // TestResult appropriate for property recording.
5428 
5429  if (current_test_info_ != nullptr) {
5430  xml_element = "testcase";
5432  } else if (current_test_suite_ != nullptr) {
5433  xml_element = "testsuite";
5435  } else {
5436  xml_element = "testsuites";
5438  }
5439  test_result->RecordProperty(xml_element, test_property);
5440 }
5441 
5442 #if GTEST_HAS_DEATH_TEST
5443 // Disables event forwarding if the control is currently in a death test
5444 // subprocess. Must not be called before InitGoogleTest.
5445 void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
5446  if (internal_run_death_test_flag_.get() != nullptr)
5448 }
5449 #endif // GTEST_HAS_DEATH_TEST
5450 
5451 // Initializes event listeners performing XML output as specified by
5452 // UnitTestOptions. Must not be called before InitGoogleTest.
5454  const std::string& output_format = UnitTestOptions::GetOutputFormat();
5455  if (output_format == "xml") {
5456  listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
5458  } else if (output_format == "json") {
5459  listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
5461  } else if (output_format != "") {
5462  GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
5463  << output_format << "\" ignored.";
5464  }
5465 }
5466 
5467 #if GTEST_CAN_STREAM_RESULTS_
5468 // Initializes event listeners for streaming test results in string form.
5469 // Must not be called before InitGoogleTest.
5470 void UnitTestImpl::ConfigureStreamingOutput() {
5471  const std::string& target = GTEST_FLAG(stream_result_to);
5472  if (!target.empty()) {
5473  const size_t pos = target.find(':');
5474  if (pos != std::string::npos) {
5475  listeners()->Append(new StreamingListener(target.substr(0, pos),
5476  target.substr(pos+1)));
5477  } else {
5478  GTEST_LOG_(WARNING) << "unrecognized streaming target \"" << target
5479  << "\" ignored.";
5480  }
5481  }
5482 }
5483 #endif // GTEST_CAN_STREAM_RESULTS_
5484 
5485 // Performs initialization dependent upon flag values obtained in
5486 // ParseGoogleTestFlagsOnly. Is called from InitGoogleTest after the call to
5487 // ParseGoogleTestFlagsOnly. In case a user neglects to call InitGoogleTest
5488 // this function is also called from RunAllTests. Since this function can be
5489 // called more than once, it has to be idempotent.
5491  // Ensures that this function does not execute more than once.
5494 
5495 #if defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
5496  // Register to send notifications about key process state changes.
5497  listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_());
5498 #endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
5499 
5500 #if GTEST_HAS_DEATH_TEST
5501  InitDeathTestSubprocessControlInfo();
5502  SuppressTestEventsIfInSubprocess();
5503 #endif // GTEST_HAS_DEATH_TEST
5504 
5505  // Registers parameterized tests. This makes parameterized tests
5506  // available to the UnitTest reflection API without running
5507  // RUN_ALL_TESTS.
5509 
5510  // Configures listeners for XML output. This makes it possible for users
5511  // to shut down the default XML output before invoking RUN_ALL_TESTS.
5513 
5514  if (GTEST_FLAG(brief)) {
5515  listeners()->SetDefaultResultPrinter(new BriefUnitTestResultPrinter);
5516  }
5517 
5518 #if GTEST_CAN_STREAM_RESULTS_
5519  // Configures listeners for streaming test results to the specified server.
5520  ConfigureStreamingOutput();
5521 #endif // GTEST_CAN_STREAM_RESULTS_
5522 
5523 #if GTEST_HAS_ABSL
5524  if (GTEST_FLAG(install_failure_signal_handler)) {
5527  }
5528 #endif // GTEST_HAS_ABSL
5529  }
5530 }
5531 
5532 // A predicate that checks the name of a TestSuite against a known
5533 // value.
5534 //
5535 // This is used for implementation of the UnitTest class only. We put
5536 // it in the anonymous namespace to prevent polluting the outer
5537 // namespace.
5538 //
5539 // TestSuiteNameIs is copyable.
5540 class TestSuiteNameIs {
5541  public:
5542  // Constructor.
5543  explicit TestSuiteNameIs(const std::string& name) : name_(name) {}
5544 
5545  // Returns true if and only if the name of test_suite matches name_.
5546  bool operator()(const TestSuite* test_suite) const {
5547  return test_suite != nullptr &&
5548  strcmp(test_suite->name(), name_.c_str()) == 0;
5549  }
5550 
5551  private:
5553 };
5554 
5555 // Finds and returns a TestSuite with the given name. If one doesn't
5556 // exist, creates one and returns it. It's the CALLER'S
5557 // RESPONSIBILITY to ensure that this function is only called WHEN THE
5558 // TESTS ARE NOT SHUFFLED.
5559 //
5560 // Arguments:
5561 //
5562 // test_suite_name: name of the test suite
5563 // type_param: the name of the test suite's type parameter, or NULL if
5564 // this is not a typed or a type-parameterized test suite.
5565 // set_up_tc: pointer to the function that sets up the test suite
5566 // tear_down_tc: pointer to the function that tears down the test suite
5568  const char* test_suite_name, const char* type_param,
5569  internal::SetUpTestSuiteFunc set_up_tc,
5570  internal::TearDownTestSuiteFunc tear_down_tc) {
5571  // Can we find a TestSuite with the given name?
5572  const auto test_suite =
5573  std::find_if(test_suites_.rbegin(), test_suites_.rend(),
5574  TestSuiteNameIs(test_suite_name));
5575 
5576  if (test_suite != test_suites_.rend()) return *test_suite;
5577 
5578  // No. Let's create one.
5579  auto* const new_test_suite =
5580  new TestSuite(test_suite_name, type_param, set_up_tc, tear_down_tc);
5581 
5582  // Is this a death test suite?
5583  if (internal::UnitTestOptions::MatchesFilter(test_suite_name,
5585  // Yes. Inserts the test suite after the last death test suite
5586  // defined so far. This only works when the test suites haven't
5587  // been shuffled. Otherwise we may end up running a death test
5588  // after a non-death test.
5591  new_test_suite);
5592  } else {
5593  // No. Appends to the end of the list.
5594  test_suites_.push_back(new_test_suite);
5595  }
5596 
5597  test_suite_indices_.push_back(static_cast<int>(test_suite_indices_.size()));
5598  return new_test_suite;
5599 }
5600 
5601 // Helpers for setting up / tearing down the given environment. They
5602 // are for use in the ForEach() function.
5603 static void SetUpEnvironment(Environment* env) { env->SetUp(); }
5604 static void TearDownEnvironment(Environment* env) { env->TearDown(); }
5605 
5606 // Runs all tests in this UnitTest object, prints the result, and
5607 // returns true if all tests are successful. If any exception is
5608 // thrown during a test, the test is considered to be failed, but the
5609 // rest of the tests will still be run.
5610 //
5611 // When parameterized tests are enabled, it expands and registers
5612 // parameterized tests first in RegisterParameterizedTests().
5613 // All other functions called from RunAllTests() may safely assume that
5614 // parameterized tests are ready to be counted and run.
5616  // True if and only if Google Test is initialized before RUN_ALL_TESTS() is
5617  // called.
5618  const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized();
5619 
5620  // Do not run any test if the --help flag was specified.
5621  if (g_help_flag)
5622  return true;
5623 
5624  // Repeats the call to the post-flag parsing initialization in case the
5625  // user didn't call InitGoogleTest.
5627 
5628  // Even if sharding is not on, test runners may want to use the
5629  // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding
5630  // protocol.
5632 
5633  // True if and only if we are in a subprocess for running a thread-safe-style
5634  // death test.
5635  bool in_subprocess_for_death_test = false;
5636 
5637 #if GTEST_HAS_DEATH_TEST
5638  in_subprocess_for_death_test =
5639  (internal_run_death_test_flag_.get() != nullptr);
5640 # if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
5641  if (in_subprocess_for_death_test) {
5642  GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();
5643  }
5644 # endif // defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
5645 #endif // GTEST_HAS_DEATH_TEST
5646 
5647  const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,
5648  in_subprocess_for_death_test);
5649 
5650  // Compares the full test names with the filter to decide which
5651  // tests to run.
5652  const bool has_tests_to_run = FilterTests(should_shard
5654  : IGNORE_SHARDING_PROTOCOL) > 0;
5655 
5656  // Lists the tests and exits if the --gtest_list_tests flag was specified.
5657  if (GTEST_FLAG(list_tests)) {
5658  // This must be called *after* FilterTests() has been called.
5660  return true;
5661  }
5662 
5663  random_seed_ = GTEST_FLAG(shuffle) ?
5665 
5666  // True if and only if at least one test has failed.
5667  bool failed = false;
5668 
5669  TestEventListener* repeater = listeners()->repeater();
5670 
5672  repeater->OnTestProgramStart(*parent_);
5673 
5674  // How many times to repeat the tests? We don't want to repeat them
5675  // when we are inside the subprocess of a death test.
5676  const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);
5677  // Repeats forever if the repeat count is negative.
5678  const bool gtest_repeat_forever = repeat < 0;
5679  for (int i = 0; gtest_repeat_forever || i != repeat; i++) {
5680  // We want to preserve failures generated by ad-hoc test
5681  // assertions executed before RUN_ALL_TESTS().
5683 
5685 
5686  // Shuffles test suites and tests if requested.
5687  if (has_tests_to_run && GTEST_FLAG(shuffle)) {
5688  random()->Reseed(static_cast<uint32_t>(random_seed_));
5689  // This should be done before calling OnTestIterationStart(),
5690  // such that a test event listener can see the actual test order
5691  // in the event.
5692  ShuffleTests();
5693  }
5694 
5695  // Tells the unit test event listeners that the tests are about to start.
5696  repeater->OnTestIterationStart(*parent_, i);
5697 
5698  // Runs each test suite if there is at least one test to run.
5699  if (has_tests_to_run) {
5700  // Sets up all environments beforehand.
5701  repeater->OnEnvironmentsSetUpStart(*parent_);
5703  repeater->OnEnvironmentsSetUpEnd(*parent_);
5704 
5705  // Runs the tests only if there was no fatal failure or skip triggered
5706  // during global set-up.
5707  if (Test::IsSkipped()) {
5708  // Emit diagnostics when global set-up calls skip, as it will not be
5709  // emitted by default.
5710  TestResult& test_result =
5712  for (int j = 0; j < test_result.total_part_count(); ++j) {
5713  const TestPartResult& test_part_result =
5714  test_result.GetTestPartResult(j);
5715  if (test_part_result.type() == TestPartResult::kSkip) {
5716  const std::string& result = test_part_result.message();
5717  printf("%s\n", result.c_str());
5718  }
5719  }
5720  fflush(stdout);
5721  } else if (!Test::HasFatalFailure()) {
5722  for (int test_index = 0; test_index < total_test_suite_count();
5723  test_index++) {
5724  GetMutableSuiteCase(test_index)->Run();
5725  if (GTEST_FLAG(fail_fast) &&
5726  GetMutableSuiteCase(test_index)->Failed()) {
5727  for (int j = test_index + 1; j < total_test_suite_count(); j++) {
5728  GetMutableSuiteCase(j)->Skip();
5729  }
5730  break;
5731  }
5732  }
5733  }
5734 
5735  // Tears down all environments in reverse order afterwards.
5736  repeater->OnEnvironmentsTearDownStart(*parent_);
5737  std::for_each(environments_.rbegin(), environments_.rend(),
5739  repeater->OnEnvironmentsTearDownEnd(*parent_);
5740  }
5741 
5743 
5744  // Tells the unit test event listener that the tests have just finished.
5745  repeater->OnTestIterationEnd(*parent_, i);
5746 
5747  // Gets the result and clears it.
5748  if (!Passed()) {
5749  failed = true;
5750  }
5751 
5752  // Restores the original test order after the iteration. This
5753  // allows the user to quickly repro a failure that happens in the
5754  // N-th iteration without repeating the first (N - 1) iterations.
5755  // This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in
5756  // case the user somehow changes the value of the flag somewhere
5757  // (it's always safe to unshuffle the tests).
5758  UnshuffleTests();
5759 
5760  if (GTEST_FLAG(shuffle)) {
5761  // Picks a new random seed for each iteration.
5763  }
5764  }
5765 
5766  repeater->OnTestProgramEnd(*parent_);
5767 
5768  if (!gtest_is_initialized_before_run_all_tests) {
5769  ColoredPrintf(
5770  GTestColor::kRed,
5771  "\nIMPORTANT NOTICE - DO NOT IGNORE:\n"
5772  "This test program did NOT call " GTEST_INIT_GOOGLE_TEST_NAME_
5773  "() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_
5774  " will start to enforce the valid usage. "
5775  "Please fix it ASAP, or IT WILL START TO FAIL.\n"); // NOLINT
5776 #if GTEST_FOR_GOOGLE_
5777  ColoredPrintf(GTestColor::kRed,
5778  "For more details, see http://wiki/Main/ValidGUnitMain.\n");
5779 #endif // GTEST_FOR_GOOGLE_
5780  }
5781 
5782  return !failed;
5783 }
5784 
5785 // Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file
5786 // if the variable is present. If a file already exists at this location, this
5787 // function will write over it. If the variable is present, but the file cannot
5788 // be created, prints an error and exits.
5790  const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);
5791  if (test_shard_file != nullptr) {
5792  FILE* const file = posix::FOpen(test_shard_file, "w");
5793  if (file == nullptr) {
5794  ColoredPrintf(GTestColor::kRed,
5795  "Could not write to the test shard status file \"%s\" "
5796  "specified by the %s environment variable.\n",
5797  test_shard_file, kTestShardStatusFile);
5798  fflush(stdout);
5799  exit(EXIT_FAILURE);
5800  }
5801  fclose(file);
5802  }
5803 }
5804 
5805 // Checks whether sharding is enabled by examining the relevant
5806 // environment variable values. If the variables are present,
5807 // but inconsistent (i.e., shard_index >= total_shards), prints
5808 // an error and exits. If in_subprocess_for_death_test, sharding is
5809 // disabled because it must only be applied to the original test
5810 // process. Otherwise, we could filter out death tests we intended to execute.
5811 bool ShouldShard(const char* total_shards_env,
5812  const char* shard_index_env,
5813  bool in_subprocess_for_death_test) {
5814  if (in_subprocess_for_death_test) {
5815  return false;
5816  }
5817 
5818  const int32_t total_shards = Int32FromEnvOrDie(total_shards_env, -1);
5819  const int32_t shard_index = Int32FromEnvOrDie(shard_index_env, -1);
5820 
5821  if (total_shards == -1 && shard_index == -1) {
5822  return false;
5823  } else if (total_shards == -1 && shard_index != -1) {
5824  const Message msg = Message()
5825  << "Invalid environment variables: you have "
5826  << kTestShardIndex << " = " << shard_index
5827  << ", but have left " << kTestTotalShards << " unset.\n";
5828  ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
5829  fflush(stdout);
5830  exit(EXIT_FAILURE);
5831  } else if (total_shards != -1 && shard_index == -1) {
5832  const Message msg = Message()
5833  << "Invalid environment variables: you have "
5834  << kTestTotalShards << " = " << total_shards
5835  << ", but have left " << kTestShardIndex << " unset.\n";
5836  ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
5837  fflush(stdout);
5838  exit(EXIT_FAILURE);
5839  } else if (shard_index < 0 || shard_index >= total_shards) {
5840  const Message msg = Message()
5841  << "Invalid environment variables: we require 0 <= "
5842  << kTestShardIndex << " < " << kTestTotalShards
5843  << ", but you have " << kTestShardIndex << "=" << shard_index
5844  << ", " << kTestTotalShards << "=" << total_shards << ".\n";
5845  ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
5846  fflush(stdout);
5847  exit(EXIT_FAILURE);
5848  }
5849 
5850  return total_shards > 1;
5851 }
5852 
5853 // Parses the environment variable var as an Int32. If it is unset,
5854 // returns default_val. If it is not an Int32, prints an error
5855 // and aborts.
5856 int32_t Int32FromEnvOrDie(const char* var, int32_t default_val) {
5857  const char* str_val = posix::GetEnv(var);
5858  if (str_val == nullptr) {
5859  return default_val;
5860  }
5861 
5862  int32_t result;
5863  if (!ParseInt32(Message() << "The value of environment variable " << var,
5864  str_val, &result)) {
5865  exit(EXIT_FAILURE);
5866  }
5867  return result;
5868 }
5869 
5870 // Given the total number of shards, the shard index, and the test id,
5871 // returns true if and only if the test should be run on this shard. The test id
5872 // is some arbitrary but unique non-negative integer assigned to each test
5873 // method. Assumes that 0 <= shard_index < total_shards.
5874 bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {
5875  return (test_id % total_shards) == shard_index;
5876 }
5877 
5878 // Compares the name of each test with the user-specified filter to
5879 // decide whether the test should be run, then records the result in
5880 // each TestSuite and TestInfo object.
5881 // If shard_tests == true, further filters tests based on sharding
5882 // variables in the environment - see
5883 // https://github.com/google/googletest/blob/master/googletest/docs/advanced.md
5884 // . Returns the number of tests that should run.
5885 int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
5886  const int32_t total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?
5888  const int32_t shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?
5890 
5891  // num_runnable_tests are the number of tests that will
5892  // run across all shards (i.e., match filter and are not disabled).
5893  // num_selected_tests are the number of tests to be run on
5894  // this shard.
5895  int num_runnable_tests = 0;
5896  int num_selected_tests = 0;
5897  for (auto* test_suite : test_suites_) {
5898  const std::string& test_suite_name = test_suite->name();
5899  test_suite->set_should_run(false);
5900 
5901  for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
5902  TestInfo* const test_info = test_suite->test_info_list()[j];
5903  const std::string test_name(test_info->name());
5904  // A test is disabled if test suite name or test name matches
5905  // kDisableTestFilter.
5906  const bool is_disabled = internal::UnitTestOptions::MatchesFilter(
5907  test_suite_name, kDisableTestFilter) ||
5909  test_name, kDisableTestFilter);
5910  test_info->is_disabled_ = is_disabled;
5911 
5912  const bool matches_filter = internal::UnitTestOptions::FilterMatchesTest(
5913  test_suite_name, test_name);
5914  test_info->matches_filter_ = matches_filter;
5915 
5916  const bool is_runnable =
5917  (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
5918  matches_filter;
5919 
5920  const bool is_in_another_shard =
5921  shard_tests != IGNORE_SHARDING_PROTOCOL &&
5922  !ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests);
5923  test_info->is_in_another_shard_ = is_in_another_shard;
5924  const bool is_selected = is_runnable && !is_in_another_shard;
5925 
5926  num_runnable_tests += is_runnable;
5927  num_selected_tests += is_selected;
5928 
5929  test_info->should_run_ = is_selected;
5930  test_suite->set_should_run(test_suite->should_run() || is_selected);
5931  }
5932  }
5933  return num_selected_tests;
5934 }
5935 
5936 // Prints the given C-string on a single line by replacing all '\n'
5937 // characters with string "\\n". If the output takes more than
5938 // max_length characters, only prints the first max_length characters
5939 // and "...".
5940 static void PrintOnOneLine(const char* str, int max_length) {
5941  if (str != nullptr) {
5942  for (int i = 0; *str != '\0'; ++str) {
5943  if (i >= max_length) {
5944  printf("...");
5945  break;
5946  }
5947  if (*str == '\n') {
5948  printf("\\n");
5949  i += 2;
5950  } else {
5951  printf("%c", *str);
5952  ++i;
5953  }
5954  }
5955  }
5956 }
5957 
5958 // Prints the names of the tests matching the user-specified filter flag.
5960  // Print at most this many characters for each type/value parameter.
5961  const int kMaxParamLength = 250;
5962 
5963  for (auto* test_suite : test_suites_) {
5964  bool printed_test_suite_name = false;
5965 
5966  for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
5967  const TestInfo* const test_info = test_suite->test_info_list()[j];
5968  if (test_info->matches_filter_) {
5969  if (!printed_test_suite_name) {
5970  printed_test_suite_name = true;
5971  printf("%s.", test_suite->name());
5972  if (test_suite->type_param() != nullptr) {
5973  printf(" # %s = ", kTypeParamLabel);
5974  // We print the type parameter on a single line to make
5975  // the output easy to parse by a program.
5976  PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
5977  }
5978  printf("\n");
5979  }
5980  printf(" %s", test_info->name());
5981  if (test_info->value_param() != nullptr) {
5982  printf(" # %s = ", kValueParamLabel);
5983  // We print the value parameter on a single line to make the
5984  // output easy to parse by a program.
5985  PrintOnOneLine(test_info->value_param(), kMaxParamLength);
5986  }
5987  printf("\n");
5988  }
5989  }
5990  }
5991  fflush(stdout);
5992  const std::string& output_format = UnitTestOptions::GetOutputFormat();
5993  if (output_format == "xml" || output_format == "json") {
5994  FILE* fileout = OpenFileForWriting(
5996  std::stringstream stream;
5997  if (output_format == "xml") {
5998  XmlUnitTestResultPrinter(
6000  .PrintXmlTestsList(&stream, test_suites_);
6001  } else if (output_format == "json") {
6002  JsonUnitTestResultPrinter(
6004  .PrintJsonTestList(&stream, test_suites_);
6005  }
6006  fprintf(fileout, "%s", StringStreamToString(&stream).c_str());
6007  fclose(fileout);
6008  }
6009 }
6010 
6011 // Sets the OS stack trace getter.
6012 //
6013 // Does nothing if the input and the current OS stack trace getter are
6014 // the same; otherwise, deletes the old getter and makes the input the
6015 // current getter.
6017  OsStackTraceGetterInterface* getter) {
6018  if (os_stack_trace_getter_ != getter) {
6019  delete os_stack_trace_getter_;
6020  os_stack_trace_getter_ = getter;
6021  }
6022 }
6023 
6024 // Returns the current OS stack trace getter if it is not NULL;
6025 // otherwise, creates an OsStackTraceGetter, makes it the current
6026 // getter, and returns it.
6027 OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {
6028  if (os_stack_trace_getter_ == nullptr) {
6029 #ifdef GTEST_OS_STACK_TRACE_GETTER_
6030  os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_;
6031 #else
6032  os_stack_trace_getter_ = new OsStackTraceGetter;
6033 #endif // GTEST_OS_STACK_TRACE_GETTER_
6034  }
6035 
6036  return os_stack_trace_getter_;
6037 }
6038 
6039 // Returns the most specific TestResult currently running.
6040 TestResult* UnitTestImpl::current_test_result() {
6041  if (current_test_info_ != nullptr) {
6042  return &current_test_info_->result_;
6043  }
6044  if (current_test_suite_ != nullptr) {
6046  }
6047  return &ad_hoc_test_result_;
6048 }
6049 
6050 // Shuffles all test suites, and the tests within each test suite,
6051 // making sure that death tests are still run first.
6053  // Shuffles the death test suites.
6055 
6056  // Shuffles the non-death test suites.
6058  static_cast<int>(test_suites_.size()), &test_suite_indices_);
6059 
6060  // Shuffles the tests inside each test suite.
6061  for (auto& test_suite : test_suites_) {
6062  test_suite->ShuffleTests(random());
6063  }
6064 }
6065 
6066 // Restores the test suites and tests to their order before the first shuffle.
6068  for (size_t i = 0; i < test_suites_.size(); i++) {
6069  // Unshuffles the tests in each test suite.
6070  test_suites_[i]->UnshuffleTests();
6071  // Resets the index of each test suite.
6072  test_suite_indices_[i] = static_cast<int>(i);
6073  }
6074 }
6075 
6076 // Returns the current OS stack trace as an std::string.
6077 //
6078 // The maximum number of stack frames to be included is specified by
6079 // the gtest_stack_trace_depth flag. The skip_count parameter
6080 // specifies the number of top frames to be skipped, which doesn't
6081 // count against the number of frames to be included.
6082 //
6083 // For example, if Foo() calls Bar(), which in turn calls
6084 // GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
6085 // the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
6086 std::string GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/,
6087  int skip_count) {
6088  // We pass skip_count + 1 to skip this wrapper function in addition
6089  // to what the user really wants to skip.
6090  return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1);
6091 }
6092 
6093 // Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to
6094 // suppress unreachable code warnings.
6095 namespace {
6096 class ClassUniqueToAlwaysTrue {};
6097 }
6098 
6099 bool IsTrue(bool condition) { return condition; }
6100 
6101 bool AlwaysTrue() {
6102 #if GTEST_HAS_EXCEPTIONS
6103  // This condition is always false so AlwaysTrue() never actually throws,
6104  // but it makes the compiler think that it may throw.
6105  if (IsTrue(false))
6106  throw ClassUniqueToAlwaysTrue();
6107 #endif // GTEST_HAS_EXCEPTIONS
6108  return true;
6109 }
6110 
6111 // If *pstr starts with the given prefix, modifies *pstr to be right
6112 // past the prefix and returns true; otherwise leaves *pstr unchanged
6113 // and returns false. None of pstr, *pstr, and prefix can be NULL.
6114 bool SkipPrefix(const char* prefix, const char** pstr) {
6115  const size_t prefix_len = strlen(prefix);
6116  if (strncmp(*pstr, prefix, prefix_len) == 0) {
6117  *pstr += prefix_len;
6118  return true;
6119  }
6120  return false;
6121 }
6122 
6123 // Parses a string as a command line flag. The string should have
6124 // the format "--flag=value". When def_optional is true, the "=value"
6125 // part can be omitted.
6126 //
6127 // Returns the value of the flag, or NULL if the parsing failed.
6128 static const char* ParseFlagValue(const char* str, const char* flag,
6129  bool def_optional) {
6130  // str and flag must not be NULL.
6131  if (str == nullptr || flag == nullptr) return nullptr;
6132 
6133  // The flag must start with "--" followed by GTEST_FLAG_PREFIX_.
6134  const std::string flag_str = std::string("--") + GTEST_FLAG_PREFIX_ + flag;
6135  const size_t flag_len = flag_str.length();
6136  if (strncmp(str, flag_str.c_str(), flag_len) != 0) return nullptr;
6137 
6138  // Skips the flag name.
6139  const char* flag_end = str + flag_len;
6140 
6141  // When def_optional is true, it's OK to not have a "=value" part.
6142  if (def_optional && (flag_end[0] == '\0')) {
6143  return flag_end;
6144  }
6145 
6146  // If def_optional is true and there are more characters after the
6147  // flag name, or if def_optional is false, there must be a '=' after
6148  // the flag name.
6149  if (flag_end[0] != '=') return nullptr;
6150 
6151  // Returns the string after "=".
6152  return flag_end + 1;
6153 }
6154 
6155 // Parses a string for a bool flag, in the form of either
6156 // "--flag=value" or "--flag".
6157 //
6158 // In the former case, the value is taken as true as long as it does
6159 // not start with '0', 'f', or 'F'.
6160 //
6161 // In the latter case, the value is taken as true.
6162 //
6163 // On success, stores the value of the flag in *value, and returns
6164 // true. On failure, returns false without changing *value.
6165 static bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
6166  // Gets the value of the flag as a string.
6167  const char* const value_str = ParseFlagValue(str, flag, true);
6168 
6169  // Aborts if the parsing failed.
6170  if (value_str == nullptr) return false;
6171 
6172  // Converts the string value to a bool.
6173  *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');
6174  return true;
6175 }
6176 
6177 // Parses a string for an int32_t flag, in the form of "--flag=value".
6178 //
6179 // On success, stores the value of the flag in *value, and returns
6180 // true. On failure, returns false without changing *value.
6181 bool ParseInt32Flag(const char* str, const char* flag, int32_t* value) {
6182  // Gets the value of the flag as a string.
6183  const char* const value_str = ParseFlagValue(str, flag, false);
6184 
6185  // Aborts if the parsing failed.
6186  if (value_str == nullptr) return false;
6187 
6188  // Sets *value to the value of the flag.
6189  return ParseInt32(Message() << "The value of flag --" << flag,
6190  value_str, value);
6191 }
6192 
6193 // Parses a string for a string flag, in the form of "--flag=value".
6194 //
6195 // On success, stores the value of the flag in *value, and returns
6196 // true. On failure, returns false without changing *value.
6197 template <typename String>
6198 static bool ParseStringFlag(const char* str, const char* flag, String* value) {
6199  // Gets the value of the flag as a string.
6200  const char* const value_str = ParseFlagValue(str, flag, false);
6201 
6202  // Aborts if the parsing failed.
6203  if (value_str == nullptr) return false;
6204 
6205  // Sets *value to the value of the flag.
6206  *value = value_str;
6207  return true;
6208 }
6209 
6210 // Determines whether a string has a prefix that Google Test uses for its
6211 // flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_.
6212 // If Google Test detects that a command line flag has its prefix but is not
6213 // recognized, it will print its help message. Flags starting with
6214 // GTEST_INTERNAL_PREFIX_ followed by "internal_" are considered Google Test
6215 // internal flags and do not trigger the help message.
6216 static bool HasGoogleTestFlagPrefix(const char* str) {
6217  return (SkipPrefix("--", &str) ||
6218  SkipPrefix("-", &str) ||
6219  SkipPrefix("/", &str)) &&
6220  !SkipPrefix(GTEST_FLAG_PREFIX_ "internal_", &str) &&
6223 }
6224 
6225 // Prints a string containing code-encoded text. The following escape
6226 // sequences can be used in the string to control the text color:
6227 //
6228 // @@ prints a single '@' character.
6229 // @R changes the color to red.
6230 // @G changes the color to green.
6231 // @Y changes the color to yellow.
6232 // @D changes to the default terminal text color.
6233 //
6234 static void PrintColorEncoded(const char* str) {
6235  GTestColor color = GTestColor::kDefault; // The current color.
6236 
6237  // Conceptually, we split the string into segments divided by escape
6238  // sequences. Then we print one segment at a time. At the end of
6239  // each iteration, the str pointer advances to the beginning of the
6240  // next segment.
6241  for (;;) {
6242  const char* p = strchr(str, '@');
6243  if (p == nullptr) {
6244  ColoredPrintf(color, "%s", str);
6245  return;
6246  }
6247 
6248  ColoredPrintf(color, "%s", std::string(str, p).c_str());
6249 
6250  const char ch = p[1];
6251  str = p + 2;
6252  if (ch == '@') {
6253  ColoredPrintf(color, "@");
6254  } else if (ch == 'D') {
6255  color = GTestColor::kDefault;
6256  } else if (ch == 'R') {
6257  color = GTestColor::kRed;
6258  } else if (ch == 'G') {
6259  color = GTestColor::kGreen;
6260  } else if (ch == 'Y') {
6261  color = GTestColor::kYellow;
6262  } else {
6263  --str;
6264  }
6265  }
6266 }
6267 
6268 static const char kColorEncodedHelpMessage[] =
6269  "This program contains tests written using " GTEST_NAME_
6270  ". You can use the\n"
6271  "following command line flags to control its behavior:\n"
6272  "\n"
6273  "Test Selection:\n"
6274  " @G--" GTEST_FLAG_PREFIX_
6275  "list_tests@D\n"
6276  " List the names of all tests instead of running them. The name of\n"
6277  " TEST(Foo, Bar) is \"Foo.Bar\".\n"
6278  " @G--" GTEST_FLAG_PREFIX_
6279  "filter=@YPOSITIVE_PATTERNS"
6280  "[@G-@YNEGATIVE_PATTERNS]@D\n"
6281  " Run only the tests whose name matches one of the positive patterns "
6282  "but\n"
6283  " none of the negative patterns. '?' matches any single character; "
6284  "'*'\n"
6285  " matches any substring; ':' separates two patterns.\n"
6286  " @G--" GTEST_FLAG_PREFIX_
6287  "also_run_disabled_tests@D\n"
6288  " Run all disabled tests too.\n"
6289  "\n"
6290  "Test Execution:\n"
6291  " @G--" GTEST_FLAG_PREFIX_
6292  "repeat=@Y[COUNT]@D\n"
6293  " Run the tests repeatedly; use a negative count to repeat forever.\n"
6294  " @G--" GTEST_FLAG_PREFIX_
6295  "shuffle@D\n"
6296  " Randomize tests' orders on every iteration.\n"
6297  " @G--" GTEST_FLAG_PREFIX_
6298  "random_seed=@Y[NUMBER]@D\n"
6299  " Random number seed to use for shuffling test orders (between 1 and\n"
6300  " 99999, or 0 to use a seed based on the current time).\n"
6301  "\n"
6302  "Test Output:\n"
6303  " @G--" GTEST_FLAG_PREFIX_
6304  "color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n"
6305  " Enable/disable colored output. The default is @Gauto@D.\n"
6306  " @G--" GTEST_FLAG_PREFIX_
6307  "brief=1@D\n"
6308  " Only print test failures.\n"
6309  " @G--" GTEST_FLAG_PREFIX_
6310  "print_time=0@D\n"
6311  " Don't print the elapsed time of each test.\n"
6312  " @G--" GTEST_FLAG_PREFIX_
6313  "output=@Y(@Gjson@Y|@Gxml@Y)[@G:@YDIRECTORY_PATH@G" GTEST_PATH_SEP_
6314  "@Y|@G:@YFILE_PATH]@D\n"
6315  " Generate a JSON or XML report in the given directory or with the "
6316  "given\n"
6317  " file name. @YFILE_PATH@D defaults to @Gtest_detail.xml@D.\n"
6318 # if GTEST_CAN_STREAM_RESULTS_
6319  " @G--" GTEST_FLAG_PREFIX_
6320  "stream_result_to=@YHOST@G:@YPORT@D\n"
6321  " Stream test results to the given server.\n"
6322 # endif // GTEST_CAN_STREAM_RESULTS_
6323  "\n"
6324  "Assertion Behavior:\n"
6325 # if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
6326  " @G--" GTEST_FLAG_PREFIX_
6327  "death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n"
6328  " Set the default death test style.\n"
6329 # endif // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
6330  " @G--" GTEST_FLAG_PREFIX_
6331  "break_on_failure@D\n"
6332  " Turn assertion failures into debugger break-points.\n"
6333  " @G--" GTEST_FLAG_PREFIX_
6334  "throw_on_failure@D\n"
6335  " Turn assertion failures into C++ exceptions for use by an external\n"
6336  " test framework.\n"
6337  " @G--" GTEST_FLAG_PREFIX_
6338  "catch_exceptions=0@D\n"
6339  " Do not report exceptions as test failures. Instead, allow them\n"
6340  " to crash the program or throw a pop-up (on Windows).\n"
6341  "\n"
6342  "Except for @G--" GTEST_FLAG_PREFIX_
6343  "list_tests@D, you can alternatively set "
6344  "the corresponding\n"
6345  "environment variable of a flag (all letters in upper-case). For example, "
6346  "to\n"
6347  "disable colored text output, you can either specify "
6348  "@G--" GTEST_FLAG_PREFIX_
6349  "color=no@D or set\n"
6350  "the @G" GTEST_FLAG_PREFIX_UPPER_
6351  "COLOR@D environment variable to @Gno@D.\n"
6352  "\n"
6353  "For more information, please read the " GTEST_NAME_
6354  " documentation at\n"
6355  "@G" GTEST_PROJECT_URL_ "@D. If you find a bug in " GTEST_NAME_
6356  "\n"
6357  "(not one in your own code or tests), please report it to\n"
6358  "@G<" GTEST_DEV_EMAIL_ ">@D.\n";
6359 
6360 static bool ParseGoogleTestFlag(const char* const arg) {
6362  &GTEST_FLAG(also_run_disabled_tests)) ||
6364  &GTEST_FLAG(break_on_failure)) ||
6366  &GTEST_FLAG(catch_exceptions)) ||
6369  &GTEST_FLAG(death_test_style)) ||
6371  &GTEST_FLAG(death_test_use_fork)) ||
6372  ParseBoolFlag(arg, kFailFast, &GTEST_FLAG(fail_fast)) ||
6373  ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) ||
6375  &GTEST_FLAG(internal_run_death_test)) ||
6376  ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) ||
6378  ParseBoolFlag(arg, kBriefFlag, &GTEST_FLAG(brief)) ||
6379  ParseBoolFlag(arg, kPrintTimeFlag, &GTEST_FLAG(print_time)) ||
6380  ParseBoolFlag(arg, kPrintUTF8Flag, &GTEST_FLAG(print_utf8)) ||
6381  ParseInt32Flag(arg, kRandomSeedFlag, &GTEST_FLAG(random_seed)) ||
6382  ParseInt32Flag(arg, kRepeatFlag, &GTEST_FLAG(repeat)) ||
6383  ParseBoolFlag(arg, kShuffleFlag, &GTEST_FLAG(shuffle)) ||
6385  &GTEST_FLAG(stack_trace_depth)) ||
6387  &GTEST_FLAG(stream_result_to)) ||
6388  ParseBoolFlag(arg, kThrowOnFailureFlag, &GTEST_FLAG(throw_on_failure));
6389 }
6390 
6391 #if GTEST_USE_OWN_FLAGFILE_FLAG_
6392 static void LoadFlagsFromFile(const std::string& path) {
6393  FILE* flagfile = posix::FOpen(path.c_str(), "r");
6394  if (!flagfile) {
6395  GTEST_LOG_(FATAL) << "Unable to open file \"" << GTEST_FLAG(flagfile)
6396  << "\"";
6397  }
6398  std::string contents(ReadEntireFile(flagfile));
6399  posix::FClose(flagfile);
6400  std::vector<std::string> lines;
6401  SplitString(contents, '\n', &lines);
6402  for (size_t i = 0; i < lines.size(); ++i) {
6403  if (lines[i].empty())
6404  continue;
6405  if (!ParseGoogleTestFlag(lines[i].c_str()))
6406  g_help_flag = true;
6407  }
6408 }
6409 #endif // GTEST_USE_OWN_FLAGFILE_FLAG_
6410 
6411 // Parses the command line for Google Test flags, without initializing
6412 // other parts of Google Test. The type parameter CharType can be
6413 // instantiated to either char or wchar_t.
6414 template <typename CharType>
6415 void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
6416  for (int i = 1; i < *argc; i++) {
6417  const std::string arg_string = StreamableToString(argv[i]);
6418  const char* const arg = arg_string.c_str();
6419 
6423 
6424  bool remove_flag = false;
6425  if (ParseGoogleTestFlag(arg)) {
6426  remove_flag = true;
6427 #if GTEST_USE_OWN_FLAGFILE_FLAG_
6428  } else if (ParseStringFlag(arg, kFlagfileFlag, &GTEST_FLAG(flagfile))) {
6429  LoadFlagsFromFile(GTEST_FLAG(flagfile));
6430  remove_flag = true;
6431 #endif // GTEST_USE_OWN_FLAGFILE_FLAG_
6432  } else if (arg_string == "--help" || arg_string == "-h" ||
6433  arg_string == "-?" || arg_string == "/?" ||
6435  // Both help flag and unrecognized Google Test flags (excluding
6436  // internal ones) trigger help display.
6437  g_help_flag = true;
6438  }
6439 
6440  if (remove_flag) {
6441  // Shift the remainder of the argv list left by one. Note
6442  // that argv has (*argc + 1) elements, the last one always being
6443  // NULL. The following loop moves the trailing NULL element as
6444  // well.
6445  for (int j = i; j != *argc; j++) {
6446  argv[j] = argv[j + 1];
6447  }
6448 
6449  // Decrements the argument count.
6450  (*argc)--;
6451 
6452  // We also need to decrement the iterator as we just removed
6453  // an element.
6454  i--;
6455  }
6456  }
6457 
6458  if (g_help_flag) {
6459  // We print the help here instead of in RUN_ALL_TESTS(), as the
6460  // latter may not be called at all if the user is using Google
6461  // Test with another testing framework.
6463  }
6464 }
6465 
6466 // Parses the command line for Google Test flags, without initializing
6467 // other parts of Google Test.
6468 void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
6469  ParseGoogleTestFlagsOnlyImpl(argc, argv);
6470 
6471  // Fix the value of *_NSGetArgc() on macOS, but if and only if
6472  // *_NSGetArgv() == argv
6473  // Only applicable to char** version of argv
6474 #if GTEST_OS_MAC
6475 #ifndef GTEST_OS_IOS
6476  if (*_NSGetArgv() == argv) {
6477  *_NSGetArgc() = *argc;
6478  }
6479 #endif
6480 #endif
6481 }
6482 void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) {
6483  ParseGoogleTestFlagsOnlyImpl(argc, argv);
6484 }
6485 
6486 // The internal implementation of InitGoogleTest().
6487 //
6488 // The type parameter CharType can be instantiated to either char or
6489 // wchar_t.
6490 template <typename CharType>
6491 void InitGoogleTestImpl(int* argc, CharType** argv) {
6492  // We don't want to run the initialization code twice.
6493  if (GTestIsInitialized()) return;
6494 
6495  if (*argc <= 0) return;
6496 
6497  g_argvs.clear();
6498  for (int i = 0; i != *argc; i++) {
6499  g_argvs.push_back(StreamableToString(argv[i]));
6500  }
6501 
6502 #if GTEST_HAS_ABSL
6504 #endif // GTEST_HAS_ABSL
6505 
6506  ParseGoogleTestFlagsOnly(argc, argv);
6508 }
6509 
6510 } // namespace internal
6511 
6512 // Initializes Google Test. This must be called before calling
6513 // RUN_ALL_TESTS(). In particular, it parses a command line for the
6514 // flags that Google Test recognizes. Whenever a Google Test flag is
6515 // seen, it is removed from argv, and *argc is decremented.
6516 //
6517 // No value is returned. Instead, the Google Test flag variables are
6518 // updated.
6519 //
6520 // Calling the function for the second time has no user-visible effect.
6521 void InitGoogleTest(int* argc, char** argv) {
6522 #if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
6523  GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);
6524 #else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
6525  internal::InitGoogleTestImpl(argc, argv);
6526 #endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
6527 }
6528 
6529 // This overloaded version can be used in Windows programs compiled in
6530 // UNICODE mode.
6531 void InitGoogleTest(int* argc, wchar_t** argv) {
6532 #if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
6533  GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);
6534 #else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
6535  internal::InitGoogleTestImpl(argc, argv);
6536 #endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
6537 }
6538 
6539 // This overloaded version can be used on Arduino/embedded platforms where
6540 // there is no argc/argv.
6541 void InitGoogleTest() {
6542  // Since Arduino doesn't have a command line, fake out the argc/argv arguments
6543  int argc = 1;
6544  const auto arg0 = "dummy";
6545  char* argv0 = const_cast<char*>(arg0);
6546  char** argv = &argv0;
6547 
6548 #if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
6549  GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(&argc, argv);
6550 #else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
6551  internal::InitGoogleTestImpl(&argc, argv);
6552 #endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
6553 }
6554 
6555 std::string TempDir() {
6556 #if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_)
6557  return GTEST_CUSTOM_TEMPDIR_FUNCTION_();
6558 #elif GTEST_OS_WINDOWS_MOBILE
6559  return "\\temp\\";
6560 #elif GTEST_OS_WINDOWS
6561  const char* temp_dir = internal::posix::GetEnv("TEMP");
6562  if (temp_dir == nullptr || temp_dir[0] == '\0') {
6563  return "\\temp\\";
6564  } else if (temp_dir[strlen(temp_dir) - 1] == '\\') {
6565  return temp_dir;
6566  } else {
6567  return std::string(temp_dir) + "\\";
6568  }
6569 #elif GTEST_OS_LINUX_ANDROID
6570  const char* temp_dir = internal::posix::GetEnv("TEST_TMPDIR");
6571  if (temp_dir == nullptr || temp_dir[0] == '\0') {
6572  return "/data/local/tmp/";
6573  } else {
6574  return temp_dir;
6575  }
6576 #elif GTEST_OS_LINUX
6577  const char* temp_dir = internal::posix::GetEnv("TEST_TMPDIR");
6578  if (temp_dir == nullptr || temp_dir[0] == '\0') {
6579  return "/tmp/";
6580  } else {
6581  return temp_dir;
6582  }
6583 #else
6584  return "/tmp/";
6585 #endif // GTEST_OS_WINDOWS_MOBILE
6586 }
6587 
6588 // Class ScopedTrace
6589 
6590 // Pushes the given source file location and message onto a per-thread
6591 // trace stack maintained by Google Test.
6592 void ScopedTrace::PushTrace(const char* file, int line, std::string message) {
6593  internal::TraceInfo trace;
6594  trace.file = file;
6595  trace.line = line;
6596  trace.message.swap(message);
6597 
6599 }
6600 
6601 // Pops the info pushed by the c'tor.
6603  GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
6605 }
6606 
6607 } // namespace testing
testing::UnitTest::listeners
TestEventListeners & listeners()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4746
testing::UnitTest::PopGTestTrace
void PopGTestTrace() GTEST_LOCK_EXCLUDED_(mutex_)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4996
testing::internal::ParseStringFlag
static bool ParseStringFlag(const char *str, const char *flag, String *value)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5811
testing::TestSuite::~TestSuite
virtual ~TestSuite()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2774
testing::UnitTest::failed_test_count
int failed_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4678
testing::internal::String::ShowWideCString
static std::string ShowWideCString(const wchar_t *wide_c_str)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1862
xds_interop_client.str
str
Definition: xds_interop_client.py:487
testing::internal::BriefUnitTestResultPrinter::PrintTestName
static void PrintTestName(const char *test_suite, const char *test)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3647
absl::time_internal::cctz::seconds
std::chrono::duration< std::int_fast64_t > seconds
Definition: abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h:40
GTEST_FLAG_PREFIX_DASH_
#define GTEST_FLAG_PREFIX_DASH_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:278
testing::internal::XmlUnitTestResultPrinter::PrintXmlTestsList
static void PrintXmlTestsList(std::ostream *stream, const std::vector< TestSuite * > &test_suites)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3929
testing::internal::FilePath::string
const std::string & string() const
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:4342
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
testing::internal::UnitTestImpl::current_test_result
TestResult * current_test_result()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5651
Type
struct Type Type
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:673
flag
uint32_t flag
Definition: ssl_versions.cc:162
testing::AssertionResult::operator!
AssertionResult operator!() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1016
testing::internal::SplitString
void SplitString(const ::std::string &str, char delimiter, ::std::vector< ::std::string > *dest)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:946
testing::internal::CmpHelperSTRCASENE
GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1546
unicode
Definition: bloaty/third_party/re2/re2/unicode.py:1
testing
Definition: aws_request_signer_test.cc:25
width
int width
Definition: libuv/docs/code/tty-gravity/main.c:10
testing::AssertionFailure
AssertionResult AssertionFailure()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1028
testing::internal::kStreamResultToFlag
const char kStreamResultToFlag[]
Definition: gmock-gtest-all.cc:508
grpc::testing::val1
const char val1[]
Definition: client_context_test_peer_test.cc:34
testing::internal::UnitTestImpl::AddTestInfo
void AddTestInfo(Test::SetUpTestCaseFunc set_up_tc, Test::TearDownTestCaseFunc tear_down_tc, TestInfo *test_info)
Definition: gmock-gtest-all.cc:1052
testing::TestPartResult
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18272
testing::internal::UnitTestImpl::PostFlagParsingInit
void PostFlagParsingInit()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5113
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
testing::ScopedTrace::PushTrace
void PushTrace(const char *file, int line, std::string message)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6166
testing::internal::UnitTestImpl::ClearNonAdHocTestResult
void ClearNonAdHocTestResult()
Definition: gmock-gtest-all.cc:1109
testing::TestInfo
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:695
now
static double now(void)
Definition: test/core/fling/client.cc:130
testing::internal::XmlUnitTestResultPrinter::output_file_
const std::string output_file_
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3598
testing::TestResult::AddTestPartResult
void AddTestPartResult(const TestPartResult &test_part_result)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2065
regen-readme.it
it
Definition: regen-readme.py:15
testing::internal::ChopLowBits
UInt32 ChopLowBits(UInt32 *bits, int n)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1758
http2_test_server.format
format
Definition: http2_test_server.py:118
absl::GetStackTrace
ABSL_ATTRIBUTE_NOINLINE ABSL_ATTRIBUTE_NO_TAIL_CALL int GetStackTrace(void **result, int max_depth, int skip_count)
Definition: abseil-cpp/absl/debugging/stacktrace.cc:101
testing::TempDir
GTEST_API_ std::string TempDir()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6140
testing::internal::TestEventRepeater::OnTestSuiteStart
void OnTestSuiteStart(const TestSuite &parameter) override
testing::kReservedTestSuiteAttributes
static const char *const kReservedTestSuiteAttributes[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2103
absl::str_format_internal::LengthMod::j
@ j
testing::internal::IsTrue
GTEST_API_ bool IsTrue(bool condition)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5710
pos
int pos
Definition: libuv/docs/code/tty-gravity/main.c:11
get
absl::string_view get(const Cont &c)
Definition: abseil-cpp/absl/strings/str_replace_test.cc:185
testing::internal::UnitTestImpl::set_current_test_suite
void set_current_test_suite(TestSuite *a_current_test_suite)
Definition: googletest/googletest/src/gtest-internal-inl.h:700
testing::TestPartResult::type
Type type() const
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18297
testing::internal::ShouldRunTestOnShard
bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5485
testing::ArrayAsVector
std::vector< std::string > ArrayAsVector(const char *const (&array)[kSize])
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2118
testing::internal::CodeLocation::file
std::string file
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:484
MutexLock
#define MutexLock(x)
Definition: bloaty/third_party/re2/util/mutex.h:125
absl::StrAppend
void StrAppend(std::string *dest, const AlphaNum &a)
Definition: abseil-cpp/absl/strings/str_cat.cc:193
const
#define const
Definition: bloaty/third_party/zlib/zconf.h:230
testing::UnitTest::total_test_suite_count
int total_test_suite_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4641
testing::internal::BriefUnitTestResultPrinter::OnTestProgramEnd
void OnTestProgramEnd(const UnitTest &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3676
testing::UnitTest::Passed
bool Passed() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4713
testing::UnitTest::current_test_info
const TestInfo * current_test_info() const GTEST_LOCK_EXCLUDED_(mutex_)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4961
generate.env
env
Definition: generate.py:37
find
static void ** find(grpc_chttp2_stream_map *map, uint32_t key)
Definition: stream_map.cc:99
testing::TestSuite::Failed
bool Failed() const
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:892
testing::internal::JsonUnitTestResultPrinter::OnTestIterationEnd
void OnTestIterationEnd(const UnitTest &unit_test, int iteration) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4048
loc_
const CodeLocation loc_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:450
check_tracer_sanity.pattern
pattern
Definition: check_tracer_sanity.py:25
memset
return memset(p, 0, total)
testing::internal::UnitTestImpl::listeners
TestEventListeners * listeners()
Definition: gmock-gtest-all.cc:997
GTEST_REVERSE_REPEATER_METHOD_
#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3823
file
const grpc_generator::File * file
Definition: python_private_generator.h:38
testing::internal::BriefUnitTestResultPrinter::OnEnvironmentsSetUpEnd
void OnEnvironmentsSetUpEnd(const UnitTest &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3656
testing::internal::kListTestsFlag
const char kListTestsFlag[]
Definition: gmock-gtest-all.cc:501
testing::UnitTest::current_test_case
const TestCase * current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4952
demumble_test.stdout
stdout
Definition: demumble_test.py:38
testing::internal::UnitTestImpl::HONOR_SHARDING_PROTOCOL
@ HONOR_SHARDING_PROTOCOL
Definition: gmock-gtest-all.cc:1125
testing::TestInfo::matches_filter_
bool matches_filter_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:814
testing::UnitTest::test_to_run_count
int test_to_run_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4699
testing::TestSuite::Skip
void Skip()
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3037
testing::UnitTest::random_seed
int random_seed() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4968
testing::internal::CmpHelperSTREQ
GTEST_API_ AssertionResult CmpHelperSTREQ(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1500
testing::internal::ParseBoolFlag
static bool ParseBoolFlag(const char *str, const char *flag, bool *value)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5776
element_name
std::string element_name
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.cc:3096
tests.google.protobuf.internal.message_test.isnan
def isnan(val)
Definition: bloaty/third_party/protobuf/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py:65
testing::internal::UnitTestImpl::ad_hoc_test_result_
TestResult ad_hoc_test_result_
Definition: gmock-gtest-all.cc:1287
testing::internal::TypeParameterizedTestSuiteRegistry::RegisterTestSuite
void RegisterTestSuite(const char *test_suite_name, CodeLocation code_location)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:524
testing::internal::XmlUnitTestResultPrinter::EscapeXmlAttribute
static std::string EscapeXmlAttribute(const std::string &str)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3909
false
#define false
Definition: setup_once.h:323
testing::internal::ShouldRunTestSuite
static bool ShouldRunTestSuite(const TestSuite *test_suite)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:386
testing::internal::ParseGoogleTestFlag
static bool ParseGoogleTestFlag(const char *const arg)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5946
testing::TestResult
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:562
testing::TestSuite::ShuffleTests
void ShuffleTests(internal::Random *random)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2847
testing::TestEventListener::OnTestCaseEnd
virtual void OnTestCaseEnd(const TestCase &)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1119
capstone.range
range
Definition: third_party/bloaty/third_party/capstone/bindings/python/capstone/__init__.py:6
testing::internal::JsonUnitTestResultPrinter::output_file_
const std::string output_file_
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4035
adds_
size_t adds_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:1336
testing::internal::UnitTestImpl::total_test_suite_count
int total_test_suite_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:765
testing::internal::Indent
static std::string Indent(size_t width)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:4496
testing::UnitTest::impl
internal::UnitTestImpl * impl()
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1411
testing::internal::kTypeParamLabel
static const char kTypeParamLabel[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3086
testing::internal::StringFromGTestEnv
const char * StringFromGTestEnv(const char *flag, const char *default_val)
Definition: bloaty/third_party/googletest/googletest/src/gtest-port.cc:1391
testing::UnitTest::test_case_to_run_count
int test_case_to_run_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4662
testing::internal::GTestColor
GTestColor
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1805
testing::TestResult::total_part_count
int total_part_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2237
testing::internal::TypeParameterizedTestSuiteRegistry::TypeParameterizedTestSuiteInfo
Definition: boringssl-with-bazel/src/third_party/googletest/include/gtest/internal/gtest-param-util.h:764
test
Definition: spinlock_test.cc:36
testing::internal::TearDownTestSuiteFunc
void(*)() TearDownTestSuiteFunc
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:478
testing::AssertionResult::success_
bool success_
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18929
setup.description
description
Definition: setup.py:544
testing::internal::BriefUnitTestResultPrinter::OnTestPartResult
void OnTestPartResult(const TestPartResult &result) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3680
testing::internal::edit_distance::kRemove
@ kRemove
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:156
testing::internal::IsUtf16SurrogatePair
bool IsUtf16SurrogatePair(wchar_t first, wchar_t second)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1805
testing::TestResult::RecordProperty
void RecordProperty(const std::string &xml_element, const TestProperty &test_property)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2072
testing::internal::Random::Generate
UInt32 Generate(UInt32 range)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:340
testing::internal::TestSuitePassed
static bool TestSuitePassed(const TestSuite *test_suite)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:375
grpc::testing::sum
double sum(const T &container, F functor)
Definition: test/cpp/qps/stats.h:30
testing::TestInfo::Skip
void Skip()
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:2880
testing::TestPartResultTypeToString
static const char * TestPartResultTypeToString(TestPartResult::Type type)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2884
testing::internal::SingleFailureChecker::SingleFailureChecker
SingleFailureChecker(const TestPartResultArray *results, TestPartResult::Type type, const string &substr)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:698
testing::TestPartResult::kFatalFailure
@ kFatalFailure
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18279
testing::Test::Test
Test()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2251
testing::TestSuite::reportable_disabled_test_count
int reportable_disabled_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2729
testing::internal::HasOneFailure
static AssertionResult HasOneFailure(const char *, const char *, const char *, const TestPartResultArray &results, TestPartResult::Type type, const std::string &substr)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:659
testing::internal::kDeathTestUseFork
const char kDeathTestUseFork[]
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h:52
testing::internal::FormatFileLocation
GTEST_API_ ::std::string FormatFileLocation(const char *file, int line)
Definition: bloaty/third_party/googletest/googletest/src/gtest-port.cc:1018
testing::internal::SetUpEnvironment
static void SetUpEnvironment(Environment *env)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5222
options
double_dict options[]
Definition: capstone_test.c:55
absl::FailureSignalHandlerOptions
Definition: abseil-cpp/absl/debugging/failure_signal_handler.h:56
testing::TestEventListener::OnTestSuiteEnd
virtual void OnTestSuiteEnd(const TestSuite &)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1115
testing::internal::HandleSehExceptionsInMethodIfSupported
Result HandleSehExceptionsInMethodIfSupported(T *object, Result(T::*method)(), const char *location)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2420
testing::internal::GetUnitTestImpl
UnitTestImpl * GetUnitTestImpl()
Definition: gmock-gtest-all.cc:1334
testing::internal::FormatForComparisonFailureMessage
std::string FormatForComparisonFailureMessage(const T1 &value, const T2 &)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-printers.h:377
testing::internal::TypeId
const typedef void * TypeId
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:405
printf
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
Definition: cs_driver.c:91
testing::AssertionResult::message_
internal::scoped_ptr< ::std::string > message_
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18934
testing::internal::CmpHelperEQ
AssertionResult CmpHelperEQ(const char *lhs_expression, const char *rhs_expression, const T1 &lhs, const T2 &rhs)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1522
testing::FormatTestSuiteCount
static std::string FormatTestSuiteCount(int test_suite_count)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2876
GTEST_FLAG_PREFIX_UPPER_
#define GTEST_FLAG_PREFIX_UPPER_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:279
left_start_
size_t left_start_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:1335
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
testing::internal::TestEventRepeater::set_forwarding_enabled
void set_forwarding_enabled(bool enable)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3758
testing::internal::edit_distance::CalculateOptimalEdits
GTEST_API_ std::vector< EditType > CalculateOptimalEdits(const std::vector< size_t > &left, const std::vector< size_t > &right)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1041
hunk_removes_
std::list< std::pair< char, const char * > > hunk_removes_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:1337
grpc::protobuf::Message
GRPC_CUSTOM_MESSAGE Message
Definition: include/grpcpp/impl/codegen/config_protobuf.h:78
type_
std::string type_
Definition: client_channel_stress_test.cc:212
testing::internal::GetNextRandomSeed
int GetNextRandomSeed(int seed)
Definition: gmock-gtest-all.cc:559
testing::internal::UnitTestOptions::MatchesFilter
static bool MatchesFilter(const std::string &name, const char *filter)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:507
testing::internal::GTEST_ATTRIBUTE_PRINTF_
GTEST_API_ GTEST_ATTRIBUTE_PRINTF_(2, 3) void ColoredPrintf(GTestColor color
testing::internal::scoped_ptr::get
T * get() const
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:2399
testing::internal::Int32FromGTestEnv
GTEST_API_ Int32 Int32FromGTestEnv(const char *flag, Int32 default_val)
Definition: bloaty/third_party/googletest/googletest/src/gtest-port.cc:1348
GTEST_DEV_EMAIL_
#define GTEST_DEV_EMAIL_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:276
loc
OPENSSL_EXPORT X509_EXTENSION int loc
Definition: x509.h:1418
absl::debugging_internal::Append
static void Append(State *state, const char *const str, const int length)
Definition: abseil-cpp/absl/debugging/internal/demangle.cc:359
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
testing::TestEventListener::OnTestEnd
virtual void OnTestEnd(const TestInfo &test_info)=0
testing::internal::kAlsoRunDisabledTestsFlag
const char kAlsoRunDisabledTestsFlag[]
Definition: gmock-gtest-all.cc:496
testing::internal::UnitTestImpl::UnshuffleTests
void UnshuffleTests()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5678
testing::internal::FilePath::RemoveFileName
FilePath RemoveFileName() const
Definition: bloaty/third_party/googletest/googletest/src/gtest-filepath.cc:162
testing::internal::FilePath::ConcatPaths
static FilePath ConcatPaths(const FilePath &directory, const FilePath &relative_path)
Definition: bloaty/third_party/googletest/googletest/src/gtest-filepath.cc:195
testing::internal::XmlUnitTestResultPrinter::ListTestsMatchingFilter
void ListTestsMatchingFilter(const std::vector< TestSuite * > &test_suites)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3621
instance
RefCountedPtr< grpc_tls_certificate_provider > instance
Definition: xds_server_config_fetcher.cc:224
testing::internal::edit_distance::kAdd
@ kAdd
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:156
testing::internal::JsonUnitTestResultPrinter::EscapeJson
static std::string EscapeJson(const std::string &str)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4058
google::protobuf::python::cmessage::Init
static int Init(CMessage *self, PyObject *args, PyObject *kwargs)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/message.cc:1287
testing::internal::PrettyUnitTestResultPrinter::OnTestStart
void OnTestStart(const TestInfo &test_info) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3218
testing::TestEventListeners::Append
void Append(TestEventListener *listener)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4548
testing::internal::UnitTestImpl::ConfigureXmlOutput
void ConfigureXmlOutput()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5076
testing::internal::HasGoogleTestFlagPrefix
static bool HasGoogleTestFlagPrefix(const char *str)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5829
testing::internal::ReportInvalidTestSuiteType
GTEST_API_ void ReportInvalidTestSuiteType(const char *test_suite_name, CodeLocation code_location)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2599
FAILED
@ FAILED
Definition: alts_tsi_handshaker_test.cc:85
setup.name
name
Definition: setup.py:542
words
std::vector< std::string > words
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field_unittest.cc:1787
testing::internal::XmlUnitTestResultPrinter::PrintXmlTestSuite
static void PrintXmlTestSuite(::std::ostream *stream, const TestSuite &test_suite)
testing::internal::AssertHelper::AssertHelper
AssertHelper(TestPartResult::Type type, const char *file, int line, const char *message)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:391
testing::internal::String::FormatHexInt
static std::string FormatHexInt(int value)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1985
testing::TestPartResultArray
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18351
check_documentation.path
path
Definition: check_documentation.py:57
testing::internal::TestEventRepeater::Release
TestEventListener * Release(TestEventListener *listener)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3445
hunk_adds_
std::list< std::pair< char, const char * > > hunk_adds_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:1337
grpc_core::ForEach
for_each_detail::ForEach< Reader, Action > ForEach(Reader reader, Action action)
For each item acquired by calling Reader::Next, run the promise Action.
Definition: for_each.h:133
testing::internal::Random::state_
UInt32 state_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:846
testing::TestInfo::Run
void Run()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2663
testing::internal::edit_distance::EditType
EditType
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:156
testing::UnitTest::successful_test_suite_count
int successful_test_suite_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4631
testing::internal::edit_distance::kReplace
@ kReplace
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:156
testing::internal::GetAnsiColorCode
static const char * GetAnsiColorCode(GTestColor color)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2983
testing::internal::CodeLocation::line
int line
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:485
testing::TestSuite::UnshuffleTests
void UnshuffleTests()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2852
xds_manager.p
p
Definition: xds_manager.py:60
detail
Definition: test_winkernel.cpp:39
python_utils.upload_rbe_results.indent
indent
Definition: upload_rbe_results.py:183
testing::TestEventListeners::SetDefaultResultPrinter
void SetDefaultResultPrinter(TestEventListener *listener)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4572
testing::UnitTest::failed_test_suite_count
int failed_test_suite_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4636
testing::internal::TestEventRepeater::OnEnvironmentsTearDownStart
void OnEnvironmentsTearDownStart(const UnitTest &unit_test) override
testing::internal::UnitTestImpl::os_stack_trace_getter_
OsStackTraceGetterInterface * os_stack_trace_getter_
Definition: gmock-gtest-all.cc:1297
testing::internal::String::CStringEquals
static bool CStringEquals(const char *lhs, const char *rhs)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:918
GTEST_FLAG_SAVER_
#define GTEST_FLAG_SAVER_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2177
testing::internal::GetCurrentOsStackTraceExceptTop
GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(UnitTest *unit_test, int skip_count)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5697
testing::Test::HasFatalFailure
static bool HasFatalFailure()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2527
testing::TestInfo::type_param
const char * type_param() const
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:714
grpc::testing::test_result
test_result
Definition: h2_ssl_cert_test.cc:201
second
StrT second
Definition: cxa_demangle.cpp:4885
env.new
def new
Definition: env.py:51
testing::internal::ScopedPrematureExitFile
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4500
testing::internal::GetElementOr
E GetElementOr(const std::vector< E > &v, int i, E default_value)
Definition: gmock-gtest-all.cc:710
testing::internal::UnitTestImpl::FilterTests
int FilterTests(ReactionToSharding shard_tests)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5496
testing::kTestTotalShards
static const char kTestTotalShards[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:170
testing::internal::XmlUnitTestResultPrinter::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter)
iterator
const typedef MCPhysReg * iterator
Definition: MCRegisterInfo.h:27
testing::internal::XmlUnitTestResultPrinter
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3521
testing::internal::GetIgnoredParameterizedTestSuites
std::set< std::string > * GetIgnoredParameterizedTestSuites()
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:458
testing::TestPartNonfatallyFailed
static bool TestPartNonfatallyFailed(const TestPartResult &result)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2226
testing::FormatCountableNoun
static std::string FormatCountableNoun(int count, const char *singular_form, const char *plural_form)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2863
testing::internal::String
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-string.h:58
testing::TestInfo::ClearTestResult
static void ClearTestResult(TestInfo *test_info)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:797
testing::TestPartResultReporterInterface::ReportTestPartResult
virtual void ReportTestPartResult(const TestPartResult &result)=0
testing::RegisterTest
TestInfo * RegisterTest(const char *test_suite_name, const char *test_name, const char *type_param, const char *value_param, const char *file, int line, Factory factory)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2437
testing::GetReservedAttributesForElement
static std::vector< std::string > GetReservedAttributesForElement(const std::string &xml_element)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2122
message
char * message
Definition: libuv/docs/code/tty-gravity/main.c:12
T
#define T(upbtypeconst, upbtype, ctype, default_value)
testing::internal::DoubleNearPredFormat
GTEST_API_ AssertionResult DoubleNearPredFormat(const char *expr1, const char *expr2, const char *abs_error_expr, double val1, double val2, double abs_error)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1377
testing::Message
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-message.h:90
testing::TestPartResult::Type
Type
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18276
failures
std::atomic< uint64_t > failures
Definition: outlier_detection.cc:233
testing::ScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter
virtual ~ScopedFakeTestPartResultReporter()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:621
true
#define true
Definition: setup_once.h:324
testing::internal::String::CaseInsensitiveCStringEquals
static bool CaseInsensitiveCStringEquals(const char *lhs, const char *rhs)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1919
testing::TestResult::GetTestPartResult
const TestPartResult & GetTestPartResult(int i) const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2044
testing::internal::ColoredPrintf
void ColoredPrintf(GTestColor color, const char *fmt,...)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3036
testing::internal::kMaxCodePoint3
const UInt32 kMaxCodePoint3
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1750
testing::TestSuite::disabled_test_count
int disabled_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2734
testing::internal::ReadEntireFile
GTEST_API_ std::string ReadEntireFile(FILE *file)
Definition: bloaty/third_party/googletest/googletest/src/gtest-port.cc:1216
testing::internal::PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart
void OnEnvironmentsTearDownStart(const UnitTest &unit_test) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3287
testing::internal::TestEventRepeater::Append
void Append(TestEventListener *listener)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3441
testing::UnitTest::PushGTestTrace
void PushGTestTrace(const internal::TraceInfo &trace) GTEST_LOCK_EXCLUDED_(mutex_)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4989
testing::internal::CmpHelperSTRCASEEQ
GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1516
testing::internal::ShouldUseColor
bool ShouldUseColor(bool stdout_is_tty)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2996
testing::internal::ShouldShard
bool ShouldShard(const char *total_shards_env, const char *shard_index_env, bool in_subprocess_for_death_test)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5422
GTEST_FLAG_PREFIX_
#define GTEST_FLAG_PREFIX_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:277
testing::internal::BriefUnitTestResultPrinter::OnTestEnd
void OnTestEnd(const TestInfo &test_info) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3694
GTEST_LOG_
#define GTEST_LOG_(severity)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:975
make_dist_html.reverse
reverse
Definition: make_dist_html.py:119
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
testing::internal::PrettyUnitTestResultPrinter::OnTestIterationStart
void OnTestIterationStart(const UnitTest &unit_test, int iteration) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3147
testing::internal::XmlUnitTestResultPrinter::IsNormalizableWhitespace
static bool IsNormalizableWhitespace(char c)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3890
testing::UnitTest::GetMutableTestSuite
TestSuite * GetMutableTestSuite(int i)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4740
error_message_
const std::string error_message_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:451
change-comments.lines
lines
Definition: change-comments.py:32
hunk_
std::list< std::pair< char, const char * > > hunk_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:1337
testing::internal::StreamableToString
std::string StreamableToString(const T &streamable)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-message.h:209
testing::TestResult::ValidateTestProperty
static bool ValidateTestProperty(const std::string &xml_element, const TestProperty &test_property)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2182
testing::internal::UnitTestImpl::CurrentOsStackTraceExceptTop
std::string CurrentOsStackTraceExceptTop(int skip_count) GTEST_NO_INLINE_
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:826
testing::internal::UnitTestImpl::IGNORE_SHARDING_PROTOCOL
@ IGNORE_SHARDING_PROTOCOL
Definition: gmock-gtest-all.cc:1126
ULL
#define ULL(x)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:57
testing::Test::IsSkipped
static bool IsSkipped()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2538
testing::TestResult::ClearTestPartResults
void ClearTestPartResults()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2060
testing::TestPartResult::line_number
int line_number() const
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18307
name_
std::string name_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:2809
testing::internal::ParseInt32
bool ParseInt32(const Message &src_text, const char *str, Int32 *value)
Definition: bloaty/third_party/googletest/googletest/src/gtest-port.cc:1292
testing::internal::FormatTimeInMillisAsDuration
static std::string FormatTimeInMillisAsDuration(TimeInMillis ms)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:4475
testing::internal::TestEventRepeater::OnTestProgramStart
void OnTestProgramStart(const UnitTest &unit_test) override
testing::GetDefaultFilter
static const char * GetDefaultFilter()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:203
start
static uint64_t start
Definition: benchmark-pound.c:74
absl::FormatConversionChar::e
@ e
testing::internal::TestEventRepeater::OnEnvironmentsSetUpStart
void OnEnvironmentsSetUpStart(const UnitTest &unit_test) override
testing::internal::XmlUnitTestResultPrinter::OnTestIterationEnd
void OnTestIterationEnd(const UnitTest &unit_test, int iteration) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3612
removes_
size_t removes_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:1336
testing::UnitTest::reportable_test_count
int reportable_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4691
testing::internal::TestEventRepeater::OnTestCaseEnd
void OnTestCaseEnd(const TestCase &parameter) override
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
testing::internal::PrettyUnitTestResultPrinter::OnTestCaseEnd
void OnTestCaseEnd(const TestCase &test_case) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3264
testing::internal::GetArgvs
GTEST_API_ std::vector< std::string > GetArgvs()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:416
testing::internal::UnitTestImpl::GetTestPartResultReporterForCurrentThread
TestPartResultReporterInterface * GetTestPartResultReporterForCurrentThread()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:744
testing::internal::String::FormatHexUInt32
static std::string FormatHexUInt32(UInt32 value)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1978
testing::TestCase
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:19377
errors
const char * errors
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer_unittest.cc:841
GTEST_PATH_SEP_
#define GTEST_PATH_SEP_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:1905
testing::internal::PrettyUnitTestResultPrinter::OnTestProgramStart
void OnTestProgramStart(const UnitTest &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3353
testing::internal::CodeLocation
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:480
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
testing::TestSuite::start_timestamp_
TimeInMillis start_timestamp_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1020
testing::internal::UnitTestOptions::GetAbsolutePathToOutputFile
static std::string GetAbsolutePathToOutputFile()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:455
testing::internal::FloatingPointLE
AssertionResult FloatingPointLE(const char *expr1, const char *expr2, RawType val1, RawType val2)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1397
array
Definition: undname.c:101
testing::UnitTest::skipped_test_count
int skipped_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4673
testing::kDeathTestSuiteFilter
static const char kDeathTestSuiteFilter[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:157
testing::internal::kTestTypeIdInGoogleTest
const TypeId kTestTypeIdInGoogleTest
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/src/gtest.cc:653
testing::internal::BriefUnitTestResultPrinter::OnTestCaseEnd
void OnTestCaseEnd(const TestCase &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3668
testing::TestResult::Skipped
bool Skipped() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2202
testing::UnitTest::Run
int Run() GTEST_MUST_USE_RESULT_
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4853
re2::Result
TestInstance::Result Result
Definition: bloaty/third_party/re2/re2/testing/tester.cc:96
versiongenerate.output_dir
output_dir
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/xcode/Scripts/versiongenerate.py:61
gen_stats_data.c_str
def c_str(s, encoding='ascii')
Definition: gen_stats_data.py:38
testing::internal::UnitTestImpl::random
internal::Random * random()
Definition: gmock-gtest-all.cc:1199
testing::kTestShardStatusFile
static const char kTestShardStatusFile[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:172
testing::internal::FormatTimeInMillisAsSeconds
std::string FormatTimeInMillisAsSeconds(TimeInMillis ms)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3715
testing::internal::UnitTestImpl::post_flag_parse_init_performed_
bool post_flag_parse_init_performed_
Definition: gmock-gtest-all.cc:1300
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
testing::internal::PrettyUnitTestResultPrinter::OnEnvironmentsTearDownEnd
void OnEnvironmentsTearDownEnd(const UnitTest &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3374
testing::internal::RegisterTypeParameterizedTestSuiteInstantiation
void RegisterTypeParameterizedTestSuiteInstantiation(const char *case_name)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:518
impl_
std::shared_ptr< ExternalConnectionAcceptorImpl > impl_
Definition: external_connection_acceptor_impl.cc:43
testing::TestSuite::total_test_count
int total_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2749
testing::internal::TestEventRepeater::OnTestEnd
void OnTestEnd(const TestInfo &test_info) override
testing::TestResult::HasNonfatalFailure
bool HasNonfatalFailure() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2231
tests._result.summary
def summary(result)
Definition: _result.py:346
testing::internal::SkipPrefix
GTEST_API_ bool SkipPrefix(const char *prefix, const char **pstr)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5725
testing::internal::UnitTestOptions::GetOutputFormat
static std::string GetOutputFormat()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:444
testing::internal::BriefUnitTestResultPrinter::OnEnvironmentsSetUpStart
void OnEnvironmentsSetUpStart(const UnitTest &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3655
testing::TestSuite::AddTestInfo
void AddTestInfo(TestInfo *test_info)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2795
testing::internal::XmlUnitTestResultPrinter::OutputXmlTestInfo
static void OutputXmlTestInfo(::std::ostream *stream, const char *test_suite_name, const TestInfo &test_info)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3788
testing::internal::CodePointToUtf8
std::string CodePointToUtf8(UInt32 code_point)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1770
testing::internal::Random::kMaxRange
static const UInt32 kMaxRange
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:835
benchmarks.python.py_benchmark.results
list results
Definition: bloaty/third_party/protobuf/benchmarks/python/py_benchmark.py:145
result_type
const typedef int * result_type
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:4325
testing::internal::BriefUnitTestResultPrinter::BriefUnitTestResultPrinter
BriefUnitTestResultPrinter()
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3646
testing::internal::posix::FileNo
int FileNo(FILE *file)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2006
testing::internal::JsonUnitTestResultPrinter::PrintJsonTestSuite
static void PrintJsonTestSuite(::std::ostream *stream, const TestSuite &test_suite)
testing::internal::XmlUnitTestResultPrinter::XmlUnitTestResultPrinter
XmlUnitTestResultPrinter(const char *output_file)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3604
testing::UnitTest::current_test_suite
const TestSuite * current_test_suite() const GTEST_LOCK_EXCLUDED_(mutex_)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4944
testing::internal::UnitTestImpl::Passed
bool Passed() const
Definition: gmock-gtest-all.cc:974
grpc::testing::val2
const char val2[]
Definition: client_context_test_peer_test.cc:35
testing::internal::UnitTestImpl::current_test_suite_
TestSuite * current_test_suite_
Definition: googletest/googletest/src/gtest-internal-inl.h:892
testing::internal::ParseFlagValue
static const char * ParseFlagValue(const char *str, const char *flag, bool def_optional)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5739
testing::internal::PrettyUnitTestResultPrinter::PrintFailedTests
static void PrintFailedTests(const UnitTest &unit_test)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3295
testing::internal::UnitTestImpl::Failed
bool Failed() const
Definition: gmock-gtest-all.cc:978
testing::internal::posix::Abort
void Abort()
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2076
testing::internal::PrettyUnitTestResultPrinter::PrintSkippedTests
static void PrintSkippedTests(const UnitTest &unit_test)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3320
testing::internal::UnitTestImpl::random_seed
int random_seed() const
Definition: gmock-gtest-all.cc:1196
testing::TestSuite::ad_hoc_test_result_
TestResult ad_hoc_test_result_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1025
testing::internal::UnitTestImpl::elapsed_time_
TimeInMillis elapsed_time_
Definition: gmock-gtest-all.cc:1313
absl::InstallFailureSignalHandler
void InstallFailureSignalHandler(const FailureSignalHandlerOptions &options)
Definition: abseil-cpp/absl/debugging/failure_signal_handler.cc:378
testing::internal::posix::FOpen
FILE * FOpen(const char *path, const char *mode)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2033
testing::internal::kValueParamLabel
static const char kValueParamLabel[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3087
testing::TestSuite::test_to_run_count
int test_to_run_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2744
bits
OPENSSL_EXPORT ASN1_BIT_STRING * bits
Definition: x509v3.h:482
testing::internal::LoadFlagsFromFile
void LoadFlagsFromFile(const std::string &path)
Definition: gmock-gtest-all.cc:6701
testing::Environment
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1045
testing::UnitTest::UnitTest
UnitTest()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4978
testing::internal::XmlUnitTestResultPrinter::EscapeXmlText
static std::string EscapeXmlText(const char *str)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3914
testing::internal::MutexLock
GTestMutexLock MutexLock
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:1875
testing::internal::IsSpace
bool IsSpace(char ch)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:1929
testing::internal::TestEventRepeater::forwarding_enabled_
bool forwarding_enabled_
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3430
test_count
int test_count
Definition: bloaty/third_party/protobuf/conformance/conformance_cpp.cc:69
testing::AssertionResult
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18855
testing::TestEventListeners::SetDefaultXmlGenerator
void SetDefaultXmlGenerator(TestEventListener *listener)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4587
testing::AssertionResult::AssertionResult
AssertionResult(const AssertionResult &other)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1002
testing::internal::PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart
void OnEnvironmentsSetUpStart(const UnitTest &unit_test) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3182
testing::internal::FilePath::GenerateUniqueFileName
static FilePath GenerateUniqueFileName(const FilePath &directory, const FilePath &base_name, const char *extension)
Definition: bloaty/third_party/googletest/googletest/src/gtest-filepath.cc:279
bm_diff.diff
diff
Definition: bm_diff.py:274
testing::TestEventListeners::EventForwardingEnabled
bool EventForwardingEnabled() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4599
arg
Definition: cmdline.cc:40
testing::internal::GTestIsInitialized
static bool GTestIsInitialized()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:360
testing::ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter
ScopedFakeTestPartResultReporter(TestPartResultArray *result)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:591
testing::internal::WideStringToUtf8
std::string WideStringToUtf8(const wchar_t *str, int num_chars)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1837
testing::internal::AlwaysTrue
GTEST_API_ bool AlwaysTrue()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5712
testing::internal::kBreakOnFailureFlag
const char kBreakOnFailureFlag[]
Definition: gmock-gtest-all.cc:497
testing::UnitTest::GetTestCase
const TestCase * GetTestCase(int i) const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4727
testing::Message::ss_
const std::unique_ptr< ::std::stringstream > ss_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-message.h:190
std::swap
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
Definition: third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h:1226
testing::internal::GTEST_DISABLE_MSC_WARNINGS_POP_
GTEST_DISABLE_MSC_WARNINGS_POP_() inline const char *SkipComma(const char *str)
Definition: googletest/googletest/include/gtest/internal/gtest-internal.h:650
testing::internal::posix::IsATTY
int IsATTY(int fd)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2007
close
#define close
Definition: test-fs.c:48
testing::TimeInMillis
internal::TimeInMillis TimeInMillis
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:519
testing::UnitTest::test_suite_to_run_count
int test_suite_to_run_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4647
negative
static uint8_t negative(signed char b)
Definition: curve25519.c:786
testing::internal::wstring
::std::wstring wstring
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:887
testing::internal::AlwaysFalse
bool AlwaysFalse()
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:817
testing::internal::SumOverTestSuiteList
static int SumOverTestSuiteList(const std::vector< TestSuite * > &case_list, int(TestSuite::*method)() const)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:365
testing::TestSuite::successful_test_count
int successful_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2714
GTEST_LOCK_EXCLUDED_
#define GTEST_LOCK_EXCLUDED_(locks)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2199
testing::internal::FilePath::MakeFileName
static FilePath MakeFileName(const FilePath &directory, const FilePath &base_name, int number, const char *extension)
Definition: bloaty/third_party/googletest/googletest/src/gtest-filepath.cc:179
testing::AssertionSuccess
AssertionResult AssertionSuccess()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1023
testing::TestPartResult::kNonFatalFailure
@ kNonFatalFailure
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18278
testing::internal::TypeParameterizedTestSuiteRegistry::RegisterInstantiation
void RegisterInstantiation(const char *test_suite_name)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:530
testing::kDefaultOutputFile
static const char kDefaultOutputFile[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:165
testing::internal::TestEventRepeater::OnEnvironmentsTearDownEnd
void OnEnvironmentsTearDownEnd(const UnitTest &unit_test) override
testing::internal::Int32FromEnvOrDie
Int32 Int32FromEnvOrDie(const char *var, Int32 default_val)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5467
testing::internal::posix::StrCaseCmp
int StrCaseCmp(const char *s1, const char *s2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2009
testing::internal::UnitTestImpl::ignored_parameterized_test_suites
std::set< std::string > * ignored_parameterized_test_suites()
Definition: googletest/googletest/src/gtest-internal-inl.h:688
google::protobuf::WARNING
static const LogLevel WARNING
Definition: bloaty/third_party/protobuf/src/google/protobuf/testing/googletest.h:71
google::protobuf.internal::StringType
StringType
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.h:53
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
testing::internal::kRandomSeedFlag
const char kRandomSeedFlag[]
Definition: gmock-gtest-all.cc:504
testing::internal::XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters
static std::string RemoveInvalidXmlCharacters(const std::string &str)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3686
testing::internal::PrettyUnitTestResultPrinter::OnTestCaseStart
void OnTestCaseStart(const TestCase &test_case) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3190
testing::internal::BriefUnitTestResultPrinter
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3644
testing::internal::XmlUnitTestResultPrinter::OutputXmlTestProperties
static void OutputXmlTestProperties(std::ostream *stream, const TestResult &result)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3964
TestCase
Definition: benchmark/test/output_test.h:31
testing::internal::CmpHelperSTRNE
GTEST_API_ AssertionResult CmpHelperSTRNE(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1532
testing::internal::kMaxCodePoint1
const UInt32 kMaxCodePoint1
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1744
testing::TestSuite::reportable_test_count
int reportable_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2739
absl::ABSL_NAMESPACE_BEGIN::custom
std::atomic< Unwinder > custom
Definition: abseil-cpp/absl/debugging/stacktrace.cc:66
testing::internal::UnitTestImpl::test_suites_
std::vector< TestSuite * > test_suites_
Definition: googletest/googletest/src/gtest-internal-inl.h:864
addrinfo::ai_family
int ai_family
Definition: ares_ipv6.h:46
TestSuite
Definition: cavp_main.cc:32
testing::internal::ScopedPrematureExitFile::~ScopedPrematureExitFile
~ScopedPrematureExitFile()
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:4890
testing::TestSuite::failed_test_count
int failed_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2724
min
#define min(a, b)
Definition: qsort.h:83
testing::internal::TestEventRepeater::~TestEventRepeater
~TestEventRepeater() override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3437
testing::TestPartResult::message
const char * message() const
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18313
testing::TestSuite::test_info_list_
std::vector< TestInfo * > test_info_list_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1008
testing::TestSuite::skipped_test_count
int skipped_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2719
ADD_FAILURE
#define ADD_FAILURE()
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1911
testing::UnitTest::total_test_count
int total_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4696
testing::ValidateTestPropertyName
static bool ValidateTestPropertyName(const std::string &property_name, const std::vector< std::string > &reserved_names)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2167
testing::TestInfo::result
const TestResult * result() const
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:761
testing::internal::GetCurrentExecutableName
FilePath GetCurrentExecutableName()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:429
testing::internal::UnitTestImpl::UnitTestImpl
UnitTestImpl(UnitTest *parent)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5004
testing::internal::TestEventRepeater::OnEnvironmentsSetUpEnd
void OnEnvironmentsSetUpEnd(const UnitTest &unit_test) override
testing::TestEventListeners::~TestEventListeners
~TestEventListeners()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4542
testing::Message::GetString
std::string GetString() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:996
testing::kReservedTestSuitesAttributes
static const char *const kReservedTestSuitesAttributes[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2090
testing::internal::GetTestTypeId
GTEST_API_ TypeId GetTestTypeId()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:648
testing::internal::GetTimeInMillis
TimeInMillis GetTimeInMillis()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:836
testing::internal::JsonUnitTestResultPrinter::PrintJsonUnitTest
static void PrintJsonUnitTest(::std::ostream *stream, const UnitTest &unit_test)
testing::TestEventListeners::SuppressEventForwarding
void SuppressEventForwarding()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4603
testing::internal::PrintOnOneLine
static void PrintOnOneLine(const char *str, int max_length)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5551
testing::TestResult::test_property_count
int test_property_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2242
testing::GTEST_DEFINE_int32_
GTEST_DEFINE_int32_(random_seed, internal::Int32FromGTestEnv("random_seed", 0), "Random number seed to use when shuffling test orders. Must be in range " "[1, 99999], or 0 to use a seed based on the current time.")
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
tests.qps.qps_worker.dest
dest
Definition: qps_worker.py:45
testing::TestSuite::GetMutableTestInfo
TestInfo * GetMutableTestInfo(int i)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2788
testing::kReservedTestCaseAttributes
static const char *const kReservedTestCaseAttributes[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2107
testing::internal::FormatEpochTimeInMillisAsRFC3339
static std::string FormatEpochTimeInMillisAsRFC3339(TimeInMillis ms)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:4483
common_
size_t common_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:1336
google::protobuf::ERROR
static const LogLevel ERROR
Definition: bloaty/third_party/protobuf/src/google/protobuf/testing/googletest.h:70
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
testing::internal::UnitTestImpl::parent_
UnitTest *const parent_
Definition: gmock-gtest-all.cc:1220
GTEST_NAME_
#define GTEST_NAME_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:280
testing::internal::PrintColorEncoded
static void PrintColorEncoded(const char *str)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5847
testing::GetDefaultFailFast
static bool GetDefaultFailFast()
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:210
testing::internal::TestEventRepeater::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater)
testing::internal::XmlUnitTestResultPrinter::IsValidXmlCharacter
static bool IsValidXmlCharacter(char c)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3895
testing::UnitTest::total_test_case_count
int total_test_case_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4659
testing::internal::CreateCodePointFromUtf16SurrogatePair
UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first, wchar_t second)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1811
testing::internal::kRepeatFlag
const char kRepeatFlag[]
Definition: gmock-gtest-all.cc:505
testing::internal::UnitTestImpl::RegisterParameterizedTests
void RegisterParameterizedTests()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2652
google_benchmark.example.empty
def empty(state)
Definition: example.py:31
testing::internal::ParseGoogleTestFlagsOnly
void ParseGoogleTestFlagsOnly(int *argc, char **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6053
testing::TestPartFatallyFailed
static bool TestPartFatallyFailed(const TestPartResult &result)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2216
add
static void add(const char *beg, const char *end, char ***ss, size_t *ns)
Definition: debug/trace.cc:96
testing::internal::UnitTestImpl::current_test_info_
TestInfo * current_test_info_
Definition: gmock-gtest-all.cc:1277
GTEST_DISALLOW_COPY_AND_ASSIGN_
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:683
testing::internal::TestEventRepeater::OnTestSuiteEnd
void OnTestSuiteEnd(const TestSuite &parameter) override
testing::internal::GTEST_DISABLE_MSC_WARNINGS_PUSH_
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251) class GTEST_API_ TypedTestSuitePState
Definition: googletest/googletest/include/gtest/internal/gtest-internal.h:595
testing::TestSuite::Run
void Run()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2801
absl::synchronization_internal::IdMap
std::map< int, GraphId > IdMap
Definition: abseil-cpp/absl/synchronization/internal/graphcycles_test.cc:43
tm
static uv_timer_t tm
Definition: test-tcp-open.c:41
testing::internal::posix::GetEnv
const char * GetEnv(const char *name)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2053
testing::internal::String::FormatIntWidthN
static std::string FormatIntWidthN(int value, int width)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:2134
value
const char * value
Definition: hpack_parser_table.cc:165
testing::internal::kDeathTestStyleFlag
const char kDeathTestStyleFlag[]
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h:51
absl::Symbolize
bool Symbolize(const void *pc, char *out, int out_size)
testing::internal::BriefUnitTestResultPrinter::OnEnvironmentsTearDownEnd
void OnEnvironmentsTearDownEnd(const UnitTest &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3674
testing::internal::UnitTestImpl::type_parameterized_test_registry
internal::TypeParameterizedTestSuiteRegistry & type_parameterized_test_registry()
Definition: googletest/googletest/src/gtest-internal-inl.h:695
testing::internal::UnitTestImpl
Definition: gmock-gtest-all.cc:906
absl::Skip
static PerThreadSynch * Skip(PerThreadSynch *x)
Definition: abseil-cpp/absl/synchronization/mutex.cc:837
testing::internal::PrettyUnitTestResultPrinter::PrintFailedTestSuites
static void PrintFailedTestSuites(const UnitTest &unit_test)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3557
testing::UnitTest::AddTestPartResult
void AddTestPartResult(TestPartResult::Type result_type, const char *file_name, int line_number, const std::string &message, const std::string &os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4773
GTEST_INIT_GOOGLE_TEST_NAME_
#define GTEST_INIT_GOOGLE_TEST_NAME_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:285
FATAL
#define FATAL(msg)
Definition: task.h:88
testing::internal::MakeAndRegisterTestInfo
GTEST_API_ TestInfo * MakeAndRegisterTestInfo(const char *test_suite_name, const char *name, const char *type_param, const char *value_param, CodeLocation code_location, TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc, TearDownTestSuiteFunc tear_down_tc, TestFactoryBase *factory)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2587
testing::TestResult::GetTestProperty
const TestProperty & GetTestProperty(int i) const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2053
testing::internal::GTEST_IMPL_CMP_HELPER_
GTEST_IMPL_CMP_HELPER_(NE, !=)
GTEST_FLAG
#define GTEST_FLAG(name)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2169
testing::internal::AppendUserMessage
GTEST_API_ std::string AppendUserMessage(const std::string &gtest_msg, const Message &user_msg)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2018
testing::internal::fmt
GTEST_API_ const char * fmt
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1808
testing::internal::BiggestInt
long long BiggestInt
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:1907
testing::internal::TestEventRepeater::TestEventRepeater
TestEventRepeater()
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3750
testing::internal::PrettyUnitTestResultPrinter::PrettyUnitTestResultPrinter
PrettyUnitTestResultPrinter()
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3347
addrinfo::ai_next
struct addrinfo * ai_next
Definition: ares_ipv6.h:52
testing::internal::TestEventRepeater::OnTestPartResult
void OnTestPartResult(const TestPartResult &result) override
contents
string_view contents
Definition: elf.cc:597
testing::kMaxStackTraceDepth
const int kMaxStackTraceDepth
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18746
testing::internal::JsonUnitTestResultPrinter::OutputJsonKey
static void OutputJsonKey(std::ostream *stream, const std::string &element_name, const std::string &name, const std::string &value, const std::string &indent, bool comma=true)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4126
testing::TestInfo::value_param
const char * value_param() const
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:721
testing::InitGoogleTest
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6106
testing::internal::ParseGoogleTestFlagsOnlyImpl
void ParseGoogleTestFlagsOnlyImpl(int *argc, CharType **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6000
testing::TestResult::elapsed_time
TimeInMillis elapsed_time() const
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:593
testing::internal::EqFailure
GTEST_API_ AssertionResult EqFailure(const char *expected_expression, const char *actual_expression, const std::string &expected_value, const std::string &actual_value, bool ignoring_case)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1326
testing::internal::kMaxCodePoint4
const UInt32 kMaxCodePoint4
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1753
testing::internal::BriefUnitTestResultPrinter::OnTestIterationEnd
void OnTestIterationEnd(const UnitTest &unit_test, int iteration) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3711
testing::UnitTest::original_working_dir
const char * original_working_dir() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4938
testing::TestEventListener::OnTestCaseStart
virtual void OnTestCaseStart(const TestCase &)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1100
GTEST_CHECK_
#define GTEST_CHECK_(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:999
key
const char * key
Definition: hpack_parser_table.cc:164
testing::internal::UnitTestImpl::GetMutableSuiteCase
TestSuite * GetMutableSuiteCase(int i)
Definition: googletest/googletest/src/gtest-internal-inl.h:589
benchmark.FILE
FILE
Definition: benchmark.py:21
testing::internal::XmlUnitTestResultPrinter::OutputXmlAttribute
static void OutputXmlAttribute(std::ostream *stream, const std::string &element_name, const std::string &name, const std::string &value)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3771
testing::UnitTest::GetTestSuite
const TestSuite * GetTestSuite(int i) const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4721
testing::TestInfo::result_
TestResult result_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:822
testing::TestResult::TestResult
TestResult()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2034
reserved_names
static HashTable * reserved_names
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.c:52
testing::internal::TestEventRepeater::OnTestProgramEnd
void OnTestProgramEnd(const UnitTest &unit_test) override
suffix
unsigned char suffix[65536]
Definition: bloaty/third_party/zlib/examples/gun.c:164
testing::internal::kFilterFlag
const char kFilterFlag[]
Definition: gmock-gtest-all.cc:500
testing::TestInfo::name
const char * name() const
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:710
testing::internal::Shuffle
void Shuffle(internal::Random *random, std::vector< E > *v)
Definition: gmock-gtest-all.cc:740
testing::internal::BriefUnitTestResultPrinter::OnTestIterationStart
void OnTestIterationStart(const UnitTest &, int) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3653
testing::internal::FilePath
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:4324
testing::internal::UnitTestOptions::FilterMatchesTest
static bool FilterMatchesTest(const std::string &test_case_name, const std::string &test_name)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:530
testing::internal::GetBoolAssertionFailureMessage
GTEST_API_ std::string GetBoolAssertionFailureMessage(const AssertionResult &assertion_result, const char *expression_text, const char *actual_predicate_value, const char *expected_predicate_value)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1361
testing::TestResult::~TestResult
~TestResult()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2038
testing::internal::kMaxCodePoint2
const UInt32 kMaxCodePoint2
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1747
testing::internal::JsonUnitTestResultPrinter::TestPropertiesAsJson
static std::string TestPropertiesAsJson(const TestResult &result, const std::string &indent)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4348
testing::internal::UnitTestImpl::test_suite_indices_
std::vector< int > test_suite_indices_
Definition: googletest/googletest/src/gtest-internal-inl.h:870
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
testing::kDefaultOutputFormat
static const char kDefaultOutputFormat[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:163
testing::internal::TestEventRepeater::listeners_
std::vector< TestEventListener * > listeners_
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3432
testing::internal::g_argvs
static ::std::vector< std::string > g_argvs
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:414
testing::internal::TestSuiteNameIs::TestSuiteNameIs
TestSuiteNameIs(const std::string &name)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:5543
testing::internal::BoolFromGTestEnv
bool BoolFromGTestEnv(const char *flag, bool default_val)
Definition: bloaty/third_party/googletest/googletest/src/gtest-port.cc:1334
testing::internal::PrettyUnitTestResultPrinter::PrintTestName
static void PrintTestName(const char *test_suite, const char *test)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3348
testing::internal::TestEventRepeater
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3393
testing::internal::PrintTestPartResult
static void PrintTestPartResult(const TestPartResult &test_part_result)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2916
testing::internal::UnitTestImpl::random_seed_
int random_seed_
Definition: gmock-gtest-all.cc:1303
grpc::fclose
fclose(creds_file)
testing::internal::edit_distance::kMatch
@ kMatch
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:156
testing::UnitTest
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1257
testing::UnitTest::AddEnvironment
Environment * AddEnvironment(Environment *env)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4760
testing::kTestShardIndex
static const char kTestShardIndex[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:168
testing::ScopedTrace::~ScopedTrace
~ScopedTrace()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6176
testing::internal::ShuffleRange
void ShuffleRange(internal::Random *random, int begin, int end, std::vector< E > *v)
Definition: gmock-gtest-all.cc:719
testing::TestPartSkipped
static bool TestPartSkipped(const TestPartResult &result)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2197
testing::FormatWordList
static std::string FormatWordList(const std::vector< std::string > &words)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2153
testing::internal::XmlUnitTestResultPrinter::EscapeXml
static std::string EscapeXml(const std::string &str, bool is_attribute)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3640
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
testing::internal::kStackTraceDepthFlag
const char kStackTraceDepthFlag[]
Definition: gmock-gtest-all.cc:507
testing::GTEST_DEFINE_string_
GTEST_DEFINE_string_(death_test_style, internal::StringFromGTestEnv("death_test_style", kDefaultDeathTestStyle), "Indicates how to run a death test in a forked child process: " "\"threadsafe\" (child process re-executes the test binary " "from the beginning, running only the specific death test) or " "\"fast\" (child process runs the death test immediately " "after forking).")
testing::internal::kColorEncodedHelpMessage
static const char kColorEncodedHelpMessage[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5881
testing::internal::UnitTestImpl::ListTestsMatchingFilter
void ListTestsMatchingFilter()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5570
ids_
IdMap ids_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:1245
testing::internal::JsonUnitTestResultPrinter::JsonUnitTestResultPrinter
JsonUnitTestResultPrinter(const char *output_file)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4041
testing::internal::ForEach
void ForEach(const Container &c, Functor functor)
Definition: gmock-gtest-all.cc:703
testing::Message::operator<<
Message & operator<<(const T &val)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-message.h:112
testing::internal::SetUpTestSuiteFunc
void(*)() SetUpTestSuiteFunc
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:477
testing::internal::String::CaseInsensitiveWideCStringEquals
static bool CaseInsensitiveWideCStringEquals(const wchar_t *lhs, const wchar_t *rhs)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1937
testing::internal::Random::Reseed
void Reseed(UInt32 seed)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:839
fix_build_deps.r
r
Definition: fix_build_deps.py:491
testing::TestEventListeners::repeater
TestEventListener * repeater()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4565
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
first
StrT first
Definition: cxa_demangle.cpp:4884
env
Definition: env.py:1
testing::internal::PatternMatchesString
static bool PatternMatchesString(const std::string &name_str, const char *pattern, const char *pattern_end)
Definition: googletest/googletest/src/gtest.cc:682
testing::internal::OpenFileForWriting
static FILE * OpenFileForWriting(const std::string &output_file)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:185
testing::internal::kShuffleFlag
const char kShuffleFlag[]
Definition: gmock-gtest-all.cc:506
testing::internal::kDefault
@ kDefault
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:9543
absl::InitializeSymbolizer
ABSL_NAMESPACE_BEGIN void InitializeSymbolizer(const char *argv0)
testing::IsSubstring
GTEST_API_ AssertionResult IsSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1617
testing::kReservedOutputTestCaseAttributes
static const char *const kReservedOutputTestCaseAttributes[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2113
testing::internal::UnitTestImpl::set_current_test_info
void set_current_test_info(TestInfo *a_current_test_info)
Definition: gmock-gtest-all.cc:1090
addrinfo::ai_socktype
int ai_socktype
Definition: ares_ipv6.h:47
testing::kUniversalFilter
static const char kUniversalFilter[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:160
testing::internal::StringStreamToString
GTEST_API_ std::string StringStreamToString(::std::stringstream *stream)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1999
testing::TestSuite::RunTearDownTestSuite
void RunTearDownTestSuite()
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:953
prefix
static const char prefix[]
Definition: head_of_line_blocking.cc:28
testing::internal::InitGoogleTestImpl
void InitGoogleTestImpl(int *argc, CharType **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6076
testing::TestEventListeners::Release
TestEventListener * Release(TestEventListener *listener)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4555
regen-readme.line
line
Definition: regen-readme.py:30
testing::FormatTestCount
static std::string FormatTestCount(int test_count)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2871
testing::internal::UnitTestImpl::environments_
std::vector< Environment * > environments_
Definition: gmock-gtest-all.cc:1243
testing::GTEST_DEFINE_bool_
GTEST_DEFINE_bool_(death_test_use_fork, internal::BoolFromGTestEnv("death_test_use_fork", false), "Instructs to use fork()/_exit() instead of clone() in death tests. " "Ignored and always uses fork() on POSIX systems where clone() is not " "implemented. Useful when running under valgrind or similar tools if " "those do not support clone(). Valgrind 3.3.1 will just fail if " "it sees an unsupported combination of clone() flags. " "It is not recommended to use this flag w/o valgrind though it will " "work in 99% of the cases. Once valgrind is fixed, this flag will " "most likely be removed.")
testing::IsNotSubstring
GTEST_API_ AssertionResult IsNotSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1629
testing::internal::BriefUnitTestResultPrinter::OnTestStart
void OnTestStart(const TestInfo &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3663
testing::internal::kOutputFlag
const char kOutputFlag[]
Definition: gmock-gtest-all.cc:502
testing::internal::String::WideCStringEquals
static bool WideCStringEquals(const wchar_t *lhs, const wchar_t *rhs)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1874
testing::UnitTest::ad_hoc_test_result
const TestResult & ad_hoc_test_result() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4734
testing::internal::PrettyUnitTestResultPrinter::OnTestEnd
void OnTestEnd(const TestInfo &test_info) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3242
testing::internal::kInternalRunDeathTestFlag
const char kInternalRunDeathTestFlag[]
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h:53
testing::UnitTest::GetInstance
static UnitTest * GetInstance()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4616
data_
std::string data_
Definition: cord_rep_btree_navigator_test.cc:84
testing::UnitTest::successful_test_count
int successful_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4668
testing::internal::String::EndsWithCaseInsensitive
static bool EndsWithCaseInsensitive(const std::string &str, const std::string &suffix)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1961
testing::internal::UnitTestImpl::set_os_stack_trace_getter
void set_os_stack_trace_getter(OsStackTraceGetterInterface *getter)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5627
testing::internal::PrintFullTestCommentIfPresent
static void PrintFullTestCommentIfPresent(const TestInfo &test_info)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3089
testing::internal::PortableLocaltime
static bool PortableLocaltime(time_t seconds, struct tm *out)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3721
testing::TestSuite::elapsed_time_
TimeInMillis elapsed_time_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1022
testing::internal::PrettyUnitTestResultPrinter::OnTestIterationEnd
void OnTestIterationEnd(const UnitTest &unit_test, int iteration) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3343
absl::base_internal::Random
static int Random(uint32_t *state)
Definition: abseil-cpp/absl/base/internal/low_level_alloc.cc:122
testing::ScopedFakeTestPartResultReporter::ReportTestPartResult
virtual void ReportTestPartResult(const TestPartResult &result)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:632
testing::UnitTest::~UnitTest
virtual ~UnitTest()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4983
testing::internal::TimeInMillis
TypeWithSize< 8 >::Int TimeInMillis
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2163
testing::UnitTest::reportable_disabled_test_count
int reportable_disabled_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4681
testing::internal::BriefUnitTestResultPrinter::OnTestProgramStart
void OnTestProgramStart(const UnitTest &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3652
testing::TestSuite::should_run_
bool should_run_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1018
testing::internal::kCatchExceptionsFlag
const char kCatchExceptionsFlag[]
Definition: gmock-gtest-all.cc:498
testing::internal::InsertSyntheticTestCase
GTEST_API_ void InsertSyntheticTestCase(const std::string &name, CodeLocation location, bool has_test_p)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:469
testing::internal::kThrowOnFailureFlag
const char kThrowOnFailureFlag[]
Definition: gmock-gtest-all.cc:509
testing::UnitTest::elapsed_time
TimeInMillis elapsed_time() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4708
testing::TestResult::HasFatalFailure
bool HasFatalFailure() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2221
testing::internal::String::FormatIntWidth2
static std::string FormatIntWidth2(int value)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1971
testing::internal::XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes
static std::string TestPropertiesAsXmlAttributes(const TestResult &result)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3953
testing::TestResult::Failed
bool Failed() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2207
testing::internal::kStackTraceMarker
const GTEST_API_ char kStackTraceMarker[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:178
testing::internal::TestSuiteNameIs::operator()
bool operator()(const TestSuite *test_suite) const
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:5546
GTEST_REPEATER_METHOD_
#define GTEST_REPEATER_METHOD_(Name, Type)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3813
testing::internal::TestEventRepeater::OnTestIterationStart
void OnTestIterationStart(const UnitTest &unit_test, int iteration) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3500
testing::internal::edit_distance::CreateUnifiedDiff
GTEST_API_ std::string CreateUnifiedDiff(const std::vector< std::string > &left, const std::vector< std::string > &right, size_t context=2)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1216
testing::internal::UnitTestImpl::ShuffleTests
void ShuffleTests()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5663
testing::AssertionResult::swap
void swap(AssertionResult &other)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1009
testing::FloatLE
GTEST_API_ AssertionResult FloatLE(const char *expr1, const char *expr2, float val1, float val2)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1434
testing::internal::TestSuiteFailed
static bool TestSuiteFailed(const TestSuite *test_suite)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:380
testing::internal::PrettyUnitTestResultPrinter::OnTestProgramEnd
void OnTestProgramEnd(const UnitTest &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3376
testing::internal::JsonUnitTestResultPrinter::OutputJsonTestInfo
static void OutputJsonTestInfo(::std::ostream *stream, const char *test_suite_name, const TestInfo &test_info)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4167
testing::internal::PrettyUnitTestResultPrinter::OnEnvironmentsSetUpEnd
void OnEnvironmentsSetUpEnd(const UnitTest &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3356
testing::UnitTest::parameterized_test_registry
internal::ParameterizedTestSuiteRegistry & parameterized_test_registry() GTEST_LOCK_EXCLUDED_(mutex_)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4973
testing::UnitTest::failed_test_case_count
int failed_test_case_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4656
testing::internal::FormatCompilerIndependentFileLocation
GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char *file, int line)
Definition: bloaty/third_party/googletest/googletest/src/gtest-port.cc:1036
testing::internal::TestEventRepeater::OnTestStart
void OnTestStart(const TestInfo &test_info) override
testing::TestPartResult::kSuccess
@ kSuccess
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18277
testing::internal::kFlagfileFlag
const char kFlagfileFlag[]
Definition: gmock-gtest-all.cc:510
testing::internal::StreamWideCharsToMessage
static void StreamWideCharsToMessage(const wchar_t *wstr, size_t length, Message *msg)
Definition: gmock-gtest-all.cc:2354
testing::internal::CountIf
int CountIf(const Container &c, Predicate predicate)
Definition: gmock-gtest-all.cc:690
testing::TestResult::Clear
void Clear()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2189
testing::internal::TestEventRepeater::OnTestCaseStart
void OnTestCaseStart(const TestSuite &parameter) override
testing::TestEventListener::OnTestStart
virtual void OnTestStart(const TestInfo &test_info)=0
internal
Definition: benchmark/test/output_test_helper.cc:20
testing::internal::kColorFlag
const char kColorFlag[]
Definition: gmock-gtest-all.cc:499
testing::TestSuite::test_indices_
std::vector< int > test_indices_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1012
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
test_server.socket
socket
Definition: test_server.py:65
right_start_
size_t right_start_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:1335
testing::UnitTest::disabled_test_count
int disabled_test_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4686
testing::UnitTest::RecordProperty
void RecordProperty(const std::string &key, const std::string &value)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4843
mutex_
internal::WrappedMutex mutex_
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.cc:569
testing::internal::HandleExceptionsInMethodIfSupported
Result HandleExceptionsInMethodIfSupported(T *object, Result(T::*method)(), const char *location)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2447
testing::internal::TestEventRepeater::forwarding_enabled
bool forwarding_enabled() const
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3757
testing::ScopedFakeTestPartResultReporter::Init
void Init()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:608
testing::internal::UnitTestImpl::RecordProperty
void RecordProperty(const TestProperty &test_property)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5048
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
testing::internal::TestSuiteNameIs::name_
std::string name_
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5171
ch
char ch
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3621
autogen_x86imm.tmp
tmp
Definition: autogen_x86imm.py:12
googletest-break-on-failure-unittest.Run
def Run(command)
Definition: bloaty/third_party/googletest/googletest/test/googletest-break-on-failure-unittest.py:76
testing::internal::XmlUnitTestResultPrinter::OutputXmlCDataSection
static void OutputXmlCDataSection(::std::ostream *stream, const char *data)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3752
testing::internal::move
const T & move(const T &t)
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:2592
testing::internal::UnitTestImpl::~UnitTestImpl
virtual ~UnitTestImpl()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5033
parent_
RefCountedPtr< GrpcLb > parent_
Definition: grpclb.cc:438
testing::GetReservedOutputAttributesForElement
static std::vector< std::string > GetReservedOutputAttributesForElement(const std::string &xml_element)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2138
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
testing::internal::OutputFlagAlsoCheckEnvVar
std::string OutputFlagAlsoCheckEnvVar()
Definition: bloaty/third_party/googletest/googletest/src/gtest-port.cc:1380
as_error_
const bool as_error_
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:452
testing::internal::UnitTestImpl::RunAllTests
bool RunAllTests()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5234
testing::internal::PrintTestPartResultToString
static std::string PrintTestPartResultToString(const TestPartResult &test_part_result)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3135
testing::TestSuite::UnitTestImpl
friend class internal::UnitTestImpl
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:911
length
std::size_t length
Definition: abseil-cpp/absl/time/internal/test_util.cc:57
testing::internal::FormatEpochTimeInMillisAsIso8601
std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3738
testing::internal::UnitTestImpl::start_timestamp_
TimeInMillis start_timestamp_
Definition: gmock-gtest-all.cc:1310
testing::TestPartResult::file_name
const char * file_name() const
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18301
testing::UnitTest::start_timestamp
TimeInMillis start_timestamp() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4703
regress.m
m
Definition: regress/regress.py:25
testing::internal::JsonUnitTestResultPrinter::PrintJsonTestList
static void PrintJsonTestList(::std::ostream *stream, const std::vector< TestSuite * > &test_suites)
method
NSString * method
Definition: ProtoMethod.h:28
testing::TestInfo::test_suite_name
const char * test_suite_name() const
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:702
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
google::protobuf::compiler::objectivec::FilePath
string FilePath(const FileDescriptor *file)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc:404
testing::internal::UnitTestImpl::os_stack_trace_getter
OsStackTraceGetterInterface * os_stack_trace_getter()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5638
testing::kDisableTestFilter
static const char kDisableTestFilter[]
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:152
testing::internal::kPrintTimeFlag
const char kPrintTimeFlag[]
Definition: gmock-gtest-all.cc:503
testing::internal::ParseInt32Flag
bool ParseInt32Flag(const char *str, const char *flag, Int32 *value)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5793
testing::TestSuite::ClearResult
void ClearResult()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2841
testing::internal::PrintTo
void PrintTo(const T &value, ::std::ostream *os)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-printers.h:483
testing::internal::WriteToShardStatusFileIfNeeded
void WriteToShardStatusFileIfNeeded()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5400
testing::internal::PrettyUnitTestResultPrinter::OnTestPartResult
void OnTestPartResult(const TestPartResult &result) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3226
testing::internal::TearDownEnvironment
static void TearDownEnvironment(Environment *env)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5223
testing::UnitTest::Failed
bool Failed() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4717
testing::internal::RegisterTypeParameterizedTestSuite
void RegisterTypeParameterizedTestSuite(const char *test_suite_name, CodeLocation code_location)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:512
testing::internal::UnitTestImpl::last_death_test_suite_
int last_death_test_suite_
Definition: googletest/googletest/src/gtest-internal-inl.h:886
setup.target
target
Definition: third_party/bloaty/third_party/protobuf/python/setup.py:179
testing::internal::XmlUnitTestResultPrinter::PrintXmlUnitTest
static void PrintXmlUnitTest(::std::ostream *stream, const UnitTest &unit_test)
addrinfo
Definition: ares_ipv6.h:43
testing::DoubleLE
GTEST_API_ AssertionResult DoubleLE(const char *expr1, const char *expr2, double val1, double val2)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1441
Test
Definition: hpack_parser_test.cc:43
testing::internal::g_help_flag
bool g_help_flag
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:182
if
if(p->owned &&p->wrapped !=NULL)
Definition: call.c:42
EXPECT_PRED_FORMAT3
#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest_pred_impl.h:218
testing::TestSuite::GetTestInfo
const TestInfo * GetTestInfo(int i) const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2781
Message
Definition: protobuf/php/ext/google/protobuf/message.c:53
testing::internal::JsonUnitTestResultPrinter::GTEST_DISALLOW_COPY_AND_ASSIGN_
GTEST_DISALLOW_COPY_AND_ASSIGN_(JsonUnitTestResultPrinter)
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
testing::internal::ReportFailureInUnknownLocation
void ReportFailureInUnknownLocation(TestPartResult::Type result_type, const std::string &message)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2287
testing::internal::GetRandomSeedFromFlag
int GetRandomSeedFromFlag(Int32 random_seed_flag)
Definition: gmock-gtest-all.cc:543
testing::UnitTest::successful_test_case_count
int successful_test_case_count() const
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:4653
testing::internal::posix::FClose
int FClose(FILE *fp)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2042
testing::internal::ScopedPrematureExitFile::ScopedPrematureExitFile
ScopedPrematureExitFile(const char *premature_exit_filepath)
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:4876
GTEST_PROJECT_URL_
#define GTEST_PROJECT_URL_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:281
testing::internal::String::FormatByte
static std::string FormatByte(unsigned char value)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1990
setup.test_suite
test_suite
Definition: src/python/grpcio_tests/setup.py:108
testing::internal::BriefUnitTestResultPrinter::OnTestCaseStart
void OnTestCaseStart(const TestCase &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3658
id
uint32_t id
Definition: flow_control_fuzzer.cc:70
testing::internal::TestEventRepeater::OnTestIterationEnd
void OnTestIterationEnd(const UnitTest &unit_test, int iteration) override
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3509
testing::TestEventListener
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1076
testing::TestEventListener::OnTestSuiteStart
virtual void OnTestSuiteStart(const TestSuite &)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1096
testing::TestSuite
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:830
testing::internal::BriefUnitTestResultPrinter::OnEnvironmentsTearDownStart
void OnEnvironmentsTearDownStart(const UnitTest &) override
Definition: boringssl-with-bazel/src/third_party/googletest/src/gtest.cc:3673
testing::internal::UnitTestImpl::GetTestSuite
const TestSuite * GetTestSuite(int i) const
Definition: googletest/googletest/src/gtest-internal-inl.h:577
testing::PrintToString
::std::string PrintToString(const T &value)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-printers.h:915
testing::TestSuite::RunSetUpTestSuite
void RunSetUpTestSuite()
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:945
stream
voidpf stream
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:50