ReactOS 0.4.16-dev-258-g81860b4
test_main.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003, 2004
3 * Zdenek Nemec
4 *
5 * This material is provided "as is", with absolutely no warranty expressed
6 * or implied. Any use is at your own risk.
7 *
8 * Permission to use or copy this software for any purpose is hereby granted
9 * without fee, provided the above notices are retained on all copies.
10 * Permission to modify the code and to distribute modified code is granted,
11 * provided the above notices are retained, and a notice that the code was
12 * modified is included with the above copyright notice.
13 *
14 */
15
16#include "cppunit_proxy.h"
17#include "file_reporter.h"
18#include "cppunit_timer.h"
19
20#include "stdio.h"
21
22#if 0
23namespace CPPUNIT_NS
24{
25#endif
28
31
33 in_testCase->m_next = m_root;
34 m_root = in_testCase;
35 }
36
37 int TestCase::run(Reporter *in_reporter, const char *in_testName, bool invert) {
38 TestCase::m_reporter = in_reporter;
39
40 m_numErrors = 0;
41 m_numTests = 0;
42
43 TestCase *tmp = m_root;
44 while (tmp != 0) {
45 tmp->myRun(in_testName, invert);
46 tmp = tmp->m_next;
47 }
48 return m_numErrors;
49 }
50#if 0
51}
52#endif
53
54static void usage(const char* name)
55{
56 printf("Usage : %s [-t=<class>[::<test>]] [-x=<class>[::<test>]] [-f=<file>]%s\n",
57 name, Timer::supported() ? " [-m]": "");
58 printf("\t[-t=<class>[::<test>]] : test class or class::test to execute;\n");
59 printf("\t[-x=<class>[::<test>]] : test class or class::test to exclude from execution;\n");
60 printf("\t[-f=<file>] : output file");
61 if (Timer::supported())
62 printf(";\n\t[-m] : monitor test execution, display time duration for each test\n");
63 else
64 printf("\n");
65}
66
67int main(int argc, char** argv) {
68
69 // CppUnit(mini) test launcher
70 // command line option syntax:
71 // test [OPTIONS]
72 // where OPTIONS are
73 // -t=CLASS[::TEST] run the test class CLASS or member test CLASS::TEST
74 // -x=CLASS[::TEST] run all except the test class CLASS or member test CLASS::TEST
75 // -f=FILE save output in file FILE instead of stdout
76 // -m monitor test(s) execution
77 const char *fileName = 0;
78 const char *testName = "";
79 const char *xtestName = "";
80 bool doMonitoring = false;
81
82 for (int i = 1; i < argc; ++i) {
83 if (argv[i][0] == '-') {
84 if (!strncmp(argv[i], "-t=", 3)) {
85 testName = argv[i]+3;
86 continue;
87 }
88 else if (!strncmp(argv[i], "-f=", 3)) {
89 fileName = argv[i]+3;
90 continue;
91 }
92 else if (!strncmp(argv[i], "-x=", 3)) {
93 xtestName = argv[i]+3;
94 continue;
95 }
96 else if (Timer::supported() && !strncmp(argv[i], "-m", 2)) {
97 doMonitoring = true;
98 continue;
99 }
100 }
101
102 // invalid option, we display normal usage.
103 usage(argv[0]);
104 return 1;
105 }
106
107 CPPUNIT_NS::Reporter* reporter;
108 if (fileName != 0)
109 reporter = new FileReporter(fileName, doMonitoring);
110 else
111 reporter = new FileReporter(stdout, doMonitoring);
112
113 int num_errors;
114 if (xtestName[0] != 0) {
115 num_errors = CPPUNIT_NS::TestCase::run(reporter, xtestName, true);
116 } else {
117 num_errors = CPPUNIT_NS::TestCase::run(reporter, testName);
118 }
119
120 reporter->printSummary();
121 delete reporter;
122
123 return num_errors;
124}
125
126// See doc/README.intel for explanation about this code
127#if defined (STLPORT) && defined (__ICL) && (__ICL >= 900) && \
128 (_STLP_MSVC_LIB < 1300) && defined (_STLP_USE_DYNAMIC_LIB)
129# include <exception>
130
131# undef std
132namespace std
133{
134 void _STLP_CALL unexpected() {
137 hdl();
138 }
139}
140#endif
static int argc
Definition: ServiceArgs.c:12
#define _STLP_CALL
Definition: _bc.h:131
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static Reporter * m_reporter
Definition: cppunit_mini.h:128
static TestCase * m_root
Definition: cppunit_mini.h:124
static int run(Reporter *in_reporter=0, const char *in_testName="", bool invert=false)
Definition: test_main.cpp:37
static int m_numTests
Definition: cppunit_mini.h:121
TestCase * m_next
Definition: cppunit_mini.h:125
static void registerTestCase(TestCase *in_testCase)
Definition: test_main.cpp:32
static int m_numErrors
Definition: cppunit_mini.h:120
virtual void myRun(const char *, bool=false)
Definition: cppunit_mini.h:63
#define CPPUNIT_NS
Definition: cppunit_mini.h:24
int main()
Definition: test.c:6
#define printf
Definition: freeldr.h:97
GLboolean invert
Definition: gl.h:1949
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define stdout
Definition: stdio.h:99
_CRTIMP void __cdecl unexpected(void)
_CRTIMP unexpected_function __cdecl set_unexpected(unexpected_function _NewPtFunc)
void(__cdecl * unexpected_handler)(void)
Definition: eh.h:22
#define argv
Definition: mplay32.c:18
Definition: features.h:417
Definition: name.c:39
static int num_errors
Definition: odbccp32.c:60