Skip to content

Incorporate changes from googlecode #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Jan 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
72c2581
Renamed files with + in them to be alphanumeric and baselined to roug…
pjohnmeyer Jan 10, 2013
67d4ecb
r3 | charles.nicholson | 2010-03-08 22:58:59 -0600 (Mon, 08 Mar 2010)…
pjohnmeyer Jan 10, 2013
4f556d6
r4 | charles.nicholson | 2010-03-08 23:23:36 -0600 (Mon, 08 Mar 2010)…
pjohnmeyer Jan 10, 2013
23c7368
r5 | charles.nicholson | 2010-03-15 17:46:01 -0500 (Mon, 15 Mar 2010)…
pjohnmeyer Jan 10, 2013
6712ae1
r6 | charles.nicholson | 2010-03-15 19:03:04 -0500 (Mon, 15 Mar 2010)…
pjohnmeyer Jan 10, 2013
ab8b818
r7 | charles.nicholson | 2010-03-16 16:18:18 -0500 (Tue, 16 Mar 2010)…
pjohnmeyer Jan 10, 2013
3a40aa8
r8 | charles.nicholson | 2010-03-16 21:27:33 -0500 (Tue, 16 Mar 2010)…
pjohnmeyer Jan 10, 2013
c8f551a
r9 | charles.nicholson | 2010-03-17 17:13:51 -0500 (Wed, 17 Mar 2010)…
pjohnmeyer Jan 10, 2013
bcde677
r10 | charles.nicholson | 2010-03-17 18:04:53 -0500 (Wed, 17 Mar 2010…
pjohnmeyer Jan 10, 2013
eebfcb4
r11 | charles.nicholson | 2010-03-17 18:49:54 -0500 (Wed, 17 Mar 2010…
pjohnmeyer Jan 10, 2013
b2e2959
r12 | charles.nicholson | 2010-03-17 18:59:25 -0500 (Wed, 17 Mar 2010…
pjohnmeyer Jan 10, 2013
946aa5e
r13 | charles.nicholson | 2010-03-17 19:05:19 -0500 (Wed, 17 Mar 2010…
pjohnmeyer Jan 10, 2013
b9825d1
r14 | charles.nicholson | 2010-03-17 19:39:17 -0500 (Wed, 17 Mar 2010…
pjohnmeyer Jan 10, 2013
c95e86c
r15 | charles.nicholson | 2010-03-17 20:08:52 -0500 (Wed, 17 Mar 2010…
pjohnmeyer Jan 10, 2013
637f00a
r16 | charles.nicholson | 2010-03-18 15:01:25 -0500 (Thu, 18 Mar 2010…
pjohnmeyer Jan 10, 2013
32288a5
r17 | charles.nicholson | 2010-03-18 15:01:48 -0500 (Thu, 18 Mar 2010…
pjohnmeyer Jan 10, 2013
88b09d4
r18 | charles.nicholson | 2010-03-18 15:42:23 -0500 (Thu, 18 Mar 2010…
pjohnmeyer Jan 10, 2013
a0501f6
r19 | charles.nicholson | 2010-03-18 16:22:06 -0500 (Thu, 18 Mar 2010…
pjohnmeyer Jan 10, 2013
534aca3
r20 | charles.nicholson | 2010-03-18 16:49:54 -0500 (Thu, 18 Mar 2010…
pjohnmeyer Jan 10, 2013
909f4b2
r21 | charles.nicholson | 2010-03-18 16:52:29 -0500 (Thu, 18 Mar 2010…
pjohnmeyer Jan 10, 2013
7b9e3a1
r22 | charles.nicholson | 2010-03-18 18:39:32 -0500 (Thu, 18 Mar 2010…
pjohnmeyer Jan 10, 2013
7510e7f
r23 | charles.nicholson | 2010-03-18 19:14:06 -0500 (Thu, 18 Mar 2010…
pjohnmeyer Jan 10, 2013
e427201
r24 | charles.nicholson | 2010-03-19 18:34:42 -0500 (Fri, 19 Mar 2010…
pjohnmeyer Jan 10, 2013
e92de84
r25 | charles.nicholson | 2010-03-22 14:01:16 -0500 (Mon, 22 Mar 2010…
pjohnmeyer Jan 10, 2013
3fe7f2f
r26 | charles.nicholson | 2010-03-22 14:16:24 -0500 (Mon, 22 Mar 2010…
pjohnmeyer Jan 10, 2013
f5ba405
r27 | charles.nicholson | 2010-03-25 15:45:52 -0500 (Thu, 25 Mar 2010…
pjohnmeyer Jan 10, 2013
57bf806
r28 | charles.nicholson | 2010-07-29 17:43:45 -0500 (Thu, 29 Jul 2010…
pjohnmeyer Jan 10, 2013
d286f58
r29 | charles.nicholson | 2010-07-30 12:44:06 -0500 (Fri, 30 Jul 2010…
pjohnmeyer Jan 10, 2013
3caf00b
r30 | charles.nicholson@gmail.com | 2010-07-30 16:09:20 -0500 (Fri, 3…
pjohnmeyer Jan 10, 2013
443b356
Fixed test failures in Streaming[Unsigned]LongLongWritesCorrectCharac…
pjohnmeyer Jan 10, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 100 additions & 96 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,96 +1,100 @@
CXX = g++
CXXFLAGS ?= -g -Wall -W -Winline -ansi
LDFLAGS ?=
SED = sed
MV = mv
RM = rm

.SUFFIXES: .o .cpp

lib = libUnitTest++.a
test = TestUnitTest++

src = src/AssertException.cpp \
src/Test.cpp \
src/Checks.cpp \
src/TestRunner.cpp \
src/TestResults.cpp \
src/TestReporter.cpp \
src/TestReporterStdout.cpp \
src/ReportAssert.cpp \
src/TestList.cpp \
src/TimeConstraint.cpp \
src/TestDetails.cpp \
src/MemoryOutStream.cpp \
src/DeferredTestReporter.cpp \
src/DeferredTestResult.cpp \
src/XmlTestReporter.cpp \
src/CurrentTest.cpp

ifeq ($(MSYSTEM), MINGW32)
src += src/Win32/TimeHelpers.cpp
else
src += src/Posix/SignalTranslator.cpp \
src/Posix/TimeHelpers.cpp
endif

test_src = src/tests/Main.cpp \
src/tests/TestAssertHandler.cpp \
src/tests/TestChecks.cpp \
src/tests/TestUnitTest++.cpp \
src/tests/TestTest.cpp \
src/tests/TestTestResults.cpp \
src/tests/TestTestRunner.cpp \
src/tests/TestCheckMacros.cpp \
src/tests/TestTestList.cpp \
src/tests/TestTestMacros.cpp \
src/tests/TestTimeConstraint.cpp \
src/tests/TestTimeConstraintMacro.cpp \
src/tests/TestMemoryOutStream.cpp \
src/tests/TestDeferredTestReporter.cpp \
src/tests/TestXmlTestReporter.cpp \
src/tests/TestCurrentTest.cpp

objects = $(patsubst %.cpp, %.o, $(src))
test_objects = $(patsubst %.cpp, %.o, $(test_src))
dependencies = $(subst .o,.d,$(objects))
test_dependencies = $(subst .o,.d,$(test_objects))

define make-depend
$(CXX) $(CXXFLAGS) -M $1 | \
$(SED) -e 's,\($(notdir $2)\) *:,$(dir $2)\1: ,' > $3.tmp
$(SED) -e 's/#.*//' \
-e 's/^[^:]*: *//' \
-e 's/ *\\$$//' \
-e '/^$$/ d' \
-e 's/$$/ :/' $3.tmp >> $3.tmp
$(MV) $3.tmp $3
endef


all: $(test)


$(lib): $(objects)
@echo Creating $(lib) library...
@ar cr $(lib) $(objects)

$(test): $(lib) $(test_objects)
@echo Linking $(test)...
@$(CXX) $(LDFLAGS) -o $(test) $(test_objects) $(lib)
@echo Running unit tests...
@./$(test)

clean:
-@$(RM) $(objects) $(test_objects) $(dependencies) $(test_dependencies) $(test) $(lib) 2> /dev/null

%.o : %.cpp
@echo $<
@$(call make-depend,$<,$@,$(subst .o,.d,$@))
@$(CXX) $(CXXFLAGS) -c $< -o $(patsubst %.cpp, %.o, $<)


ifneq "$(MAKECMDGOALS)" "clean"
-include $(dependencies)
-include $(test_dependencies)
endif
CXX = g++
CXXFLAGS ?= -g -Wall -W -Winline -ansi
LDFLAGS ?=
SED = sed
MV = mv
RM = rm

.SUFFIXES: .o .cpp

lib = libunittestpp.a
test = test-unittestpp

src = src/AssertException.cpp \
src/Test.cpp \
src/Checks.cpp \
src/TestRunner.cpp \
src/TestResults.cpp \
src/TestReporter.cpp \
src/TestReporterStdout.cpp \
src/ReportAssert.cpp \
src/TestList.cpp \
src/TimeConstraint.cpp \
src/TestDetails.cpp \
src/MemoryOutStream.cpp \
src/DeferredTestReporter.cpp \
src/DeferredTestResult.cpp \
src/XmlTestReporter.cpp \
src/CurrentTest.cpp \
src/CompositeTestReporter.cpp

ifeq ($(MSYSTEM), MINGW32)
src += src/Win32/TimeHelpers.cpp
else
src += src/Posix/SignalTranslator.cpp \
src/Posix/TimeHelpers.cpp
endif

test_src = src/tests/Main.cpp \
src/tests/TestAssertHandler.cpp \
src/tests/TestChecks.cpp \
src/tests/TestUnitTestPP.cpp \
src/tests/TestTest.cpp \
src/tests/TestTestResults.cpp \
src/tests/TestTestRunner.cpp \
src/tests/TestCheckMacros.cpp \
src/tests/TestTestList.cpp \
src/tests/TestTestMacros.cpp \
src/tests/TestTimeConstraint.cpp \
src/tests/TestTimeConstraintMacro.cpp \
src/tests/TestMemoryOutStream.cpp \
src/tests/TestDeferredTestReporter.cpp \
src/tests/TestXmlTestReporter.cpp \
src/tests/TestCurrentTest.cpp \
src/tests/TestCompositeTestReporter.cpp

objects = $(patsubst %.cpp, %.o, $(src))
test_objects = $(patsubst %.cpp, %.o, $(test_src))
dependencies = $(subst .o,.d,$(objects))
test_dependencies = $(subst .o,.d,$(test_objects))

define make-depend
$(CXX) $(CXXFLAGS) -M $1 | \
$(SED) -e 's,\($(notdir $2)\) *:,$(dir $2)\1: ,' > $3.tmp
$(SED) -e 's/#.*//' \
-e 's/^[^:]*: *//' \
-e 's/ *\\$$//' \
-e '/^$$/ d' \
-e 's/$$/ :/' $3.tmp >> $3.tmp
$(MV) $3.tmp $3
endef


all: $(test)


$(lib): $(objects)
@mkdir -p lib/win32_gcc_debug
@echo Creating $(lib) library...
@ar cr lib/win32_gcc_debug/$(lib) $(objects)

$(test): $(lib) $(test_objects)
@mkdir -p bin/win32_gcc_static_debug
@echo Linking $(test)...
@$(CXX) $(LDFLAGS) -o bin/win32_gcc_static_debug/$(test) $(test_objects) lib/win32_gcc_debug/$(lib)
@echo Running unit tests...
@bin/win32_gcc_static_debug/$(test)

clean:
-@$(RM) $(objects) $(test_objects) $(dependencies) $(test_dependencies) $(test) $(lib) 2> /dev/null

%.o : %.cpp
@echo $<
@$(call make-depend,$<,$@,$(subst .o,.d,$@))
@$(CXX) $(CXXFLAGS) -c $< -o $(patsubst %.cpp, %.o, $<)


ifneq "$(MAKECMDGOALS)" "clean"
-include $(dependencies)
-include $(test_dependencies)
endif
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Version 1.2 (2006-10-29)
- Added named test suites
- Added CHECK_ARRAY2D_CLOSE
- Posix library name is libUnitTest++.a now
- Floating point numbers are postfixed with f in the failure reports
- Floating point numbers are postfixed with 'f' in the failure reports

Version 1.1 (2006-04-18)
- CHECK macros do not have side effects even if one of the parameters changes state
Expand Down
2 changes: 1 addition & 1 deletion TestUnitTest++.vsnet2003.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
RelativePath=".\src\tests\TestTimeConstraintMacro.cpp">
</File>
<File
RelativePath=".\src\tests\TestUnitTest++.cpp">
RelativePath=".\src\tests\TestUnitTestPP.cpp">
</File>
<File
RelativePath=".\src\tests\TestXmlTestReporter.cpp">
Expand Down
2 changes: 1 addition & 1 deletion TestUnitTest++.vsnet2005.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
>
</File>
<File
RelativePath=".\src\tests\TestUnitTest++.cpp"
RelativePath=".\src\tests\TestUnitTestPP.cpp"
>
</File>
<File
Expand Down
2 changes: 1 addition & 1 deletion TestUnitTestPP_vs6.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion UnitTest++.vsnet2003.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
RelativePath=".\src\TimeHelpers.h">
</File>
<File
RelativePath=".\src\UnitTest++.h">
RelativePath=".\src\unittestpp.h">
</File>
<File
RelativePath=".\src\XmlTestReporter.cpp">
Expand Down
2 changes: 1 addition & 1 deletion UnitTest++.vsnet2005.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
>
</File>
<File
RelativePath=".\src\UnitTest++.h"
RelativePath=".\src\unittestpp.h"
>
</File>
<File
Expand Down
2 changes: 1 addition & 1 deletion UnitTestPP_vs6.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#ifndef UNITTEST_CONFIG_H
#define UNITTEST_CONFIG_H

// Standard defines documented here: http://predef.sourceforge.net

#if defined(_MSC_VER)
#pragma warning(disable:4702) // unreachable code
#pragma warning(disable:4722) // destructor never returns, potential memory leak

#if (_MSC_VER == 1200) // VC6
#pragma warning(disable:4786)
#pragma warning(disable:4290)
#endif

#ifdef _USRDLL
#define UNITTEST_WIN32_DLL
#endif
#define UNITTEST_WIN32
#endif

#if defined(unix) || defined(__unix__) || defined(__unix) || defined(linux) || \
defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
#define UNITTEST_POSIX
#endif

#if defined(__MINGW32__)
#define UNITTEST_MINGW
#endif


// MemoryOutStream is a custom reimplementation of parts of std::ostringstream.
// Uncomment this line to have MemoryOutStream implemented in terms of std::ostringstream.
// This is useful if you are using the CHECK macros on objects that have something like this defined:
// std::ostringstream& operator<<(std::ostringstream& s, const YourObject& value)

//#define UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM


// DeferredTestReporter uses the STL to collect test results for subsequent export by reporters like
// XmlTestReporter. If you don't want to use this functionality, uncomment this line and no STL
// headers or code will be compiled into UnitTest++

//#define UNITTEST_NO_DEFERRED_REPORTER


// By default, asserts that you report via UnitTest::ReportAssert() abort the current test and
// continue to the next one by throwing an exception, which unwinds the stack naturally, destroying
// all auto variables on its way back down. If you don't want to (or can't) use exceptions for your
// platform/compiler, uncomment this line. All exception code will be removed from UnitTest++,
// assert recovery will be done via setjmp/longjmp, and NO correct stack unwinding will happen!

//#define UNITTEST_NO_EXCEPTIONS

#endif
6 changes: 3 additions & 3 deletions docs/UnitTest++.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ <h3>Packaging</h3>
<p>You'll probably want to keep the generated library in a shared space in source control, so you can reuse it for multiple test projects. A redistributable package of UnitTest++ would consist of the generated library file, and all of the header files in <code>UnitTest++/src/</code> and its per-platform subfolders. The <code>tests</code> directory only contains the unit tests for the library, and need not be included.</p>

<h2>Using UnitTest++</h2>
<p>The source code for UnitTest++ comes with a full test suite written <em>using</em> UnitTest++. This is a great place to learn techniques for testing. There is one sample .cpp file: <code>UnitTest++/src/tests/TestUnitTest++.cpp</code>. It covers most of UnitTest++'s features in an easy-to-grasp context, so start there if you want a quick overview of typical usage.</p>
<p>The source code for UnitTest++ comes with a full test suite written <em>using</em> UnitTest++. This is a great place to learn techniques for testing. There is one sample .cpp file: <code>UnitTest++/src/tests/TestUnitTestPP.cpp</code>. It covers most of UnitTest++'s features in an easy-to-grasp context, so start there if you want a quick overview of typical usage.</p>

<h3>Getting started</h3>
<p>Listed below is a minimal C++ program to run a failing test through UnitTest++.</p>

<pre>
// test.cpp
#include &lt;UnitTest++.h&gt;
#include &lt;unittestpp.h&gt;

TEST(FailSpectacularly)
{
Expand All @@ -51,7 +51,7 @@ <h3>Getting started</h3>
}
</pre>

<p><code>UnitTest++.h</code> is a facade header for UnitTest++, so including that should get you all features of the library. All classes and free functions are placed in namespace <code>UnitTest</code>, so you need to either qualify their full names (as with <code>RunAllTests()</code> in the example) or add a <code>using namespace UnitTest;</code> statement in your .cpp files. Note that any mention of UnitTest++ functions and classes in this document assume that the <code>UnitTest</code> namespace has been opened.</p>
<p><code>unittestpp.h</code> is a facade header for UnitTest++, so including that should get you all features of the library. All classes and free functions are placed in namespace <code>UnitTest</code>, so you need to either qualify their full names (as with <code>RunAllTests()</code> in the example) or add a <code>using namespace UnitTest;</code> statement in your .cpp files. Note that any mention of UnitTest++ functions and classes in this document assume that the <code>UnitTest</code> namespace has been opened.</p>

<p>Compiling and linking this program with UnitTest++'s static library into an executable, and running it, will produce the following output (details may vary):</p>

Expand Down
25 changes: 4 additions & 21 deletions src/AssertException.cpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
#include "AssertException.h"
#include <cstring>

#ifndef UNITTEST_NO_EXCEPTIONS

namespace UnitTest {

AssertException::AssertException(char const* description, char const* filename, int lineNumber)
: m_lineNumber(lineNumber)
AssertException::AssertException()
{
using namespace std;

strcpy(m_description, description);
strcpy(m_filename, filename);
}

AssertException::~AssertException() throw()
{
}

char const* AssertException::what() const throw()
{
return m_description;
}

char const* AssertException::Filename() const
{
return m_filename;
}

int AssertException::LineNumber() const
{
return m_lineNumber;
}

}
#endif
Loading