ReactOS 0.4.15-dev-7924-g5949c20
TestCase Class Reference

#include <cppunit_mini.h>

Inheritance diagram for TestCase:
Collaboration diagram for TestCase:

Public Member Functions

 TestCase ()
 
void setUp ()
 Set up context before running a test.
 
int numErrors ()
 
virtual void myRun (const char *, bool=false)
 
virtual void error (const char *in_macroName, const char *in_macro, const char *in_file, int in_line)
 
bool equalDoubles (double in_expected, double in_real, double in_maxErr)
 
virtual void progress (const char *in_className, const char *in_functionName, bool ignored, bool explicitTest)
 
bool shouldRunThis (const char *in_desiredTest, const char *in_className, const char *in_functionName, bool invert, bool explicit_test, bool &do_progress)
 
void tearDown ()
 Clean up after the test run.
 
- Public Member Functions inherited from TestFixture
virtual ~TestFixture ()
 
virtual void setUp ()
 Set up context before running a test.
 
virtual void tearDown ()
 Clean up after the test run.
 

Static Public Member Functions

static int run (Reporter *in_reporter=0, const char *in_testName="", bool invert=false)
 
static void registerTestCase (TestCase *in_testCase)
 
static void message (const char *msg)
 

Static Protected Attributes

static int m_numErrors = 0
 
static int m_numTests = 0
 

Private Attributes

TestCasem_next
 
bool m_failed
 

Static Private Attributes

static TestCasem_root = 0
 
static Reporterm_reporter = 0
 

Detailed Description

Definition at line 54 of file cppunit_mini.h.

Constructor & Destructor Documentation

◆ TestCase()

TestCase::TestCase ( )
inline

Definition at line 56 of file cppunit_mini.h.

56{ registerTestCase(this); }
static void registerTestCase(TestCase *in_testCase)
Definition: test_main.cpp:32

Member Function Documentation

◆ equalDoubles()

bool TestCase::equalDoubles ( double  in_expected,
double  in_real,
double  in_maxErr 
)
inline

Definition at line 78 of file cppunit_mini.h.

78 {
79 double diff = in_expected - in_real;
80 if (diff < 0.) {
81 diff = -diff;
82 }
83 return diff < in_maxErr;
84 }

◆ error()

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

Definition at line 65 of file cppunit_mini.h.

65 {
66 m_failed = true;
67 if (m_reporter) {
68 m_reporter->error(in_macroName, in_macro, in_file, in_line);
69 }
70 }
virtual void error(const char *, const char *, const char *, int)
Definition: cppunit_mini.h:36
static Reporter * m_reporter
Definition: cppunit_mini.h:128
bool m_failed
Definition: cppunit_mini.h:126

◆ message()

static void TestCase::message ( const char msg)
inlinestatic

Definition at line 72 of file cppunit_mini.h.

72 {
73 if (m_reporter) {
75 }
76 }
#define msg(x)
Definition: auth_time.c:54
virtual void message(const char *)
Definition: cppunit_mini.h:37

◆ myRun()

virtual void TestCase::myRun ( const char ,
bool  = false 
)
inlinevirtual

Definition at line 63 of file cppunit_mini.h.

63{}

Referenced by run().

◆ numErrors()

int TestCase::numErrors ( )
inline

Definition at line 60 of file cppunit_mini.h.

60{ return m_numErrors; }
static int m_numErrors
Definition: cppunit_mini.h:120

◆ progress()

virtual void TestCase::progress ( const char in_className,
const char in_functionName,
bool  ignored,
bool  explicitTest 
)
inlinevirtual

Definition at line 86 of file cppunit_mini.h.

86 {
87 ++m_numTests;
88 if (m_reporter) {
89 m_reporter->progress(in_className, in_functionName, ignored, explicitTest);
90 }
91 }
virtual void progress(const char *, const char *, bool, bool)
Definition: cppunit_mini.h:38
static int m_numTests
Definition: cppunit_mini.h:121
uint8_t ignored[3]
Definition: fsck.fat.h:0

◆ registerTestCase()

void TestCase::registerTestCase ( TestCase in_testCase)
static

Definition at line 32 of file test_main.cpp.

32 {
33 in_testCase->m_next = m_root;
34 m_root = in_testCase;
35 }
static TestCase * m_root
Definition: cppunit_mini.h:124
TestCase * m_next
Definition: cppunit_mini.h:125

◆ run()

int TestCase::run ( Reporter in_reporter = 0,
const char in_testName = "",
bool  invert = false 
)
static

Definition at line 37 of file test_main.cpp.

37 {
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 }
virtual void myRun(const char *, bool=false)
Definition: cppunit_mini.h:63
GLboolean invert
Definition: gl.h:1949

◆ setUp()

void TestCase::setUp ( )
inlinevirtual

Set up context before running a test.

Reimplemented from TestFixture.

Definition at line 58 of file cppunit_mini.h.

58{ m_failed = false; }

◆ shouldRunThis()

bool TestCase::shouldRunThis ( const char in_desiredTest,
const char in_className,
const char in_functionName,
bool  invert,
bool  explicit_test,
bool do_progress 
)
inline

Definition at line 93 of file cppunit_mini.h.

94 {
95 if ((in_desiredTest) && (in_desiredTest[0] != '\0')) {
96 do_progress = false;
97 const char *ptr = strstr(in_desiredTest, "::");
98 if (ptr) {
99 bool match = (strncmp(in_desiredTest, in_className, strlen(in_className)) == 0) &&
100 (strncmp(ptr + 2, in_functionName, strlen(in_functionName)) == 0);
101 // Invert shall not make explicit test run:
102 return invert ? (match ? !match : !explicit_test)
103 : match;
104 }
105 bool match = (strcmp(in_desiredTest, in_className) == 0);
106 do_progress = match;
107 return !explicit_test && (match == !invert);
108 }
109 do_progress = true;
110 return !explicit_test;
111 }
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static PVOID ptr
Definition: dispmode.c:27
Definition: match.c:28

◆ tearDown()

void TestCase::tearDown ( )
inlinevirtual

Clean up after the test run.

Reimplemented from TestFixture.

Definition at line 113 of file cppunit_mini.h.

113 {
114 if (m_failed)
115 ++m_numErrors;
116 m_reporter->end();
117 }
virtual void end()
Definition: cppunit_mini.h:39

Member Data Documentation

◆ m_failed

bool TestCase::m_failed
private

Definition at line 126 of file cppunit_mini.h.

◆ m_next

TestCase* TestCase::m_next
private

Definition at line 125 of file cppunit_mini.h.

Referenced by registerTestCase(), and run().

◆ m_numErrors

int TestCase::m_numErrors = 0
staticprotected

Definition at line 120 of file cppunit_mini.h.

◆ m_numTests

int TestCase::m_numTests = 0
staticprotected

Definition at line 121 of file cppunit_mini.h.

◆ m_reporter

Reporter * TestCase::m_reporter = 0
staticprivate

Definition at line 128 of file cppunit_mini.h.

Referenced by run().

◆ m_root

TestCase * TestCase::m_root = 0
staticprivate

Definition at line 124 of file cppunit_mini.h.


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