npm.io
0.0.6 • Published 4 years ago

@ekx/unit

Licence
MIT
Version
0.0.6
Deps
0
Size
40 kB
Vulns
0
Weekly
0
Stars
9

unit

Build codecov

Tiny unit testing library for C language

Standard License Download Documentation Twitter Try it online

output

Example

Compile executable with -D UNIT_TESTING to enable tests

#define UNIT_MAIN
#include <unit.h>

SUITE( suite name ) {
  DESCRIBE( subcase name ) {
    IT("is test behaviour") {
      WARN("use WARN_* to print failed assumptions");
      CHECK("use CHECK_* to continue execute assertions on fail");
      REQUIRE("use REQUIRE_* to skip next assertions on fail");
    }
  }
}

Features and design goals

✓ Main focus and features
  • Written in Pure C: only standard libc is used
  • Simplicity and tiny build-size
  • No dynamic memory allocations: only static memory is used for reporting test running infrastructure.
  • Single-header library: easy to integrate
  • Embedded runner & pretty reporter: build self-executable test
  • Disable test code: allow you to write tests for your private implementation right at the end of impl.c file
  • Cross-platform: should work for Linux / macOS / Windows
✕ What you won't find here
  • Cross-compiler support: no MSVC support, only clang is tested
  • Multithreading and parallel test running
  • Tricky test matchers design
  • Fixtures, before / after or mocking
  • Crash tests and signal interception
  • Fuzz testing

In any case, if you have a desire, you can support and contribute! Feel free to ask me any feature you need Thank you for your interest!

Keywords