Compare commits

...

279 commits
v1.4 ... master

Author SHA1 Message Date
Patrick Johnmeyer
10e50ad70c
Extend hiatus to 26 November 2020-11-12 23:26:38 -06:00
Patrick Johnmeyer
854cae2518
Extend hiatus to 15 October
See #180
2020-10-01 19:56:11 -05:00
Patrick Johnmeyer
37df68be21
Add hiatus note & link to issue 2020-08-17 19:53:58 -05:00
Patrick Johnmeyer
0ea55a251b
Merge pull request #173 from dhuantes/install-improvements
UnitTest++ now correctly supports CMake's find_package config mode
2020-04-18 19:17:46 -05:00
Dan Huantes
f871471d90 Added Namespace to Exported Target
[CMakeLists.txt]
- It is standard practice to have a namespace
for an imported target.  Added UnitTest++::
as the namespace argument so that
find_package(UnitTest++) will result in
UnitTest++::UnitTest++ target that will
be used in target_link_libraries.
- Updated target_link_libraries for
TestUnitTest++ as an example
2020-04-07 18:07:24 -05:00
Dan Huantes
c269666681 Version made explicitly 3 parts
- Updated to appveyor.yml and
configure.ac to 2.1.0 to
match CMake project version.
2019-10-17 08:23:46 -05:00
Patrick Johnmeyer
d355e127be
Merge pull request #172 from Flow86/patch-1
add support to build unittest cpp on AIX (IBM)
2019-10-15 21:27:12 -05:00
Dan Huantes
2423fcac76 CrasingTestsAreReportedAsFailures no longer core dumps on Clang Release
Found that Crashing tests at some point in Clang
history were actually caught but testing on
Clang 6.0 and Clang 7.0 this is not the case.
So added Clang to the list of compilers that
don't run this tests.  Noted that several
other Pull Requests were failing for the same
reason.
2019-08-15 08:30:43 -05:00
Dan Huantes
bdef2bdd62 UnitTest++ now correctly supports CMake's find_package config mode
[CMakeLists.txt]
- Bumped cmake minimum requirement to go to 3.0 as this
appears to be earliest version that transitive usage
requirements are supported.
- Added version to project so that is evident
when looking at CMakeLists.txt
- Removed include_directories as that command
affects more than just UnitTest++ in favor
of target_include_directories.
- The target_include_directories uses the
generator expressions to do the same thing
for the BUILD_INTERFACE condition but only
affects UnitTest++.  The INSTALL_INTERFACE
ensures that when UnitTest++ is installed
client applications calling find_package
for UnitTest++ only have to add the
UnitTest++ target to the target_link_libraries
and will get the correct include path
for UnitTest++ added to their include paths.
- Added DEBUG_POSTFIX to both library and
unit test to distinguish them from each other
as they are installed into the same directory
and would otherwise overwrite one another.
- Added Versioning using write_basic_package_version_file
to the install so that a client can call
find_package(UnitTest++ 2.1 REQUIRED) and it will be
able to confirm the version.  If the version is updated
you could theoretically ahve a version 2.2, 2.3 ,etc...
and the find_package mechanism will find the correct one.
the SameMajorVersion option in that call indicates
that 2.3 is compatible with 2.1 or in other words if
find_package(UnitTest++ 2.1 REQUIRED) is called and
2.3 is installed that satisfies the condition but
if only 3.0 was installed it will fail because of
'SameMajorVersion'.
- Also added installation for the Version file.
2019-08-15 07:26:45 -05:00
Flow86
a7d506d7eb
add support to build unittest cpp on AIX (IBM) 2019-03-20 13:19:15 +01:00
Patrick Johnmeyer
bc5d87f484 Merge pull request #161 from martinmoene/cmake
Use if (MSVC) as per issue #160
2017-07-08 10:06:47 -05:00
Martin Moene
a6fdaeef12 Use if (MSVC) as per issue #160 2017-07-08 11:09:38 +02:00
Patrick Johnmeyer
85b3666173 Merge pull request #149 from timdave13/patch-1
fix clang warnings
2017-07-07 23:16:00 -05:00
Patrick Johnmeyer
8c460c48e6 Merge pull request #141 from Reification/feature-MSVC-Clang
Feature msvc clang
2017-06-30 23:46:28 -05:00
Patrick Johnmeyer
65af507437 Merge pull request #155 from vicentebolea/adding-autogen-script
Added autogen.sh file to ease autotools installation
2017-06-30 23:35:29 -05:00
Patrick Johnmeyer
ee996164f2 Merge branch 'master' into feature-MSVC-Clang 2017-06-30 23:31:18 -05:00
Patrick Johnmeyer
af28992c5d Merge pull request #148 from cwilling/add-lib_dir
Add support for LIB_SUFFIX
2017-06-30 23:13:06 -05:00
Vicente Adolfo Bolea Sanchez
33e6314753 Added autogen.sh file to ease autotools installation 2017-05-22 00:22:38 +09:00
Tim Bochenek
07d4872076 fix clang warnings
fix clang warning warning: no previous extern declaration for non-static variable 'X' [-Wmissing-variable-declarations]
2017-02-03 08:19:17 -05:00
Gabriel Hare
0b15459ee4 Downgrade message to STATUS and do not declare C++11 as a requirement. 2017-02-02 21:56:48 -08:00
Tim Bochenek
0a6857e388 fix clang warning
fix clang warning 'extra ';' outside function is c++11 extension
2017-02-02 18:03:59 -05:00
timdave13
d7bd757862 fix clang warning
fix clang warning: 'X' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Wweak-vtables]
2017-02-02 17:14:27 -05:00
Christoph Willing
0757ba8f90
Add support for LIB_SUFFIX
Signed-off-by: Christoph Willing <chris.willing@iinet.net.au>
2017-01-23 17:49:12 +10:00
Patrick Johnmeyer
c331bb0dea Merge pull request #146 from iblis17/fbsd-cmake
cmake: fix pkgconfig dir path on FreeBSD
2017-01-19 19:00:12 -06:00
Iblis Lin
85bade33f5 cmake: fix pkgconfig dir path on FreeBSD 2017-01-14 23:00:24 +08:00
Patrick Johnmeyer
d0980fe7e2 Merge pull request #143 from unittest-cpp/v2-prep
v2.0.0 prep

Closes #96
2017-01-13 15:55:01 -06:00
Patrick Johnmeyer
615b6cdd0f Add note re: autotools to INSTALL file 2017-01-13 14:51:19 -06:00
Patrick Johnmeyer
8e5968bb05 Roll version number to 2.0.0 2017-01-13 14:38:23 -06:00
Patrick Johnmeyer
8d70dff05b Delete unused ChangeLog file
Closes #138
2017-01-13 14:38:07 -06:00
Patrick Johnmeyer
5e3b37825c Merge pull request #139 from edanaher/pkgconfig-with-cmake
Build pkgconfig file with CMake, not just with autoconf.

Fixes #89
2017-01-13 13:28:25 -06:00
Gabriel Hare
a2fe23887a Use “MATCHES” instead of “STREQUAL” to avoid ambiguous comparison.
NOTE: Unlike STREQUAL this comparison is supported pre and post CMake v3.1.0
2016-12-15 02:50:09 -08:00
Gabriel Hare
bb49539107 Revert "Increase CMake version to resolve developer warnings regarding implicit quoted dereference in STREQUAL comparison"
This reverts commit 8f7a263446.
2016-12-15 02:46:13 -08:00
Gabriel Hare
c4ab9d31ed Identify Clang compiler when used as an MSVC extension 2016-12-15 00:40:03 -08:00
Gabriel Hare
8f7a263446 Increase CMake version to resolve developer warnings regarding implicit quoted dereference in STREQUAL comparison 2016-12-15 00:31:56 -08:00
Gabriel Hare
9eba823269 Demonstrate that compiler is identified as MSVC when VS2014 Clang extension is used 2016-12-14 23:11:20 -08:00
Patrick Johnmeyer
478b6545b2 Merge pull request #135 from jumonatr/master
Update Docs Hash
2016-12-03 22:57:09 -06:00
Evan Danaher
40f90dc601 Build pkgconfig file with CMake, not just with autoconf. 2016-12-01 12:52:48 -05:00
Julien Monat Rodier
0d77b1ae10 Update docs reference to avoid bad path names on windows 2016-10-11 13:00:40 -07:00
Patrick Johnmeyer
d8e27e1825 Merge pull request #127 from pjohnmeyer/up_gcc_clang_warning_levels
Up non-MSVC warning levels
2016-08-30 20:45:40 -05:00
Patrick Johnmeyer
1d0e157c5a Merge pull request #126 from pjohnmeyer/up_msvc_warning_levels
Up MSVC warning levels
2016-08-30 20:45:20 -05:00
Patrick Johnmeyer
c431be9f94 Merge pull request #128 from killoctal/useSize_t
Use size_t for array or vector index
2016-08-30 20:44:49 -05:00
Gabriel Schlozer
eca039304b Used size_t for CHECK macros 2016-08-29 22:36:31 +02:00
Patrick Johnmeyer
7d7ba0aba4 Re-enable ignored-qualifiers warning and fix 2016-08-27 20:41:41 -05:00
Patrick Johnmeyer
e161d44077 Use CMake SET instead of string CONCAT
string(CONCAT...) was not available in older versions of CMake
targeted by this project.
2016-08-27 10:04:54 -05:00
Patrick Johnmeyer
2e2475fa54 Fix unused variable warnings 2016-08-27 09:55:37 -05:00
Patrick Johnmeyer
f0044e919d Up warning level to -Wall/extra/error for non-MSVC
UTPP_AMPLIFY_WARNINGS can be turned OFF to disable the new behavior.
2016-08-27 09:54:32 -05:00
Patrick Johnmeyer
7e4fff3bb4 Fix "assignment operator could not be generated" warning
This shows up with /W4 on MSVC. Fixes #107.
2016-08-27 08:27:15 -05:00
Patrick Johnmeyer
7c15942751 Up warning level to /W4 /WX for MSVC-like compilers
Also adds a CMake option, UTPP_AMPLIFY_WARNINGS, that can be turned
OFF to disable the new behavior.
2016-08-27 08:26:05 -05:00
Patrick Johnmeyer
83dbcc076d Merge pull request #115 from unittest-cpp/add_cmake_option_to_disable_running_tests_as_build_step
Add UTPP_INCLUDE_TESTS_IN_BUILD CMake option
2016-08-16 22:45:34 -05:00
Patrick Johnmeyer
097c71e6b8 Merge pull request #114 from unittest-cpp/long_and_short_macros
Long and short macros
2016-08-16 22:41:13 -05:00
Patrick Johnmeyer
77ae15ab8a Merge pull request #120 from pjohnmeyer/check_by_reference
Take UnitTest::Check parameter by const reference
2016-08-16 22:22:58 -05:00
Patrick Johnmeyer
6b69ed78ba Skip test build with same option as run
As part of this, changed the option name to
`UTPP_INCLUDE_TESTS_IN_BUILD`. The test target is still added to the
build and can be built/run separately using the CMake --target option.
2016-07-18 21:13:03 -05:00
Patrick Johnmeyer
14f317c40c Eliminate double-negative in option name / value
UTPP_SKIP_TESTS_AS_BUILD_STEP with a default value of OFF was an
unfortunate choice, so this changes it to UTPP_RUN_TESTS_AS_BUILD_STEP
with a default value of ON.
2016-07-18 20:49:18 -05:00
Patrick Johnmeyer
fa97152619 Add UTPP_SKIP_TESTS_AS_BUILD_STEP CMake option
Helps address #104.
2016-07-18 20:49:18 -05:00
Patrick Johnmeyer
de915185f6 Remove unused variable from test copy constructor 2016-07-15 23:58:48 -05:00
Patrick Johnmeyer
bec6ba56ec Attempted fix for Travis build. 2016-07-15 23:54:59 -05:00
Patrick Johnmeyer
21589e5612 Take UnitTest::Check parameter by const reference
Fixes #119 and #7
2016-07-15 23:23:45 -05:00
Patrick Johnmeyer
510903c880 Merge pull request #117 from korli/master
Add support for Haiku.
2016-07-15 22:58:31 -05:00
Patrick Johnmeyer
c7a9e7fd9e Merge pull request #116 from JonChesterfield/master
Prefix local variable message in CHECK macros with UnitTest_
2016-07-15 22:54:17 -05:00
Jerome Duval
053bcfc9c7 Add support for Haiku. 2016-06-03 13:13:33 +02:00
JonChesterfield
27317ec077 Prefix local variable message in CHECK macros with UnitTest_ to reduce the risk of name collisions with application code 2016-05-16 11:13:51 +01:00
Patrick Johnmeyer
910381fadc Change UNITTEST_ENABLE_SHORT_MACROS to DISABLE
Also add a test file.
2016-05-07 01:02:20 -05:00
Patrick Johnmeyer
df386f189f Add UNITTEST_ prefixes to remaining macros
TEST, SUITE, and REQUIRE macros now have UNITTEST_ and UNITTEST_IMPL_
prefixes like the others, completing the set.
2016-05-07 00:12:09 -05:00
Patrick Johnmeyer
c96bf52613 Replace UT_ macro prefix with UNITTEST_IMPL_
The UT_ prefix was primarily for "internal" macros. This commit seeks
to more consistently "namespace" UnitTest++ macros with the UNITTEST_
prefix, while also marking these particular macros as "private"
implementation details with the IMPL_ wart.
2016-05-06 23:57:59 -05:00
Patrick Johnmeyer
185b3d5086 Add UNITTEST_ versions of all CHECK macros
UNITTEST_ now prefixes the implementation of all CHECK macros.
Additionally, the build option UNITTEST_ENABLE_SHORT_MACROS can be
shut off, disabling the creation of the existing short forms. This is
helpful for users who may have conflicts with their projects or other
libs.
2016-05-06 23:44:02 -05:00
Patrick Johnmeyer
d220612eba Merge pull request #111 from unittest-cpp/v1.6.1-prep
v1.6.1 prep
2016-05-04 22:48:32 -05:00
Patrick Johnmeyer
782e620fbb Update versions to 1.6.1 2016-05-04 21:36:40 -05:00
Patrick Johnmeyer
1a62540b79 Determine autoconf package version from git tags 2016-05-04 21:30:44 -05:00
Patrick Johnmeyer
b7e0d70a63 Fix failures in make distcheck 2016-04-25 13:37:31 -05:00
Patrick Johnmeyer
90357e2138 Merge pull request #109 from bittwiddler1/master
autoconf & automake improvements
2016-04-19 22:13:28 -05:00
Patrick Johnmeyer
8973952bbe Merge pull request #106 from jasonhorsburgh/master
Add support for CMake find_package()

Fixes #99
2016-04-19 22:09:19 -05:00
Patrick Johnmeyer
032e495bba Merge branch 'master' of https://github.com/jasonhorsburgh/unittest-cpp into jasonhorsburgh-master
Conflicts:
	CMakeLists.txt
2016-04-19 22:08:24 -05:00
Patrick Johnmeyer
843d17398f Merge pull request #110 from stubb/patch-1
Fix spelling of UTPP_USE_PLUS_SIGN option comment.
2016-04-19 21:51:48 -05:00
bittwiddler1
791c37a9f1 Enabling silent build rules for automake 2016-04-16 19:12:21 -04:00
Kilian Köppchen
451ba1e2bc Fix spelling of UTPP_USE_PLUS_SIGN option comment. 2016-04-14 15:23:10 +02:00
bittwiddler1
2a806451b1 Comment changes
Making the comments more explicative and less opinionated. :)
2016-04-07 15:03:34 -04:00
Saul Beniquez
80d6bf7568 Better native OS detection using AC_CANONICAL_HOST. More information here: https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Canonicalizing.html 2016-04-07 14:56:31 -04:00
Saul Beniquez
8544b5b6be Fix for #105 - Automake improvements: fixing pkgincludedir. 2016-04-07 14:55:53 -04:00
Jason Horsburgh
e88121f69e Add support for CMake find_package()
Added export configuration for UnitTest++ target and installed the export and config file in libs/cmake/UnitTest++.
Added basic UnitTest++Config.cmake file which includes exported targets file and sets UTPP_INCLUDE_DIRS to the install location of the includes directory, this allows UnitTest++ to be used as a normal target in your own CMakeLists.txt file.

e.g.:

    find_package(UnitTest++ REQUIRED NO_MODULE)
    add_executable(foo ...)
    include_directories(${UTPP_INCLUDE_DIRS})
    target_link_libraries(foo UnitTest++)

which will ensure the library and installed headers paths are set up correctly for your own target.
2016-03-15 12:14:19 +00:00
Patrick Johnmeyer
b69b63ac2b Update docs, versions for 1.6.0. 2016-02-29 22:32:58 -06:00
Patrick Johnmeyer
13687226ed Merge pull request #101 from pjohnmeyer/add_more_vs_appveyor_configs
Fixes #86
2016-02-24 00:20:38 -06:00
Patrick Johnmeyer
6ce4bbe8d9 Use build_script instead of build for appveyor
Using build_script to run cmake --build fixes issues with msbuild
not always finding the correct file formats, etc.
2016-02-23 23:59:31 -06:00
Patrick Johnmeyer
8080a0c798 Fix CMAKE_GENERATOR values 2016-02-23 23:54:50 -06:00
Patrick Johnmeyer
5908e00efb Add forgotten quotes around CMAKE_GENERATOR 2016-02-23 23:49:15 -06:00
Patrick Johnmeyer
6c78c6ea2b Add more compilers to appveyor config 2016-02-23 23:45:52 -06:00
Patrick Johnmeyer
5ad8cd86c9 Add new tests to Makefile.am 2016-02-23 23:12:40 -06:00
Patrick Johnmeyer
240bf00f49 Merge branch 'paxos1977-paxos1977-pjohnmeyer-RequiredMacro' 2016-02-23 23:10:35 -06:00
Patrick Johnmeyer
898f18d799 Enable C++11 support in autoconf 2016-02-23 23:10:30 -06:00
Patrick Johnmeyer
962387ce5d Update autotools for new source files. 2016-02-23 23:10:29 -06:00
Austin Gilbert
0a99a9a5c9 Correcting RequiredCheckArrayCloseDoesNotHaveSideEffectsWhenPassing to exercise the passing case (per the UT name). 2016-02-23 23:10:29 -06:00
Patrick Johnmeyer
9fd7b2202e Merge pull request #98 from paxos1977/dev/FixingIncorrectUnitTest
Fixing a unit test that's exercising the wrong case
2016-02-23 22:45:42 -06:00
Patrick Johnmeyer
983a990484 Merge pull request #95 from pjohnmeyer/paxos1977-pjohnmeyer-RequiredMacro
Add REQUIRE macro for stopping tests early
2016-02-23 22:44:31 -06:00
Patrick Johnmeyer
073a1ea0e1 Enable C++11 support in autoconf 2016-02-23 21:44:25 -06:00
Patrick Johnmeyer
adebd8376a Update autotools for new source files. 2016-02-23 21:11:19 -06:00
Austin Gilbert
1c30bcd16b Correcting RequiredCheckArrayCloseDoesNotHaveSideEffectsWhenPassing to exercise the passing case (per the UT name). 2016-02-08 21:54:58 -06:00
Austin Gilbert
de385090d9 Merge branch 'dev/RequireMacroUsingLongjmp' into paxos1977-pjohnmeyer-RequiredMacro 2016-02-08 21:45:35 -06:00
Austin Gilbert
2e53a17d7e With code proposed in Pull Request #95, when UNITTEST_NO_EXCEPTIONS is defined, the definition for REQUIRE macro is empty.
This commit adds functionality for stopping unit tests early when UNITTEST_NO_EXCEPTIONS is defined via std::longjmp.
2016-02-08 21:38:56 -06:00
Austin Gilbert
4b0ac3f34a UT_RETHROW needed to take an argument when UNITTEST_NO_EXCEPTIONS=1. 2016-02-08 21:36:05 -06:00
Austin Gilbert
7a68264b0f Renaming tests/TestRequireMacros.cpp -> tests/TestRequireMacrosWithExceptionsOn.cpp, testing REQUIRE with exceptions turned off will require a significantly different approach. 2016-02-08 19:11:05 -06:00
Austin Gilbert
cd34fffa40 Merge remote-tracking branch 'pj/paxos1977-pjohnmeyer-RequiredMacro' into paxos1977-pjohnmeyer-RequiredMacro 2016-02-08 18:09:11 -06:00
Patrick Johnmeyer
6bb9541ae2 Fix warnings, errors, 2x error reporting in MSVC
Visual Studio 2015 complained about calling UT_THROW with zero arguments.
Visual Studio 6 complained about calling UT_CATCH with an empty second
argument. For these cases, I added UT_RETHROW(ExceptionName).

I also added a catch of RequiredCheckException to ExecuteTest to avoid
two error messages on each failed REQUIRE check.
2016-02-06 22:04:52 -06:00
Patrick Johnmeyer
3f5095ba13 Eliminate some single-line if statements. 2016-02-06 09:30:15 -06:00
Patrick Johnmeyer
5eec0a255f Simplify required check reporter interactions
Was able to remove ThrowingTestReporter::SetDecorated and
::GetDecorated by changing RequiredCheckTestReporter to accept
its TestResults by reference. This simple change removed
several if-checks and some functions.
2016-02-06 09:30:15 -06:00
Patrick Johnmeyer
57fc32c114 Change camelCase methods to PascalCase 2016-02-06 09:30:15 -06:00
Patrick Johnmeyer
40b8f0b17b Use new RequiredCheckException for REQUIRE
Rather than re-using AssertException, it felt more correct to
create a new special-purpose exception.
2016-02-06 09:30:15 -06:00
Patrick Johnmeyer
74ca0c301f Merge and uncrustify. 2016-02-06 09:30:06 -06:00
Austin Gilbert
89ff2596ee Eliminating 'unused exception variable' warnings. 2016-02-06 09:30:05 -06:00
Austin Gilbert
a9161c1ba6 This commit addresses two issues:
(1) unreachable code in for loop shenanigans is eliminated.
(2) code after a failing REQUIRE check no longer executes. Used a
    decorating TestReporter to achive this.
2016-02-06 09:29:38 -06:00
Patrick Johnmeyer
06308ee802 Use for loop to achieve REQUIRE with no parens
I changed the definition of the REQUIRE macro to use for loops and
some comma operator shenanigans to allow things like:

    REQUIRE
    {
      CHECK(...);
      CHECK_EQUAL(..., ...);
    }

or

    REQUIRE CHECK(...);

I updated the tests and they all passed on my machine. My only
concern is that some compilers might complain about the unreachable
code in the (throw UnitTest::AssertException(), true) expression.
2016-02-06 09:28:48 -06:00
Austin Gilbert
e7b56d4e3c Introducing additional functionality to allow client code to stop a unit
test when an assert fails.

The following macro has been added:

	REQUIRE

An example of when these type of checks are useful:

    std::vector<int> v = foo();

    REQUIRE(CHECK_EQUAL(3, v.size())); // test stops here on a fail
                                       // so we don't segfault looking at
                                       // v[0] below.
    CHECK_EQUAL(1, v[0]);
    CHECK_EQUAL(2, v[1]);
    CHECK_EQUAL(3, v[2]);

