mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-08-06 16:11:46 +02:00
Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
This commit is contained in:
75
vendor/POCO/CppUnit/doc/README.html
vendored
Normal file
75
vendor/POCO/CppUnit/doc/README.html
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
|
||||
<META NAME="Generator" CONTENT="Microsoft Word 97">
|
||||
<TITLE>CppUnit 1.5</TITLE>
|
||||
<META NAME="Template" CONTENT="C:\Program Files\MSOffice\Office\html.dot">
|
||||
</HEAD>
|
||||
<BODY LINK="#0000ff" VLINK="#800080">
|
||||
|
||||
<P><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"></P>
|
||||
<H1>CppUnit 1.5</H1>
|
||||
<P>Last Revision: 12/15/99 - Michael Feathers (mfeathers@acm.org) - written in standard C++, tested under Microsoft Visual C++ 6.0</P>
|
||||
<P><HR></P>
|
||||
<H3>Background</H3>
|
||||
<P>CppUnit is a simple unit test framework for C++. It is a port from JUnit, a testing framework for Java, developed by Kent Beck and Erich Gamma. </P>
|
||||
<H3>Contents</H3>
|
||||
<PRE>README.html this file
|
||||
|
||||
test the source code
|
||||
framework the testing framework
|
||||
		extensions	some framework extension classes
|
||||
textui a command line interface to run tests
|
||||
ms code for a Microsoft specific TestRunner
|
||||
samples some example test cases and extensions to the framework
|
||||
multicaster a sample illustrating a publish/subscribe
|
||||
				multicaster under test
