proxygen
sample10_unittest.cc File Reference
#include <stdio.h>
#include <stdlib.h>
#include "gtest/gtest.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 112 of file sample10_unittest.cc.

References testing::InitGoogleTest(), and RUN_ALL_TESTS().

112  {
113  InitGoogleTest(&argc, argv);
114 
115  bool check_for_leaks = false;
116  if (argc > 1 && strcmp(argv[1], "--check_for_leaks") == 0 )
117  check_for_leaks = true;
118  else
119  printf("%s\n", "Run this program with --check_for_leaks to enable "
120  "custom leak checking in the tests.");
121 
122  // If we are given the --check_for_leaks command line flag, installs the
123  // leak checker.
124  if (check_for_leaks) {
125  TestEventListeners& listeners = UnitTest::GetInstance()->listeners();
126 
127  // Adds the leak checker to the end of the test event listener list,
128  // after the default text output printer and the default XML report
129  // generator.
130  //
131  // The order is important - it ensures that failures generated in the
132  // leak checker's OnTestEnd() method are processed by the text and XML
133  // printers *before* their OnTestEnd() methods are called, such that
134  // they are attributed to the right test. Remember that a listener
135  // receives an OnXyzStart event *after* listeners preceding it in the
136  // list received that event, and receives an OnXyzEnd event *before*
137  // listeners preceding it.
138  //
139  // We don't need to worry about deleting the new listener later, as
140  // Google Test will do it.
141  listeners.Append(new LeakChecker);
142  }
143  return RUN_ALL_TESTS();
144 }
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: gtest.h:2232
char ** argv
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: gtest.cc:5370