Multiple checks are supported as follows:

    REQUIRE({
        CHECK_EQUAL(1, 2);
        CHECK(true);
    };

In the multiple check scenario, all the checks in the REQUIRE block will
be run. After which, if any failures were reported, the TEST case will
be stopped.

When UNITTEST_NO_EXCEPTIONS is defined, REQUIRE is a noop.
2016-02-06 09:28:48 -06:00
Patrick Johnmeyer
5b34768df0 Prepare v1.5.1 tag 2016-01-29 23:24:21 -06:00
Patrick Johnmeyer
353d3989d3 Delete straggling .vcproj files. 2016-01-29 23:10:38 -06:00
Patrick Johnmeyer
6bfab53a64 Merge pull request #93 from unittest-cpp/uncrustify
Make formatting more consistent
2016-01-29 23:09:26 -06:00
Patrick Johnmeyer
bb7555c718 Tweak preprocessor blocks. 2016-01-29 22:48:36 -06:00
Patrick Johnmeyer
f82c403768 Change preprocessor indent rules. 2016-01-29 22:22:37 -06:00
Patrick Johnmeyer
b47b4f7e85 Add uncrustify config and run first pass. 2016-01-29 22:15:10 -06:00
Patrick Johnmeyer
6e1d0f48ab Fix comment in TestTestRunner.cpp
"Self-recursive" didn't make much sense.
2016-01-29 20:05:53 -06:00
Patrick Johnmeyer
7186084dd8 Merge pull request #92 from unittest-cpp/issue90
Reduce possible timing test failures
2016-01-29 20:03:48 -06:00
Patrick Johnmeyer
44aa33b02b Reduce possible timing test failures
TestFinishIsCalledWithCorrectTime was reliant on SleepMs(20) waking
up before a certain threshold was hit, which is not reliable. This
change uses the actual time of running tests as the top threshold;
not a great improvement but a good quick fix.

Fixes #90
2016-01-29 19:50:23 -06:00
Patrick Johnmeyer
2fc284af64 Merge pull request #87 from rmpowell77/fix-sign-conversion
Adding an explicit cast for the conversion from int to useconds_t in TimeHelpers:::SleepMS.

Fixes #88
2016-01-29 19:32:41 -06:00
Richard Powell
014d6e48f8 adding an explicit cast for the conversion from int to useconds_t in TimeHelpers::SleepMS. 2015-12-16 06:53:06 -08:00
Patrick Johnmeyer
540f6615fb Merge pull request #85 from grahamreeds/master
Removed conditional compile around FixtureDtorThrows structure. Added…
2015-11-17 00:11:30 -06:00
grahamreeds
4fccb76875 Removed conditional compile around FixtureDtorThrows structure. Added a preprocessor block for _MSC_VER noexcept support. 2015-11-12 12:01:07 +00:00
Patrick Johnmeyer
24061e420c Merge pull request #71 from LocutusOfBorg/add-pkgconfig
Add pkg-config file
2015-11-04 20:18:44 -06:00
Patrick Johnmeyer
c5a3903bf9 Prepare v1.5.0 tag. 2015-11-04 12:04:13 -06:00
Patrick Johnmeyer
dc6b908380 Merge pull request #78 from Microsoft/vs2015Support
Vs2015 support
2015-10-15 22:20:22 -05:00
Anna Gringauze
0a14abb0a5 Added support for VS2015 2015-09-22 07:36:28 -07:00
Gianfranco Costamagna
5e52ae70dc
Add pkg config file (with help from Vicente Adolfo Bolea Sánchez) 2015-09-22 08:34:51 +02:00
Patrick Johnmeyer
dab64862c4 Merge pull request #77 from paxos1977/Issue76
Disable tests in TestTestMacros.cpp which throw exceptions from destructors
2015-09-21 22:54:39 -05:00
Patrick Johnmeyer
8741891f85 Merge pull request #69 from bittwiddler1/master
Adding conditional automake directives to allow Win32 compilation on win...
2015-09-21 22:19:05 -05:00
Austin Gilbert
c4e36176d9 Disable tests in TestTestMacros.cpp which throw exceptions from user
defined destructors.

In accordance with the C++11 standard, Visual Studio 2015 adds an implicit
'noexcept' to all user defined destructors. Any destructor throwing an
exception causes abort() to be called on the process.

This commit fixes #76.
2015-09-17 17:28:44 -05:00
Patrick Johnmeyer
ae24d94242 Add travis and appveyor badges to README.md 2015-07-14 20:58:37 -05:00
Patrick Johnmeyer
67013d4b88 Add tiny comment change to trigger Travis. 2015-07-14 20:49:26 -05:00
Patrick Johnmeyer
ab716658dc Merge pull request #70 from hymerman/continuous-integration
Continuous integration
2015-07-14 20:43:29 -05:00
Ben Hymers
76e9982dd4 Add Travis CI configuration file, .travis.yml
Builds using CMAKE then GCC and Clang, in Debug and Release configurations
2015-04-27 09:09:35 +01:00
Ben Hymers
4b8d3a7418 Add AppVeyor configuration file, appveyor.yml
Builds project files with cmake, then builds those with VS2013.
OS is Windows Server 2012.
Debug and Release configurations are both built.
2015-04-27 08:52:29 +01:00
Patrick Johnmeyer
edf1e370ef Updating docs submodule reference. 2015-04-25 02:30:22 -05:00
Saul Beniquez
2d493d8020 Using the $host variable to detect win32 compilers.
This is a more portable solution for platform detection in autoconf.

Tested on Linux, Cygwin and Cygwin-to-Mingw32 cross-compilation.
2015-04-19 18:48:56 -04:00
Saul Beniquez
c0e97bf082 [UnitTest++] Removing a spurrious UnitTest___libUnitTest___la_CPPFLAGS assignment 2015-04-07 12:48:47 -04:00
Saul Beniquez
9257dc7feb Removing duplicated UNITTEST_POSIX #define from cmdline -D flags 2015-04-07 09:34:52 -04:00
Saul Beniquez
7549615b31 Adding conditional automake directives to allow Win32 compilation on win32-mingw/cygwin-mingw systems. 2015-04-07 08:46:20 -04:00
Patrick Johnmeyer
53598bdeb6 Update wiki docs submodule. 2015-04-04 01:58:43 -05:00
Patrick Johnmeyer
2ee151af76 Change unit tests to run as post-build step.
This is how it used to be in most of the old project files. The
CMake conversion required the tests to be run manually after the
build, either by running the binary directly or by calling CTest.
This commit removes the 'dependency' on CTest and restores the
old build process.
2015-04-04 01:31:04 -05:00
Patrick Johnmeyer
bd11339b2d Disable CrashingTests... in debug.
After some consideration I decided to just remove this test in debug
configurations. Many debuggers will behave as XCode does and try to
'catch' this by default. The test still works in release configs.

Fixes #45.
2015-04-04 00:56:40 -05:00
Patrick Johnmeyer
d310c03eea Add missing headers to Makefile.
Closes #42.
2015-04-03 23:27:32 -05:00
Patrick Johnmeyer
db377423a3 Update AUTHORS and configure.ac
AUTHORS now references readme.md for the contributor list
and identifies pjohnmeyer@gmail.com as the maintainer.

configure.ac was modified to version 1.4.1 to differentiate
between 1.4 and HEAD, and to prepare for the upcoming 1.5.

Fixes #55.
2014-12-19 11:51:26 -06:00
Patrick Johnmeyer
59f2f901a3 Merge pull request #61 from pjohnmeyer/remove_project_files
Remove VS and XCode project files.

Resolves #47 and relates to #42.
2014-11-14 22:27:33 -06:00
Patrick Johnmeyer
19fd65743b Remove lurking tests/*.vcproj files. 2014-11-08 00:24:51 -06:00
Patrick Johnmeyer
493c05527e Remove all Visual Studio 6 project files. 2014-11-07 23:49:58 -06:00
Patrick Johnmeyer
719a6e4bf5 Remove vs_projects and xcode_projects 2014-11-07 23:47:37 -06:00
Patrick Johnmeyer
1fe3d72776 Reformatted code from #54. 2014-06-27 22:42:53 -05:00
Patrick Johnmeyer
7459844be1 Merge branch 'novawave-master' 2014-06-27 22:37:25 -05:00
Nathan Lapierre
6ea2db4cb1 keep absolute path 2014-06-05 02:07:49 -03:00
Nathan Lapierre
7b47f1c59a fix broken tests 2014-06-05 02:06:44 -03:00
Patrick Johnmeyer
f250db3376 Merge pull request #53 from warmist/patch-1
Fix crash bug in msvc
2014-01-15 19:58:20 -08:00
warmist
1fdc44246d Fix crash bug in msvc
fprintf had incorrect number of arguments.
2014-01-06 14:02:59 +02:00
Patrick Johnmeyer
311f4df4eb Replace absolute paths with relative paths in Visual Studio project files (untested). 2013-08-23 22:36:50 -05:00
Patrick Johnmeyer
04a6094d63 Merge pull request #48 from magicant/autotools
Fix autotools configuration
2013-07-22 07:13:26 -07:00
Patrick Johnmeyer
4661f377da Merge pull request #46 from lijoantony/master
Integrating test failures into QTCreator IDE build errors
2013-07-22 07:12:57 -07:00
WATANABE Yuki
cda955dee4 Fix autotools configuration
* Add some headers to the list of installed files.
* Specify the "foreign" strictness so that automake does not complain
  about missing files.
* Specify a directory for m4 macros as suggested by libtoolize.
* Add autotools-generated files to gitignore.
2013-07-20 13:27:19 +09:00
Patrick Johnmeyer
cc3fbd8e0b Merge pull request #43 from martinmoene/master
Add changes required to compile with MS VC6
2013-07-01 22:34:34 -07:00
Lijo Antony
bd1239bff7 Integrating test failure in to QtCreator IDE build errors 2013-06-09 23:48:16 +04:00
Martin Moene
65d2e03ec9 Adapt MemoryOutStream for VC6 __int64 type 2013-05-10 11:32:15 +02:00
Martin Moene
424918c2d5 Merge remote-tracking branch 'remotes/upstream/master' 2013-05-09 14:40:52 +02:00
Patrick Johnmeyer
49fb0ce68a Add 'empty' builds directory per the wiki. (The folder is not actually empty as it includes a .gitignore.) 2013-05-09 07:17:00 -05:00
Martin Moene
23127fe5b9 Add changes required to compile with MS VC6
Add macro UNITTEST_COMPILER_IS_MSVC6
Add macro UNIITEST_NS_QUAL_STD(fun)
Avoid __pragma()
Skip tests with long long
2013-05-09 11:12:29 +02:00
Patrick Johnmeyer
b8cd1d300b Fix spelling error in README 2013-05-08 23:34:47 -05:00
Patrick Johnmeyer
15f1688bdd Merge pull request #41 from pjohnmeyer/documentationUpdates
Documentation updates from my repository. Further doc updating will be done directly on master.
2013-05-08 21:31:50 -07:00
Patrick Johnmeyer
315535bbef Incorporate latest wiki docs. 2013-05-08 23:22:20 -05:00
Patrick Johnmeyer
20f1ccd20f Incorporate new commits in wiki. 2013-05-08 23:13:57 -05:00
Patrick Johnmeyer
a0badc46e8 Add link to contributor graph under 'Contributors'. 2013-05-08 22:45:11 -05:00
Patrick Johnmeyer
b10efb4ca4 Add Documentation, Pre-requisites, and Downloading instructions to main README. 2013-05-08 22:38:43 -05:00
Patrick Johnmeyer
71f986568e Add https://github.com/unittest-cpp/unittest-cpp.wiki.git as submodule 'docs'. 2013-05-08 22:24:22 -05:00
Patrick Johnmeyer
db52c49adc Remove old docs folder. 2013-05-08 22:19:41 -05:00
Patrick Johnmeyer
c342726312 Merge pull request #40 from chris-frederick/xcode_project
Add Xcode 4.6 project
2013-05-03 07:23:21 -07:00
Christopher Frederick
c3e4f2b8cb Update TestUnitTest++ to use existing code
- Add files from the tests directory
- Add $(SRCROOT)/../../ to the include paths
- Link to libUnitTest++.a
- Remove the TestUnitTest++ group (with main.cpp and TestUnitTest__.1)
  that was automatically generated by Xcode
2013-04-18 11:47:31 +09:00
Christopher Frederick
532914d9b5 Add a target for TestUnitTest++
TestUnitTest++ is a command-line tool.
2013-04-18 11:47:01 +09:00
Christopher Frederick
c74f0cfb80 Add UnitTest++ source to the project 2013-04-18 11:47:01 +09:00
Christopher Frederick
03503dbeb8 Add a new Xcode 4.6 project 2013-04-18 11:46:31 +09:00
Christopher Frederick
f9cfd92f8c Add .gitignore for Xcode projects 2013-04-18 10:45:03 +09:00
Patrick Johnmeyer
d233fbc176 Remove COPYING inadvertently merged from #38 2013-04-10 22:28:43 -05:00
Victor Lavaud (qdii)
0e306b25db Added license (MIT) 2013-03-29 21:03:46 +01:00
Victor Lavaud (qdii)
e90b9e5a63 Fixed autotools 2013-03-29 20:59:47 +01:00
Patrick Johnmeyer
5caa8265d0 Merge pull request #35 from pjohnmeyer/master
Visual Studio 2003, 2005, 2008, 2010, 2012 support
2013-03-24 00:34:27 -07:00
Patrick Johnmeyer
d761d7d7b8 Remove old Visual Studio 2003 project files. 2013-03-24 02:14:53 -05:00
Patrick Johnmeyer
6824ef6f6d Remove missed Visual Studio 2005 file. 2013-03-24 02:14:44 -05:00
Patrick Johnmeyer
caa4df97b0 Generate new Visual Studio 2003 projects. 2013-03-24 02:13:59 -05:00
Patrick Johnmeyer
c39d185b23 Remove old Visual Studio 2005 projects. 2013-03-24 02:09:19 -05:00
Patrick Johnmeyer
90c1b7a3b7 Generate new Visual Studio 2005 projects. 2013-03-24 02:08:36 -05:00
Patrick Johnmeyer
d4551abf58 Remove old TestUnitTest++ 2010 project files. 2013-03-24 01:46:31 -05:00
Patrick Johnmeyer
aaf008f458 Generate new Visual Studio 2008 projects. 2013-03-24 01:46:01 -05:00
Patrick Johnmeyer
77e92e35ad Generate new Visual Studio 2010 projects. 2013-03-24 01:35:33 -05:00
Patrick Johnmeyer
500bb6ef7d Add strip_cmake.bat for deleting "extra" files generated by CMake.
Note that the solutions/workspaces generated for Visual Studio, by
default, will still have the extra projects in them. They must be
deleted from the project before running this strip_cmake.bat.

TODO: Teach strip_cmake.bat how to actually strip the offending
projects from the solutions/workspaces.
2013-03-24 01:31:51 -05:00
Patrick Johnmeyer
11405eee0f Add *.bat as eol=crlf. 2013-03-24 01:31:40 -05:00
Patrick Johnmeyer
ce196f218a Add support and project files for Visual Studio 2012 2013-03-24 01:13:10 -05:00
Patrick Johnmeyer
c13d2471e9 Merge pull request #34 from pjohnmeyer/version1.4CompatibilityFixes
Address multiple version 1.4 incompatibilities
2013-03-23 21:07:52 -07:00
Patrick Johnmeyer
c23edddd15 - Fixed include path in CMakeLists.txt 2013-03-23 22:24:57 -05:00
Patrick Johnmeyer
57e049c523 Add Markdown formatting to README.md 2013-02-20 23:04:28 -06:00
Patrick Johnmeyer
e5d732991c Rename README to README.md 2013-02-20 23:04:14 -06:00
Patrick Johnmeyer
e239750813 Delete COPYING (previously renamed to LICENSE). 2013-02-20 22:59:33 -06:00
Patrick Johnmeyer
647ce0a491 Rename COPYING to LICENSE; delete NEWS since it was empty anyway. 2013-02-20 22:59:01 -06:00
Patrick Johnmeyer
859e6250d2 Move src to UnitTest++ and move src/tests to tests.
CMakeLists was modified to support this, then include paths for the
test executable also had to be modified to include UnitTest++.
2013-02-20 00:22:14 -06:00
Patrick Johnmeyer
deb7e2736d Ensure all headers, including platform, are being installed. 2013-02-20 00:13:07 -06:00
Patrick Johnmeyer
0f8d425de7 Move config.h to src/Config.h.
This is a 1.4 compatibility and consistency change.
2013-02-20 00:01:55 -06:00
Patrick Johnmeyer
c3aa1e45a8 Move unittestpp.h to src/UnitTestPP.h and add src/UnitTest++.h.
This is a 1.4 compatibility and consistency fix.
2013-02-19 23:56:22 -06:00
Patrick Johnmeyer
13a6c9e6ad Add install targets and install path customization.
This commit adds install() directives to the CMake file. By default,
headers will be installed to CMAKE_INSTALL_PREFIX/include/UnitTest++
and libUnitTest++.a will be installed to CMAKE_INSTALL_PREFIX/lib.

If the user defines UTPP_USE_PLUS_SIGN=OFF when generating, the ++
will be replaced with PP in both the library file name and the
include path.
2013-02-19 23:35:10 -06:00
Patrick Johnmeyer
c702d69a85 Revert "Add install targets and install path customization."
This reverts commit 1fa77e11c6.
2013-02-19 23:33:33 -06:00
Patrick Johnmeyer
8a58afab17 Add install targets and install path customization.
This commit adds install() directives to the CMake file. By default,
headers will be installed to CMAKE_INSTALL_PREFIX/include/UnitTest++
and libUnitTest++.a will be installed to CMAKE_INSTALL_PREFIX/lib.

If the user defines UTPP_USE_PLUS_SIGN=OFF when generating, the ++
will be replaced with PP in both the library file name and the
include path.
2013-02-19 23:26:18 -06:00
Patrick Johnmeyer
b840df2d0d Change default MemoryOutStream to be a std::ostringstream.
This changes restores the default behavior to that of UT++ 1.4.

It is accomplished by reintroducing the old UNITTEST_USE_CUSTOM_STREAMS
define, commented out, and surrounding the new define in an ifndef
block. It was done this way to preserve any unconventional users that
were specifying either flag in their build system, instead of in this
file.
2013-02-19 22:23:26 -06:00
Patrick Johnmeyer
0c329ad8c2 Merge pull request #33 from pjohnmeyer/addingWhatToCheckMessages
Add .what() to check messages for unhandled std::exceptions.

Adds a `UT_CATCH(std::exception...)` block to:

    CHECK
    CHECK_EQUAL
    CHECK_CLOSE
    CHECK_ARRAY_CLOSE
    CHECK_ARRAY_EQUAL
    CHECK_ARRAY2D_CLOSE

Closes #11.
2013-02-19 19:58:59 -08:00
Patrick Johnmeyer
299df3efe5 Group all exception tests into suites and normalize indentation. 2013-02-19 21:46:40 -06:00
Patrick Johnmeyer
4a95a3473a Add .what() to error reporting for std::exceptions in CHECK_ARRAY2D_CLOSE. 2013-02-19 21:40:38 -06:00
Patrick Johnmeyer
af9d91d16b Add .what() to error reporting for std::exceptions in CHECK_ARRAY_EQUAL. 2013-02-19 21:20:34 -06:00
Patrick Johnmeyer
17293bf412 Add .what() to error reporting for std::exceptions in CHECK_ARRAY_CLOSE. 2013-02-17 22:46:04 -06:00
Patrick Johnmeyer
858fa04977 Refactor TestExceptions CheckClose tests to use a fixture and add additional tests for std:: exceptions. 2013-02-17 22:23:59 -06:00
Patrick Johnmeyer
3d1e3324d2 Refactor TestExceptions CheckEqual tests to use a fixture and add additional tests for std:: exceptions. 2013-02-17 22:17:35 -06:00
Patrick Johnmeyer
7e97b46aa4 Improve CheckFixture method names.
Rename `CheckFixture::Throw` to `CheckFixture::PerformCheckWithNonStdThrow`.
Rename `CheckFixture::StdThrow` to CheckFixture::PerformCheckWithStdThrow`.
2013-02-17 22:03:36 -06:00
Patrick Johnmeyer
6266300f01 Refactor common logic for CHECK tests into a fixture and add separate tests for std::exception and non. 2013-02-17 00:31:05 -06:00
Patrick Johnmeyer
0950a96eee Add .what() to error message when standard exception is raised in CHECK_CLOSE. 2013-02-16 23:59:18 -06:00
Patrick Johnmeyer
5ddcdd9682 Add .what() to error message when standard exception is raised in CHECK_EQUAL. 2013-02-16 23:56:20 -06:00
Patrick Johnmeyer
fbf390cd8d Add .what() to error message when standard exception is raised in CHECK. 2013-02-16 23:53:30 -06:00
Patrick Johnmeyer
4a0d15302e Merge pull request #31 from rioki/master
Visual Studio 2010 Project Files
2013-02-15 17:14:15 -08:00
Sean Farrell
d62159e6ab Adds .gitignore. 2013-02-15 13:35:23 +01:00
Sean Farrell
14ec171068 Adds Visual Studio 2010 project files. 2013-02-15 13:34:58 +01:00
Sean Farrell
cd36781bed Fixes compile error with MSC.
Unfortunately MSC does not support C99 where snprintf was added to the
standard. As a workaround alias _snprint to snprintf.
2013-02-15 13:34:25 +01:00
Patrick Johnmeyer
e5dc218387 Merge pull request #29 from pjohnmeyer/removeSizeDependenciesFromTestMemoryOutStream
Converted integral stream testing to min/max/mid style. Fixes #14.
2013-02-08 21:48:23 -08:00
Patrick Johnmeyer
4706ca942f Converted integral stream testing to min/max/mid style. Added hard-coded strings for each sizeof() the common integral sizes to eliminate dependency on platform-specific sizes. 2013-02-08 23:33:47 -06:00
Patrick Johnmeyer
db81d25d94 Merge pull request #28 from pjohnmeyer/fixCheckEqualCrashForLargeNumbers
Changed sprintf to snprintf in MemoryOutStream::FormatToStream. Fixes #18.
2013-02-08 18:46:04 -08:00
Patrick Johnmeyer
000349718d Changed sprintf to snprintf in MemoryOutStream::FormatToStream. Removed trailing 'f' from floats and formatted all floats and doubles to '%0.6f'. 2013-02-06 00:13:45 -06:00
Patrick Johnmeyer
9f7f6e366c Merge pull request #27 from pjohnmeyer/declarationDefinitionMismatch
Changed all parameters to TestReporterStdout::ReportSummary to be const. Closes #15.
2013-02-05 21:24:11 -08:00
Patrick Johnmeyer
107378a397 Changed all parameters to TestReporterStdout::ReportSummary to be const. This best preserved the intent of the original definition while supporting a non-conformant compiler that could not handle the mismatch. 2013-02-05 23:22:32 -06:00
Patrick Johnmeyer
5f90bc56d7 Merge pull request #26 from pjohnmeyer/fixUnitTestTimeConstraintExemptForFixtures
Fix unit test time constraint exempt for fixtures; closes #9.
2013-02-05 19:15:13 -08:00
Patrick Johnmeyer
c5cc43c701 Merge pull request #25 from pjohnmeyer/fixCheckEqualExplodesIfNull
CHECK_EQUAL no longer crashes if string pointers are NULL. Closes #8.
2013-02-02 23:47:02 -08:00
Patrick Johnmeyer
4dced283c8 Refactored SlowTestWithTimeExemptionPass into two tests, defined in the SlowTestHelper namespace. These tests are actually run by new test SlowTestsWithTimeExemptionsPass. 2013-02-03 01:38:16 -06:00
Patrick Johnmeyer
904f733b15 Added test verifying that UNITTEST_TIME_CONSTRAINT works in TEST_FIXTURE tests. 2013-02-03 01:14:24 -06:00
Patrick Johnmeyer
69acc43ef4 CHECK_EQUAL no longer crashes if string pointers are NULL. 2013-02-03 00:47:52 -06:00
Pete Johns
aeaae3e6e6 Compare char* with char* to fix OS X build with clang. 2013-01-31 20:49:24 -06:00
Patrick Johnmeyer
7e99532785 Normalized line endings 2013-01-31 20:49:13 -06:00
Patrick Johnmeyer
8379eb5661 Fix inadvertent 'crlt' for .vcxproj 2013-01-26 09:04:33 -06:00
Patrick Johnmeyer
cbbcffa26b Setting up an initial .gitattributes to start dealing with line endings 2013-01-26 01:27:06 -06:00
Patrick Johnmeyer
4ca25c5651 Merged googlecode branch, closes #3 2013-01-26 01:05:18 -06:00
Patrick Johnmeyer
e83811d8d7 Closes #2 2013-01-26 01:01:37 -06:00
Patrick Johnmeyer
443b35690a Fixed test failures in Streaming[Unsigned]LongLongWritesCorrectCharacters 2013-01-10 00:05:00 -06:00
Patrick Johnmeyer
3caf00bcf7 r30 | charles.nicholson@gmail.com | 2010-07-30 16:09:20 -0500 (Fri, 30 Jul 2010) | 1 line
dummy change to test committing
2013-01-09 23:45:36 -06:00
Patrick Johnmeyer
d286f58ead r29 | charles.nicholson | 2010-07-30 12:44:06 -0500 (Fri, 30 Jul 2010) | 1 line
normalize configurations, output paths
2013-01-09 23:45:30 -06:00
Patrick Johnmeyer
57bf80682e r28 | charles.nicholson | 2010-07-29 17:43:45 -0500 (Thu, 29 Jul 2010) | 1 line
fix strict aliasing violation, was causing gcc failures.  use std::memcpy instead of union-cast
2013-01-09 23:45:25 -06:00
Patrick Johnmeyer
f5ba405795 r27 | charles.nicholson | 2010-03-25 15:45:52 -0500 (Thu, 25 Mar 2010) | 1 line
add Clear() to MemoryOutStream()
2013-01-09 23:45:20 -06:00
Patrick Johnmeyer
3fe7f2f5bd r26 | charles.nicholson | 2010-03-22 14:16:24 -0500 (Mon, 22 Mar 2010) | 1 line
platform macros for jmp_buf, setjmp, longjmp.  Remove unused code, fix shadowed virtual functions (yikes!)
2013-01-09 23:45:16 -06:00
Patrick Johnmeyer
e92de84bc2 r25 | charles.nicholson | 2010-03-22 14:01:16 -0500 (Mon, 22 Mar 2010) | 1 line
add vs2008 solution + vcproj files
2013-01-09 23:45:10 -06:00
Patrick Johnmeyer
e4272010e6 r24 | charles.nicholson | 2010-03-19 18:34:42 -0500 (Fri, 19 Mar 2010) | 1 line
inject 'using namespace std' into TestTestMacros.cpp
2013-01-09 23:45:02 -06:00
Patrick Johnmeyer
7510e7f42b r23 | charles.nicholson | 2010-03-18 19:14:06 -0500 (Thu, 18 Mar 2010) | 1 line
long long streaming for MemoryOutStream, from sony
2013-01-09 23:44:56 -06:00
Patrick Johnmeyer
7b9e3a17f8 r22 | charles.nicholson | 2010-03-18 18:39:32 -0500 (Thu, 18 Mar 2010) | 1 line
negate config flags and comment them out by default; this allows command-line preprocessor symbol injection to control flags.  Useful for having a master copy of utpp that build with different flags for different compilers/platforms
2013-01-09 23:44:50 -06:00
Patrick Johnmeyer
909f4b2e91 r21 | charles.nicholson | 2010-03-18 16:52:29 -0500 (Thu, 18 Mar 2010) | 1 line
reset config.h macros
2013-01-09 23:44:42 -06:00
Patrick Johnmeyer
534aca3236 r20 | charles.nicholson | 2010-03-18 16:49:54 -0500 (Thu, 18 Mar 2010) | 1 line
add UNITTEST_WIN32 macro, turn dllmacros.h into helpermacros.h, wrap do/while(0) in __pragma to avoid VS 'conditional expression is constant' warning
2013-01-09 23:44:37 -06:00
Patrick Johnmeyer
a0501f6b71 r19 | charles.nicholson | 2010-03-18 16:22:06 -0500 (Thu, 18 Mar 2010) | 1 line
add mt and md build configurations for vs2005, for CRT selection convenience
2013-01-09 23:44:30 -06:00
Patrick Johnmeyer
88b09d46e8 r18 | charles.nicholson | 2010-03-18 15:42:23 -0500 (Thu, 18 Mar 2010) | 1 line
add scea 'TestReporterMulti' as 'CompositeTestReporter', add tests
2013-01-09 23:44:22 -06:00
Patrick Johnmeyer
32288a53b9 r17 | charles.nicholson | 2010-03-18 15:01:48 -0500 (Thu, 18 Mar 2010) | 1 line
forgot to add file
2013-01-09 23:44:16 -06:00
Patrick Johnmeyer
637f00a8a6 r16 | charles.nicholson | 2010-03-18 15:01:25 -0500 (Thu, 18 Mar 2010) | 1 line
DLL builds for win32, more bin/lib/obj location and configuration name changing in vs2005
2013-01-09 23:44:07 -06:00
Patrick Johnmeyer
c95e86cf8b r15 | charles.nicholson | 2010-03-17 20:08:52 -0500 (Wed, 17 Mar 2010) | 1 line
simple changes from sony
2013-01-09 23:43:59 -06:00
Patrick Johnmeyer
b9825d16f8 r14 | charles.nicholson | 2010-03-17 19:39:17 -0500 (Wed, 17 Mar 2010) | 1 line
better configuration names
2013-01-09 23:43:54 -06:00
Patrick Johnmeyer
946aa5e7d4 r13 | charles.nicholson | 2010-03-17 19:05:19 -0500 (Wed, 17 Mar 2010) | 1 line
rename sln/vcproj to '_vs2005', fix up targets to still be named unittestpp and test-unittestpp
2013-01-09 23:43:48 -06:00
Patrick Johnmeyer
b2e2959c76 r12 | charles.nicholson | 2010-03-17 18:59:25 -0500 (Wed, 17 Mar 2010) | 1 line
move unittestpp.h and config.h to top-level folder, to allow 'include unittestpp/unittestpp.h' directives in client code
2013-01-09 23:43:37 -06:00
Patrick Johnmeyer
eebfcb4103 r11 | charles.nicholson | 2010-03-17 18:49:54 -0500 (Wed, 17 Mar 2010) | 1 line
fix makefile, gcc 4.3 compiles cleanly, fix obj/bin/lib dirs
2013-01-09 23:43:32 -06:00
Patrick Johnmeyer
bcde677ff0 r10 | charles.nicholson | 2010-03-17 18:04:53 -0500 (Wed, 17 Mar 2010) | 1 line
rename unittestpp folder to src, fix bin/lib/obj folders in vcproj files
2013-01-09 23:43:23 -06:00
Patrick Johnmeyer
c8f551a502 r9 | charles.nicholson | 2010-03-17 17:13:51 -0500 (Wed, 17 Mar 2010) | 1 line
setjmp/longjmp in place for assert handling when UNITTEST_USE_EXCEPTIONS is not defined
2013-01-09 23:43:13 -06:00
Patrick Johnmeyer
3a40aa80a1 r8 | charles.nicholson | 2010-03-16 21:27:33 -0500 (Tue, 16 Mar 2010) | 1 line
fixed bug where tests weren't correctly executing while testing the TestRunner (accessing the Details and Results singletons was redirecting failures to bogus RecordingReporters, instead of the real UT++ test engine).  Hoisted assert failure reporting into ReportAssert, in preparation for setjmp/longjmp assert handling in the absence of exceptions.  Slight renamings and cosmetic fixups
2013-01-09 23:43:07 -06:00
Patrick Johnmeyer
ab8b818591 r7 | charles.nicholson | 2010-03-16 16:18:18 -0500 (Tue, 16 Mar 2010) | 1 line
add DeferredTestReporter and DeferredTestResult back in, conditional on UNITTEST_USE_DEFERRED_REPORTER
2013-01-09 23:42:51 -06:00
Patrick Johnmeyer
6712ae184a r6 | charles.nicholson | 2010-03-15 19:03:04 -0500 (Mon, 15 Mar 2010) | 1 line
pull in less win32 stuff in timehelpers, strip down top-level unittestpp.h
2013-01-09 23:42:44 -06:00
Patrick Johnmeyer
23c7368d92 r5 | charles.nicholson | 2010-03-15 17:46:01 -0500 (Mon, 15 Mar 2010) | 1 line
remove leftover exception test structures, fix ReportAssert for no-exceptions build
2013-01-09 23:42:35 -06:00
Patrick Johnmeyer
4f556d6539 r4 | charles.nicholson | 2010-03-08 23:23:36 -0600 (Mon, 08 Mar 2010) | 1 line
all try/catch calls are either #ifdefd out or replaced with UT_TRY/UT_CATCH macro madness
2013-01-09 23:42:29 -06:00
Patrick Johnmeyer
67d4ecb5c5 r3 | charles.nicholson | 2010-03-08 22:58:59 -0600 (Mon, 08 Mar 2010) | 1 line
first pass at adding exception macros
2013-01-09 23:42:14 -06:00
Patrick Johnmeyer
72c2581719 Renamed files with + in them to be alphanumeric and baselined to roughly r2 or http://unittestpp.googlecode.com/svn/trunk/ 2013-01-09 23:33:51 -06:00
Patrick Johnmeyer
a3f957c09f ------------------------------------------------------------------------
r207 | llopis | 2009-04-26 19:51:43 -0500 (Sun, 26 Apr 2009) | 2 lines

Updated announcement URL'

------------------------------------------------------------------------
2012-12-14 00:25:19 -06:00
Patrick Johnmeyer
d1c51eb71b ------------------------------------------------------------------------
r206 | cnicholson | 2009-02-01 23:09:01 -0600 (Sun, 01 Feb 2009) | 1 line

- apply patch from tracker issue 2528976, VC6 support from Koji Yoshioka
------------------------------------------------------------------------
2012-12-14 00:24:48 -06:00
Patrick Johnmeyer
270380845c ------------------------------------------------------------------------
r205 | cnicholson | 2009-02-01 22:50:16 -0600 (Sun, 01 Feb 2009) | 2 lines

- TimeHelpers reports fractions of msec, though time constraint is still on integers.
- compile fixes for more strict gcc warnings.
------------------------------------------------------------------------
2012-12-14 00:17:17 -06:00
Patrick Johnmeyer
d6ba794823 ------------------------------------------------------------------------
r204 | cnicholson | 2008-11-15 11:08:34 -0600 (Sat, 15 Nov 2008) | 1 line

fix for VC6 with native dinkumware stl, cstdio doesn't pull in std:: so we redefine it at the top of the file.  yuck.
------------------------------------------------------------------------
2012-12-13 23:53:56 -06:00
qdii
6b6d9ae192 Merge pull request #1 from paleozogt/master
merged. Thanks!
2012-11-15 11:06:06 -08:00
Aaron Simmons
062241c85d adding CMakeLists.txt 2012-11-15 10:07:33 -07:00
qdii
259cf50b21 Added autobuild system 2012-11-14 18:44:50 -05:00
174 changed files with 10142 additions and 6316 deletions

17
.gitattributes vendored Normal file
View file

@ -0,0 +1,17 @@
* text=auto
*.h text
*.cpp text
# VS 20xx files
*.sln text eol=crlf
*.vcproj text eol=crlf
*.vcxproj text eol=crlf
*.vcxproj.filters text eol=crlf
# VC6 files
*.dsw text eol=crlf
*.dsp text eol=crlf
# Other 'windows-specific' files
*.bat text eol=crlf

44
.gitignore vendored Normal file
View file

@ -0,0 +1,44 @@
*.o
*.a
*.lo
*.la
# Visual Studio temp/user files
*.user
*.suo
*.sdf
*.opensdf
*.ncb
# Build output directories
Release
Debug
MinSizeRel
RelWithDebInfo
ipch
# files generated by autotools
/aclocal.m4
/autom4te.cache
/config.guess
/config.h
/config.h.in
/config.status
/config.sub
/configure
/depcomp
/install-sh
/libtool
/ltmain.sh
/m4
/missing
/stamp-h*
/test-driver
/UnitTest++/TestUnitTest++
Makefile
Makefile.in
.deps
.libs
*.log
*.trs
*.pc

4
.gitmodules vendored Normal file
View file

@ -0,0 +1,4 @@
[submodule "docs"]
path = docs
url = https://github.com/unittest-cpp/unittest-cpp.wiki.git
ignore = dirty

21
.travis.yml Normal file
View file

@ -0,0 +1,21 @@
language: cpp
# Build with gcc and clang.
compiler:
- gcc
- clang
# Build both debug and release configurations, through use of an environment variable in the build matrix.
env:
- CONFIGURATION=Debug
- CONFIGURATION=Release
# Run cmake to generate makefiles in 'builds' directory.
# No need to create it because it's part of the repo.
# Pass along configuration type to cmake.
before_script:
- cd builds && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$CONFIGURATION ../ && cd ..
# Run make in the directory containing generated makefiles.
script:
- make -C builds

488
.uncrustify Normal file
View file

@ -0,0 +1,488 @@
# Uncrustify 0.61
newlines = auto
input_tab_size = 4
output_tab_size = 3
string_escape_char = 92
string_escape_char2 = 0
tok_split_gte = false
utf8_bom = remove
utf8_byte = false
utf8_force = false
indent_columns = 3
indent_continue = 0
indent_with_tabs = 0
indent_cmt_with_tabs = false
indent_align_string = false
indent_xml_string = 0
indent_brace = 0
indent_braces = false
indent_braces_no_func = false
indent_braces_no_class = false
indent_braces_no_struct = false
indent_brace_parent = false
indent_paren_open_brace = false
indent_namespace = true
indent_namespace_single_indent = false
indent_namespace_level = 0
indent_namespace_limit = 0
indent_extern = false
indent_class = true
indent_class_colon = false
indent_constr_colon = false
indent_ctor_init_leading = 1
indent_ctor_init = 0
indent_else_if = false
indent_var_def_blk = 0
indent_var_def_cont = false
indent_func_def_force_col1 = false
indent_func_call_param = false
indent_func_def_param = false
indent_func_proto_param = false
indent_func_class_param = false
indent_func_ctor_var_param = false
indent_template_param = false
indent_func_param_double = false
indent_func_const = 0
indent_func_throw = 0
indent_member = indent_columns
indent_sing_line_comments = 0
indent_relative_single_line_comments = true
indent_switch_case = 0
indent_case_shift = 0
indent_case_brace = 0
indent_col1_comment = false
indent_label = 1
indent_access_spec = -3
indent_access_spec_body = false
indent_paren_nl = false
indent_paren_close = 0
indent_comma_paren = false
indent_bool_paren = false
indent_first_bool_expr = false
indent_square_nl = false
indent_preserve_sql = false
indent_align_assign = true
indent_oc_block = false
indent_oc_block_msg = 0
indent_oc_msg_colon = 0
indent_oc_msg_prioritize_first_colon = true
indent_oc_block_msg_xcode_style = false
indent_oc_block_msg_from_keyword = false
indent_oc_block_msg_from_colon = false
indent_oc_block_msg_from_caret = false
indent_oc_block_msg_from_brace = false
sp_arith = ignore
sp_assign = ignore
sp_cpp_lambda_assign = ignore
sp_cpp_lambda_paren = ignore
sp_assign_default = ignore
sp_before_assign = ignore
sp_after_assign = ignore
sp_enum_paren = ignore
sp_enum_assign = ignore
sp_enum_before_assign = ignore
sp_enum_after_assign = ignore
sp_pp_concat = add
sp_pp_stringify = ignore
sp_before_pp_stringify = ignore
sp_bool = ignore
sp_compare = ignore
sp_inside_paren = ignore
sp_paren_paren = ignore
sp_cparen_oparen = ignore
sp_balance_nested_parens = false
sp_paren_brace = ignore
sp_before_ptr_star = ignore
sp_before_unnamed_ptr_star = ignore
sp_between_ptr_star = ignore
sp_after_ptr_star = ignore
sp_after_ptr_star_qualifier = ignore
sp_after_ptr_star_func = ignore
sp_ptr_star_paren = ignore
sp_before_ptr_star_func = ignore
sp_before_byref = ignore
sp_before_unnamed_byref = ignore
sp_after_byref = ignore
sp_after_byref_func = ignore
sp_before_byref_func = ignore
sp_after_type = force
sp_before_template_paren = ignore
sp_template_angle = ignore
sp_before_angle = ignore
sp_inside_angle = ignore
sp_after_angle = ignore
sp_angle_paren = ignore
sp_angle_word = ignore
sp_angle_shift = add
sp_permit_cpp11_shift = false
sp_before_sparen = ignore
sp_inside_sparen = ignore
sp_inside_sparen_close = ignore
sp_inside_sparen_open = ignore
sp_after_sparen = ignore
sp_sparen_brace = ignore
sp_invariant_paren = ignore
sp_after_invariant_paren = ignore
sp_special_semi = ignore
sp_before_semi = remove
sp_before_semi_for = ignore
sp_before_semi_for_empty = ignore
sp_after_semi = add
sp_after_semi_for = force
sp_after_semi_for_empty = ignore
sp_before_square = ignore
sp_before_squares = ignore
sp_inside_square = ignore
sp_after_comma = ignore
sp_before_comma = remove
sp_paren_comma = force
sp_before_ellipsis = ignore
sp_after_class_colon = ignore
sp_before_class_colon = ignore
sp_after_constr_colon = ignore
sp_before_constr_colon = ignore
sp_before_case_colon = remove
sp_after_operator = ignore
sp_after_operator_sym = ignore
sp_after_cast = ignore
sp_inside_paren_cast = ignore
sp_cpp_cast_paren = ignore
sp_sizeof_paren = ignore
sp_after_tag = ignore
sp_inside_braces_enum = ignore
sp_inside_braces_struct = ignore
sp_inside_braces = ignore
sp_inside_braces_empty = ignore
sp_type_func = ignore
sp_func_proto_paren = ignore
sp_func_def_paren = ignore
sp_inside_fparens = ignore
sp_inside_fparen = ignore
sp_inside_tparen = ignore
sp_after_tparen_close = ignore
sp_square_fparen = ignore
sp_fparen_brace = ignore
sp_fparen_dbrace = ignore
sp_func_call_paren = ignore
sp_func_call_paren_empty = ignore
sp_func_call_user_paren = ignore
sp_func_class_paren = ignore
sp_return_paren = ignore
sp_attribute_paren = ignore
sp_defined_paren = ignore
sp_throw_paren = ignore
sp_after_throw = ignore
sp_catch_paren = ignore
sp_version_paren = ignore
sp_scope_paren = ignore
sp_macro = ignore
sp_macro_func = ignore
sp_else_brace = ignore
sp_brace_else = ignore
sp_brace_typedef = ignore
sp_catch_brace = ignore
sp_brace_catch = ignore
sp_finally_brace = ignore
sp_brace_finally = ignore
sp_try_brace = ignore
sp_getset_brace = ignore
sp_word_brace = add
sp_word_brace_ns = add
sp_before_dc = ignore
sp_after_dc = ignore
sp_d_array_colon = ignore
sp_not = remove
sp_inv = remove
sp_addr = remove
sp_member = remove
sp_deref = remove
sp_sign = remove
sp_incdec = remove
sp_before_nl_cont = add
sp_after_oc_scope = ignore
sp_after_oc_colon = ignore
sp_before_oc_colon = ignore
sp_after_oc_dict_colon = ignore
sp_before_oc_dict_colon = ignore
sp_after_send_oc_colon = ignore
sp_before_send_oc_colon = ignore
sp_after_oc_type = ignore
sp_after_oc_return_type = ignore
sp_after_oc_at_sel = ignore
sp_after_oc_at_sel_parens = ignore
sp_inside_oc_at_sel_parens = ignore
sp_before_oc_block_caret = ignore
sp_after_oc_block_caret = ignore
sp_after_oc_msg_receiver = ignore
sp_after_oc_property = ignore
sp_cond_colon = ignore
sp_cond_colon_before = ignore
sp_cond_colon_after = ignore
sp_cond_question = ignore
sp_cond_question_before = ignore
sp_cond_question_after = ignore
sp_cond_ternary_short = ignore
sp_case_label = ignore
sp_range = ignore
sp_after_for_colon = ignore
sp_before_for_colon = ignore
sp_extern_paren = ignore
sp_cmt_cpp_start = ignore
sp_endif_cmt = ignore
sp_after_new = ignore
sp_before_tr_emb_cmt = ignore
sp_num_before_tr_emb_cmt = 0
sp_annotation_paren = ignore
align_keep_tabs = false
align_with_tabs = false
align_on_tabstop = false
align_number_left = false
align_keep_extra_space = false
align_func_params = false
align_same_func_call_params = false
align_var_def_span = 0
align_var_def_star_style = 0
align_var_def_amp_style = 0
align_var_def_thresh = 0
align_var_def_gap = 0
align_var_def_colon = false
align_var_def_attribute = false
align_var_def_inline = false
align_assign_span = 0
align_assign_thresh = 0
align_enum_equ_span = 0
align_enum_equ_thresh = 0
align_var_struct_span = 0
align_var_struct_thresh = 0
align_var_struct_gap = 0
align_struct_init_span = 0
align_typedef_gap = 0
align_typedef_span = 0
align_typedef_func = 0
align_typedef_star_style = 0
align_typedef_amp_style = 0
align_right_cmt_span = 0
align_right_cmt_mix = false
align_right_cmt_gap = 0
align_right_cmt_at_col = 0
align_func_proto_span = 0
align_func_proto_gap = 0
align_on_operator = false
align_mix_var_proto = false
align_single_line_func = false
align_single_line_brace = false
align_single_line_brace_gap = 0
align_oc_msg_spec_span = 0
align_nl_cont = true
align_pp_define_together = false
align_pp_define_gap = 0
align_pp_define_span = 0
align_left_shift = true
align_oc_msg_colon_span = 0
align_oc_msg_colon_first = false
align_oc_decl_colon = false
nl_collapse_empty_body = true
nl_assign_leave_one_liners = false
nl_class_leave_one_liners = false
nl_enum_leave_one_liners = false
nl_getset_leave_one_liners = false
nl_func_leave_one_liners = false
nl_cpp_lambda_leave_one_liners = false
nl_if_leave_one_liners = false
nl_oc_msg_leave_one_liner = false
nl_start_of_file = ignore
nl_start_of_file_min = 0
nl_end_of_file = ignore
nl_end_of_file_min = 0
nl_assign_brace = ignore
nl_assign_square = ignore
nl_after_square_assign = ignore
nl_func_var_def_blk = 0
nl_typedef_blk_start = 0
nl_typedef_blk_end = 0
nl_typedef_blk_in = 0
nl_var_def_blk_start = 0
nl_var_def_blk_end = 0
nl_var_def_blk_in = 0
nl_fcall_brace = ignore
nl_enum_brace = ignore
nl_struct_brace = ignore
nl_union_brace = ignore
nl_if_brace = ignore
nl_brace_else = ignore
nl_elseif_brace = ignore
nl_else_brace = ignore
nl_else_if = ignore
nl_brace_finally = ignore
nl_finally_brace = ignore
nl_try_brace = ignore
nl_getset_brace = ignore
nl_for_brace = ignore
nl_catch_brace = ignore
nl_brace_catch = ignore
nl_brace_square = ignore
nl_brace_fparen = ignore
nl_while_brace = ignore
nl_scope_brace = ignore
nl_unittest_brace = ignore
nl_version_brace = ignore
nl_using_brace = ignore
nl_brace_brace = ignore
nl_do_brace = ignore
nl_brace_while = ignore
nl_switch_brace = ignore
nl_multi_line_cond = false
nl_multi_line_define = false
nl_before_case = false
nl_before_throw = ignore
nl_after_case = false
nl_case_colon_brace = ignore
nl_namespace_brace = ignore
nl_template_class = ignore
nl_class_brace = ignore
nl_class_init_args = ignore
nl_constr_init_args = ignore
nl_func_type_name = ignore
nl_func_type_name_class = ignore
nl_func_scope_name = ignore
nl_func_proto_type_name = ignore
nl_func_paren = ignore
nl_func_def_paren = ignore
nl_func_decl_start = ignore
nl_func_def_start = ignore
nl_func_decl_start_single = ignore
nl_func_def_start_single = ignore
nl_func_decl_args = ignore
nl_func_def_args = ignore
nl_func_decl_end = ignore
nl_func_def_end = ignore
nl_func_decl_end_single = ignore
nl_func_def_end_single = ignore
nl_func_decl_empty = ignore
nl_func_def_empty = ignore
nl_oc_msg_args = false
nl_fdef_brace = ignore
nl_cpp_ldef_brace = ignore
nl_return_expr = ignore
nl_after_semicolon = false
nl_paren_dbrace_open = ignore
nl_after_brace_open = false
nl_after_brace_open_cmt = false
nl_after_vbrace_open = false
nl_after_vbrace_open_empty = false
nl_after_brace_close = false
nl_after_vbrace_close = false
nl_brace_struct_var = ignore
nl_define_macro = false
nl_squeeze_ifdef = false
nl_before_if = ignore
nl_after_if = ignore
nl_before_for = ignore
nl_after_for = ignore
nl_before_while = ignore
nl_after_while = ignore
nl_before_switch = ignore
nl_after_switch = ignore
nl_before_do = ignore
nl_after_do = ignore
nl_ds_struct_enum_cmt = false
nl_ds_struct_enum_close_brace = false
nl_class_colon = ignore
nl_constr_colon = ignore
nl_create_if_one_liner = false
nl_create_for_one_liner = false
nl_create_while_one_liner = false
pos_arith = ignore
pos_assign = ignore
pos_bool = ignore
pos_compare = ignore
pos_conditional = ignore
pos_comma = ignore
pos_class_comma = ignore
pos_constr_comma = ignore
pos_class_colon = ignore
pos_constr_colon = ignore
code_width = 0
ls_for_split_full = false
ls_func_split_full = false
ls_code_width = false
nl_max = 0
nl_after_func_proto = 0
nl_after_func_proto_group = 0
nl_after_func_body = 0
nl_after_func_body_class = 0
nl_after_func_body_one_liner = 0
nl_before_block_comment = 0
nl_before_c_comment = 0
nl_before_cpp_comment = 0
nl_after_multiline_comment = false
nl_after_struct = 0
nl_after_class = 0
nl_before_access_spec = 0
nl_after_access_spec = 0
nl_comment_func_def = 0
nl_after_try_catch_finally = 0
nl_around_cs_property = 0
nl_between_get_set = 0
nl_property_brace = ignore
eat_blanks_after_open_brace = false
eat_blanks_before_close_brace = false
nl_remove_extra_newlines = 0
nl_before_return = false
nl_after_return = false
nl_after_annotation = ignore
nl_between_annotation = ignore
mod_full_brace_do = ignore
mod_full_brace_for = ignore
mod_full_brace_function = ignore
mod_full_brace_if = ignore
mod_full_brace_if_chain = false
mod_full_brace_nl = 0
mod_full_brace_while = ignore
mod_full_brace_using = ignore
mod_paren_on_return = ignore
mod_pawn_semicolon = false
mod_full_paren_if_bool = false
mod_remove_extra_semicolon = false
mod_add_long_function_closebrace_comment = 0
mod_add_long_namespace_closebrace_comment = 0
mod_add_long_switch_closebrace_comment = 0
mod_add_long_ifdef_endif_comment = 0
mod_add_long_ifdef_else_comment = 0
mod_sort_import = false
mod_sort_using = false
mod_sort_include = false
mod_move_case_break = false
mod_case_brace = ignore
mod_remove_empty_return = false
cmt_width = 0
cmt_reflow_mode = 0
cmt_convert_tab_to_spaces = false
cmt_indent_multi = true
cmt_c_group = false
cmt_c_nl_start = false
cmt_c_nl_end = false
cmt_cpp_group = false
cmt_cpp_nl_start = false
cmt_cpp_nl_end = false
cmt_cpp_to_c = false
cmt_star_cont = false
cmt_sp_before_star_cont = 0
cmt_sp_after_star_cont = 0
cmt_multi_check_last = true
cmt_insert_file_header = ""
cmt_insert_file_footer = ""
cmt_insert_func_header = ""
cmt_insert_class_header = ""
cmt_insert_oc_msg_header = ""
cmt_insert_before_preproc = false
pp_indent = ignore
pp_indent_at_level = false
pp_indent_count = 3
pp_space = ignore
pp_space_count = 0
pp_indent_region = 0
pp_region_indent_code = false
pp_indent_if = 0
pp_if_indent_code = false
pp_define_at_level = true

3
AUTHORS Normal file
View file

@ -0,0 +1,3 @@
See README.md for the historic contributor list.
The maintainer of UnitTest++ is Patrick Johnmeyer (pjohnmeyer@gmail.com).

145
CMakeLists.txt Normal file
View file

@ -0,0 +1,145 @@
cmake_minimum_required(VERSION 3.0)
project(UnitTest++ VERSION 2.1.0)
option(UTPP_USE_PLUS_SIGN
"Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths"
ON)
option(UTPP_INCLUDE_TESTS_IN_BUILD
"Set this to OFF if you do not wish to automatically build or run unit tests as part of the default cmake --build"
ON)
option(UTPP_AMPLIFY_WARNINGS
"Set this to OFF if you wish to use CMake default warning levels; should generally only use to work around support issues for your specific compiler"
ON)
set(LIB_SUFFIX "" CACHE STRING "Identifier to add to end of lib directory name e.g. 64 for lib64")
if (MSVC)
# CHECK_CXX_COMPILER_FLAG could be used
# but MSVC version is preferred for feature requirements
if (MSVC14 OR MSVC12)
# has the support we need
else()
message(STATUS "The MSVC compiler version does not support UnitTest++ C++11 features.")
endif()
else()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
elseif(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
endif()
endif()
# up warning level for project
if (${UTPP_AMPLIFY_WARNINGS})
# instead of getting compiler specific, we're going to try making an assumption that an existing /W# means
# we are dealing with an MSVC or MSVC-like compiler (e.g. Intel on Windows)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
endif()
endif()
# get the main sources
file(GLOB headers_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.h)
file(GLOB sources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.cpp)
source_group("" FILES ${headers_} ${sources_})
# get platform specific sources
if (WIN32)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
set(platformDir_ Win32)
else()
set(platformDir_ Posix)
endif(WIN32)
file(GLOB platformHeaders_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/${platformDir_}/*.h)
file(GLOB platformSources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/${platformDir_}/*.cpp)
source_group(${platformDir_} FILES ${platformHeaders_} ${platformSources_})
# create the lib
add_library(UnitTest++ STATIC ${headers_} ${sources_} ${platformHeaders_} ${platformSources_})
add_library(UnitTest++::UnitTest++ ALIAS UnitTest++)
if(${UTPP_USE_PLUS_SIGN})
set_target_properties(UnitTest++ PROPERTIES OUTPUT_NAME UnitTest++)
endif()
# build the test runner
file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp tests/*.h)
source_group( "" FILES ${TEST_SRCS})
add_executable(TestUnitTest++ ${TEST_SRCS})
if(${UTPP_USE_PLUS_SIGN})
set_target_properties(TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++)
endif()
target_link_libraries(TestUnitTest++
PUBLIC
UnitTest++::UnitTest++
)
# run unit tests as post build step
add_custom_command(TARGET TestUnitTest++
POST_BUILD COMMAND TestUnitTest++
COMMENT "Running unit tests")
if(NOT ${UTPP_INCLUDE_TESTS_IN_BUILD})
set_target_properties(TestUnitTest++ PROPERTIES EXCLUDE_FROM_ALL 1)
endif()
# add install targets
# need a custom install path?
# define CMAKE_INSTALL_PREFIX to change root folder
if(${UTPP_USE_PLUS_SIGN})
set (UTPP_INSTALL_DESTINATION "include/UnitTest++")
else()
set (UTPP_INSTALL_DESTINATION "include/UnitTestPP")
endif()
target_include_directories( UnitTest++
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/UnitTest++>
)
set_target_properties(UnitTest++ PROPERTIES DEBUG_POSTFIX "-d")
set_target_properties(TestUnitTest++ PROPERTIES DEBUG_POSTFIX "-d")
set(config_install_dir_ lib${LIB_SUFFIX}/cmake/${PROJECT_NAME})
set(targets_export_name_ "${PROJECT_NAME}Targets")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
cmake/UnitTest++ConfigVersion.cmake
VERSION ${UnitTest++_VERSION}
COMPATIBILITY SameMajorVersion
)
install(TARGETS UnitTest++ EXPORT "${targets_export_name_}" DESTINATION lib${LIB_SUFFIX})
install(FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION})
install(FILES ${platformHeaders_} DESTINATION ${UTPP_INSTALL_DESTINATION}/${platformDir_})
install(FILES
cmake/UnitTest++Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/UnitTest++ConfigVersion.cmake
DESTINATION "${config_install_dir_}")
install(EXPORT "${targets_export_name_}" NAMESPACE "UnitTest++::" DESTINATION "${config_install_dir_}")
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
set(includedir ${CMAKE_INSTALL_PREFIX}/include/UnitTest++)
configure_file("UnitTest++.pc.in" "UnitTest++.pc" @ONLY)
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(pkgconfdir ${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig)
else()
set(pkgconfdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig)
endif()
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/UnitTest++.pc"
DESTINATION "${pkgconfdir}")

376
INSTALL Normal file
View file

@ -0,0 +1,376 @@
Preamble: If you are installing UnitTest++ from source, or from a
release prior to 1.6.1, you will need to have autotools installed and
run `autoreconf -i; autoconf` prior to following the standard
instructions below.
Installation Instructions
*************************
Copyright (C) 1994-1996, 1999-2002, 2004-2012 Free Software Foundation,
Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without warranty of any kind.
Basic Installation
==================
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
below. The lack of an optional feature in a given package is not
necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type `make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the `make install' phase executed with root
privileges.
5. Optionally, type `make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior `make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type `make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide `make
distcheck', which can by used by developers to test that all other
targets like `make install' and `make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. This
is known as a "VPATH" build.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, `make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'. Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated. The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.
The second method involves providing the `DESTDIR' variable. For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names. The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of `make' will be. For these packages, running `./configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
HP-UX `make' updates targets which have the same time stamps as
their prerequisites, which makes it generally unusable when shipped
generated files such as `configure' are involved. Use GNU `make'
instead.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
./configure CC="cc"
and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf limitation. Until the limitation is lifted, you can use
this workaround:
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
`--help=short'
`--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
`--no-create'
`-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View file

@ -1,20 +1,20 @@
Copyright (c) 2006 Noel Llopis and Charles Nicholson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2006 Noel Llopis and Charles Nicholson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,96 +0,0 @@
CXX = g++
CXXFLAGS ?= -g -Wall -W -ansi # -pedantic
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

8
Makefile.am Normal file
View file

@ -0,0 +1,8 @@
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = docs
include UnitTest++/Makefile.am
include tests/Makefile.am
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = UnitTest++.pc

68
README
View file

@ -1,68 +0,0 @@
UnitTest++ README
Version: v1.4
Last update: 2008-10-30
UnitTest++ is free software. You may copy, distribute, and modify it under
the terms of the License contained in the file COPYING distributed
with this package. This license is the same as the MIT/X Consortium
license.
See src/tests/TestUnitTest++.cpp for usage.
Authors:
Noel Llopis (llopis@convexhull.com)
Charles Nicholson (charles.nicholson@gmail.com)
Contributors:
Jim Tilander
Kim Grasman
Jonathan Jansson
Dirck Blaskey
Rory Driscoll
Dan Lind
Matt Kimmel -- Submitted with permission from Blue Fang Games
Anthony Moralez
Jeff Dixon
Randy Coulman
Lieven van der Heide
Release notes:
--------------
Version 1.4 (2008-10-30)
- CHECK macros work at arbitrary stack depth from inside TESTs.
- Remove obsolete TEST_UTILITY macros
- Predicated test execution (via TestRunner::RunTestsIf)
- Better exception handling for fixture ctors/dtors.
- VC6/7/8/9 support
Version 1.3 (2007-4-22)
- Removed dynamic memory allocations (other than streams)
- MinGW support
- Consistent (native) line endings
- Minor bug fixing
Version 1.2 (2006-10-29)
- First pass at documentation.
- More detailed error crash catching in fixtures.
- Standard streams used for printing objects under check. This should allow the
use of standard class types such as std::string or other custom classes with
stream operators to ostream.
- Standard streams can be optionally compiled off by defining UNITTEST_USE_CUSTOM_STREAMS
in Config.h
- 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
Version 1.1 (2006-04-18)
- CHECK macros do not have side effects even if one of the parameters changes state
- Removed CHECK_ARRAY_EQUAL (too similar to CHECK_ARRAY_CLOSE)
- Added local and global time constraints
- Removed dependencies on strstream
- Improved Posix signal to exception translator
- Failing tests are added to Visual Studio's error list
- Fixed Visual Studio projects to work with spaces in directories
Version 1.0 (2006-03-15)
- Initial release

141
README.md Normal file
View file

@ -0,0 +1,141 @@
> ### Maintenance of UnitTest++, recently sporadic, is officially on hiatus until 26 November 2020. Subscribe to https://github.com/unittest-cpp/unittest-cpp/issues/180 for updates.
[![Build Status](https://travis-ci.org/unittest-cpp/unittest-cpp.svg?branch=master)](https://travis-ci.org/unittest-cpp/unittest-cpp)
[![Build status](https://ci.appveyor.com/api/projects/status/ffs2k8dddts5cyok/branch/master?svg=true)](https://ci.appveyor.com/project/pjohnmeyer/unittest-cpp/branch/master)
UnitTest++
===========
UnitTest++ is a lightweight unit testing framework for C++. It was designed to do test-driven development on a wide variety of platforms. Simplicity, portability, speed, and small footprint are all very important aspects of UnitTest++. UnitTest++ is mostly standard C++ and makes minimal use of advanced library and language features, which means it should be easily portable to just about any platform. Out of the box, the following platforms are supported:
* Windows
* Linux
* Mac OS X
Documentation
--------------
The full documentation for building and using UnitTest++ can be found on the [GitHub wiki page](https://github.com/unittest-cpp/unittest-cpp/wiki). The contents of this wiki are also included as a git submodule under the `docs` folder, so version-specific Markdown documentation is always available along with the download.
Pre-requisites
---------------
While there are currently some bundled automake files, UnitTest++ is primarily built and supported using [CMake](http://cmake.org).
Downloading
------------
### Latest (HEAD) ###
Via git:
git clone https://github.com/unittest-cpp/unittest-cpp
Via svn:
svn checkout https://github.com/unittest-cpp/unittest-cpp/trunk unittest-cpp
### Latest release (v2.0.0) ###
Via git:
git clone https://github.com/unittest-cpp/unittest-cpp
cd unittest-cpp
git checkout v2.0.0
Via svn:
svn checkout https://github.com/unittest-cpp/unittest-cpp/tags/v2.0.0 unittest-cpp
License
---------
*UnitTest++ is free software. You may copy, distribute, and modify it under
the terms of the License contained in the file LICENSE distributed
with this package. This license is the same as the MIT/X Consortium
license.*
Contributors
--------------
### [GitHub Contributor Graph](https://github.com/unittest-cpp/unittest-cpp/contributors) ###
### Current Maintainers: ###
* Patrick Johnmeyer (pjohnmeyer@gmail.com) @pjohnmeyer
* Charles Nicholson (charles.nicholson@gmail.com) @charlesnicholson
### Original Authors: ###
* Noel Llopis (llopis@convexhull.com)
* Charles Nicholson (charles.nicholson@gmail.com)
### Contributors not included in github history ###
* Jim Tilander
* Kim Grasman
* Jonathan Jansson
* Dirck Blaskey
* Rory Driscoll
* Dan Lind
* Matt Kimmel -- Submitted with permission from Blue Fang Games
* Anthony Moralez
* Jeff Dixon
* Randy Coulman
* Lieven van der Heide
Historic release notes
----------------------
### Version 2.0.0 (2017-01-13) ###
- Change Check method supporting CHECK macro to accept argument by reference
- Introduce long macro forms (e.g. UNITTEST_CHECK); make short forms optional
- Improved Visual Studio 2015 support
- [Full List](https://github.com/unittest-cpp/unittest-cpp/issues?q=milestone%3A2.0.0+)
### Version 1.6.0 (2016-02-29) ###
- Add REQUIRE macro to end tests early when selected checks fail
- [Full List](https://github.com/unittest-cpp/unittest-cpp/issues?q=milestone%3A1.6.0+)
### Version 1.5.1 (2016-01-30) ###
- pkg-config support
- Fix for Visual Studio 2010 compilation issue in 1.5.0
- [Full List](https://github.com/unittest-cpp/unittest-cpp/issues?q=milestone%3A1.5.1+)
### Version 1.5 (2015-11-04) ###
- Visual Studio 2015 support
- CMake-based build management
- Integration of SourceForge and Google Code versions of the project
- [Full List](https://github.com/unittest-cpp/unittest-cpp/issues?q=is%3Aissue+is%3Aclosed+milestone%3A1.5.0)
### Version 1.4 (2008-10-30) ###
- CHECK macros work at arbitrary stack depth from inside TESTs.
- Remove obsolete TEST_UTILITY macros
- Predicated test execution (via TestRunner::RunTestsIf)
- Better exception handling for fixture ctors/dtors.
- VC6/7/8/9 support
### Version 1.3 (2007-4-22) ###
- Removed dynamic memory allocations (other than streams)
- MinGW support
- Consistent (native) line endings
- Minor bug fixing
### Version 1.2 (2006-10-29) ###
- First pass at documentation.
- More detailed error crash catching in fixtures.
- Standard streams used for printing objects under check. This should allow the
use of standard class types such as std::string or other custom classes with
stream operators to ostream.
- Standard streams can be optionally compiled off by defining UNITTEST_USE_CUSTOM_STREAMS
in Config.h
- 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
### Version 1.1 (2006-04-18) ###
- CHECK macros do not have side effects even if one of the parameters changes state
- Removed CHECK_ARRAY_EQUAL (too similar to CHECK_ARRAY_CLOSE)
- Added local and global time constraints
- Removed dependencies on strstream
- Improved Posix signal to exception translator
- Failing tests are added to Visual Studio's error list
- Fixed Visual Studio projects to work with spaces in directories
### Version 1.0 (2006-03-15) ###
- Initial release

View file

@ -1,174 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="TestUnitTest++.vsnet2003"
ProjectGUID="{ACDF9A6A-874F-49E5-AB7C-74F8150BB4C7}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="obj\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/TestUnitTest++.vsnet2003.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/TestUnitTest++.vsnet2003.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="&quot;$(TargetPath)&quot;"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="obj\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/TestUnitTest++.vsnet2003.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="&quot;$(TargetPath)&quot;"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\src\tests\Main.cpp">
</File>
<File
RelativePath=".\src\tests\RecordingReporter.h">
</File>
<File
RelativePath=".\src\tests\ScopedCurrentTest.h">
</File>
<File
RelativePath=".\src\tests\TestAssertHandler.cpp">
</File>
<File
RelativePath=".\src\tests\TestCheckMacros.cpp">
</File>
<File
RelativePath=".\src\tests\TestChecks.cpp">
</File>
<File
RelativePath=".\src\tests\TestCurrentTest.cpp">
</File>
<File
RelativePath=".\src\tests\TestDeferredTestReporter.cpp">
</File>
<File
RelativePath=".\src\tests\TestMemoryOutStream.cpp">
</File>
<File
RelativePath=".\src\tests\TestTest.cpp">
</File>
<File
RelativePath=".\src\tests\TestTestList.cpp">
</File>
<File
RelativePath=".\src\tests\TestTestMacros.cpp">
</File>
<File
RelativePath=".\src\tests\TestTestResults.cpp">
</File>
<File
RelativePath=".\src\tests\TestTestRunner.cpp">
</File>
<File
RelativePath=".\src\tests\TestTestSuite.cpp">
</File>
<File
RelativePath=".\src\tests\TestTimeConstraint.cpp">
</File>
<File
RelativePath=".\src\tests\TestTimeConstraintMacro.cpp">
</File>
<File
RelativePath=".\src\tests\TestUnitTest++.cpp">
</File>
<File
RelativePath=".\src\tests\TestXmlTestReporter.cpp">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -1,256 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="TestUnitTest++.vsnet2005"
ProjectGUID="{9CCC3439-309E-4E85-B3B8-CE704D385D48}"
RootNamespace="TestUnitTestvsnet2005"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="obj\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
ExceptionHandling="2"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="&quot;$(TargetPath)&quot;"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="obj\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
ExceptionHandling="2"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="&quot;$(TargetPath)&quot;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\src\tests\Main.cpp"
>
</File>
<File
RelativePath=".\src\tests\RecordingReporter.h"
>
</File>
<File
RelativePath=".\src\tests\ScopedCurrentTest.h"
>
</File>
<File
RelativePath=".\src\tests\TestAssertHandler.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestCheckMacros.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestChecks.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestCurrentTest.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestDeferredTestReporter.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestMemoryOutStream.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestTest.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestTestList.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestTestMacros.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestTestResults.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestTestRunner.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestTestSuite.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestTimeConstraint.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestTimeConstraintMacro.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestUnitTest++.cpp"
>
</File>
<File
RelativePath=".\src\tests\TestXmlTestReporter.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

11
UnitTest++.pc.in Normal file
View file

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: UnitTest++
Description: UnitTest++ is a simple C++ Unit Test Framework
URL: https://github.com/unittest-cpp/unittest-cpp
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lUnitTest++
Cflags: -I${includedir}/

View file

@ -1,30 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest++.vsnet2003", "UnitTest++.vsnet2003.vcproj", "{7E5DD804-EC63-4FA5-BB6D-53DA86806EF5}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestUnitTest++.vsnet2003", "TestUnitTest++.vsnet2003.vcproj", "{ACDF9A6A-874F-49E5-AB7C-74F8150BB4C7}"
ProjectSection(ProjectDependencies) = postProject
{7E5DD804-EC63-4FA5-BB6D-53DA86806EF5} = {7E5DD804-EC63-4FA5-BB6D-53DA86806EF5}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{7E5DD804-EC63-4FA5-BB6D-53DA86806EF5}.Debug.ActiveCfg = Debug|Win32
{7E5DD804-EC63-4FA5-BB6D-53DA86806EF5}.Debug.Build.0 = Debug|Win32
{7E5DD804-EC63-4FA5-BB6D-53DA86806EF5}.Release.ActiveCfg = Release|Win32
{7E5DD804-EC63-4FA5-BB6D-53DA86806EF5}.Release.Build.0 = Release|Win32
{ACDF9A6A-874F-49E5-AB7C-74F8150BB4C7}.Debug.ActiveCfg = Debug|Win32
{ACDF9A6A-874F-49E5-AB7C-74F8150BB4C7}.Debug.Build.0 = Debug|Win32
{ACDF9A6A-874F-49E5-AB7C-74F8150BB4C7}.Release.ActiveCfg = Release|Win32
{ACDF9A6A-874F-49E5-AB7C-74F8150BB4C7}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -1,226 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="UnitTest++.vsnet2003"
ProjectGUID="{7E5DD804-EC63-4FA5-BB6D-53DA86806EF5}"
RootNamespace="UnitTest++.vsnet2003"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="obj\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/UnitTest++.vsnet2003.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="obj\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="4"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/UnitTest++.vsnet2003.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Win32">
<File
RelativePath=".\src\Win32\TimeHelpers.cpp">
</File>
<File
RelativePath=".\src\Win32\TimeHelpers.h">
</File>
</Filter>
<File
RelativePath=".\src\AssertException.cpp">
</File>
<File
RelativePath=".\src\AssertException.h">
</File>
<File
RelativePath=".\src\CheckMacros.h">
</File>
<File
RelativePath=".\src\Checks.cpp">
</File>
<File
RelativePath=".\src\Checks.h">
</File>
<File
RelativePath=".\src\Config.h">
</File>
<File
RelativePath=".\src\CurrentTest.cpp">
</File>
<File
RelativePath=".\src\CurrentTest.h">
</File>
<File
RelativePath=".\src\DeferredTestReporter.cpp">
</File>
<File
RelativePath=".\src\DeferredTestReporter.h">
</File>
<File
RelativePath=".\src\DeferredTestResult.cpp">
</File>
<File
RelativePath=".\src\DeferredTestResult.h">
</File>
<File
RelativePath=".\src\ExecuteTest.h">
</File>
<File
RelativePath=".\src\MemoryOutStream.cpp">
</File>
<File
RelativePath=".\src\MemoryOutStream.h">
</File>
<File
RelativePath=".\src\ReportAssert.cpp">
</File>
<File
RelativePath=".\src\ReportAssert.h">
</File>
<File
RelativePath=".\src\Test.cpp">
</File>
<File
RelativePath=".\src\Test.h">
</File>
<File
RelativePath=".\src\TestDetails.cpp">
</File>
<File
RelativePath=".\src\TestDetails.h">
</File>
<File
RelativePath=".\src\TestList.cpp">
</File>
<File
RelativePath=".\src\TestList.h">
</File>
<File
RelativePath=".\src\TestMacros.h">
</File>
<File
RelativePath=".\src\TestReporter.cpp">
</File>
<File
RelativePath=".\src\TestReporter.h">
</File>
<File
RelativePath=".\src\TestReporterStdout.cpp">
</File>
<File
RelativePath=".\src\TestReporterStdout.h">
</File>
<File
RelativePath=".\src\TestResults.cpp">
</File>
<File
RelativePath=".\src\TestResults.h">
</File>
<File
RelativePath=".\src\TestRunner.cpp">
</File>
<File
RelativePath=".\src\TestRunner.h">
</File>
<File
RelativePath=".\src\TestSuite.h">
</File>
<File
RelativePath=".\src\TimeConstraint.cpp">
</File>
<File
RelativePath=".\src\TimeConstraint.h">
</File>
<File
RelativePath=".\src\TimeHelpers.h">
</File>
<File
RelativePath=".\src\UnitTest++.h">
</File>
<File
RelativePath=".\src\XmlTestReporter.cpp">
</File>
<File
RelativePath=".\src\XmlTestReporter.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -1,29 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest++.vsnet2005", "UnitTest++.vsnet2005.vcproj", "{64A4FEFE-0461-4E95-8CC1-91EF5F57DBC6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestUnitTest++.vsnet2005", "TestUnitTest++.vsnet2005.vcproj", "{9CCC3439-309E-4E85-B3B8-CE704D385D48}"
ProjectSection(ProjectDependencies) = postProject
{64A4FEFE-0461-4E95-8CC1-91EF5F57DBC6} = {64A4FEFE-0461-4E95-8CC1-91EF5F57DBC6}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{64A4FEFE-0461-4E95-8CC1-91EF5F57DBC6}.Debug|Win32.ActiveCfg = Debug|Win32
{64A4FEFE-0461-4E95-8CC1-91EF5F57DBC6}.Debug|Win32.Build.0 = Debug|Win32
{64A4FEFE-0461-4E95-8CC1-91EF5F57DBC6}.Release|Win32.ActiveCfg = Release|Win32
{64A4FEFE-0461-4E95-8CC1-91EF5F57DBC6}.Release|Win32.Build.0 = Release|Win32
{9CCC3439-309E-4E85-B3B8-CE704D385D48}.Debug|Win32.ActiveCfg = Debug|Win32
{9CCC3439-309E-4E85-B3B8-CE704D385D48}.Debug|Win32.Build.0 = Debug|Win32
{9CCC3439-309E-4E85-B3B8-CE704D385D48}.Release|Win32.ActiveCfg = Release|Win32
{9CCC3439-309E-4E85-B3B8-CE704D385D48}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -1,318 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="UnitTest++.vsnet2005"
ProjectGUID="{64A4FEFE-0461-4E95-8CC1-91EF5F57DBC6}"
RootNamespace="UnitTestvsnet2005"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="obj\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
ExceptionHandling="2"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="obj\$(ProjectName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="1"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
ExceptionHandling="2"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Win32"
>
<File
RelativePath=".\src\Win32\TimeHelpers.cpp"
>
</File>
<File
RelativePath=".\src\Win32\TimeHelpers.h"
>
</File>
</Filter>
<File
RelativePath=".\src\AssertException.cpp"
>
</File>
<File
RelativePath=".\src\AssertException.h"
>
</File>
<File
RelativePath=".\src\CheckMacros.h"
>
</File>
<File
RelativePath=".\src\Checks.cpp"
>
</File>
<File
RelativePath=".\src\Checks.h"
>
</File>
<File
RelativePath=".\src\Config.h"
>
</File>
<File
RelativePath=".\src\CurrentTest.cpp"
>
</File>
<File
RelativePath=".\src\CurrentTest.h"
>
</File>
<File
RelativePath=".\src\DeferredTestReporter.cpp"
>
</File>
<File
RelativePath=".\src\DeferredTestReporter.h"
>
</File>
<File
RelativePath=".\src\DeferredTestResult.cpp"
>
</File>
<File
RelativePath=".\src\DeferredTestResult.h"
>
</File>
<File
RelativePath=".\src\ExecuteTest.h"
>
</File>
<File
RelativePath=".\src\MemoryOutStream.cpp"
>
</File>
<File
RelativePath=".\src\MemoryOutStream.h"
>
</File>
<File
RelativePath=".\src\ReportAssert.cpp"
>
</File>
<File
RelativePath=".\src\ReportAssert.h"
>
</File>
<File
RelativePath=".\src\Test.cpp"
>
</File>
<File
RelativePath=".\src\Test.h"
>
</File>
<File
RelativePath=".\src\TestDetails.cpp"
>
</File>
<File
RelativePath=".\src\TestDetails.h"
>
</File>
<File
RelativePath=".\src\TestList.cpp"
>
</File>
<File
RelativePath=".\src\TestList.h"
>
</File>
<File
RelativePath=".\src\TestMacros.h"
>
</File>
<File
RelativePath=".\src\TestReporter.cpp"
>
</File>
<File
RelativePath=".\src\TestReporter.h"
>
</File>
<File
RelativePath=".\src\TestReporterStdout.cpp"
>
</File>
<File
RelativePath=".\src\TestReporterStdout.h"
>
</File>
<File
RelativePath=".\src\TestResults.cpp"
>
</File>
<File
RelativePath=".\src\TestResults.h"
>
</File>
<File
RelativePath=".\src\TestRunner.cpp"
>
</File>
<File
RelativePath=".\src\TestRunner.h"
>
</File>
<File
RelativePath=".\src\TestSuite.h"
>
</File>
<File
RelativePath=".\src\TimeConstraint.cpp"
>
</File>
<File
RelativePath=".\src\TimeConstraint.h"
>
</File>
<File
RelativePath=".\src\TimeHelpers.h"
>
</File>
<File
RelativePath=".\src\UnitTest++.h"
>
</File>
<File
RelativePath=".\src\XmlTestReporter.cpp"
>
</File>
<File
RelativePath=".\src\XmlTestReporter.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,15 @@
#include "AssertException.h"
#ifndef UNITTEST_NO_EXCEPTIONS
namespace UnitTest {
AssertException::AssertException()
{}
AssertException::~AssertException() throw()
{}
}
#endif

View file

@ -0,0 +1,23 @@
#ifndef UNITTEST_ASSERTEXCEPTION_H
#define UNITTEST_ASSERTEXCEPTION_H
#include "Config.h"
#ifndef UNITTEST_NO_EXCEPTIONS
#include "HelperMacros.h"
#include <exception>
namespace UnitTest {
class UNITTEST_LINKAGE AssertException : public std::exception
{
public:
AssertException();
virtual ~AssertException() throw();
};
}
#endif
#endif

216
UnitTest++/CheckMacros.h Normal file
View file

@ -0,0 +1,216 @@
#ifndef UNITTEST_CHECKMACROS_H
#define UNITTEST_CHECKMACROS_H
#include "HelperMacros.h"
#include "ExceptionMacros.h"
#include "Checks.h"
#include "AssertException.h"
#include "RequiredCheckException.h"
#include "MemoryOutStream.h"
#include "TestDetails.h"
#include "CurrentTest.h"
#include "ReportAssertImpl.h"
#define UNITTEST_CHECK(value) \
UNITTEST_MULTILINE_MACRO_BEGIN \
UNITTEST_IMPL_TRY \
({ \
if (!UnitTest::Check(value)) \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), #value); \
}) \
UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \
UNITTEST_IMPL_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream UnitTest_message; \
UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK(" #value ")"; \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
UnitTest_message.GetText()); \
}) \
UNITTEST_IMPL_CATCH_ALL \
({ \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK(" #value ")"); \
}) \
UNITTEST_MULTILINE_MACRO_END
#define UNITTEST_CHECK_EQUAL(expected, actual) \
UNITTEST_MULTILINE_MACRO_BEGIN \
UNITTEST_IMPL_TRY \
({ \
UnitTest::CheckEqual(*UnitTest::CurrentTest::Results(), expected, actual, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \
UNITTEST_IMPL_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream UnitTest_message; \
UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_EQUAL(" #expected ", " #actual ")"; \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
UnitTest_message.GetText()); \
}) \
UNITTEST_IMPL_CATCH_ALL \
({ \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_EQUAL(" #expected ", " #actual ")"); \
}) \
UNITTEST_MULTILINE_MACRO_END
#define UNITTEST_CHECK_CLOSE(expected, actual, tolerance) \
UNITTEST_MULTILINE_MACRO_BEGIN \
UNITTEST_IMPL_TRY \
({ \
UnitTest::CheckClose(*UnitTest::CurrentTest::Results(), expected, actual, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \
UNITTEST_IMPL_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream UnitTest_message; \
UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_CLOSE(" #expected ", " #actual ")"; \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
UnitTest_message.GetText()); \
}) \
UNITTEST_IMPL_CATCH_ALL \
({ \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_CLOSE(" #expected ", " #actual ")"); \
}) \
UNITTEST_MULTILINE_MACRO_END
#define UNITTEST_CHECK_ARRAY_EQUAL(expected, actual, count) \
UNITTEST_MULTILINE_MACRO_BEGIN \
UNITTEST_IMPL_TRY \
({ \
UnitTest::CheckArrayEqual(*UnitTest::CurrentTest::Results(), expected, actual, count, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \
UNITTEST_IMPL_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream UnitTest_message; \
UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY_EQUAL(" #expected ", " #actual ")"; \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
UnitTest_message.GetText()); \
}) \
UNITTEST_IMPL_CATCH_ALL \
({ \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_ARRAY_EQUAL(" #expected ", " #actual ")"); \
}) \
UNITTEST_MULTILINE_MACRO_END
#define UNITTEST_CHECK_ARRAY_CLOSE(expected, actual, count, tolerance) \
UNITTEST_MULTILINE_MACRO_BEGIN \
UNITTEST_IMPL_TRY \
({ \
UnitTest::CheckArrayClose(*UnitTest::CurrentTest::Results(), expected, actual, count, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \
UNITTEST_IMPL_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream UnitTest_message; \
UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY_CLOSE(" #expected ", " #actual ")"; \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
UnitTest_message.GetText()); \
}) \
UNITTEST_IMPL_CATCH_ALL \
({ \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_ARRAY_CLOSE(" #expected ", " #actual ")"); \
}) \
UNITTEST_MULTILINE_MACRO_END
#define UNITTEST_CHECK_ARRAY2D_CLOSE(expected, actual, rows, columns, tolerance) \
UNITTEST_MULTILINE_MACRO_BEGIN \
UNITTEST_IMPL_TRY \
({ \
UnitTest::CheckArray2DClose(*UnitTest::CurrentTest::Results(), expected, actual, rows, columns, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
}) \
UNITTEST_IMPL_RETHROW (UnitTest::RequiredCheckException) \
UNITTEST_IMPL_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream UnitTest_message; \
UnitTest_message << "Unhandled exception (" << e.what() << ") in CHECK_ARRAY2D_CLOSE(" #expected ", " #actual ")"; \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
UnitTest_message.GetText()); \
}) \
UNITTEST_IMPL_CATCH_ALL \
({ \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_ARRAY2D_CLOSE(" #expected ", " #actual ")"); \
}) \
UNITTEST_MULTILINE_MACRO_END
#ifndef UNITTEST_DISABLE_SHORT_MACROS
#ifdef CHECK
#error CHECK already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK instead
#else
#define CHECK UNITTEST_CHECK
#endif
#ifdef CHECK_EQUAL
#error CHECK_EQUAL already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_EQUAL instead
#else
#define CHECK_EQUAL UNITTEST_CHECK_EQUAL
#endif
#ifdef CHECK_CLOSE
#error CHECK_CLOSE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_CLOSE instead
#else
#define CHECK_CLOSE UNITTEST_CHECK_CLOSE
#endif
#ifdef CHECK_ARRAY_EQUAL
#error CHECK_ARRAY_EQUAL already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_ARRAY_EQUAL instead
#else
#define CHECK_ARRAY_EQUAL UNITTEST_CHECK_ARRAY_EQUAL
#endif
#ifdef CHECK_ARRAY_CLOSE
#error CHECK_ARRAY_CLOSE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_ARRAY_CLOSE instead
#else
#define CHECK_ARRAY_CLOSE UNITTEST_CHECK_ARRAY_CLOSE
#endif
#ifdef CHECK_ARRAY2D_CLOSE
#error CHECK_ARRAY2D_CLOSE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_ARRAY2D_CLOSE instead
#else
#define CHECK_ARRAY2D_CLOSE UNITTEST_CHECK_ARRAY2D_CLOSE
#endif
#endif
// CHECK_THROW and CHECK_ASSERT only exist when UNITTEST_NO_EXCEPTIONS isn't defined (see config.h)
#ifndef UNITTEST_NO_EXCEPTIONS
#define UNITTEST_CHECK_THROW(expression, ExpectedExceptionType) \
UNITTEST_MULTILINE_MACRO_BEGIN \
bool caught_ = false; \
try { expression; } \
catch (ExpectedExceptionType const&) { caught_ = true; } \
catch (...) {} \
if (!caught_) \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), "Expected exception: \"" #ExpectedExceptionType "\" not thrown"); \
UNITTEST_MULTILINE_MACRO_END
#define UNITTEST_CHECK_ASSERT(expression) \
UNITTEST_MULTILINE_MACRO_BEGIN \
UnitTest::Detail::ExpectAssert(true); \
CHECK_THROW(expression, UnitTest::AssertException); \
UnitTest::Detail::ExpectAssert(false); \
UNITTEST_MULTILINE_MACRO_END
#endif
#ifndef UNITTEST_DISABLE_SHORT_MACROS
#ifdef CHECK_THROW
#error CHECK_THROW already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_THROW instead
#else
#define CHECK_THROW UNITTEST_CHECK_THROW
#endif
#ifdef CHECK_ASSERT
#error CHECK_ASSERT already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_CHECK_ASSERT instead
#else
#define CHECK_ASSERT UNITTEST_CHECK_ASSERT
#endif
#endif
#endif

50
UnitTest++/Checks.cpp Normal file
View file

@ -0,0 +1,50 @@
#include "Checks.h"
#include <cstring>
namespace UnitTest {
namespace {
void CheckStringsEqual(TestResults& results, char const* expected, char const* actual,
TestDetails const& details)
{
using namespace std;
if ((expected && actual) ? strcmp(expected, actual) : (expected || actual))
{
UnitTest::MemoryOutStream stream;
stream << "Expected " << (expected ? expected : "<NULLPTR>") << " but was " << (actual ? actual : "<NULLPTR>");
results.OnTestFailure(details, stream.GetText());
}
}
}
void CheckEqual(TestResults& results, char const* expected, char const* actual,
TestDetails const& details)
{
CheckStringsEqual(results, expected, actual, details);
}
void CheckEqual(TestResults& results, char* expected, char* actual,
TestDetails const& details)
{
CheckStringsEqual(results, expected, actual, details);
}
void CheckEqual(TestResults& results, char* expected, char const* actual,
TestDetails const& details)
{
CheckStringsEqual(results, expected, actual, details);
}
void CheckEqual(TestResults& results, char const* expected, char* actual,
TestDetails const& details)
{
CheckStringsEqual(results, expected, actual, details);
}
}

158
UnitTest++/Checks.h Normal file
View file

@ -0,0 +1,158 @@
#ifndef UNITTEST_CHECKS_H
#define UNITTEST_CHECKS_H
#include "Config.h"
#include "TestResults.h"
#include "MemoryOutStream.h"
namespace UnitTest {
template< typename Value >
bool Check(Value const& value)
{
return !!value; // doing double negative to avoid silly VS warnings
}
template< typename Expected, typename Actual >
void CheckEqual(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details)
{
if (!(expected == actual))
{
UnitTest::MemoryOutStream stream;
stream << "Expected " << expected << " but was " << actual;
results.OnTestFailure(details, stream.GetText());
}
}
UNITTEST_LINKAGE void CheckEqual(TestResults& results, char const* expected, char const* actual, TestDetails const& details);
UNITTEST_LINKAGE void CheckEqual(TestResults& results, char* expected, char* actual, TestDetails const& details);
UNITTEST_LINKAGE void CheckEqual(TestResults& results, char* expected, char const* actual, TestDetails const& details);
UNITTEST_LINKAGE void CheckEqual(TestResults& results, char const* expected, char* actual, TestDetails const& details);
template< typename Expected, typename Actual, typename Tolerance >
bool AreClose(Expected const& expected, Actual const& actual, Tolerance const& tolerance)
{
return (actual >= (expected - tolerance)) && (actual <= (expected + tolerance));
}
template< typename Expected, typename Actual, typename Tolerance >
void CheckClose(TestResults& results, Expected const& expected, Actual const& actual, Tolerance const& tolerance,
TestDetails const& details)
{
if (!AreClose(expected, actual, tolerance))
{
UnitTest::MemoryOutStream stream;
stream << "Expected " << expected << " +/- " << tolerance << " but was " << actual;
results.OnTestFailure(details, stream.GetText());
}
}
template< typename Expected, typename Actual >
void CheckArrayEqual(TestResults& results, Expected const& expected, Actual const& actual,
size_t const count, TestDetails const& details)
{
bool equal = true;
for (size_t i = 0; i < count; ++i)
equal &= (expected[i] == actual[i]);
if (!equal)
{
UnitTest::MemoryOutStream stream;
stream << "Expected [ ";
for (size_t expectedIndex = 0; expectedIndex < count; ++expectedIndex)
stream << expected[expectedIndex] << " ";
stream << "] but was [ ";
for (size_t actualIndex = 0; actualIndex < count; ++actualIndex)
stream << actual[actualIndex] << " ";
stream << "]";
results.OnTestFailure(details, stream.GetText());
}
}
template< typename Expected, typename Actual, typename Tolerance >
bool ArrayAreClose(Expected const& expected, Actual const& actual, size_t const count, Tolerance const& tolerance)
{
bool equal = true;
for (size_t i = 0; i < count; ++i)
equal &= AreClose(expected[i], actual[i], tolerance);
return equal;
}
template< typename Expected, typename Actual, typename Tolerance >
void CheckArrayClose(TestResults& results, Expected const& expected, Actual const& actual,
size_t const count, Tolerance const& tolerance, TestDetails const& details)
{
bool equal = ArrayAreClose(expected, actual, count, tolerance);
if (!equal)
{
UnitTest::MemoryOutStream stream;
stream << "Expected [ ";
for (size_t expectedIndex = 0; expectedIndex < count; ++expectedIndex)
stream << expected[expectedIndex] << " ";
stream << "] +/- " << tolerance << " but was [ ";
for (size_t actualIndex = 0; actualIndex < count; ++actualIndex)
stream << actual[actualIndex] << " ";
stream << "]";
results.OnTestFailure(details, stream.GetText());
}
}
template< typename Expected, typename Actual, typename Tolerance >
void CheckArray2DClose(TestResults& results, Expected const& expected, Actual const& actual,
size_t const rows, size_t const columns, Tolerance const& tolerance, TestDetails const& details)
{
bool equal = true;
for (size_t i = 0; i < rows; ++i)
equal &= ArrayAreClose(expected[i], actual[i], columns, tolerance);
if (!equal)
{
UnitTest::MemoryOutStream stream;
stream << "Expected [ ";
for (size_t expectedRow = 0; expectedRow < rows; ++expectedRow)
{
stream << "[ ";
for (size_t expectedColumn = 0; expectedColumn < columns; ++expectedColumn)
stream << expected[expectedRow][expectedColumn] << " ";
stream << "] ";
}
stream << "] +/- " << tolerance << " but was [ ";
for (size_t actualRow = 0; actualRow < rows; ++actualRow)
{
stream << "[ ";
for (size_t actualColumn = 0; actualColumn < columns; ++actualColumn)
stream << actual[actualRow][actualColumn] << " ";
stream << "] ";
}
stream << "]";
results.OnTestFailure(details, stream.GetText());
}
}
}
#endif

View file

@ -0,0 +1,66 @@
#include "CompositeTestReporter.h"
#include <cstddef>
namespace UnitTest {
CompositeTestReporter::CompositeTestReporter()
: m_reporterCount(0)
{}
int CompositeTestReporter::GetReporterCount() const
{
return m_reporterCount;
}
bool CompositeTestReporter::AddReporter(TestReporter* reporter)
{
if (m_reporterCount == kMaxReporters)
return false;
m_reporters[m_reporterCount++] = reporter;
return true;
}
bool CompositeTestReporter::RemoveReporter(TestReporter* reporter)
{
for (int index = 0; index < m_reporterCount; ++index)
{
if (m_reporters[index] == reporter)
{
m_reporters[index] = m_reporters[m_reporterCount - 1];
--m_reporterCount;
return true;
}
}
return false;
}
void CompositeTestReporter::ReportFailure(TestDetails const& details, char const* failure)
{
for (int index = 0; index < m_reporterCount; ++index)
m_reporters[index]->ReportFailure(details, failure);
}
void CompositeTestReporter::ReportTestStart(TestDetails const& test)
{
for (int index = 0; index < m_reporterCount; ++index)
m_reporters[index]->ReportTestStart(test);
}
void CompositeTestReporter::ReportTestFinish(TestDetails const& test, float secondsElapsed)
{
for (int index = 0; index < m_reporterCount; ++index)
m_reporters[index]->ReportTestFinish(test, secondsElapsed);
}
void CompositeTestReporter::ReportSummary(int totalTestCount,
int failedTestCount,
int failureCount,
float secondsElapsed)
{
for (int index = 0; index < m_reporterCount; ++index)
m_reporters[index]->ReportSummary(totalTestCount, failedTestCount, failureCount, secondsElapsed);
}
}

View file

@ -0,0 +1,34 @@
#ifndef UNITTEST_COMPOSITETESTREPORTER_H
#define UNITTEST_COMPOSITETESTREPORTER_H
#include "TestReporter.h"
namespace UnitTest {
class UNITTEST_LINKAGE CompositeTestReporter : public TestReporter
{
public:
CompositeTestReporter();
int GetReporterCount() const;
bool AddReporter(TestReporter* reporter);
bool RemoveReporter(TestReporter* reporter);
virtual void ReportTestStart(TestDetails const& test);
virtual void ReportFailure(TestDetails const& test, char const* failure);
virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed);
virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed);
private:
enum { kMaxReporters = 16 };
TestReporter* m_reporters[kMaxReporters];
int m_reporterCount;
// revoked
CompositeTestReporter(const CompositeTestReporter&);
CompositeTestReporter& operator =(const CompositeTestReporter&);
};
}
#endif

84
UnitTest++/Config.h Normal file
View file

@ -0,0 +1,84 @@
#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
#define UNITTEST_COMPILER_IS_MSVC6
#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__) \
|| defined (__HAIKU__) || defined(_AIX)
#define UNITTEST_POSIX
#endif
#if defined(__MINGW32__)
#define UNITTEST_MINGW
#endif
// By default, MemoryOutStream is 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)
//
// On the other hand, it can be more expensive.
// Un-comment this line to use the custom MemoryOutStream (no deps on std::ostringstream).
// #define UNITTEST_USE_CUSTOM_STREAMS
// Developer note: This dual-macro setup is to preserve compatibility with UnitTest++ 1.4 users
// who may have used or defined UNITTEST_USE_CUSTOM_STREAMS outside of this configuration file, as
// well as Google Code HEAD users that may have used or defined
// UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM outside of this configuration file.
#ifndef UNITTEST_USE_CUSTOM_STREAMS
#define UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM
#endif
// 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
// std namespace qualification: used for functions like strcpy that
// may live in std:: namespace (cstring header).
#if defined( UNITTEST_COMPILER_IS_MSVC6 )
#define UNIITEST_NS_QUAL_STD(x) x
#else
#define UNIITEST_NS_QUAL_STD(x) ::std::x
#endif
// By default, UnitTest++ will attempt to define "short" macro names like CHECK and CHECK_EQUAL
// for "public" interface macros etc. Defining UNITTEST_DISABLE_SHORT_MACROS in your project
// will disable this behavior, leaving only the longer macros "namespaced" with the UNITTEST_
// prefix.
//
// "Internal" utility macros will only have the UNITTEST_IMPL_ prefix.
// #define UNITTEST_DISABLE_SHORT_MACROS
#endif

View file

@ -0,0 +1,18 @@
#include "CurrentTest.h"
#include <cstddef>
namespace UnitTest {
UNITTEST_LINKAGE TestResults*& CurrentTest::Results()
{
static TestResults* testResults = NULL;
return testResults;
}
UNITTEST_LINKAGE const TestDetails*& CurrentTest::Details()
{
static const TestDetails* testDetails = NULL;
return testDetails;
}
}

19
UnitTest++/CurrentTest.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef UNITTEST_CURRENTTESTRESULTS_H
#define UNITTEST_CURRENTTESTRESULTS_H
#include "HelperMacros.h"
namespace UnitTest {
class TestResults;
class TestDetails;
namespace CurrentTest
{
UNITTEST_LINKAGE TestResults*& Results();
UNITTEST_LINKAGE const TestDetails*& Details();
}
}
#endif

View file

@ -1,29 +1,33 @@
#include "DeferredTestReporter.h"
#include "TestDetails.h"
#include "Config.h"
using namespace UnitTest;
void DeferredTestReporter::ReportTestStart(TestDetails const& details)
{
m_results.push_back(DeferredTestResult(details.suiteName, details.testName));
}
void DeferredTestReporter::ReportFailure(TestDetails const& details, char const* failure)
{
DeferredTestResult& r = m_results.back();
r.failed = true;
r.failures.push_back(DeferredTestResult::Failure(details.lineNumber, failure));
r.failureFile = details.filename;
}
void DeferredTestReporter::ReportTestFinish(TestDetails const&, float secondsElapsed)
{
DeferredTestResult& r = m_results.back();
r.timeElapsed = secondsElapsed;
}
DeferredTestReporter::DeferredTestResultList& DeferredTestReporter::GetResults()
{
return m_results;
}
#include "Config.h"
#ifndef UNITTEST_NO_DEFERRED_REPORTER
#include "DeferredTestReporter.h"
#include "TestDetails.h"
using namespace UnitTest;
void DeferredTestReporter::ReportTestStart(TestDetails const& details)
{
m_results.push_back(DeferredTestResult(details.suiteName, details.testName));
}
void DeferredTestReporter::ReportFailure(TestDetails const& details, char const* failure)
{
DeferredTestResult& r = m_results.back();
r.failed = true;
r.failures.push_back(DeferredTestFailure(details.lineNumber, failure));
r.failureFile = details.filename;
}
void DeferredTestReporter::ReportTestFinish(TestDetails const&, float secondsElapsed)
{
DeferredTestResult& r = m_results.back();
r.timeElapsed = secondsElapsed;
}
DeferredTestReporter::DeferredTestResultList& DeferredTestReporter::GetResults()
{
return m_results;
}
#endif

View file

@ -0,0 +1,35 @@
#ifndef UNITTEST_DEFERREDTESTREPORTER_H
#define UNITTEST_DEFERREDTESTREPORTER_H
#include "Config.h"
#ifndef UNITTEST_NO_DEFERRED_REPORTER
#include "TestReporter.h"
#include "DeferredTestResult.h"
#include <vector>
UNITTEST_STDVECTOR_LINKAGE(UnitTest::DeferredTestResult);
namespace UnitTest
{
class UNITTEST_LINKAGE DeferredTestReporter : public TestReporter
{
public:
virtual void ReportTestStart(TestDetails const& details);
virtual void ReportFailure(TestDetails const& details, char const* failure);
virtual void ReportTestFinish(TestDetails const& details, float secondsElapsed);
typedef std::vector< DeferredTestResult > DeferredTestResultList;
DeferredTestResultList& GetResults();
private:
DeferredTestResultList m_results;
};
}
#endif
#endif

View file

@ -0,0 +1,43 @@
#include "Config.h"
#ifndef UNITTEST_NO_DEFERRED_REPORTER
#include "DeferredTestResult.h"
#include <cstring>
namespace UnitTest
{
DeferredTestFailure::DeferredTestFailure()
: lineNumber(-1)
{
failureStr[0] = '\0';
}
DeferredTestFailure::DeferredTestFailure(int lineNumber_, const char* failureStr_)
: lineNumber(lineNumber_)
{
UNIITEST_NS_QUAL_STD(strcpy)(failureStr, failureStr_);
}
DeferredTestResult::DeferredTestResult()
: suiteName("")
, testName("")
, failureFile("")
, timeElapsed(0.0f)
, failed(false)
{}
DeferredTestResult::DeferredTestResult(char const* suite, char const* test)
: suiteName(suite)
, testName(test)
, failureFile("")
, timeElapsed(0.0f)
, failed(false)
{}
DeferredTestResult::~DeferredTestResult()
{}
}
#endif

View file

@ -0,0 +1,52 @@
#ifndef UNITTEST_DEFERREDTESTRESULT_H
#define UNITTEST_DEFERREDTESTRESULT_H
#include "Config.h"
#ifndef UNITTEST_NO_DEFERRED_REPORTER
#include "HelperMacros.h"
#include <string>
#include <vector>
namespace UnitTest
{
class UNITTEST_LINKAGE DeferredTestFailure
{
public:
DeferredTestFailure();
DeferredTestFailure(int lineNumber_, const char* failureStr_);
int lineNumber;
char failureStr[1024];
};
}
UNITTEST_STDVECTOR_LINKAGE(UnitTest::DeferredTestFailure);
namespace UnitTest
{
class UNITTEST_LINKAGE DeferredTestResult
{
public:
DeferredTestResult();
DeferredTestResult(char const* suite, char const* test);
~DeferredTestResult();
std::string suiteName;
std::string testName;
std::string failureFile;
typedef std::vector< DeferredTestFailure > FailureVec;
FailureVec failures;
float timeElapsed;
bool failed;
};
}
#endif
#endif

View file

@ -0,0 +1,20 @@
#ifndef UNITTEST_EXCEPTIONMACROS_H
#define UNITTEST_EXCEPTIONMACROS_H
#include "Config.h"
#ifndef UNITTEST_NO_EXCEPTIONS
#define UNITTEST_IMPL_TRY(x) try x
#define UNITTEST_IMPL_THROW(x) throw x
#define UNITTEST_IMPL_RETHROW(ExceptionType) catch(ExceptionType&) { throw; }
#define UNITTEST_IMPL_CATCH(ExceptionType, ExceptionName, CatchBody) catch(ExceptionType& ExceptionName) CatchBody
#define UNITTEST_IMPL_CATCH_ALL(CatchBody) catch(...) CatchBody
#else
#define UNITTEST_IMPL_TRY(x) x
#define UNITTEST_IMPL_THROW(x)
#define UNITTEST_IMPL_RETHROW(ExceptionType)
#define UNITTEST_IMPL_CATCH(ExceptionType, ExceptionName, CatchBody)
#define UNITTEST_IMPL_CATCH_ALL(CatchBody)
#endif
#endif

61
UnitTest++/ExecuteTest.h Normal file
View file

@ -0,0 +1,61 @@
#ifndef UNITTEST_EXECUTE_TEST_H
#define UNITTEST_EXECUTE_TEST_H
#include "Config.h"
#include "ExceptionMacros.h"
#include "TestDetails.h"
#include "TestResults.h"
#include "MemoryOutStream.h"
#include "AssertException.h"
#include "RequiredCheckException.h"
#include "CurrentTest.h"
#ifdef UNITTEST_NO_EXCEPTIONS
#include "ReportAssertImpl.h"
#endif
#ifdef UNITTEST_POSIX
#include "Posix/SignalTranslator.h"
#endif
namespace UnitTest {
template< typename T >
void ExecuteTest(T& testObject, TestDetails const& details, bool isMockTest)
{
if (isMockTest == false)
CurrentTest::Details() = &details;
#ifdef UNITTEST_NO_EXCEPTIONS
if (UNITTEST_SET_ASSERT_JUMP_TARGET() == 0)
{
#endif
#ifndef UNITTEST_POSIX
UNITTEST_IMPL_TRY({ testObject.RunImpl(); })
#else
UNITTEST_IMPL_TRY
({
UNITTEST_THROW_SIGNALS_POSIX_ONLY
testObject.RunImpl();
})
#endif
UNITTEST_IMPL_CATCH(RequiredCheckException, e, { (void)e; })
UNITTEST_IMPL_CATCH(AssertException, e, { (void)e; })
UNITTEST_IMPL_CATCH(std::exception, e,
{
MemoryOutStream stream;
stream << "Unhandled exception: " << e.what();
CurrentTest::Results()->OnTestFailure(details, stream.GetText());
})
UNITTEST_IMPL_CATCH_ALL
({
CurrentTest::Results()->OnTestFailure(details, "Unhandled exception: test crashed");
})
#ifdef UNITTEST_NO_EXCEPTIONS
}
#endif
}
}
#endif

52
UnitTest++/HelperMacros.h Normal file
View file

@ -0,0 +1,52 @@
#ifndef UNITTEST_HELPERMACROS_H
#define UNITTEST_HELPERMACROS_H
#include "Config.h"
#define UNITTEST_MULTILINE_MACRO_BEGIN do {
#if defined(UNITTEST_WIN32) && !defined(UNITTEST_COMPILER_IS_MSVC6)
#define UNITTEST_MULTILINE_MACRO_END \
} __pragma(warning(push)) __pragma(warning(disable: 4127)) while (0) __pragma(warning(pop))
#else
#define UNITTEST_MULTILINE_MACRO_END } while(0)
#endif
#ifdef UNITTEST_WIN32_DLL
#define UNITTEST_IMPORT __declspec(dllimport)
#define UNITTEST_EXPORT __declspec(dllexport)
#ifdef UNITTEST_DLL_EXPORT
#define UNITTEST_LINKAGE UNITTEST_EXPORT
#define UNITTEST_IMPEXP_TEMPLATE
#else
#define UNITTEST_LINKAGE UNITTEST_IMPORT
#define UNITTEST_IMPEXP_TEMPLATE extern
#endif
#define UNITTEST_STDVECTOR_LINKAGE(T) \
__pragma(warning(push)) \
__pragma(warning(disable: 4231)) \
UNITTEST_IMPEXP_TEMPLATE template class UNITTEST_LINKAGE std::allocator< T >; \
UNITTEST_IMPEXP_TEMPLATE template class UNITTEST_LINKAGE std::vector< T >; \
__pragma(warning(pop))
#else
#define UNITTEST_IMPORT
#define UNITTEST_EXPORT
#define UNITTEST_LINKAGE
#define UNITTEST_IMPEXP_TEMPLATE
#define UNITTEST_STDVECTOR_LINKAGE(T)
#endif
#ifdef UNITTEST_WIN32
#define UNITTEST_JMPBUF jmp_buf
#define UNITTEST_SETJMP setjmp
#define UNITTEST_LONGJMP longjmp
#elif defined UNITTEST_POSIX
#define UNITTEST_JMPBUF std::jmp_buf
#define UNITTEST_SETJMP setjmp
#define UNITTEST_LONGJMP std::longjmp
#endif
#endif

17
UnitTest++/Makefile.am Normal file
View file

@ -0,0 +1,17 @@
lib_LTLIBRARIES = UnitTest++/libUnitTest++.la
pkgincludedir = $(includedir)
nobase_pkginclude_HEADERS = UnitTest++/AssertException.h UnitTest++/CheckMacros.h UnitTest++/Checks.h UnitTest++/CompositeTestReporter.h UnitTest++/Config.h UnitTest++/CurrentTest.h UnitTest++/DeferredTestReporter.h UnitTest++/DeferredTestResult.h UnitTest++/ExceptionMacros.h UnitTest++/ExecuteTest.h UnitTest++/HelperMacros.h UnitTest++/MemoryOutStream.h UnitTest++/ReportAssert.h UnitTest++/ReportAssertImpl.h UnitTest++/RequireMacros.h UnitTest++/RequiredCheckException.h UnitTest++/RequiredCheckTestReporter.h UnitTest++/Test.h UnitTest++/TestDetails.h UnitTest++/TestList.h UnitTest++/TestMacros.h UnitTest++/TestReporter.h UnitTest++/TestReporterStdout.h UnitTest++/TestResults.h UnitTest++/TestRunner.h UnitTest++/TestSuite.h UnitTest++/ThrowingTestReporter.h UnitTest++/TimeConstraint.h UnitTest++/TimeHelpers.h UnitTest++/UnitTest++.h UnitTest++/UnitTestPP.h UnitTest++/XmlTestReporter.h
UnitTest___libUnitTest___la_SOURCES = UnitTest++/AssertException.cpp UnitTest++/Checks.cpp UnitTest++/CompositeTestReporter.cpp UnitTest++/CurrentTest.cpp UnitTest++/DeferredTestReporter.cpp UnitTest++/DeferredTestResult.cpp UnitTest++/MemoryOutStream.cpp UnitTest++/ReportAssert.cpp UnitTest++/RequiredCheckException.cpp UnitTest++/RequiredCheckTestReporter.cpp UnitTest++/Test.cpp UnitTest++/TestDetails.cpp UnitTest++/TestList.cpp UnitTest++/TestReporter.cpp UnitTest++/TestReporterStdout.cpp UnitTest++/TestResults.cpp UnitTest++/TestRunner.cpp UnitTest++/ThrowingTestReporter.cpp UnitTest++/TimeConstraint.cpp UnitTest++/XmlTestReporter.cpp
if WINDOWS
nobase_pkginclude_HEADERS += UnitTest++/Win32/TimeHelpers.h
UnitTest___libUnitTest___la_SOURCES += UnitTest++/Win32/TimeHelpers.cpp
else
nobase_pkginclude_HEADERS += UnitTest++/Posix/SignalTranslator.h UnitTest++/Posix/TimeHelpers.h
UnitTest___libUnitTest___la_SOURCES += UnitTest++/Posix/SignalTranslator.cpp UnitTest++/Posix/TimeHelpers.cpp
endif
UnitTest___libUnitTest___la_LDFLAGS = -version-number @LIBUNITTEST_SO_VERSION@

View file

@ -0,0 +1,218 @@
#include "MemoryOutStream.h"
#ifdef UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM
namespace UnitTest {
char const* MemoryOutStream::GetText() const
{
m_text = this->str();
return m_text.c_str();
}
void MemoryOutStream::Clear()
{
this->str(std::string());
m_text = this->str();
}
#ifdef UNITTEST_COMPILER_IS_MSVC6
#define snprintf _snprintf
template<typename ValueType>
std::ostream& FormatToStream(std::ostream& stream, char const* format, ValueType const& value)
{
using namespace std;
const size_t BUFFER_SIZE=32;
char txt[BUFFER_SIZE];
snprintf(txt, BUFFER_SIZE, format, value);
return stream << txt;
}
std::ostream& operator<<(std::ostream& stream, __int64 const n)
{
return FormatToStream(stream, "%I64d", n);
}
std::ostream& operator<<(std::ostream& stream, unsigned __int64 const n)
{
return FormatToStream(stream, "%I64u", n);
}
#endif
}
#else
#include <cstring>
#include <cstdio>
#if _MSC_VER
#define snprintf _snprintf
#endif
namespace UnitTest {
namespace {
template<typename ValueType>
void FormatToStream(MemoryOutStream& stream, char const* format, ValueType const& value)
{
using namespace std;
const size_t BUFFER_SIZE=32;
char txt[BUFFER_SIZE];
snprintf(txt, BUFFER_SIZE, format, value);
stream << txt;
}
int RoundUpToMultipleOfPow2Number (int n, int pow2Number)
{
return (n + (pow2Number - 1)) & ~(pow2Number - 1);
}
}
MemoryOutStream::MemoryOutStream(int const size)
: m_capacity (0)
, m_buffer (0)
{
GrowBuffer(size);
}
MemoryOutStream::~MemoryOutStream()
{
delete [] m_buffer;
}
void MemoryOutStream::Clear()
{
m_buffer[0] = '\0';
}
char const* MemoryOutStream::GetText() const
{
return m_buffer;
}
MemoryOutStream& MemoryOutStream::operator <<(char const* txt)
{
using namespace std;
int const bytesLeft = m_capacity - (int)strlen(m_buffer);
int const bytesRequired = (int)strlen(txt) + 1;
if (bytesRequired > bytesLeft)
{
int const requiredCapacity = bytesRequired + m_capacity - bytesLeft;
GrowBuffer(requiredCapacity);
}
strcat(m_buffer, txt);
return *this;
}
MemoryOutStream& MemoryOutStream::operator <<(int const n)
{
FormatToStream(*this, "%i", n);
return *this;
}
MemoryOutStream& MemoryOutStream::operator <<(long const n)
{
FormatToStream(*this, "%li", n);
return *this;
}
MemoryOutStream& MemoryOutStream::operator <<(unsigned long const n)
{
FormatToStream(*this, "%lu", n);
return *this;
}
#ifdef UNITTEST_COMPILER_IS_MSVC6
MemoryOutStream& MemoryOutStream::operator <<(__int64 const n)
#else
MemoryOutStream& MemoryOutStream::operator <<(long long const n)
#endif
{
#ifdef UNITTEST_WIN32
FormatToStream(*this, "%I64d", n);
#else
FormatToStream(*this, "%lld", n);
#endif
return *this;
}
#ifdef UNITTEST_COMPILER_IS_MSVC6
MemoryOutStream& MemoryOutStream::operator <<(unsigned __int64 const n)
#else
MemoryOutStream& MemoryOutStream::operator <<(unsigned long long const n)
#endif
{
#ifdef UNITTEST_WIN32
FormatToStream(*this, "%I64u", n);
#else
FormatToStream(*this, "%llu", n);
#endif
return *this;
}
MemoryOutStream& MemoryOutStream::operator <<(float const f)
{
FormatToStream(*this, "%0.6f", f);
return *this;
}
MemoryOutStream& MemoryOutStream::operator <<(void const* p)
{
FormatToStream(*this, "%p", p);
return *this;
}
MemoryOutStream& MemoryOutStream::operator <<(unsigned int const s)
{
FormatToStream(*this, "%u", s);
return *this;
}
MemoryOutStream& MemoryOutStream::operator <<(double const d)
{
FormatToStream(*this, "%0.6f", d);
return *this;
}
int MemoryOutStream::GetCapacity() const
{
return m_capacity;
}
void MemoryOutStream::GrowBuffer(int const desiredCapacity)
{
int const newCapacity = RoundUpToMultipleOfPow2Number(desiredCapacity, GROW_CHUNK_SIZE);
using namespace std;
char* buffer = new char[newCapacity];
if (m_buffer)
strcpy(buffer, m_buffer);
else
strcpy(buffer, "");
delete [] m_buffer;
m_buffer = buffer;
m_capacity = newCapacity;
}
}
#endif

View file

@ -0,0 +1,87 @@
#ifndef UNITTEST_MEMORYOUTSTREAM_H
#define UNITTEST_MEMORYOUTSTREAM_H
#include "Config.h"
#include "HelperMacros.h"
#ifdef UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM
#include <sstream>
namespace UnitTest
{
class UNITTEST_LINKAGE MemoryOutStream : public std::ostringstream
{
public:
MemoryOutStream() {}
~MemoryOutStream() {}
void Clear();
char const* GetText() const;
private:
MemoryOutStream(MemoryOutStream const&);
void operator =(MemoryOutStream const&);
mutable std::string m_text;
};
#ifdef UNITTEST_COMPILER_IS_MSVC6
std::ostream& operator<<(std::ostream& stream, __int64 const n);
std::ostream& operator<<(std::ostream& stream, unsigned __int64 const n);
#endif
}
#else
#include <cstddef>
#ifdef UNITTEST_COMPILER_IS_MSVC6
namespace std {}
#endif
namespace UnitTest
{
class UNITTEST_LINKAGE MemoryOutStream
{
public:
explicit MemoryOutStream(int const size = 256);
~MemoryOutStream();
void Clear();
char const* GetText() const;
MemoryOutStream& operator <<(char const* txt);
MemoryOutStream& operator <<(int n);
MemoryOutStream& operator <<(long n);
MemoryOutStream& operator <<(unsigned long n);
#ifdef UNITTEST_COMPILER_IS_MSVC6
MemoryOutStream& operator <<(__int64 n);
MemoryOutStream& operator <<(unsigned __int64 n);
#else
MemoryOutStream& operator <<(long long n);
MemoryOutStream& operator <<(unsigned long long n);
#endif
MemoryOutStream& operator <<(float f);
MemoryOutStream& operator <<(double d);
MemoryOutStream& operator <<(void const* p);
MemoryOutStream& operator <<(unsigned int s);
enum { GROW_CHUNK_SIZE = 32 };
int GetCapacity() const;
private:
void operator= (MemoryOutStream const&);
void GrowBuffer(int capacity);
int m_capacity;
char* m_buffer;
};
}
#endif
#endif

View file

@ -0,0 +1,46 @@
#include "SignalTranslator.h"
namespace UnitTest {
sigjmp_buf* SignalTranslator::s_jumpTarget = 0;
namespace {
void SignalHandler(int sig)
{
siglongjmp(*SignalTranslator::s_jumpTarget, sig );
}
}
SignalTranslator::SignalTranslator()
{
m_oldJumpTarget = s_jumpTarget;
s_jumpTarget = &m_currentJumpTarget;
struct sigaction action;
action.sa_flags = 0;
action.sa_handler = SignalHandler;
sigemptyset( &action.sa_mask );
sigaction( SIGSEGV, &action, &m_old_SIGSEGV_action );
sigaction( SIGFPE, &action, &m_old_SIGFPE_action );
sigaction( SIGTRAP, &action, &m_old_SIGTRAP_action );
sigaction( SIGBUS, &action, &m_old_SIGBUS_action );
sigaction( SIGILL, &action, &m_old_SIGILL_action );
}
SignalTranslator::~SignalTranslator()
{
sigaction( SIGILL, &m_old_SIGILL_action, 0 );
sigaction( SIGBUS, &m_old_SIGBUS_action, 0 );
sigaction( SIGTRAP, &m_old_SIGTRAP_action, 0 );
sigaction( SIGFPE, &m_old_SIGFPE_action, 0 );
sigaction( SIGSEGV, &m_old_SIGSEGV_action, 0 );
s_jumpTarget = m_oldJumpTarget;
}
}

View file

@ -0,0 +1,41 @@
#ifndef UNITTEST_SIGNALTRANSLATOR_H
#define UNITTEST_SIGNALTRANSLATOR_H
#include <setjmp.h>
#include <signal.h>
namespace UnitTest {
class SignalTranslator
{
public:
SignalTranslator();
~SignalTranslator();
static sigjmp_buf* s_jumpTarget;
private:
sigjmp_buf m_currentJumpTarget;
sigjmp_buf* m_oldJumpTarget;
struct sigaction m_old_SIGFPE_action;
struct sigaction m_old_SIGTRAP_action;
struct sigaction m_old_SIGSEGV_action;
struct sigaction m_old_SIGBUS_action;
struct sigaction m_old_SIGILL_action;
};
#if !defined (__GNUC__)
#define UNITTEST_EXTENSION
#else
#define UNITTEST_EXTENSION __extension__
#endif
#define UNITTEST_THROW_SIGNALS_POSIX_ONLY \
UnitTest::SignalTranslator sig; \
if (UNITTEST_EXTENSION sigsetjmp(*UnitTest::SignalTranslator::s_jumpTarget, 1) != 0) \
throw ("Unhandled system exception");
}
#endif

View file

@ -0,0 +1,33 @@
#include "TimeHelpers.h"
#include <unistd.h>
namespace UnitTest {
Timer::Timer()
{
m_startTime.tv_sec = 0;
m_startTime.tv_usec = 0;
}
void Timer::Start()
{
gettimeofday(&m_startTime, 0);
}
double Timer::GetTimeInMs() const
{
struct timeval currentTime;
gettimeofday(&currentTime, 0);
double const dsecs = currentTime.tv_sec - m_startTime.tv_sec;
double const dus = currentTime.tv_usec - m_startTime.tv_usec;
return (dsecs * 1000.0) + (dus / 1000.0);
}
void TimeHelpers::SleepMs(int ms)
{
usleep(static_cast<useconds_t>(ms * 1000));
}
}

View file

@ -0,0 +1,28 @@
#ifndef UNITTEST_TIMEHELPERS_H
#define UNITTEST_TIMEHELPERS_H
#include <sys/time.h>
namespace UnitTest {
class Timer
{
public:
Timer();
void Start();
double GetTimeInMs() const;
private:
struct timeval m_startTime;
};
namespace TimeHelpers
{
void SleepMs(int ms);
}
}
#endif

View file

@ -0,0 +1,71 @@
#include "ReportAssert.h"
#include "ReportAssertImpl.h"
#include "AssertException.h"
#include "CurrentTest.h"
#include "TestResults.h"
#include "TestDetails.h"
#ifdef UNITTEST_NO_EXCEPTIONS
#include "ReportAssertImpl.h"
#endif
namespace UnitTest {
namespace
{
bool& AssertExpectedFlag()
{
static bool s_assertExpected = false;
return s_assertExpected;
}
}
UNITTEST_LINKAGE void ReportAssert(char const* description, char const* filename, int lineNumber)
{
Detail::ReportAssertEx(CurrentTest::Results(), CurrentTest::Details(),
description, filename, lineNumber);
}
namespace Detail {
#ifdef UNITTEST_NO_EXCEPTIONS
UNITTEST_JMPBUF* GetAssertJmpBuf()
{
static UNITTEST_JMPBUF s_jmpBuf;
return &s_jmpBuf;
}
#endif
UNITTEST_LINKAGE void ReportAssertEx(TestResults* testResults,
const TestDetails* testDetails,
char const* description,
char const* filename,
int lineNumber)
{
if (AssertExpectedFlag() == false)
{
TestDetails assertDetails(testDetails->testName, testDetails->suiteName, filename, lineNumber);
testResults->OnTestFailure(assertDetails, description);
}
ExpectAssert(false);
#ifndef UNITTEST_NO_EXCEPTIONS
throw AssertException();
#else
UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET();
#endif
}
UNITTEST_LINKAGE void ExpectAssert(bool expected)
{
AssertExpectedFlag() = expected;
}
UNITTEST_LINKAGE bool AssertExpected()
{
return AssertExpectedFlag();
}
}
}

12
UnitTest++/ReportAssert.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef UNITTEST_ASSERT_H
#define UNITTEST_ASSERT_H
#include "HelperMacros.h"
namespace UnitTest {
UNITTEST_LINKAGE void ReportAssert(char const* description, char const* filename, int lineNumber);
}
#endif

View file

@ -0,0 +1,46 @@
#ifndef UNITTEST_REPORTASSERTIMPL_H
#define UNITTEST_REPORTASSERTIMPL_H
#include "Config.h"
#include "HelperMacros.h"
#ifdef UNITTEST_NO_EXCEPTIONS
#include <csetjmp>
#endif
namespace UnitTest {
class TestResults;
class TestDetails;
namespace Detail {
UNITTEST_LINKAGE void ExpectAssert(bool expected);
UNITTEST_LINKAGE void ReportAssertEx(TestResults* testResults,
const TestDetails* testDetails,
char const* description,
char const* filename,
int lineNumber);
UNITTEST_LINKAGE bool AssertExpected();
#ifdef UNITTEST_NO_EXCEPTIONS
UNITTEST_LINKAGE UNITTEST_JMPBUF* GetAssertJmpBuf();
#ifdef UNITTEST_WIN32
#define UNITTEST_SET_ASSERT_JUMP_TARGET() \
__pragma(warning(push)) __pragma(warning(disable: 4611)) \
UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf()) \
__pragma(warning(pop))
#else
#define UNITTEST_SET_ASSERT_JUMP_TARGET() UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf())
#endif
#define UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET() UNITTEST_LONGJMP(*UnitTest::Detail::GetAssertJmpBuf(), 1)
#endif
}
}
#endif

View file

@ -0,0 +1,16 @@
#ifndef UNITTEST_REQUIREMACROS_H
#define UNITTEST_REQUIREMACROS_H
#include "RequiredCheckTestReporter.h"
#define UNITTEST_REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(*UnitTest::CurrentTest::Results()); decoratedReporter.Next(); )
#ifndef UNITTEST_DISABLE_SHORT_MACROS
#ifdef REQUIRE
#error REQUIRE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_REQUIRE instead
#else
#define REQUIRE UNITTEST_REQUIRE
#endif
#endif
#endif

View file

@ -0,0 +1,17 @@
#include "RequiredCheckException.h"
#ifndef UNITTEST_NO_EXCEPTIONS
namespace UnitTest {
RequiredCheckException::RequiredCheckException()
{
}
RequiredCheckException::~RequiredCheckException() throw()
{
}
}
#endif

View file

@ -0,0 +1,23 @@
#ifndef UNITTEST_REQUIREDCHECKEXCEPTION_H
#define UNITTEST_REQUIREDCHECKEXCEPTION_H
#include "Config.h"
#ifndef UNITTEST_NO_EXCEPTIONS
#include "HelperMacros.h"
#include <exception>
namespace UnitTest {
class UNITTEST_LINKAGE RequiredCheckException : public std::exception
{
public:
RequiredCheckException();
virtual ~RequiredCheckException() throw();
};
}
#endif
#endif

View file

@ -0,0 +1,26 @@
#include "RequiredCheckTestReporter.h"
#include "CurrentTest.h"
#include "TestResults.h"
namespace UnitTest {
RequiredCheckTestReporter::RequiredCheckTestReporter(TestResults& results)
: m_results(results)
, m_originalTestReporter(results.m_testReporter)
, m_throwingReporter(results.m_testReporter)
, m_continue(0)
{
m_results.m_testReporter = &m_throwingReporter;
}
RequiredCheckTestReporter::~RequiredCheckTestReporter()
{
m_results.m_testReporter = m_originalTestReporter;
}
bool RequiredCheckTestReporter::Next()
{
return m_continue++ == 0;
}
}

View file

@ -0,0 +1,33 @@
#ifndef UNITTEST_REQUIRED_CHECK_TEST_REPORTER_H
#define UNITTEST_REQUIRED_CHECK_TEST_REPORTER_H
#include "HelperMacros.h"
#include "ThrowingTestReporter.h"
namespace UnitTest {
class TestResults;
// This RAII class decorates the current TestReporter with
// a version that throws after reporting a failure.
class UNITTEST_LINKAGE RequiredCheckTestReporter
{
public:
explicit RequiredCheckTestReporter(TestResults& results);
~RequiredCheckTestReporter();
bool Next();
private:
RequiredCheckTestReporter(RequiredCheckTestReporter const&);
RequiredCheckTestReporter& operator =(RequiredCheckTestReporter const&);
TestResults& m_results;
TestReporter* m_originalTestReporter;
ThrowingTestReporter m_throwingReporter;
int m_continue;
};
}
#endif

38
UnitTest++/Test.cpp Normal file
View file

@ -0,0 +1,38 @@
#include "Config.h"
#include "Test.h"
#include "TestList.h"
#include "TestResults.h"
#include "AssertException.h"
#include "MemoryOutStream.h"
#include "ExecuteTest.h"
#ifdef UNITTEST_POSIX
#include "Posix/SignalTranslator.h"
#endif
namespace UnitTest {
TestList& Test::GetTestList()
{
static TestList s_list;
return s_list;
}
Test::Test(char const* testName, char const* suiteName, char const* filename, int lineNumber)
: m_details(testName, suiteName, filename, lineNumber)
, m_nextTest(0)
, m_isMockTest(false)
{}
Test::~Test()
{}
void Test::Run()
{
ExecuteTest(*this, m_details, m_isMockTest);
}
void Test::RunImpl() const
{}
}

35
UnitTest++/Test.h Normal file
View file

@ -0,0 +1,35 @@
#ifndef UNITTEST_TEST_H
#define UNITTEST_TEST_H
#include "TestDetails.h"
namespace UnitTest {
class TestResults;
class TestList;
class UNITTEST_LINKAGE Test
{
public:
explicit Test(char const* testName, char const* suiteName = "DefaultSuite", char const* filename = "", int lineNumber = 0);
virtual ~Test();
void Run();
TestDetails const m_details;
Test* m_nextTest;
mutable bool m_isMockTest;
static TestList& GetTestList();
virtual void RunImpl() const;
private:
Test(Test const&);
Test& operator =(Test const&);
};
}
#endif

View file

@ -0,0 +1,22 @@
#include "TestDetails.h"
namespace UnitTest {
TestDetails::TestDetails(char const* testName_, char const* suiteName_, char const* filename_, int lineNumber_)
: suiteName(suiteName_)
, testName(testName_)
, filename(filename_)
, lineNumber(lineNumber_)
, timeConstraintExempt(false)
{}
TestDetails::TestDetails(const TestDetails& details, int lineNumber_)
: suiteName(details.suiteName)
, testName(details.testName)
, filename(details.filename)
, lineNumber(lineNumber_)
, timeConstraintExempt(details.timeConstraintExempt)
{}
}

27
UnitTest++/TestDetails.h Normal file
View file

@ -0,0 +1,27 @@
#ifndef UNITTEST_TESTDETAILS_H
#define UNITTEST_TESTDETAILS_H
#include "HelperMacros.h"
namespace UnitTest {
class UNITTEST_LINKAGE TestDetails
{
public:
TestDetails(char const* testName, char const* suiteName, char const* filename, int lineNumber);
TestDetails(const TestDetails& details, int lineNumber);
char const* const suiteName;
char const* const testName;
char const* const filename;
int const lineNumber;
mutable bool timeConstraintExempt;
TestDetails(TestDetails const&); // Why is it public? --> http://gcc.gnu.org/bugs.html#cxx_rvalbind
private:
TestDetails& operator=(TestDetails const&);
};
}
#endif

38
UnitTest++/TestList.cpp Normal file
View file

@ -0,0 +1,38 @@
#include "TestList.h"
#include "Test.h"
#include <cassert>
namespace UnitTest {
TestList::TestList()
: m_head(0)
, m_tail(0)
{}
void TestList::Add(Test* test)
{
if (m_tail == 0)
{
assert(m_head == 0);
m_head = test;
m_tail = test;
}
else
{
m_tail->m_nextTest = test;
m_tail = test;
}
}
Test* TestList::GetHead() const
{
return m_head;
}
ListAdder::ListAdder(TestList& list, Test* test)
{
list.Add(test);
}
}

33
UnitTest++/TestList.h Normal file
View file

@ -0,0 +1,33 @@
#ifndef UNITTEST_TESTLIST_H
#define UNITTEST_TESTLIST_H
#include "HelperMacros.h"
namespace UnitTest {
class Test;
class UNITTEST_LINKAGE TestList
{
public:
TestList();
void Add (Test* test);
Test* GetHead() const;
private:
Test* m_head;
Test* m_tail;
};
class UNITTEST_LINKAGE ListAdder
{
public:
ListAdder(TestList& list, Test* test);
};
}
#endif

126
UnitTest++/TestMacros.h Normal file
View file

@ -0,0 +1,126 @@
#ifndef UNITTEST_TESTMACROS_H
#define UNITTEST_TESTMACROS_H
#include "Config.h"
#include "TestSuite.h"
#include "ExceptionMacros.h"
#include "ExecuteTest.h"
#include "AssertException.h"
#include "TestDetails.h"
#include "MemoryOutStream.h"
#ifndef UNITTEST_POSIX
#define UNITTEST_THROW_SIGNALS_POSIX_ONLY
#else
#include "Posix/SignalTranslator.h"
#endif
#define UNITTEST_SUITE(Name) \
namespace Suite ## Name { \
namespace UnitTestSuite { \
inline char const* GetSuiteName () { \
return #Name; \
} \
} \
} \
namespace Suite ## Name
#define UNITTEST_IMPL_TEST(Name, List) \
class Test ## Name : public UnitTest::Test \
{ \
public: \
Test ## Name() : Test(#Name, UnitTestSuite::GetSuiteName(), __FILE__, __LINE__) {} \
private: \
virtual void RunImpl() const; \
} static test ## Name ## Instance; \
\
static UnitTest::ListAdder adder ## Name (List, &test ## Name ## Instance); \
\
void Test ## Name::RunImpl() const
#define UNITTEST_TEST(Name) UNITTEST_IMPL_TEST(Name, UnitTest::Test::GetTestList())
#define UNITTEST_IMPL_TEST_FIXTURE(Fixture, Name, List) \
class Fixture ## Name ## Helper : public Fixture \
{ \
public: \
explicit Fixture ## Name ## Helper(UnitTest::TestDetails const& details) : m_details(details) {} \
void RunImpl(); \
UnitTest::TestDetails const& m_details; \
virtual ~Fixture ## Name ## Helper(); \
private: \
Fixture ## Name ## Helper(Fixture ## Name ## Helper const&); \
Fixture ## Name ## Helper& operator =(Fixture ## Name ## Helper const&); \
}; \
Fixture ## Name ## Helper::~Fixture ## Name ## Helper(){} \
\
class Test ## Fixture ## Name : public UnitTest::Test \
{ \
public: \
Test ## Fixture ## Name() : Test(#Name, UnitTestSuite::GetSuiteName(), __FILE__, __LINE__) {} \
private: \
virtual void RunImpl() const; \
} static test ## Fixture ## Name ## Instance; \
\
static UnitTest::ListAdder adder ## Fixture ## Name (List, &test ## Fixture ## Name ## Instance); \
\
void Test ## Fixture ## Name::RunImpl() const \
{ \
volatile bool ctorOk = false; \
UNITTEST_IMPL_TRY \
({ \
Fixture ## Name ## Helper fixtureHelper(m_details); \
ctorOk = true; \
UnitTest::ExecuteTest(fixtureHelper, m_details, false); \
}) \
UNITTEST_IMPL_CATCH (UnitTest::AssertException, e, \
{ \
(void)e; \
}) \
UNITTEST_IMPL_CATCH (std::exception, e, \
{ \
UnitTest::MemoryOutStream stream; \
stream << "Unhandled exception: " << e.what(); \
UnitTest::CurrentTest::Results()->OnTestFailure(m_details, stream.GetText()); \
}) \
UNITTEST_IMPL_CATCH_ALL \
({ \
if (ctorOk) \
{ \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(m_details, __LINE__), \
"Unhandled exception while destroying fixture " #Fixture); \
} \
else \
{ \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(m_details, __LINE__), \
"Unhandled exception while constructing fixture " #Fixture); \
} \
}) \
} \
void Fixture ## Name ## Helper::RunImpl()
#define UNITTEST_TEST_FIXTURE(Fixture,Name) UNITTEST_IMPL_TEST_FIXTURE(Fixture, Name, UnitTest::Test::GetTestList())
#ifndef UNITTEST_DISABLE_SHORT_MACROS
#ifdef SUITE
#error SUITE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_SUITE instead
#else
#define SUITE UNITTEST_SUITE
#endif
#ifdef TEST
#error TEST already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_TEST instead
#else
#define TEST UNITTEST_TEST
#endif
#ifdef TEST_FIXTURE
#error TEST_FIXTURE already defined, re-configure with UNITTEST_ENABLE_SHORT_MACROS set to 0 and use UNITTEST_TEST_FIXTURE instead
#else
#define TEST_FIXTURE UNITTEST_TEST_FIXTURE
#endif
#endif
#endif

View file

@ -1,10 +1,8 @@
#include "TestReporter.h"
namespace UnitTest {
TestReporter::~TestReporter()
{
}
}
#include "TestReporter.h"
namespace UnitTest {
TestReporter::~TestReporter()
{}
}

22
UnitTest++/TestReporter.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef UNITTEST_TESTREPORTER_H
#define UNITTEST_TESTREPORTER_H
#include "HelperMacros.h"
namespace UnitTest {
class TestDetails;
class UNITTEST_LINKAGE TestReporter
{
public:
virtual ~TestReporter();
virtual void ReportTestStart(TestDetails const& test) = 0;
virtual void ReportFailure(TestDetails const& test, char const* failure) = 0;
virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed) = 0;
virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed) = 0;
};
}
#endif

View file

@ -0,0 +1,44 @@
#include "TestReporterStdout.h"
#include <cstdio>
#include "TestDetails.h"
// cstdio doesn't pull in namespace std on VC6, so we do it here.
#if defined(UNITTEST_WIN32) && (_MSC_VER == 1200)
namespace std {}
#endif
namespace UnitTest {
void TestReporterStdout::ReportFailure(TestDetails const& details, char const* failure)
{
using namespace std;
#if defined(__APPLE__) || defined(__GNUG__)
char const* const errorFormat = "%s:%d:%d: error: Failure in %s: %s\n";
fprintf(stderr, errorFormat, details.filename, details.lineNumber, 1, details.testName, failure);
#else
char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n";
fprintf(stderr, errorFormat, details.filename, details.lineNumber, details.testName, failure);
#endif
}
void TestReporterStdout::ReportTestStart(TestDetails const& /*test*/)
{}
void TestReporterStdout::ReportTestFinish(TestDetails const& /*test*/, float)
{}
void TestReporterStdout::ReportSummary(int const totalTestCount, int const failedTestCount,
int const failureCount, float const secondsElapsed)
{
using namespace std;
if (failureCount > 0)
printf("FAILURE: %d out of %d tests failed (%d failures).\n", failedTestCount, totalTestCount, failureCount);
else
printf("Success: %d tests passed.\n", totalTestCount);
printf("Test time: %.2f seconds.\n", secondsElapsed);
}
}

View file

@ -0,0 +1,19 @@
#ifndef UNITTEST_TESTREPORTERSTDOUT_H
#define UNITTEST_TESTREPORTERSTDOUT_H
#include "TestReporter.h"
namespace UnitTest {
class UNITTEST_LINKAGE TestReporterStdout : public TestReporter
{
private:
virtual void ReportTestStart(TestDetails const& test);
virtual void ReportFailure(TestDetails const& test, char const* failure);
virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed);
virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed);
};
}
#endif

View file

@ -0,0 +1,59 @@
#include "TestResults.h"
#include "TestReporter.h"
#include "TestDetails.h"
namespace UnitTest {
TestResults::TestResults(TestReporter* testReporter)
: m_testReporter(testReporter)
, m_totalTestCount(0)
, m_failedTestCount(0)
, m_failureCount(0)
, m_currentTestFailed(false)
{}
void TestResults::OnTestStart(TestDetails const& test)
{
++m_totalTestCount;
m_currentTestFailed = false;
if (m_testReporter)
m_testReporter->ReportTestStart(test);
}
void TestResults::OnTestFailure(TestDetails const& test, char const* failure)
{
++m_failureCount;
if (!m_currentTestFailed)
{
++m_failedTestCount;
m_currentTestFailed = true;
}
if (m_testReporter)
m_testReporter->ReportFailure(test, failure);
}
void TestResults::OnTestFinish(TestDetails const& test, float secondsElapsed)
{
if (m_testReporter)
m_testReporter->ReportTestFinish(test, secondsElapsed);
}
int TestResults::GetTotalTestCount() const
{
return m_totalTestCount;
}
int TestResults::GetFailedTestCount() const
{
return m_failedTestCount;
}
int TestResults::GetFailureCount() const
{
return m_failureCount;
}
}