|
||||
doc documentation</PRE>
|
||||
<H3>Installation</H3>
|
||||
<P>To use the test framework, create a makefile or load all files in test\framework into your IDE. In this incarnation of CppUnit, all includes assume the current directory first. A makefile or project can be used to resolve the dependencies. </P>
|
||||
<P>The directory test\textui contains a simple command line example that uses the framework.</P>
|
||||
<H3>Documentation</H3>
|
||||
<P>CppUnit comes with the following documentation: </P>
|
||||
|
||||
<UL>
|
||||
<LI>a cookbook: doc\cookbook.htm </LI>
|
||||
<LI>this file </LI></UL>
|
||||
|
||||
<H3>Samples</H3>
|
||||
<P>You can find several sample test cases in the samples directory: </P>
|
||||
|
||||
<UL>
|
||||
<LI>ExampleTestCase - some simple tests </LI>
|
||||
<LI>Multicaster - test cases for a sample publish/subscribe multicaster class </LI></UL>
|
||||
|
||||
<P>Also, the wiki page <a HREF="http://c2.com/cgi/wiki?ClassHierarchyTestingInCppUnit">http://c2.com/cgi/wiki?ClassHierarchyTestingInCppUnit</a> shows how to automatically apply tests of classes to the classes' subclasses.</P>
|
||||
|
||||
<H3>Extensions</H3>
|
||||
<P>You can find several classes that illustrate framework extensions in the extensions directory: </P>
|
||||
|
||||
<UL>
|
||||
<LI>TestDecorator - A Decorator for Test. You can use it as the base class for decorators that extend test cases. </LI>
|
||||
<LI>TestSetup - A Decorator that can be used to set up and tear down additional fixture state. Subclass TestSetup and insert it into your tests when you want to set up additional state once before the test is run. </LI>
|
||||
<LI>Orthodox - a template class which can be used to verify operations on an arbitrary class.</LI></UL>
|
||||
|
||||
|
||||
<H3>Notes</H3>
|
||||
<P>Porting this framework has been fun. I've tried to maintain the spirit and utility of JUnit in a C++ environment. Naturally, the move from Java to standard C++ forces out several nice JUnit features:</P>
|
||||
<OL>
|
||||
|
||||
<LI>Platform independent GUI.</LI>
|
||||
<LI>Stack traces of test failures</LI>
|
||||
<LI>Active (threaded) tests</LI>
|
||||
<LI>Direct invocation of test cases via reflection</LI>
|
||||
<LI>Run-time loading of new tests</LI></OL>
|
||||
|
||||
<P>In addition, the lack of garbage collection in C++ requires some careful use of the framework classes. In particular, TestSuites are composites that manage the lifetime of any tests added to them. Holding onto a TestResult past the lifetime of the tests which filled it is a bad idea. This is because TestResults hold TestFailures and TestFailures hold pointers to the Tests that generated them.</P>
|
||||
<P>On the plus side, we can use the C++ macro preprocessor to get the exact line at which a failure occurs, along with the actual text inside the assert () call that detected the failure. The features of C++ that enable this are the __LINE__ and __FILE__ preprocessor definitions, along with the <I>stringizing</I> operator. If you find that generating this much literal text bulks up your test executables, you can use the CPP_UNIT_SOURCEANNOT define to disable that portion of the reporting.</P>
|
||||
<P>Note: If you use the C++ macro "assert ()" in your code, or include assert.h, you may have a name clash with CppUnit's assert macro. This can be remedied by changing the name of the macro to "cu_assert ()" in TestCase.h.</P>
|
||||
<P>I'd like to thank Kent Beck and Erich Gamma for the inspiration, design, and a wonderful cookbook that was easily/shamelessly mutated to describe CppUnit. Double thanks to Erich for thinking up a way to implement TestCaller. Additional thanks to Kent, Ward Cunningham, Ron Jeffries, Martin Fowler, and several other netizens of the WikiWikiWeb. I don't think any other bunch of people could have convinced me that rapid development with unit tests can be both effective and easy.</P>
|
||||
<P>Thanks also to Fred Huls for mentioning the idea of template-based testing. The <EM>orthodox</EM> template class demonstrates only a small part of what can be done with templated test cases.</P>
|
||||
<H3>History Of Changes</H3>
|
||||
<P>1.2 -- Added the TestCaller template class. There is now no need to use the CPP_UNIT_TESTCASEDISPATCH macro unless you are using a C++ compiler which does not support templates well. CPP_UNIT_TESTCASEDISPATCH remains in TestCase.h for backward compatibility. I've also kept the use of the macro in the Multicaster sample to leave in an example.</P>
|
||||
<P>1.3 -- Retired the CPP_UNIT_TESTCASEDISPATCH macro and cleaned up the include structure. Fixed bug in the textui version.</P>
|
||||
<P>1.4 -- Removed using directives for std in CppUnit headers. Merged the old AssertionFailedError into CppUnitException. Fixed a memory leak in the TestRunner class of the MS GUI TestRunner. Removed CppUnit.h file. Now headers for each class must be included directly.</P></BODY></HTML>
|
||||
<P>1.5 -- Upgraded projects from VC++ 5.0 to 6.0.</P></BODY></HTML>
|
164
vendor/POCO/CppUnit/doc/cookbook.htm
vendored
Normal file
164
vendor/POCO/CppUnit/doc/cookbook.htm
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
|
||||
<META NAME="Generator" CONTENT="Microsoft Word 97">
|
||||
<TITLE>CppUnit Cookbook</TITLE>
|
||||
<META NAME="Template" CONTENT="C:\Program Files\MSOffice\Office\html.dot">
|
||||
</HEAD>
|
||||
<BODY LINK="#0000ff" VLINK="#800080">
|
||||
|
||||
<P><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"></P>
|
||||
<H1>CppUnit Cookbook</H1>
|
||||
<P>Here is a short cookbook to help you get started. </P>
|
||||
<H2>Simple Test Case</H2>
|
||||
<P>You want to know whether your code is working. How do you do it? There are many ways. Stepping through a debugger or littering your code with stream output calls are two of the simpler ways, but they both have drawbacks. Stepping through your code is a good idea, but it is not automatic. You have to do it every time you make changes. Streaming out text is also fine, but it makes code ugly and it generates far more information than you need most of the time.</P>
|
||||
<P>Tests in CppUnit can be run automatically. They are easy to set up and once you have written them, they are always there to help you keep confidence in the quality of your code.</P>
|
||||
<P>To make a simple test, here is what you do:</P>
|
||||
<P>Subclass the TestCase class. Override the method "runTest ()". When you want to check a value, call "assert (bool)" and pass in an expression that is true if the test succeeds. </P>
|
||||
<P>For example, to test the equality comparison for a Complex number class, write:</P>
|
||||
<TT><PRE>	class ComplexNumberTest : public TestCase {
|
||||
	public:
|
||||
ComplexNumberTest (string name) : TestCase (name) {}
|
||||
void runTest () {
|
||||
assert (Complex (10, 1) == Complex (10, 1));
|
||||
assert (!(Complex (1, 1) == Complex (2, 2)));
|
||||
}
|
||||
};</PRE>
|
||||
</TT><P>That was a very simple test. Ordinarily, you'll have many little test cases that you'll want to run on the same set of objects. To do this, use a fixture.</P>
|
||||
<P> </P>
|
||||
<H2>Fixture</H2>
|
||||
<P>A fixture is a known set of objects that serves as a base for a set of test cases. Fixtures come in very handy when you are testing as you develop. Let's try out this style of development and learn about fixtures along the away. Suppose that we are really developing a complex number class. Let's start by defining a empty class named Complex.</P>
|
||||
<TT><PRE>	class Complex {}; </PRE>
|
||||
</TT><P>Now create an instance of ComplexNumberTest above, compile the code and see what happens. The first thing we notice is a few compiler errors. The test uses operator==, but it is not defined. Let's fix that.</P>
|
||||
<TT><PRE>	bool operator== (const Complex& a, const Complex& b) { return true; }</PRE>
|
||||
</TT><P>Now compile the test, and run it. This time it compiles but the test fails. We need a bit more to get an operator== working correctly, so we revisit the code.</P>
|
||||
<TT><PRE>	class Complex {
|
||||
friend bool operator== (const Complex& a, const Complex& b);
|
||||
double real, imaginary;
|
||||
public:
|
||||
Complex () {
|
||||
real = imaginary = 0.0;
|
||||
}
|
||||
};
|
||||
|
||||
bool operator== (const Complex& a, const Complex& b)
|
||||
{ return eq(a.real,b.real) && eq(a.imaginary,b.imaginary); }</PRE>
|
||||
</TT><P>If we compile now and run our test it will pass. </P>
|
||||
<P>Now we are ready to add new operations and new tests. At this point a fixture would be handy. We would probably be better off when doing our tests if we decided to instantiate three or four complex numbers and reuse them across our tests. </P>
|
||||
<P>Here is how we do it:</P>
|
||||
<OL>
|
||||
|
||||
<LI>Add member variables for each part of the fixture </LI>
|
||||
<LI>Override "setUp ()" to initialize the variables </LI>
|
||||
<LI>Override "tearDown ()" to release any permanent resources you allocated in "setUp ()"</LI></OL>
|
||||
|
||||
<TT><PRE>	class ComplexNumberTest : public TestCase {
|
||||
	private:
|
||||
Complex 	*m_10_1, *m_1_1; *m_11_2;
|
||||
	protected:
|
||||
	void		setUp () {
|
||||
			 m_10_1 = new Complex (10, 1);
|
||||
			 m_1_1 = new Complex (1, 1);
|
||||
			 m_11_2 = new Complex (11, 2);
|
||||
}
|
||||
	void		tearDown () {
|
||||
			 delete m_10_1, delete m_1_1, delete m_11_2;
|
||||
			}
|
||||
	};</PRE>
