tesseract v5.3.3.20231005
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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 107 of file sample10_unittest.cc.

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