41
UnitTest++/TestResults.h Normal file
View file

@ -0,0 +1,41 @@
#ifndef UNITTEST_TESTRESULTS_H
#define UNITTEST_TESTRESULTS_H
#include "HelperMacros.h"
namespace UnitTest {
class RequiredCheckTestReporter;
class TestReporter;
class TestDetails;
class UNITTEST_LINKAGE TestResults
{
public:
explicit TestResults(TestReporter* reporter = 0);
void OnTestStart(TestDetails const& test);
void OnTestFailure(TestDetails const& test, char const* failure);
void OnTestFinish(TestDetails const& test, float secondsElapsed);
int GetTotalTestCount() const;
int GetFailedTestCount() const;
int GetFailureCount() const;
private:
friend class RequiredCheckTestReporter;
TestReporter* m_testReporter;
int m_totalTestCount;
int m_failedTestCount;
int m_failureCount;
bool m_currentTestFailed;
TestResults(TestResults const&);
TestResults& operator =(TestResults const&);
};
}
#endif

82
UnitTest++/TestRunner.cpp Normal file
View file

@ -0,0 +1,82 @@
#include "TestRunner.h"
#include "TestResults.h"
#include "TestReporter.h"
#include "TestReporterStdout.h"
#include "TimeHelpers.h"
#include "MemoryOutStream.h"
#include <cstring>
namespace UnitTest {
int RunAllTests()
{
TestReporterStdout reporter;
TestRunner runner(reporter);
return runner.RunTestsIf(Test::GetTestList(), NULL, True(), 0);
}
TestRunner::TestRunner(TestReporter& reporter)
: m_reporter(&reporter)
, m_result(new TestResults(&reporter))
, m_timer(new Timer)
{
m_timer->Start();
}
TestRunner::~TestRunner()
{
delete m_result;
delete m_timer;
}
TestResults* TestRunner::GetTestResults()
{
return m_result;
}
int TestRunner::Finish() const
{
float const secondsElapsed = static_cast<float>(m_timer->GetTimeInMs() / 1000.0);
m_reporter->ReportSummary(m_result->GetTotalTestCount(),
m_result->GetFailedTestCount(),
m_result->GetFailureCount(),
secondsElapsed);
return m_result->GetFailureCount();
}
bool TestRunner::IsTestInSuite(const Test* const curTest, char const* suiteName) const
{
using namespace std;
return (suiteName == NULL) || !strcmp(curTest->m_details.suiteName, suiteName);
}
void TestRunner::RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const
{
if (curTest->m_isMockTest == false)
CurrentTest::Results() = result;
Timer testTimer;
testTimer.Start();
result->OnTestStart(curTest->m_details);
curTest->Run();
double const testTimeInMs = testTimer.GetTimeInMs();
if (maxTestTimeInMs > 0 && testTimeInMs > maxTestTimeInMs && !curTest->m_details.timeConstraintExempt)
{
MemoryOutStream stream;
stream << "Global time constraint failed. Expected under " << maxTestTimeInMs <<
"ms but took " << testTimeInMs << "ms.";
result->OnTestFailure(curTest->m_details, stream.GetText());
}
result->OnTestFinish(curTest->m_details, static_cast< float >(testTimeInMs / 1000.0));
}
}

