ReactOS  0.4.15-dev-499-g1f31905
FileReporter Class Reference

#include <file_reporter.h>

Inheritance diagram for FileReporter:
Collaboration diagram for FileReporter:

Public Member Functions

 FileReporter (bool doMonitor=false)
 
 FileReporter (const char *file, bool doMonitor=false)
 
 FileReporter (FILE *stream, bool doMonitor=false)
 
virtual ~FileReporter ()
 
virtual void error (const char *in_macroName, const char *in_macro, const char *in_file, int in_line)
 
virtual void message (const char *msg)
 
virtual void progress (const char *in_className, const char *in_shortTestName, bool ignored, bool explicitTest)
 
virtual void end ()
 
virtual void printSummary ()
 

Private Member Functions

 FileReporter (const FileReporter &)
 
FileReporteroperator= (const FileReporter &)
 

Private Attributes

int m_numErrors
 
int m_numIgnored
 
int m_numExplicit
 
int m_numTests
 
bool _myStream
 
bool m_failed
 
bool m_doMonitor
 
Timer m_globalTimer
 
Timer m_testTimer
 
FILE_file
 

Detailed Description

Definition at line 28 of file file_reporter.h.

Constructor & Destructor Documentation

◆ FileReporter() [1/4]

FileReporter::FileReporter ( const FileReporter )
private

◆ FileReporter() [2/4]

FileReporter::FileReporter ( bool  doMonitor = false)
inlineexplicit

Definition at line 34 of file file_reporter.h.

34  :
36  m_failed(false), m_doMonitor(doMonitor)
37  { _file = stderr; }
FILE * stderr

◆ FileReporter() [3/4]

FileReporter::FileReporter ( const char file,
bool  doMonitor = false 
)
inlineexplicit

Definition at line 40 of file file_reporter.h.

40  :
42  m_failed(false), m_doMonitor(doMonitor)
43  {
44 #ifndef _STLP_USE_SAFE_STRING_FUNCTIONS
45  _file = fopen(file, "w");
46 #else
47  fopen_s(&_file, file, "w");
48 #endif
49  }
int CDECL fopen_s(FILE **pFile, const char *filename, const char *mode)
Definition: file.c:3255
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
Definition: fci.c:126

◆ FileReporter() [4/4]

FileReporter::FileReporter ( FILE stream,
bool  doMonitor = false 
)
inlineexplicit

Definition at line 52 of file file_reporter.h.

52  :
54  m_failed(false), m_doMonitor(doMonitor)
55  { _file = stream; }
GLuint GLuint stream
Definition: glext.h:7522

◆ ~FileReporter()

virtual FileReporter::~FileReporter ( )
inlinevirtual

Definition at line 57 of file file_reporter.h.

57  {
58  if (_myStream)
59  fclose(_file);
60  else
61  fflush(_file);
62  }
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)

Member Function Documentation

◆ end()

virtual void FileReporter::end ( )
inlinevirtual

Definition at line 98 of file file_reporter.h.

98  {
99  if (m_doMonitor) {
101  m_testTimer.stop();
103  }
104  if (m_failed) {
105  ++m_numErrors;
106  }
107  fprintf(_file, "\n");
108  }
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
double elapsedMilliseconds() const
Definition: cppunit_timer.h:75
Timer m_globalTimer
void stop()
Definition: cppunit_timer.h:49

◆ error()

virtual void FileReporter::error ( const char in_macroName,
const char in_macro,
const char in_file,
int  in_line 
)
inlinevirtual

Definition at line 64 of file file_reporter.h.

64  {
65  // Error might be called several times between 2 progress calls, we shouldn't however consider
66  // that a test failed twice so we simply keep the info that test failed, number of failed tests
67  // is computed later in end method.
68  m_failed = true;
69  fprintf(_file, "\n\n%s(%d) : %s(%s);", in_file, in_line, in_macroName, in_macro);
70  }
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)

◆ message()

virtual void FileReporter::message ( const char msg)
inlinevirtual

Definition at line 72 of file file_reporter.h.

73  { fprintf(_file, "\n\t%s", msg ); }
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define msg(x)
Definition: auth_time.c:54

◆ operator=()

◆ printSummary()

virtual void FileReporter::printSummary ( )
inlinevirtual

Definition at line 110 of file file_reporter.h.

110  {
111  if (m_numErrors > 0) {
112  fprintf(_file, "\nThere were errors! %d of %d tests", m_numErrors, m_numTests);
113  }
114  else {
115  fprintf(_file, "\nOK %d tests", m_numTests);
116  }
117 
118  if (m_numIgnored > 0) {
119  fprintf(_file, ", %d ignored", m_numIgnored);
120  }
121 
122  if (m_numExplicit > 0) {
123  fprintf(_file, " (%d explicit)", m_numExplicit);
124  }
125 
126  if (m_doMonitor) {
128  }
129 
130  fprintf(_file, "\n\n");
131  }
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
double elapsedMilliseconds() const
Definition: cppunit_timer.h:75
Timer m_globalTimer

◆ progress()

virtual void FileReporter::progress ( const char in_className,
const char in_shortTestName,
bool  ignored,
bool  explicitTest 
)
inlinevirtual

Definition at line 75 of file file_reporter.h.

75  {
76  if (m_doMonitor) {
79  }
80  ++m_numTests;
81  m_failed = false;
82  if (ignored)
83  ++m_numIgnored;
84  fprintf(_file, "%s::%s", in_className, in_shortTestName);
85  if (ignored) {
86  const char *ignoredReason;
87  if (explicitTest) {
88  ++m_numExplicit;
89  ignoredReason = " EXPLICIT";
90  }
91  else
92  ignoredReason = " IGNORED";
93 
94  fprintf(_file, "%s", ignoredReason);
95  }
96  }
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
void start()
Definition: cppunit_timer.h:34
void restart()
Definition: cppunit_timer.h:40
uint8_t ignored[3]
Definition: fsck.fat.h:35
Timer m_globalTimer

Member Data Documentation

◆ _file

FILE* FileReporter::_file
private

Definition at line 142 of file file_reporter.h.

Referenced by end(), error(), FileReporter(), message(), printSummary(), progress(), and ~FileReporter().

◆ _myStream

bool FileReporter::_myStream
private

Definition at line 138 of file file_reporter.h.

Referenced by ~FileReporter().

◆ m_doMonitor

bool FileReporter::m_doMonitor
private

Definition at line 140 of file file_reporter.h.

Referenced by end(), printSummary(), and progress().

◆ m_failed

bool FileReporter::m_failed
private

Definition at line 139 of file file_reporter.h.

Referenced by end(), error(), and progress().

◆ m_globalTimer

Timer FileReporter::m_globalTimer
private

Definition at line 141 of file file_reporter.h.

Referenced by end(), printSummary(), and progress().

◆ m_numErrors

int FileReporter::m_numErrors
private

Definition at line 133 of file file_reporter.h.

Referenced by end(), and printSummary().

◆ m_numExplicit

int FileReporter::m_numExplicit
private

Definition at line 135 of file file_reporter.h.

Referenced by printSummary(), and progress().

◆ m_numIgnored

int FileReporter::m_numIgnored
private

Definition at line 134 of file file_reporter.h.

Referenced by printSummary(), and progress().

◆ m_numTests

int FileReporter::m_numTests
private

Definition at line 136 of file file_reporter.h.

Referenced by printSummary(), and progress().

◆ m_testTimer

Timer FileReporter::m_testTimer
private

Definition at line 141 of file file_reporter.h.

Referenced by end(), and progress().


The documentation for this class was generated from the following file: