Qt 4.8
Public Functions | List of all members
QTestFileLogger Class Reference

#include <qtestfilelogger.h>

Public Functions

void flush (const char *msg)
 
void init ()
 
 QTestFileLogger ()
 
 ~QTestFileLogger ()
 

Detailed Description

Definition at line 53 of file qtestfilelogger.h.

Constructors and Destructors

◆ QTestFileLogger()

QTestFileLogger::QTestFileLogger ( )

Definition at line 59 of file qtestfilelogger.cpp.

60 {
61 }

◆ ~QTestFileLogger()

QTestFileLogger::~QTestFileLogger ( )

Definition at line 63 of file qtestfilelogger.cpp.

64 {
65  if(QTest::stream)
66  fclose(QTest::stream);
67 
68  QTest::stream = 0;
69 }
static FILE * stream

Functions

◆ flush()

void QTestFileLogger::flush ( const char *  msg)

Definition at line 105 of file qtestfilelogger.cpp.

Referenced by QTestLogger::enterTestFunction().

106 {
108 
109  ::fputs(msg, QTest::stream);
110  ::fflush(QTest::stream);
111 }
static FILE * stream
#define QTEST_ASSERT(cond)
Definition: qtestassert.h:53

◆ init()

void QTestFileLogger::init ( )

Definition at line 71 of file qtestfilelogger.cpp.

Referenced by QTestLogger::startLogging().

72 {
73  char filename[100];
74  int index = 0;
75 #if defined(Q_OS_SYMBIAN)
77  index = ba.length();
78  QTest::qt_snprintf(filename, sizeof(filename), "%s%s.log",
79  ba.constData(), QTestResult::currentTestObjectName());
80 #else
81  QTest::qt_snprintf(filename, sizeof(filename), "%s.log",
83 #endif
84 
85  // Keep filenames simple
86  for (uint i = index; i < sizeof(filename) && filename[i]; ++i) {
87  char& c = filename[i];
88  if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
89  || (c >= '0' && c <= '9') || c == '-' || c == '.')) {
90  c = '_';
91  }
92  }
93 
94 #if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
95  if (::fopen_s(&QTest::stream, filename, "wt")) {
96 #else
97  QTest::stream = ::fopen(filename, "wt");
98  if (!QTest::stream) {
99 #endif
100  printf("Unable to open file for simple logging: %s", filename);
101  ::exit(1);
102  }
103 }
unsigned char c[8]
Definition: qnumeric_p.h:62
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QChar separator()
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\\" under Windows...
Definition: qdir.cpp:1831
static const char * currentTestObjectName()
static FILE * stream
unsigned int uint
Definition: qglobal.h:996
int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format,...)
Definition: qtestcase.cpp:961
quint16 index
static QString toNativeSeparators(const QString &pathName)
Returns pathName with the &#39;/&#39; separators converted to separators that are appropriate for the underly...
Definition: qdir.cpp:812
static QString homePath()
Returns the absolute path of the user&#39;s home directory.
Definition: qdir.cpp:1942

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