61
UnitTest++/TestRunner.h Normal file
View file

@ -0,0 +1,61 @@
#ifndef UNITTEST_TESTRUNNER_H
#define UNITTEST_TESTRUNNER_H
#include "Test.h"
#include "TestList.h"
#include "CurrentTest.h"
namespace UnitTest {
class TestReporter;
class TestResults;
class Timer;
UNITTEST_LINKAGE int RunAllTests();
struct True
{
bool operator()(const Test* const) const
{
return true;
}
};
class UNITTEST_LINKAGE TestRunner
{
public:
explicit TestRunner(TestReporter& reporter);
~TestRunner();
template< class Predicate >
int RunTestsIf(TestList const& list, char const* suiteName,
const Predicate& predicate, int maxTestTimeInMs) const
{
Test* curTest = list.GetHead();
while (curTest != 0)
{
if (IsTestInSuite(curTest, suiteName) && predicate(curTest))
RunTest(m_result, curTest, maxTestTimeInMs);
curTest = curTest->m_nextTest;
}
return Finish();
}
TestResults* GetTestResults();
private:
TestReporter* m_reporter;
TestResults* m_result;
Timer* m_timer;
int Finish() const;
bool IsTestInSuite(const Test* const curTest, char const* suiteName) const;
void RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const;
};
}
#endif