|
||||
</TT><P>Once we have this fixture, we can add the complex addition test case any any others that we need over the course of our development.</P>
|
||||
<P> </P>
|
||||
<H2>Test Case</H2>
|
||||
<P>How do you write and invoke individual tests using a fixture? </P>
|
||||
<P>There are two steps to this process:</P>
|
||||
<OL>
|
||||
|
||||
<LI>Write the test case as a method in the fixture class</LI>
|
||||
<LI>Create a TestCaller which runs that particular method</LI></OL>
|
||||
|
||||
<P>Here is our test case class with a few extra case methods:</P>
|
||||
<TT><PRE>	class ComplexNumberTest : public TestCase {
|
||||
	private:
|
||||
Complex 	*m_10_1, *m_1_1; *m_11_2;
|
||||
	protected:
|
||||
	void		setUp () {
|
||||
			 m_10_1 = new Complex (10, 1);
|
||||
			 m_1_1 = new Complex (1, 1);
|
||||
			 m_11_2 = new Complex (11, 2);
|
||||
}
|
||||
	void		tearDown () {
|
||||
			 delete m_10_1, delete m_1_1, delete m_11_2;
|
||||
			}
|
||||
	void		testEquality () {
|
||||
			 assert (*m_10_1 == *m_10_1);
|
||||
			 assert (!(*m_10_1 == *m_11_2));
|
||||
			}
|
||||
	void		testAddition () {
|
||||
			 assert (*m_10_1 + *m_1_1 == *m_11_2);
|
||||
	}
|
||||
	};</PRE>
