API

Defines

UNIT__NOOP

unit.h - v0.0.6 - Simple header-only testing library for C - https://github.com/eliasku/unit

Minimal example. Compile executable with -D UNIT_TESTING to enable tests.

#define UNIT_MAIN
#include "unit.h"

suite( you_should_define_the_suite_name_here ) {
  describe( optionally_add_the_subject ) {
    it( "describe the test behaviour" ) {
      check("use warn / check / require functions");
    }
  }
}

By default all test code is stripped away, to enable test-code you should pass -D UNIT_TESTING and build executable

In any translation unit you need to #define UNIT_MAIN before #include <unit.h> to implement the library and generate default main entry-point to run all tests.

If you need just to implement library, you #define UNIT_IMPLEMENT before include <unit.h> in any single translation unit Declare default main arguments

UNIT__CONCAT_(a, b)
UNIT__CONCAT(a, b)
UNIT_SUITE(Name, ...)
UNIT_DESCRIBE(Name, ...)
UNIT_TEST(Description, ...)
UNIT_ECHO(...)
UNIT_WARN(x, ...)
UNIT_WARN_FALSE(x, ...)
UNIT_WARN_EQ(a, b, ...)
UNIT_WARN_NE(a, b, ...)
UNIT_WARN_GT(a, b, ...)
UNIT_WARN_GE(a, b, ...)
UNIT_WARN_LT(a, b, ...)
UNIT_WARN_LE(a, b, ...)
UNIT_CHECK(x, ...)
UNIT_CHECK_FALSE(x, ...)
UNIT_CHECK_EQ(a, b, ...)
UNIT_CHECK_NE(a, b, ...)
UNIT_CHECK_GT(a, b, ...)
UNIT_CHECK_GE(a, b, ...)
UNIT_CHECK_LT(a, b, ...)
UNIT_CHECK_LE(a, b, ...)
UNIT_REQUIRE(x, ...)
UNIT_REQUIRE_FALSE(x, ...)
UNIT_REQUIRE_EQ(a, b, ...)
UNIT_REQUIRE_NE(a, b, ...)
UNIT_REQUIRE_GT(a, b, ...)
UNIT_REQUIRE_GE(a, b, ...)
UNIT_REQUIRE_LT(a, b, ...)
UNIT_REQUIRE_LE(a, b, ...)
UNIT_SKIP(...)
unit_main(...)
SUITE(...)
DESCRIBE(...)
IT(...)
TEST(...)
ECHO(...)
WARN(...)
WARN_FALSE(...)
WARN_EQ(...)
WARN_NE(...)
WARN_GT(...)
WARN_GE(...)
WARN_LT(...)
WARN_LE(...)
CHECK(...)
CHECK_FALSE(...)
CHECK_EQ(...)
CHECK_NE(...)
CHECK_GT(...)
CHECK_GE(...)
CHECK_LT(...)
CHECK_LE(...)
REQUIRE(...)
REQUIRE_FALSE(...)
REQUIRE_EQ(...)
REQUIRE_NE(...)
REQUIRE_GT(...)
REQUIRE_GE(...)
REQUIRE_LT(...)
REQUIRE_LE(...)
SKIP(...)