12
UnitTest++/TestSuite.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef UNITTEST_TESTSUITE_H
#define UNITTEST_TESTSUITE_H
namespace UnitTestSuite
{
inline char const* GetSuiteName ()
{
return "DefaultSuite";
}
}
#endif

View file

@ -0,0 +1,61 @@
#include "ThrowingTestReporter.h"
#include "RequiredCheckException.h"
#ifdef UNITTEST_NO_EXCEPTIONS
#include "ReportAssertImpl.h"
#endif
namespace UnitTest {
ThrowingTestReporter::ThrowingTestReporter(TestReporter* decoratedReporter)
: m_decoratedReporter(decoratedReporter)
{}
//virtual
ThrowingTestReporter::~ThrowingTestReporter()
{}
//virtual
void ThrowingTestReporter::ReportTestStart(TestDetails const& test)
{
if(m_decoratedReporter)
{
m_decoratedReporter->ReportTestStart(test);
}
}
//virtual
void ThrowingTestReporter::ReportFailure(TestDetails const& test, char const* failure)
{
if(m_decoratedReporter)
{
m_decoratedReporter->ReportFailure(test, failure);
}
#ifndef UNITTEST_NO_EXCEPTIONS
throw RequiredCheckException();
#else
static const int stopTest = 1;
UNITTEST_LONGJMP(*UnitTest::Detail::GetAssertJmpBuf(), stopTest);
#endif
}
//virtual
void ThrowingTestReporter::ReportTestFinish(TestDetails const& test, float secondsElapsed)
{
if(m_decoratedReporter)
{
m_decoratedReporter->ReportTestFinish(test, secondsElapsed);
}
}
//virtual
void ThrowingTestReporter::ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed)
{
if(m_decoratedReporter)
{
m_decoratedReporter->ReportSummary(totalTestCount, failedTestCount, failureCount, secondsElapsed);
}
}
}

