commit | 9018eabe0c4337e0bf49d2d801b2de5835061886 | [log] [tgz] |
---|---|---|
author | onqtam <vik.kirilov@gmail.com> | Sun May 22 04:38:12 2016 +0300 |
committer | onqtam <vik.kirilov@gmail.com> | Sun May 22 04:45:58 2016 +0300 |
tree | 4147087b10272115b2e6170ad52493eb0bc43ecd | |
parent | aff213cccf316d80487d3e0bbceac42db8651273 [diff] |
fixing gcc 4.7 builds...
The doctest library is inspired by the unittest {}
functionality of the D programming language and Python's docstrings - tests can be considered a form of documentation and should be able to reside near the production code which they test.
A complete example with a self-registering test that compiles to an executable looks like this:
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "doctest.h" int factorial(int number) { return number <= 1 ? number : factorial(number - 1) * number; } TEST_CASE("testing the factorial function") { CHECK(factorial(1) == 1); CHECK(factorial(2) == 2); CHECK(factorial(10) == 3628800); }
Note how a standard C++ operator for the comparison is used - doctest has only one core assertion macro (instead of many for less than, equals, greater than...) - yet the full expression is decomposed and the left and right values are logged.
It is modeled after Catch which is currently the most popular and easy to use alternative for testing in C++
There are many C++ testing frameworks - Catch, Boost.Test, UnitTest++, lest, bandit, igloo, xUnit++, CppTest, CppUnit, CxxTest, cpputest, googletest, cute and many other.
What makes doctest different is that it is ultra light on compile times (by orders of magnitude) and is unintrusive.
The key differences between it and other testing libraries are:
DOCTEST_CONFIG_DISABLE
identifierdoctest
namespace) and doesn't drag any headers with itThis allows the library to be used in more ways than any other - tests can be written directly in the production code!
The library can be used like any other if you don't like the idea of mixing production code and tests - check out the features
master branch | |||
---|---|---|---|
dev branch |
main()
entry point and dealing with shared objectsSupport the development of the project with donations! There is a list of planned features which are all important and big - see the roadmap. I work on this project in my spare time and every cent is a big deal. I took a break from working in the industry to make open source software.
Contributions in the form of issues and pull requests are welcome as well.
Open an issue for a discussion before making a pull request to make sure the contribution goes smoothly.
This framework has some design goals which must be kept. Make sure you have read the features and design goals page.
The master
branch is the stable one with the latest release and the dev
branch is on the bleeding edge.
All the framework tests (using ctest) have their output collected when the CMake TEST_MODE
variable is set to COLLECT
(making the new reference output) and later the tests are ran on the CI services (travis
and appveyor
) - their output is compared with the current reference output in the repository with the COMPARE
mode (default mode is COMPARE
).
Code should be formatted with a recent-enough clang-format
using the config file in the root of the repo (or I will do it...)
Testing with compilers different from GCC/Clang/MSVC (and more platforms) is something the project would benefit from.