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