View file

@ -0,0 +1,26 @@
#ifndef UNITTEST_THROWINGTESTREPORTER_H
#define UNITTEST_THROWINGTESTREPORTER_H
#include "TestReporter.h"
namespace UnitTest {
// A TestReporter that throws when ReportFailure is called. Otherwise it
// forwards the calls to a decorated TestReporter
class ThrowingTestReporter : public TestReporter
{
public:
explicit ThrowingTestReporter(TestReporter* reporter);
virtual ~ThrowingTestReporter();
virtual void ReportTestStart(TestDetails const& test);
virtual void ReportFailure(TestDetails const& test, char const* failure);
virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed);
virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed);
private:
TestReporter* m_decoratedReporter;
};
}
#endif

View file

@ -0,0 +1,29 @@
#include "TimeConstraint.h"
#include "TestResults.h"
#include "MemoryOutStream.h"
#include "CurrentTest.h"
namespace UnitTest {
TimeConstraint::TimeConstraint(int ms, TestDetails const& details, int lineNumber)
: m_details(details, lineNumber)
, m_maxMs(ms)
{
m_timer.Start();
}
TimeConstraint::~TimeConstraint()
{
double const totalTimeInMs = m_timer.GetTimeInMs();
if (totalTimeInMs > m_maxMs)
{
MemoryOutStream stream;
stream << "Time constraint failed. Expected to run test under " << m_maxMs <<
"ms but took " << totalTimeInMs << "ms.";
CurrentTest::Results()->OnTestFailure(m_details, stream.GetText());
}
}
}

View file

@ -0,0 +1,37 @@
#ifndef UNITTEST_TIMECONSTRAINT_H
#define UNITTEST_TIMECONSTRAINT_H
#include "TimeHelpers.h"
#include "HelperMacros.h"
#include "TestDetails.h"
namespace UnitTest {
class TestResults;
class UNITTEST_LINKAGE TimeConstraint
{
public:
TimeConstraint(int ms, TestDetails const& details, int lineNumber);
~TimeConstraint();
private:
void operator=(TimeConstraint const&);
TimeConstraint(TimeConstraint const&);
Timer m_timer;
TestDetails const m_details;
int const m_maxMs;
};
#define UNITTEST_TIME_CONSTRAINT(ms) \
UnitTest::TimeConstraint unitTest__timeConstraint__(ms, m_details, __LINE__)
#define UNITTEST_TIME_CONSTRAINT_EXEMPT() \
UNITTEST_MULTILINE_MACRO_BEGIN \
m_details.timeConstraintExempt = true; \
UNITTEST_MULTILINE_MACRO_END
}
#endif

7
UnitTest++/TimeHelpers.h Normal file
View file

@ -0,0 +1,7 @@
#include "Config.h"
#if defined UNITTEST_POSIX
#include "Posix/TimeHelpers.h"
#else
#include "Win32/TimeHelpers.h"
#endif

1
UnitTest++/UnitTest++.h Normal file
View file

@ -0,0 +1 @@
#include "UnitTestPP.h"

12
UnitTest++/UnitTestPP.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef UNITTESTPP_H
#define UNITTESTPP_H
#include "Config.h"
#include "TestMacros.h"
#include "CheckMacros.h"
#include "RequireMacros.h"
#include "TestRunner.h"
#include "TimeConstraint.h"
#include "ReportAssert.h"
#endif

View file

@ -0,0 +1,49 @@
#include "TimeHelpers.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
namespace UnitTest {
Timer::Timer()
: m_threadHandle(::GetCurrentThread())
, m_startTime(0)
{
#if defined(UNITTEST_WIN32) && (_MSC_VER == 1200) // VC6 doesn't have DWORD_PTR
typedef unsigned long DWORD_PTR;
#endif
DWORD_PTR systemMask;
::GetProcessAffinityMask(GetCurrentProcess(), &m_processAffinityMask, &systemMask);
::SetThreadAffinityMask(m_threadHandle, 1);
::QueryPerformanceFrequency(reinterpret_cast< LARGE_INTEGER* >(&m_frequency));
::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask);
}
void Timer::Start()
{
m_startTime = GetTime();
}
double Timer::GetTimeInMs() const
{
__int64 const elapsedTime = GetTime() - m_startTime;
double const seconds = double(elapsedTime) / double(m_frequency);
return seconds * 1000.0;
}
__int64 Timer::GetTime() const
{
LARGE_INTEGER curTime;
::SetThreadAffinityMask(m_threadHandle, 1);
::QueryPerformanceCounter(&curTime);
::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask);
return curTime.QuadPart;
}
void TimeHelpers::SleepMs(int ms)
{
::Sleep(ms);
}
}

View file

@ -0,0 +1,45 @@
#ifndef UNITTEST_TIMEHELPERS_H
#define UNITTEST_TIMEHELPERS_H
#include "../Config.h"
#include "../HelperMacros.h"
#ifdef UNITTEST_MINGW
#ifndef __int64
#define __int64 long long
#endif
#endif
namespace UnitTest {
class UNITTEST_LINKAGE Timer
{
public:
Timer();
void Start();
double GetTimeInMs() const;
private:
__int64 GetTime() const;
void* m_threadHandle;
#if defined(_WIN64)
unsigned __int64 m_processAffinityMask;
#else
unsigned long m_processAffinityMask;
#endif
__int64 m_startTime;
__int64 m_frequency;
};
namespace TimeHelpers
{
UNITTEST_LINKAGE void SleepMs(int ms);
}
}
#endif

View file

@ -0,0 +1,130 @@
#include "Config.h"
#ifndef UNITTEST_NO_DEFERRED_REPORTER
#include "XmlTestReporter.h"
#include <iostream>
#include <sstream>
#include <string>
using std::string;
using std::ostringstream;
using std::ostream;
namespace {
void ReplaceChar(string& str, char c, string const& replacement)
{
for (size_t pos = str.find(c); pos != string::npos; pos = str.find(c, pos + 1))
str.replace(pos, 1, replacement);
}
string XmlEscape(string const& value)
{
string escaped = value;
ReplaceChar(escaped, '&', "&amp;");
ReplaceChar(escaped, '<', "&lt;");
ReplaceChar(escaped, '>', "&gt;");
ReplaceChar(escaped, '\'', "&apos;");
ReplaceChar(escaped, '\"', "&quot;");
return escaped;
}
string BuildFailureMessage(string const& file, int line, string const& message)
{
ostringstream failureMessage;
failureMessage << file << "(" << line << ") : " << message;
return failureMessage.str();
}
}
namespace UnitTest {
XmlTestReporter::XmlTestReporter(ostream& ostream)
: m_ostream(ostream)
{}
void XmlTestReporter::ReportSummary(int totalTestCount, int failedTestCount,
int failureCount, float secondsElapsed)
{
AddXmlElement(m_ostream, NULL);
BeginResults(m_ostream, totalTestCount, failedTestCount, failureCount, secondsElapsed);
DeferredTestResultList const& results = GetResults();
for (DeferredTestResultList::const_iterator i = results.begin(); i != results.end(); ++i)
{
BeginTest(m_ostream, *i);
if (i->failed)
AddFailure(m_ostream, *i);
EndTest(m_ostream, *i);
}
EndResults(m_ostream);
}
void XmlTestReporter::AddXmlElement(ostream& os, char const* encoding)
{
os << "<?xml version=\"1.0\"";
if (encoding != NULL)
os << " encoding=\"" << encoding << "\"";
os << "?>";
}
void XmlTestReporter::BeginResults(std::ostream& os, int totalTestCount, int failedTestCount,
int failureCount, float secondsElapsed)
{
os << "<unittest-results"
<< " tests=\"" << totalTestCount << "\""
<< " failedtests=\"" << failedTestCount << "\""
<< " failures=\"" << failureCount << "\""
<< " time=\"" << secondsElapsed << "\""
<< ">";
}
void XmlTestReporter::EndResults(std::ostream& os)
{
os << "</unittest-results>";
}
void XmlTestReporter::BeginTest(std::ostream& os, DeferredTestResult const& result)
{
os << "<test"
<< " suite=\"" << result.suiteName << "\""
<< " name=\"" << result.testName << "\""
<< " time=\"" << result.timeElapsed << "\"";
}
void XmlTestReporter::EndTest(std::ostream& os, DeferredTestResult const& result)
{
if (result.failed)
os << "</test>";
else
os << "/>";
}
void XmlTestReporter::AddFailure(std::ostream& os, DeferredTestResult const& result)
{
os << ">"; // close <test> element
for (DeferredTestResult::FailureVec::const_iterator it = result.failures.begin();
it != result.failures.end();
++it)
{
string const escapedMessage = XmlEscape(std::string(it->failureStr));
string const message = BuildFailureMessage(result.failureFile, it->lineNumber, escapedMessage);
os << "<failure" << " message=\"" << message << "\"" << "/>";
}
}
}
#endif

View file

@ -0,0 +1,38 @@
#ifndef UNITTEST_XMLTESTREPORTER_H
#define UNITTEST_XMLTESTREPORTER_H
#include "Config.h"
#ifndef UNITTEST_NO_DEFERRED_REPORTER
#include "DeferredTestReporter.h"
#include <iosfwd>
namespace UnitTest
{
class UNITTEST_LINKAGE XmlTestReporter : public DeferredTestReporter
{
public:
explicit XmlTestReporter(std::ostream& ostream);
virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed);
private:
XmlTestReporter(XmlTestReporter const&);
XmlTestReporter& operator=(XmlTestReporter const&);
void AddXmlElement(std::ostream& os, char const* encoding);
void BeginResults(std::ostream& os, int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed);
void EndResults(std::ostream& os);
void BeginTest(std::ostream& os, DeferredTestResult const& result);
void AddFailure(std::ostream& os, DeferredTestResult const& result);
void EndTest(std::ostream& os, DeferredTestResult const& result);
std::ostream& m_ostream;
};
}
#endif
#endif

30
appveyor.yml Normal file
View file

@ -0,0 +1,30 @@
version: 2.1.0.{build}
os:
- Windows Server 2012 R2
environment:
matrix:
- CMAKE_GENERATOR: Visual Studio 9 2008
- CMAKE_GENERATOR: Visual Studio 10 2010
- CMAKE_GENERATOR: Visual Studio 11 2012
- CMAKE_GENERATOR: Visual Studio 12 2013
- CMAKE_GENERATOR: Visual Studio 14 2015
before_build:
# Generate solution files using cmake, in 'builds' directory.
# No need to create it because it's part of the repo.
- pushd builds && cmake -G "%CMAKE_GENERATOR%" ..\ && popd
configuration:
- Debug
- Release
build_script:
- pushd builds && cmake --build . && popd
matrix:
fast_finish: true

9
autogen.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
test -e ./.autotools_aux || mkdir .autotools_aux
libtoolize -cq
aclocal -I m4 --install # Generate aclocal
autoconf # Generate configure script
autoheader # Generate config.h
automake --add-missing --copy # Generate Makefile.in and other scripts

4
builds/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View file

