Skip to content

Commit f72077e

Browse files
committed
0 parents  commit f72077e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+8935
-0
lines changed

lib/CppUTest/COPYING

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
6+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9+
10+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#ifndef D_CommandLineArguments_H
2+
#define D_CommandLineArguments_H
3+
4+
///////////////////////////////////////////////////////////////////////////////
5+
//
6+
// CommandLineArguments is responsible for ...
7+
//
8+
///////////////////////////////////////////////////////////////////////////////
9+
#include "SimpleString.h"
10+
#include "TestOutput.h"
11+
12+
class TestPlugin;
13+
14+
class CommandLineArguments
15+
{
16+
public:
17+
explicit CommandLineArguments(int ac, const char** av, TestPlugin*);
18+
virtual ~CommandLineArguments();
19+
20+
bool parse();
21+
bool isVerbose() const;
22+
int getRepeatCount() const;
23+
SimpleString getGroupFilter() const;
24+
SimpleString getNameFilter() const;
25+
bool isJUnitOutput() const;
26+
bool isEclipseOutput() const;
27+
const char* usage() const;
28+
29+
private:
30+
31+
enum OutputType
32+
{
33+
OUTPUT_ECLIPSE, OUTPUT_JUNIT
34+
};
35+
int ac;
36+
const char** av;
37+
TestPlugin* plugin_;
38+
39+
bool verbose_;
40+
int repeat_;
41+
SimpleString groupFilter_;
42+
SimpleString nameFilter_;
43+
OutputType outputType_;
44+
45+
SimpleString getParameterField(int ac, const char** av, int& i);
46+
void SetRepeatCount(int ac, const char** av, int& index);
47+
void SetGroupFilter(int ac, const char** av, int& index);
48+
void SetNameFilter(int ac, const char** av, int& index);
49+
bool SetOutputType(int ac, const char** av, int& index);
50+
51+
CommandLineArguments(const CommandLineArguments&);
52+
CommandLineArguments& operator=(const CommandLineArguments&);
53+
54+
};
55+
56+
#endif // D_CommandLineArguments_H
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the <organization> nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
17+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
#ifndef D_CommandLineTestRunner_H
29+
#define D_CommandLineTestRunner_H
30+
31+
#include "TestHarness.h"
32+
#include "TestOutput.h"
33+
#include "CommandLineArguments.h"
34+
35+
///////////////////////////////////////////////////////////////////////////////
36+
//
37+
// Main entry point for running a collection of unit tests
38+
//
39+
///////////////////////////////////////////////////////////////////////////////
40+
41+
class JUnitTestOutput;
42+
43+
#define DEF_PLUGIN_MEM_LEAK "MemoryLeakPlugin"
44+
#define DEF_PLUGIN_SET_POINTER "SetPointerPlugin"
45+
46+
class CommandLineTestRunner
47+
{
48+
public:
49+
enum OutputType
50+
{
51+
OUTPUT_NORMAL, OUTPUT_JUNIT
52+
};
53+
54+
static int RunAllTests(int ac, const char** av);
55+
static int RunAllTests(int ac, char** av);
56+
CommandLineTestRunner(int ac, const char** av, TestOutput*);
57+
58+
virtual ~CommandLineTestRunner();
59+
int runAllTestsMain();
60+
61+
private:
62+
63+
int argc;
64+
const char** argv;
65+
TestOutput* output_;
66+
JUnitTestOutput* jUnitOutput;
67+
CommandLineArguments* arguments;
68+
69+
bool parseArguments(TestPlugin*);
70+
int runAllTests();
71+
void initializeTestRun();
72+
bool isVerbose();
73+
int getRepeatCount();
74+
SimpleString getGroupFilter();
75+
SimpleString getNameFilter();
76+
};
77+
78+
#endif
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the <organization> nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
17+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
///////////////////////////////////////////////////////////////////////////////
29+
//
30+
// FAILURE.H
31+
//
32+
// Failure is a class which holds information for a specific
33+
// test failure. It can be overriden for more complex failure messages
34+
//
35+
///////////////////////////////////////////////////////////////////////////////
36+
37+
38+
#ifndef D_Failure_H
39+
#define D_Failure_H
40+
41+
#include "SimpleString.h"
42+
43+
class Utest;
44+
class TestOutput;
45+
46+
class Failure
47+
{
48+
49+
public:
50+
Failure(Utest*, const char* fileName, long lineNumber,
51+
const SimpleString& theMessage);
52+
Failure(Utest*, const SimpleString& theMessage);
53+
Failure(Utest*, const char* fileName, long lineNumber);
54+
Failure(const Failure&);
55+
virtual ~Failure();
56+
57+
virtual SimpleString getFileName() const;
58+
virtual SimpleString getTestName() const;
59+
virtual int getLineNumber() const;
60+
virtual SimpleString getMessage() const;
61+
62+
protected:
63+
SimpleString testName;
64+
SimpleString fileName;
65+
long lineNumber;
66+
SimpleString message;
67+
68+
Failure& operator=(const Failure&);
69+
70+
};
71+
72+
class EqualsFailure: public Failure
73+
{
74+
public:
75+
76+
EqualsFailure(Utest*, const char* fileName, long lineNumber,
77+
const SimpleString& expected, const SimpleString& actual);
78+
79+
private:
80+
EqualsFailure(const EqualsFailure&);
81+
EqualsFailure& operator=(const EqualsFailure&);
82+
};
83+
84+
class ContainsFailure: public Failure
85+
{
86+
public:
87+
88+
ContainsFailure(Utest*, const char* fileName, long lineNumber,
89+
const SimpleString& expected, const SimpleString& actual);
90+
91+
private:
92+
ContainsFailure(const ContainsFailure&);
93+
ContainsFailure& operator=(const ContainsFailure&);
94+
};
95+
96+
#endif
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the <organization> nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
17+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
#ifndef D_JUnitTestOutput_h
29+
#define D_JUnitTestOutput_h
30+
31+
#include "TestOutput.h"
32+
#include "SimpleString.h"
33+
34+
struct JUnitTestOutputImpl;
35+
struct JUnitTestCaseResultNode;
36+
37+
class JUnitTestOutput: public TestOutput
38+
{
39+
public:
40+
JUnitTestOutput();
41+
virtual ~JUnitTestOutput();
42+
43+
virtual void printTestsStarted();
44+
virtual void printTestsEnded(const TestResult& result);
45+
virtual void printCurrentTestStarted(const Utest& test);
46+
virtual void printCurrentTestEnded(const TestResult& res);
47+
virtual void printCurrentGroupStarted(const Utest& test);
48+
virtual void printCurrentGroupEnded(const TestResult& res);
49+
50+
virtual void verbose();
51+
virtual void print(const char*);
52+
virtual void print(long);
53+
virtual void print(const Failure& failure);
54+
virtual void printTestRun(int number, int total);
55+
56+
virtual void flush();
57+
58+
protected:
59+
60+
JUnitTestOutputImpl* impl_;
61+
void resetTestGroupResult();
62+
63+
virtual void openFileForWrite(const SimpleString& fileName);
64+
virtual void writeTestGroupToFile();
65+
virtual void writeToFile(const SimpleString& buffer);
66+
virtual void closeFile();
67+
68+
virtual void writeXmlHeader();
69+
virtual void writeTestSuiteSummery();
70+
virtual void writeProperties();
71+
virtual void writeTestCases();
72+
virtual void writeFailure(JUnitTestCaseResultNode* node);
73+
virtual void writeFileEnding();
74+
75+
};
76+
77+
#endif

0 commit comments

Comments
 (0)