Features

  • Lightweight, just a few header files.
  • Rich, expandable, set of assertions, including assertions for exceptions and collections (arrays, vectors, sets etc.).
  • Simple and intuitve syntax, just ordinary C++.
  • Both test setup/teardown and suite setup/teardown methods.
  • Possibility to run all tests, all tests in a single suite or just a single test.

A trivial example

This is a trivial but complete example to give the “look and feel” of wide::unittest.

#include<string>
#include<wide/unittest>

using namespace wide::unittest;
using namespace std;

// The test suite
class my_test_suite : public test_suite<my_test_suite> {
public:
  my_test_suite() :
    test_suite("Tests for some program logic") {
    stage(&my_test_suite::string_addition, "Test of string addition");
  }
  
  void string_addition() {
    string hello("Hello");
    string world("World!");
    string hello_world = hello + " " + world;
    Verify(hello_world, Is.EqualTo("Hello World!"));
  }
};

// The test application
int main() {
  test_runner tester;
  
  int failCount = tester.run_suite<my_test_suite>();
  return failCount;
}

The output of this program when run will, if all tests pass, be:

Tests for some program logic
  Test of string addition... pass
Tests: 1,  Failed: 0,  Errors: 0

Suites: 1,  Tests: 1,  Failed 0,  Errors: 0