Skip to content

Simple C++ unit testing library

Notifications You must be signed in to change notification settings

mitya57/cxxunit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Usage example:

#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).

Releases

No releases published

Packages

No packages published

Languages