|
||||
</TT><P>Create and run instances for each test case like this:</P>
|
||||
<TT><PRE>	test = new TestCaller<ComplexNumberTest>("testEquality", ComplexNumberTest::testEquality);
|
||||
test->run (); </PRE>
|
||||
</TT><P>The second argument to the test caller constructor is the address of a method on ComplexNumberTest. When the test caller is run, that specific method will be run.</P>
|
||||
<P>Once you have several tests, organize them into a suite.</P>
|
||||
<P> </P>
|
||||
<H2>Suite</H2>
|
||||
<P>How do you set up your tests so that you can run them all at once?<BR>
|
||||
<BR>
|
||||
CppUnit provides a TestSuite class that runs any number of TestCases together. For example, to run a single test case, you execute:</P>
|
||||
<TT><PRE>	TestResult result;
|
||||
	TestCaller<ComplexNumberTest> test ("testAddition", ComplexNumberTest::testAddition);
|
||||
	Test.run (&result);</PRE>
|
||||
</TT><P> </P>
|
||||
<P>To create a suite of two or more tests, you do the following:</P>
|
||||
<TT><PRE>	TestSuite suite;
|
||||
	TestResult result;
|
||||
	suite.addTest (new TestCaller<ComplexNumberTest>("testEquality", ComplexNumberTest::testEquality));
|
||||
	suite.addTest (new TestCaller<ComplexNumberTest>("testAddition", ComplexNumberTest::testAddition));
|
||||
	suite.run (&result);
|
||||
</PRE>
|
||||
</TT><P>TestSuites don't only have to contain callers for TestCases. They can contain any object that implements the Test interface. For example, you can create a TestSuite in your code and I can create one in mine, and we can run them together by creating a TestSuite that contains both: </P>
|
||||
<TT><PRE>	TestSuite suite;
|
||||
	suite.addTest (ComplexNumberTest.suite ());
|
||||
	suite.addTest (SurrealNumberTest.suite ());
|
||||
	suite.run (&result);</PRE>
|
||||
</TT><P> </P>
|
||||
<H2>TestRunner</H2>
|
||||
<P>How do you run your tests and collect their results? </P>
|
||||
<P>Once you have a test suite, you'll want to run it. CppUnit provides tools to define the suite to be run and to display its results. You make your suite accessible to a TestRunner program with a static method <I>suite</I> that returns a test suite. <BR>
|
||||
For example, to make a ComplexNumberTest suite available to a TestRunner, add the following code to ComplexNumberTest: </P>
|
||||
<TT><PRE>	public: static Test *suite () {
|
||||
	 TestSuite *suiteOfTests = new TestSuite;
|
||||
	 suiteOfTests->addTest (new TestCaller<ComplexNumberTest>("testEquality", testEquality));
|
||||
	 suiteOfTests->addTest (new TestCaller<ComplexNumberTest>("testAddition", testAddition));
|
||||
return suiteOfTests;
|
||||
	}</PRE>
|
||||
</TT><P>CppUnit provides both a textual version of a TestRunner tool, and a Micosoft Visual C++ 5.0 graphical version. If you are running on another platform, take a look at the graphical version. It is easy to port.</P>
|
||||
<P>To use the text version, include the header file for the test in TestRunner.cpp:</P>
|
||||
<TT><PRE>	#include "ExampleTestCase.h"
|
||||
	#include "ComplexNumberTest.h"</PRE>