@ -0,0 +1,2 @@
include("${CMAKE_CURRENT_LIST_DIR}/UnitTest++Targets.cmake")
get_filename_component(UTPP_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/../../../include/" ABSOLUTE)

48
configure.ac Normal file
View file

@ -0,0 +1,48 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([UnitTest++],
m4_esyscmd_s([git describe --tags | cut -c2-]),
[pjohnmeyer@gmail.com],
[unittest-cpp])
AC_CONFIG_SRCDIR([UnitTest++/TestDetails.cpp])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([UnitTest++.pc])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AM_SILENT_RULES([yes])
AC_CANONICAL_HOST
dnl Detect Windows, as it doesn't implement UNIX signals and requires special code
AM_CONDITIONAL([WINDOWS],
[test "${host//mingw/}" != "${host}" -o "${host//msvc/}" != "${host}"])
LT_INIT()
AC_SUBST([LIBUNITTEST_SO_VERSION], [2:1:0])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AX_CXX_COMPILE_STDCXX_11(noext, optional)
# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS([sys/time.h unistd.h setjmp.h signal.h cassert cstddef cstdio cstring exception iosfwd iostream sstream string vector])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_SIZE_T
# Checks for library functions.
AC_CHECK_FUNCS([gettimeofday strstr])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

1
docs Submodule

@ -0,0 +1 @@
Subproject commit a6963b798400df760e148a6e15e9c13db965a3ec

View file

@ -1,260 +0,0 @@
<html>
<head>
<title>UnitTest++ in brief</title>
</head>
<body>
<h1>UnitTest++ in brief</h1>
<h2>Introduction</h2>
<p>This little document serves as bare-bones documentation for UnitTest++.</p>
<p>For background, goals and license details, see:</p>
<ul>
<li><a href="http://unittest-cpp.sourceforge.net/">The UnitTest++ home page</a></li>
<li><a href="http://www.gamesfromwithin.com/articles/0603/000108.html">Noel Llopis' announcement</a></li>
</ul>
<p>The documentation, while sparse, aims to be practical, so it should give you enough info to get started using UnitTest++ as fast as possible.</p>
<h2>Building UnitTest++</h2>
<p>Building UnitTest++ will be specific to each platform and build environment, but it should be straightforward.</p>
<h3>Building with Visual Studio</h3>
<p>If you are using Visual Studio, go for either of the provided .sln files, depending on version. There are no prefabricated solutions for versions earlier than VS.NET 2003, but we have had reports of people building UnitTest++ with at least VS.NET 2002.</p>
<h3>Building with Make</h3>
<p>The bundled makefile is written to build with g++. It also needs <code>sed</code> installed in the path, and to be able to use the <code>mv</code> and <code>rm</code> shell commands. The makefile should be usable on most Posix-like platforms.</p>
<p>Do "make all" to generate a library and test executable. A final build step runs all unit tests to make sure that the result works as expected.</p>
<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>
<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;
TEST(FailSpectacularly)
{
CHECK(false);
}
int main()
{
return UnitTest::RunAllTests();
}
</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>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>
<pre>
.\test.cpp(5): error: Failure in FailSpectacularly: false
FAILED: 1 out of 1 tests failed (1 failures).
Test time: 0.00 seconds.
</pre>
<p>UnitTest++ attempts to report every failure in an IDE-friendly format, depending on platform (e.g. you can double-click it in Visual Studio's error list.) The exit code will be the number of failed tests, so that a failed test run always returns a non-zero exit code.</p>
<h3>Test macros</h3>
<p>To add a test, simply put the following code in a .cpp file of your choice:</p>
<pre>
TEST(YourTestName)
{
}
</pre>
<p>The <code>TEST</code> macro contains enough machinery to turn this slightly odd-looking syntax into legal C++, and automatically register the test in a global list. This test list forms the basis of what is executed by <code>RunAllTests()</code>.</p>
<p>If you want to re-use a set of test data for more than one test, or provide setup/teardown for tests, you can use the <code>TEST_FIXTURE</code> macro instead. The macro requires that you pass it a class name that it will instantiate, so any setup and teardown code should be in its constructor and destructor.</p>
<pre>
struct SomeFixture
{
SomeFixture() { /* some setup */ }
~SomeFixture() { /* some teardown */ }
int testData;
};
TEST_FIXTURE(SomeFixture, YourTestName)
{
int temp = testData;
}
</pre>
<p>Note how members of the fixture are used as if they are a part of the test, since the macro-generated test class derives from the provided fixture class.</p>
<h3>Suite macros</h3>
<p>Tests can be grouped into suites, using the <code>SUITE</code> macro. A suite serves as a namespace for test names, so that the same test name can be used in two difference contexts.</p>
<pre>
SUITE(YourSuiteName)
{
TEST(YourTestName)
{
}
TEST(YourOtherTestName)
{
}
}
</pre>
<p>This will place the tests into a C++ namespace called <code>YourSuiteName</code>, and make the suite name available to UnitTest++. <code>RunAllTests()</code> can be called for a specific suite name, so you can use this to build named groups of tests to be run together.</p>
<h3>Simple check macros</h3>
<p>In test cases, we want to check the results of our system under test. UnitTest++ provides a number of check macros that handle comparison and proper failure reporting.</p>
<p>The most basic variety is the boolean <code>CHECK</code> macro:</p>
<pre>
CHECK(false); // fails
</pre>
<p>It will fail if the boolean expression evaluates to false.</p>
<p>For equality checks, it's generally better to use <code>CHECK_EQUAL</code>:</p>
<pre>
CHECK_EQUAL(10, 20); // fails
CHECK_EQUAL("foo", "bar"); // fails
</pre>
<p>Note how <code>CHECK_EQUAL</code> is overloaded for C strings, so you don't have to resort to <code>strcmp</code> or similar. There is no facility for case-insensitive comparison or string searches, so you may have to drop down to a plain boolean <code>CHECK</code> with help from the CRT:</p>
<pre>
CHECK(std::strstr("zaza", "az") != 0); // succeeds
</pre>
<p>For floating-point comparison, equality <a href="http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm">isn't necessarily well-defined</a>, so you should prefer the <code>CHECK_CLOSE</code> macro:</p>
<pre>
CHECK_CLOSE(3.14, 3.1415, 0.01); // succeeds
</pre>
<p>All of the macros are tailored to avoid unintended side-effects, for example:</p>
<pre>
TEST(CheckMacrosHaveNoSideEffects)
{
int i = 4;
CHECK_EQUAL(5, ++i); // succeeds
CHECK_EQUAL(5, i); // succeeds
}
</pre>
<p>The check macros guarantee that the <code>++i</code> expression isn't repeated internally, as demonstrated above.</p>
<h3>Array check macros</h3>
<p>There is a set of check macros for array comparison as well:</p>
<pre>
const float oned[2] = { 10, 20 };
CHECK_ARRAY_EQUAL(oned, oned, 2); // succeeds
CHECK_ARRAY_CLOSE(oned, oned, 2, 0.00); // succeeds
const float twod[2][3] = { {0, 1, 2}, {2, 3, 4} };
CHECK_ARRAY2D_CLOSE(twod, twod, 2, 3, 0.00); // succeeds
</pre>
<p>The array equal macro compares elements using <code>operator==</code>, so <code>CHECK_ARRAY_EQUAL</code> won't work for an array of C strings, for example.</p>
<p>The array close macros are similar to the regular CHECK_CLOSE macro, and are really only useful for scalar types, that can be compared in terms of a difference between two array elements.</p>
<p>Note that the one-dimensional array macros work for <code>std::vector</code> as well, as it can be indexed just as a C array.</p>
<h3>Exception check macros</h3>
<p>Finally, there's a <code>CHECK_THROW</code> macro, which asserts that its enclosed expression throws the specified type:</p>
<pre>
struct TestException {};
CHECK_THROW(throw TestException(), TestException); // succeeds
</pre>
<p>UnitTest++ natively catches exceptions if your test code doesn't. So if your code under test throws any exception UnitTest++ will fail the test and report either using the <code>what()</code> method for <code>std::exception</code> derivatives or just a plain message for unknown exception types.</p>
<p>Should your test or code raise an irrecoverable error (an Access Violation on Win32, for example, or a signal on Linux), UnitTest++ will attempt to map them to an exception and fail the test, just as for other unhandled exceptions.</p>
<h3>Time constraints</h3>
<p>UnitTest++ can fail a test if it takes too long to complete, using so-called time constraints.</p>
<p>They come in two flavors; <em>local</em> and <em>global</em> time constraints.</p>
<p>Local time constraints are limited to the current scope, like so:</p>
<pre>
TEST(YourTimedTest)
{
// Lengthy setup...
{
UNITTEST_TIME_CONSTRAINT(50);
// Do time-critical stuff
}
// Lengthy teardown...
}
</pre>
<p>The test will fail if the "Do time-critical stuff" block takes longer than 50 ms to complete. The time-consuming setup and teardown are not measured, since the time constraint is scope-bound. It's perfectly valid to have multiple local time constraints in the same test, as long as there is only one per block.</p>
<p>A global time constraint, on the other hand, requires that all of the tests in a test run are faster than a specified amount of time. This allows you, when you run a suite of tests, to ask UnitTest++ to fail it entirely if any test exceeds the global constraint. The max time is passed as a parameter to an overload of <code>RunAllTests()</code>.</p>
<p>If you want to use a global time constraint, but have one test that is notoriously slow, you can exempt it from inspection by using the <code>UNITTEST_TIME_CONSTRAINT_EXEMPT</code> macro anywhere inside the test body.</p>
<pre>
TEST(NotoriouslySlowTest)
{
UNITTEST_TIME_CONSTRAINT_EXEMPT();
// Oh boy, this is going to take a while
...
}
</pre>
<h3>Test runners</h3>
<p>The <code>RunAllTests()</code> function has an overload that lets you customize the behavior of the runner, such as global time constraints, custom reporters, which suite to run, etc.</p>
<pre>
int RunAllTests(TestReporter& reporter, TestList const& list, char const* suiteName, int const maxTestTimeInMs);
</pre>
<p>If you attempt to pass custom parameters to <code>RunAllTests()</code>, note that the <code>list</code> parameter should have the value <code>Test::GetTestList()</code>.</p>
<p>The parameterless <code>RunAllTests()</code> is a simple wrapper for this one, with sensible defaults.</p>
<h3>Example setup</h3>
<p>How to create a new test project varies depending on your environment, but here are some directions on common file structure and usage.</p>
<p>The general idea is that you keep one <code>Main.cpp</code> file with the entry-point which calls <code>RunAllTests()</code>.</p>
<p>Then you can simply compile and link new .cpp files at will, typically one per test suite.</p>
<pre>
+ ShaverTests/
|
+- Main.cpp
|
+- TestBrush.cpp
+- TestEngine.cpp
+- TestRazor.cpp
</pre>
<p>Each of the <code>Test*.cpp</code> files will contain one or more <code>TEST</code> macro incantations with the associated test code. There are no source-level dependencies between <code>Main.cpp</code> and <code>Test*.cpp</code>, as the <code>TEST</code> macro handles the registration and setup necessary for <code>RunAllTests()</code> to find all tests compiled into the same final executable.</p>
<p>UnitTest++ does not require this structure, even if this is how the library itself does it. As long as your test project contains one or more <code>TESTs</code> and calls <code>RunAllTests()</code> at one point or another, it will be handled by UnitTest++.</p>
<p>It's common to make the generated executable start as a post-build step, so that merely building your test project will run the tests as well. Since the exit code is the count of failures, a failed test will generally break the build, as most build engines will fail a build if any step returns a non-zero exit code.</p>
</body>
</html>

558
m4/ax_cxx_compile_stdcxx.m4 Normal file
View file

@ -0,0 +1,558 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the specified
# version of the C++ standard. If necessary, add switches to CXXFLAGS to
# enable support. VERSION may be '11' (for the C++11 standard) or '14'
# (for the C++14 standard).
#
# The second argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
# -std=c++11). If neither is specified, you get whatever works, with
# preference for an extended mode.
#
# The third argument, if specified 'mandatory' or if left unspecified,
# indicates that baseline support for the specified C++ standard is
# required and that the macro should error out if no mode with that
# support is found. If specified 'optional', then configuration proceeds
# regardless, after defining HAVE_CXX${VERSION} if and only if a
# supporting mode is found.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 1
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13).
AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [],
[$1], [14], [],
[$1], [17], [m4_fatal([support for C++17 not yet implemented in AX_CXX_COMPILE_STDCXX])],
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [],
[$2], [ext], [],
[$2], [noext], [],
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
[$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
[$3], [optional], [ax_cxx_compile_cxx$1_required=false],
[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
AC_LANG_PUSH([C++])dnl
ac_success=no
AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
ax_cv_cxx_compile_cxx$1,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[ax_cv_cxx_compile_cxx$1=yes],
[ax_cv_cxx_compile_cxx$1=no])])
if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
ac_success=yes
fi
m4_if([$2], [noext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=gnu++$1 -std=gnu++0x; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
m4_if([$2], [ext], [], [dnl
if test x$ac_success = xno; then
dnl HP's aCC needs +std=c++11 according to:
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
dnl Cray's crayCC needs "-h std=c++11"
for switch in -std=c++$1 -std=c++0x +std=c++$1 "-h std=c++$1"; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx$1_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
fi
else
if test x$ac_success = xno; then
HAVE_CXX$1=0
AC_MSG_NOTICE([No compiler with C++$1 support was found])
else
HAVE_CXX$1=1
AC_DEFINE(HAVE_CXX$1,1,
[define if the compiler supports basic C++$1 syntax])
fi
AC_SUBST(HAVE_CXX$1)
fi
])
dnl Test body for checking C++11 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
)
dnl Test body for checking C++14 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
)
dnl Tests for new features in C++11
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
// If the compiler admits that it is not ready for C++11, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201103L
#error "This is not a C++11 compiler"
#else
namespace cxx11
{
namespace test_static_assert
{
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
}
namespace test_final_override
{
struct Base
{
virtual void f() {}
};
struct Derived : public Base
{
virtual void f() override {}
};
}
namespace test_double_right_angle_brackets
{
template < typename T >
struct check {};
typedef check<void> single_type;
typedef check<check<void>> double_type;
typedef check<check<check<void>>> triple_type;
typedef check<check<check<check<void>>>> quadruple_type;
}
namespace test_decltype
{
int
f()
{
int a = 1;
decltype(a) b = 2;
return a + b;
}
}
namespace test_type_deduction
{
template < typename T1, typename T2 >
struct is_same
{
static const bool value = false;
};
template < typename T >
struct is_same<T, T>
{
static const bool value = true;
};
template < typename T1, typename T2 >
auto
add(T1 a1, T2 a2) -> decltype(a1 + a2)
{
return a1 + a2;
}
int
test(const int c, volatile int v)
{
static_assert(is_same<int, decltype(0)>::value == true, "");
static_assert(is_same<int, decltype(c)>::value == false, "");
static_assert(is_same<int, decltype(v)>::value == false, "");
auto ac = c;
auto av = v;
auto sumi = ac + av + 'x';
auto sumf = ac + av + 1.0;
static_assert(is_same<int, decltype(ac)>::value == true, "");
static_assert(is_same<int, decltype(av)>::value == true, "");
static_assert(is_same<int, decltype(sumi)>::value == true, "");
static_assert(is_same<int, decltype(sumf)>::value == false, "");
static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
return (sumf > 0.0) ? sumi : add(c, v);
}
}
namespace test_noexcept
{
int f() { return 0; }
int g() noexcept { return 0; }
static_assert(noexcept(f()) == false, "");
static_assert(noexcept(g()) == true, "");
}
namespace test_constexpr
{
template < typename CharT >
unsigned long constexpr
strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
{
return *s ? strlen_c_r(s + 1, acc + 1) : acc;
}
template < typename CharT >
unsigned long constexpr
strlen_c(const CharT *const s) noexcept
{
return strlen_c_r(s, 0UL);
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("1") == 1UL, "");
static_assert(strlen_c("example") == 7UL, "");
static_assert(strlen_c("another\0example") == 7UL, "");
}
namespace test_rvalue_references
{
template < int N >
struct answer
{
static constexpr int value = N;
};
answer<1> f(int&) { return answer<1>(); }
answer<2> f(const int&) { return answer<2>(); }
answer<3> f(int&&) { return answer<3>(); }
void
test()
{
int i = 0;
const int c = 0;
static_assert(decltype(f(i))::value == 1, "");
static_assert(decltype(f(c))::value == 2, "");
static_assert(decltype(f(0))::value == 3, "");
}
}
namespace test_uniform_initialization
{
struct test
{
static const int zero {};
static const int one {1};
};
static_assert(test::zero == 0, "");
static_assert(test::one == 1, "");
}
namespace test_lambdas
{
void
test1()
{
auto lambda1 = [](){};
auto lambda2 = lambda1;
lambda1();
lambda2();
}
int
test2()
{
auto a = [](int i, int j){ return i + j; }(1, 2);
auto b = []() -> int { return '0'; }();
auto c = [=](){ return a + b; }();
auto d = [&](){ return c; }();
auto e = [a, &b](int x) mutable {
const auto identity = [](int y){ return y; };
for (auto i = 0; i < a; ++i)
a += b--;
return x + identity(a + b);
}(0);
return a + b + c + d + e;
}
int
test3()
{
const auto nullary = [](){ return 0; };
const auto unary = [](int x){ return x; };
using nullary_t = decltype(nullary);
using unary_t = decltype(unary);
const auto higher1st = [](nullary_t f){ return f(); };
const auto higher2nd = [unary](nullary_t f1){
return [unary, f1](unary_t f2){ return f2(unary(f1())); };
};
return higher1st(nullary) + higher2nd(nullary)(unary);
}
}
namespace test_variadic_templates
{
template <int...>
struct sum;
template <int N0, int... N1toN>
struct sum<N0, N1toN...>
{
static constexpr auto value = N0 + sum<N1toN...>::value;
};
template <>
struct sum<>
{
static constexpr auto value = 0;
};
static_assert(sum<>::value == 0, "");
static_assert(sum<1>::value == 1, "");
static_assert(sum<23>::value == 23, "");
static_assert(sum<1, 2>::value == 3, "");
static_assert(sum<5, 5, 11>::value == 21, "");
static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
}
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
// because of this.
namespace test_template_alias_sfinae
{
struct foo {};
template<typename T>
using member = typename T::member_type;
template<typename T>
void func(...) {}
template<typename T>
void func(member<T>*) {}
void test();
void test() { func<foo>(0); }
}
} // namespace cxx11
#endif // __cplusplus >= 201103L
]])
dnl Tests for new features in C++14
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
// If the compiler admits that it is not ready for C++14, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201402L
#error "This is not a C++14 compiler"
#else
namespace cxx14
{
namespace test_polymorphic_lambdas
{
int
test()
{
const auto lambda = [](auto&&... args){
const auto istiny = [](auto x){
return (sizeof(x) == 1UL) ? 1 : 0;
};
const int aretiny[] = { istiny(args)... };
return aretiny[0];
};
return lambda(1, 1L, 1.0f, '1');
}
}
namespace test_binary_literals
{
constexpr auto ivii = 0b0000000000101010;
static_assert(ivii == 42, "wrong value");
}
namespace test_generalized_constexpr
{
template < typename CharT >
constexpr unsigned long
strlen_c(const CharT *const s) noexcept
{
auto length = 0UL;
for (auto p = s; *p; ++p)
++length;
return length;
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("x") == 1UL, "");
static_assert(strlen_c("test") == 4UL, "");
static_assert(strlen_c("another\0test") == 7UL, "");
}
namespace test_lambda_init_capture
{
int
test()
{
auto x = 0;
const auto lambda1 = [a = x](int b){ return a + b; };
const auto lambda2 = [a = lambda1(x)](){ return a; };
return lambda2();
}
}
namespace test_digit_seperators
{
constexpr auto ten_million = 100'000'000;
static_assert(ten_million == 100000000, "");
}
namespace test_return_type_deduction
{
auto f(int& x) { return x; }
decltype(auto) g(int& x) { return x; }
template < typename T1, typename T2 >
struct is_same
{
static constexpr auto value = false;
};
template < typename T >
struct is_same<T, T>
{
static constexpr auto value = true;
};
int
test()
{
auto x = 0;
static_assert(is_same<int, decltype(f(x))>::value, "");
static_assert(is_same<int&, decltype(g(x))>::value, "");
return x;
}
}
} // namespace cxx14
#endif // __cplusplus >= 201402L
]])

View file

@ -0,0 +1,39 @@
# ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# ============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++11
# standard; if necessary, add switches to CXXFLAGS to enable support.
#
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++11. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 14
include([ax_cxx_compile_stdcxx.m4])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])])

View file

@ -1,34 +0,0 @@
#include "AssertException.h"
#include <cstring>
namespace UnitTest {
AssertException::AssertException(char const* description, char const* filename, int lineNumber)
: m_lineNumber(lineNumber)
{
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;
}
}

View file

@ -1,28 +0,0 @@
#ifndef UNITTEST_ASSERTEXCEPTION_H
#define UNITTEST_ASSERTEXCEPTION_H
#include <exception>
namespace UnitTest {
class AssertException : public std::exception
{
public:
AssertException(char const* description, char const* filename, int lineNumber);
virtual ~AssertException() throw();
virtual char const* what() const throw();
char const* Filename() const;
int LineNumber() const;
private:
char m_description[512];
char m_filename[256];
int m_lineNumber;
};
}
#endif

View file

@ -1,122 +0,0 @@
#ifndef UNITTEST_CHECKMACROS_H
#define UNITTEST_CHECKMACROS_H
#include "Checks.h"
#include "AssertException.h"
#include "MemoryOutStream.h"
#include "TestDetails.h"
#include "CurrentTest.h"
#ifdef CHECK
#error UnitTest++ redefines CHECK
#endif
#ifdef CHECK_EQUAL
#error UnitTest++ redefines CHECK_EQUAL
#endif
#ifdef CHECK_CLOSE
#error UnitTest++ redefines CHECK_CLOSE
#endif
#ifdef CHECK_ARRAY_EQUAL
#error UnitTest++ redefines CHECK_ARRAY_EQUAL
#endif
#ifdef CHECK_ARRAY_CLOSE
#error UnitTest++ redefines CHECK_ARRAY_CLOSE
#endif
#ifdef CHECK_ARRAY2D_CLOSE
#error UnitTest++ redefines CHECK_ARRAY2D_CLOSE
#endif
#define CHECK(value) \
do \
{ \
try { \
if (!UnitTest::Check(value)) \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), #value); \
} \
catch (...) { \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK(" #value ")"); \
} \
} while (0)
#define CHECK_EQUAL(expected, actual) \
do \
{ \
try { \
UnitTest::CheckEqual(*UnitTest::CurrentTest::Results(), expected, actual, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
} \
catch (...) { \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_EQUAL(" #expected ", " #actual ")"); \
} \
} while (0)
#define CHECK_CLOSE(expected, actual, tolerance) \
do \
{ \
try { \
UnitTest::CheckClose(*UnitTest::CurrentTest::Results(), expected, actual, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
} \
catch (...) { \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_CLOSE(" #expected ", " #actual ")"); \
} \
} while (0)
#define CHECK_ARRAY_EQUAL(expected, actual, count) \
do \
{ \
try { \
UnitTest::CheckArrayEqual(*UnitTest::CurrentTest::Results(), expected, actual, count, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
} \
catch (...) { \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_ARRAY_EQUAL(" #expected ", " #actual ")"); \
} \
} while (0)
#define CHECK_ARRAY_CLOSE(expected, actual, count, tolerance) \
do \
{ \
try { \
UnitTest::CheckArrayClose(*UnitTest::CurrentTest::Results(), expected, actual, count, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
} \
catch (...) { \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_ARRAY_CLOSE(" #expected ", " #actual ")"); \
} \
} while (0)
#define CHECK_ARRAY2D_CLOSE(expected, actual, rows, columns, tolerance) \
do \
{ \
try { \
UnitTest::CheckArray2DClose(*UnitTest::CurrentTest::Results(), expected, actual, rows, columns, tolerance, UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__)); \
} \
catch (...) { \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), \
"Unhandled exception in CHECK_ARRAY_CLOSE(" #expected ", " #actual ")"); \
} \
} while (0)
#define CHECK_THROW(expression, ExpectedExceptionType) \
do \
{ \
bool caught_ = false; \
try { expression; } \
catch (ExpectedExceptionType const&) { caught_ = true; } \
catch (...) {} \
if (!caught_) \
UnitTest::CurrentTest::Results()->OnTestFailure(UnitTest::TestDetails(*UnitTest::CurrentTest::Details(), __LINE__), "Expected exception: \"" #ExpectedExceptionType "\" not thrown"); \
} while(0)
#define CHECK_ASSERT(expression) \
CHECK_THROW(expression, UnitTest::AssertException);
#endif

View file

@ -1,50 +0,0 @@
#include "Checks.h"
#include <cstring>
namespace UnitTest {
namespace {
void CheckStringsEqual(TestResults& results, char const* expected, char const* actual,
TestDetails const& details)
{
using namespace std;
if (strcmp(expected, actual))
{
UnitTest::MemoryOutStream stream;
stream << "Expected " << expected << " but was " << actual;
results.OnTestFailure(details, stream.GetText());
}
}
}
void CheckEqual(TestResults& results, char const* expected, char const* actual,
TestDetails const& details)
{
CheckStringsEqual(results, expected, actual, details);
}
void CheckEqual(TestResults& results, char* expected, char* actual,
TestDetails const& details)
{
CheckStringsEqual(results, expected, actual, details);
}
void CheckEqual(TestResults& results, char* expected, char const* actual,
TestDetails const& details)
{
CheckStringsEqual(results, expected, actual, details);
}
void CheckEqual(TestResults& results, char const* expected, char* actual,
TestDetails const& details)
{
CheckStringsEqual(results, expected, actual, details);
}
}

View file

@ -1,158 +0,0 @@
#ifndef UNITTEST_CHECKS_H
#define UNITTEST_CHECKS_H
#include "Config.h"
#include "TestResults.h"
#include "MemoryOutStream.h"
namespace UnitTest {
template< typename Value >
bool Check(Value const value)
{
return !!value; // doing double negative to avoid silly VS warnings
}
template< typename Expected, typename Actual >
void CheckEqual(TestResults& results, Expected const& expected, Actual const& actual, TestDetails const& details)
{
if (!(expected == actual))
{
UnitTest::MemoryOutStream stream;
stream << "Expected " << expected << " but was " << actual;
results.OnTestFailure(details, stream.GetText());
}
}
void CheckEqual(TestResults& results, char const* expected, char const* actual, TestDetails const& details);
void CheckEqual(TestResults& results, char* expected, char* actual, TestDetails const& details);
void CheckEqual(TestResults& results, char* expected, char const* actual, TestDetails const& details);
void CheckEqual(TestResults& results, char const* expected, char* actual, TestDetails const& details);
template< typename Expected, typename Actual, typename Tolerance >
bool AreClose(Expected const& expected, Actual const& actual, Tolerance const& tolerance)
{
return (actual >= (expected - tolerance)) && (actual <= (expected + tolerance));
}
template< typename Expected, typename Actual, typename Tolerance >
void CheckClose(TestResults& results, Expected const& expected, Actual const& actual, Tolerance const& tolerance,
TestDetails const& details)
{
if (!AreClose(expected, actual, tolerance))
{
UnitTest::MemoryOutStream stream;
stream << "Expected " << expected << " +/- " << tolerance << " but was " << actual;
results.OnTestFailure(details, stream.GetText());
}
}
template< typename Expected, typename Actual >
void CheckArrayEqual(TestResults& results, Expected const& expected, Actual const& actual,
int const count, TestDetails const& details)
{
bool equal = true;
for (int i = 0; i < count; ++i)
equal &= (expected[i] == actual[i]);
if (!equal)
{
UnitTest::MemoryOutStream stream;
stream << "Expected [ ";
for (int expectedIndex = 0; expectedIndex < count; ++expectedIndex)
stream << expected[expectedIndex] << " ";
stream << "] but was [ ";
for (int actualIndex = 0; actualIndex < count; ++actualIndex)
stream << actual[actualIndex] << " ";
stream << "]";
results.OnTestFailure(details, stream.GetText());
}
}
template< typename Expected, typename Actual, typename Tolerance >
bool ArrayAreClose(Expected const& expected, Actual const& actual, int const count, Tolerance const& tolerance)
{
bool equal = true;
for (int i = 0; i < count; ++i)
equal &= AreClose(expected[i], actual[i], tolerance);
return equal;
}
template< typename Expected, typename Actual, typename Tolerance >
void CheckArrayClose(TestResults& results, Expected const& expected, Actual const& actual,
int const count, Tolerance const& tolerance, TestDetails const& details)
{
bool equal = ArrayAreClose(expected, actual, count, tolerance);
if (!equal)
{
UnitTest::MemoryOutStream stream;
stream << "Expected [ ";
for (int expectedIndex = 0; expectedIndex < count; ++expectedIndex)
stream << expected[expectedIndex] << " ";
stream << "] +/- " << tolerance << " but was [ ";
for (int actualIndex = 0; actualIndex < count; ++actualIndex)
stream << actual[actualIndex] << " ";
stream << "]";
results.OnTestFailure(details, stream.GetText());
}
}
template< typename Expected, typename Actual, typename Tolerance >
void CheckArray2DClose(TestResults& results, Expected const& expected, Actual const& actual,
int const rows, int const columns, Tolerance const& tolerance, TestDetails const& details)
{
bool equal = true;
for (int i = 0; i < rows; ++i)
equal &= ArrayAreClose(expected[i], actual[i], columns, tolerance);
if (!equal)
{
UnitTest::MemoryOutStream stream;
stream << "Expected [ ";
for (int expectedRow = 0; expectedRow < rows; ++expectedRow)
{
stream << "[ ";
for (int expectedColumn = 0; expectedColumn < columns; ++expectedColumn)
stream << expected[expectedRow][expectedColumn] << " ";
stream << "] ";
}
stream << "] +/- " << tolerance << " but was [ ";
for (int actualRow = 0; actualRow < rows; ++actualRow)
{
stream << "[ ";
for (int actualColumn = 0; actualColumn < columns; ++actualColumn)
stream << actual[actualRow][actualColumn] << " ";
stream << "] ";
}
stream << "]";
results.OnTestFailure(details, stream.GetText());
}
}
}
#endif

View file

@ -1,31 +0,0 @@
#ifndef UNITTEST_CONFIG_H
#define UNITTEST_CONFIG_H
// Standard defines documented here: http://predef.sourceforge.net
#if defined(_MSC_VER)
#pragma warning(disable:4127) // conditional expression is constant
#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
#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
// by default, MemoryOutStream is implemented in terms of std::ostringstream, which can be expensive.
// uncomment this line to use the custom MemoryOutStream (no deps on std::ostringstream).
//#define UNITTEST_USE_CUSTOM_STREAMS
#endif

View file

@ -1,18 +0,0 @@
#include "CurrentTest.h"
#include <cstddef>
namespace UnitTest {
TestResults*& CurrentTest::Results()
{
static TestResults* testResults = NULL;
return testResults;
}
const TestDetails*& CurrentTest::Details()
{
static const TestDetails* testDetails = NULL;
return testDetails;
}
}

View file

@ -1,17 +0,0 @@
#ifndef UNITTEST_CURRENTTESTRESULTS_H
#define UNITTEST_CURRENTTESTRESULTS_H
namespace UnitTest {
class TestResults;
class TestDetails;
namespace CurrentTest
{
TestResults*& Results();
const TestDetails*& Details();
}
}
#endif

View file

@ -1,28 +0,0 @@
#ifndef UNITTEST_DEFERREDTESTREPORTER_H
#define UNITTEST_DEFERREDTESTREPORTER_H
#include "TestReporter.h"
#include "DeferredTestResult.h"
#include <vector>
namespace UnitTest
{
class DeferredTestReporter : public TestReporter
{
public:
virtual void ReportTestStart(TestDetails const& details);
virtual void ReportFailure(TestDetails const& details, char const* failure);
virtual void ReportTestFinish(TestDetails const& details, float secondsElapsed);
typedef std::vector< DeferredTestResult > DeferredTestResultList;
DeferredTestResultList& GetResults();
private:
DeferredTestResultList m_results;
};
}
#endif

View file

@ -1,25 +0,0 @@
#include "DeferredTestResult.h"
#include "Config.h"
namespace UnitTest
{
DeferredTestResult::DeferredTestResult()
: suiteName("")
, testName("")
, failureFile("")
, timeElapsed(0.0f)
, failed(false)
{
}
DeferredTestResult::DeferredTestResult(char const* suite, char const* test)
: suiteName(suite)
, testName(test)
, failureFile("")
, timeElapsed(0.0f)
, failed(false)
{
}
}

View file

@ -1,29 +0,0 @@
#ifndef UNITTEST_DEFERREDTESTRESULT_H
#define UNITTEST_DEFERREDTESTRESULT_H
#include <string>
#include <vector>
namespace UnitTest
{
struct DeferredTestResult
{
DeferredTestResult();
DeferredTestResult(char const* suite, char const* test);
std::string suiteName;
std::string testName;
std::string failureFile;
typedef std::pair< int, std::string > Failure;
typedef std::vector< Failure > FailureVec;
FailureVec failures;
float timeElapsed;
bool failed;
};
}
#endif //UNITTEST_DEFERREDTESTRESULT_H

View file

@ -1,46 +0,0 @@
#ifndef UNITTEST_EXECUTE_TEST_H
#define UNITTEST_EXECUTE_TEST_H
#include "TestDetails.h"
#include "MemoryOutStream.h"
#include "AssertException.h"
#include "CurrentTest.h"
#ifdef UNITTEST_POSIX
#include "Posix/SignalTranslator.h"
#endif
namespace UnitTest {
template< typename T >
void ExecuteTest(T& testObject, TestDetails const& details)
{
CurrentTest::Details() = &details;
try
{
#ifdef UNITTEST_POSIX
UNITTEST_THROW_SIGNALS
#endif
testObject.RunImpl();
}
catch (AssertException const& e)
{
CurrentTest::Results()->OnTestFailure(
TestDetails(details.testName, details.suiteName, e.Filename(), e.LineNumber()), e.what());
}
catch (std::exception const& e)
{
MemoryOutStream stream;
stream << "Unhandled exception: " << e.what();
CurrentTest::Results()->OnTestFailure(details, stream.GetText());
}
catch (...)
{
CurrentTest::Results()->OnTestFailure(details, "Unhandled exception: Crash!");
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show more