Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/mitya57/cxxunit

Simple C++ unit testing library
https://github.com/mitya57/cxxunit

cplusplus header-only testing unit-testing

Last synced: 21 days ago
JSON representation

Simple C++ unit testing library

Awesome Lists containing this project

README

        

This is a simple C++ unit testing library. It requires C++11 or newer.

Usage example:

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

struct test_FirstAndTrivial: TestCase {
void run() override {
unsigned int val = 1;

ASSERT_EQUAL((val + 1) / 2, 1);
}
};

REGISTER_TEST(test_FirstAndTrivial, "Arithmetic operations");
```

In the `run` method, the following macros are supported:

- `ASSERT_TRUE(expression)`;
- `ASSERT_FALSE(expression)`;
- `ASSERT_RELATION(e1, rel, e2)`, for example `ASSERT_RELATION(e1, <=, e2)`;
- `ASSERT_EQUAL(e1, e2)`;
- `ASSERT_ALMOST_EQUAL(e1, e2, precision)`;
- `ASSERT_FLOATS_EQUAL(e1, e2)` — for fuzzy comparison of floats and doubles;
- `ASSERT_STRINGS_EQUAL(e1, e2)` — with better formatted output for strings;
- `ASSERT_THROWS(exception_class, expression)`.