|
||||
</TT><P>And add a call to "addTest (string, Test *) in the "main ()" function:</P>
|
||||
<TT><PRE>	int main (int ac, char **av) {
|
||||
	 TestRunner runner;
|
||||
	 runner.addTest (ExampleTestCase::suite ());
|
||||
	 runner.addTest (ComplexNumberTest::suite ());
|
||||
	 runner.run ();
|
||||
	 return 0;
|
||||
	}</PRE>
|
||||
</TT><P>The TestRunner will run the tests. If all the tests pass, you'll get an informative message. If any fail, you'll get the following information:</P>
|
||||
<OL>
|
||||
|
||||
<LI>The name of the test case that failed</LI>
|
||||
<LI>The name of the source file that contains the test</LI>
|
||||
<LI>The line number where the failure occurred</LI>
|
||||
<LI>All of the text inside the call to assert which detected the failure</LI></OL>
|
||||
|
||||
<P>CppUnit distinguishes between <I>failures</I> and <I>errors</I>. A failure is anticipated and checked for with assertions. Errors are unanticipated problems like division by zero and other exceptions thrown by the C++ runtime or your code.</P>
|
||||
<P>If you are running MS Developer's Studio, you can build the GUI version rather easily. There are three projects: culib, TestRunner, and HostApp. They make a static library for the framework, a dialog based TestRunner in a DLL and an example Hosting application, respectively. To incorporate a TestRunner in an application you are developing, link with the static library and the TestRunner DLL. Note that the TestRunner DLL must be in the home directory of your application, the system directory or the path. In your application, create an instance of TestRunnerDlg whenever you want to run tests. Pass tests you want to run to the dialog object and then execute.</P>
|
||||
<P>Here is a screen shot of the TestRunner in use:</P>
|
||||
<P><IMG SRC="test.gif" WIDTH=574 HEIGHT=351></P>
|
||||
<P> </P>
|
||||
<P>More notes about the implementation of CppUnit can be found in README.HTML.</P>
|
||||
<P> </P>
|
||||
<P> </P></BODY>
|
||||
</HTML>
|
15
vendor/POCO/CppUnit/doc/license.htm
vendored
Normal file
15
vendor/POCO/CppUnit/doc/license.htm
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
|
||||
<META NAME="Generator" CONTENT="Microsoft Word 97">
|
||||
<TITLE>License Agreement</TITLE>
|
||||
<META NAME="Template" CONTENT="C:\Program Files\MSOffice\Office\html.dot">
|
||||
</HEAD>
|
||||
<BODY LINK="#0000ff" VLINK="#800080">
|
||||
|
||||
<P>Permission to reproduce and create derivative works from the Software ("Software Derivative Works") is hereby granted to you under the copyright of Michael Feathers. Michael Feathers also grants you the right to distribute the Software and Software Derivative Works. </P>
|
||||
<P>Michael Feathers licenses the Software to you on an "AS IS" basis, without warranty of any kind. Michael Feathers HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES OR CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, NON INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using the Software and assume all risks associated with the use and distribution of this Software, including but not limited to the risks of program errors, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. MICHAEL FEATHERS WILL NOT BE LIABLE FOR ANY DIRECT DAMAGES OR FOR ANY SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF MICHAEL FEATHERS HAD BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Michael Feathers will not be liable for the loss of, or damage to, your records or data, or any damages claimed by you based on a third party claim. </P>
|
||||
<P>You agree to distribute the Software and any Software Derivatives under a license agreement that: 1) is sufficient to notify all licensees of the Software and Software Derivatives that Michael Feathers assumes no liability for any claim that may arise regarding the Software or Software Derivatives, and 2) that disclaims all warranties, both express and implied, from Michael Feathers regarding the Software and Software Derivatives. (If you include this Agreement with any distribution of the Software and Software Derivatives you will have meet this requirement). You agree that you will not delete any copyright notices in the Software. </P>
|
||||
<P>This Agreement is the exclusive statement of your rights in the Software as provided by Michael Feathers. Except for the licenses granted to you in the second paragraph above, no other licenses are granted hereunder, by estoppel, implication or otherwise. <BR>
|
||||
</P></BODY>
|
||||
</HTML>
|
BIN
vendor/POCO/CppUnit/doc/test.gif
vendored
Normal file
BIN
vendor/POCO/CppUnit/doc/test.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
Reference in New Issue
Block a user