Giter Site home page Giter Site logo

eliasku / unit Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 1.71 MB

Tiny unit testing library for C language

License: MIT License

CMake 5.28% C 92.56% C++ 0.17% JavaScript 1.99%
bdd c unit-testing clang cross-platform kiss single-header-library small-projects cmake header-only

unit's Introduction

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");
    }
  }
}

Command-line options

  • --version, -v: Prints the version of unit library
  • --help, -h: Prints usage help message
  • --list, -l: Prints all available tests
  • --animate, -a: Simulate waits for printing messages, just for making fancy printing animation
  • --ascii: Don't use colors and fancy unicode symbols in the output
  • --short-filenames, -S: Use only basename for displaying file-pos information
  • --quiet, -q: Disables all output
  • -r=xml: Special switch prints XML report in DocTest-friendly format (for CLion test run configuration)

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 / WebAssembly

โœ• 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!

unit's People

Contributors

eliasku avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

unit's Issues

Split source code

  • Split and group to different h/c files in src folder
  • Make script which build (amalgamate) to header-only library include/unit.h
  • Add version from package.json to library header
  • Add library pre-build steps in CI

compile errors because of `test` macro

Macros should be SCREAMING_UPPER_CASE.
Currently:

  • it could be mismatched with variables called it as iterators
  • test macro corrupts CXX atomic headers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.