Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/amdmi3/testing.h

Small and simple single-header library for writing C++ unit tests
https://github.com/amdmi3/testing.h

c-plus-plus header-only testing unit-testing

Last synced: about 2 hours ago
JSON representation

Small and simple single-header library for writing C++ unit tests

Awesome Lists containing this project

README

        

# testing.h #

This is a simple C++11 unit test frame work.

## Features ##

* Single header file, no dependencies
* Provides detailed information of which expressions are tested and test results
* Colored output

To use this in your project, you may just grab testing.h and add it to
your source tree.

## Short example ##

```c++
#include "testing.h"

BEGIN_TEST()
EXPECT_TRUE(MyFunc() == "foo");
EXPECT_EQUAL(GetSomeStr(), "ExpectedString");
EXPECT_EXCEPTION(MyFunc(), std::runtime_error);
END_TEST()
```

Possible output:

```
PASS: MyFunc() == "foo"
FAIL: MyFunc() returned "UnexpectedString" while expected "ExpectedString"
FAIL: MyFunc() hasn't thrown expected exception std::runtime_error
```

## Longer example ##

See [demo.cc](demo.cc), which demonstrates almost all framework abilities. You
may compile and run the demo by calling ```make```.

## License ##

2-clause BSD, see [COPYING](COPYING) or source files.

## Author ##

Dmitry Marakasov

## Contributors ##

* [Vladimir Gamalian](https://github.com/vladimirgamalian)