# @ekx/unit

> Simple header-only testing library for C

Latest version **0.0.6** (published 2022-06-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ekx/unit
pnpm add @ekx/unit
yarn add @ekx/unit
bun add @ekx/unit
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2022-06-03 |
| First published | 2022-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 39.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Ilya Kuzmichev |
| Maintainers | eliasku |
| Keywords | c, testing, unit-testing, cmake, embedded, cross-platform, bdd, assertions, clang, kiss, header-only, single-header-library |

## Links

- npm: https://www.npmjs.com/package/@ekx/unit
- Repository: https://github.com/eliasku/unit
- Homepage: https://github.com/eliasku/unit#readme
- Issues: https://github.com/eliasku/unit/issues
- npm.io page: https://npm.io/package/@ekx/unit

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.0.6 (latest) — 2022-06-03
- 0.0.5 — 2022-06-02
- 0.0.4 — 2022-06-02
- 0.0.3 — 2022-05-26
- 0.0.2 — 2022-05-22
- 0.0.1 — 2022-05-22

## README

# unit

[![Build](https://github.com/eliasku/unit/actions/workflows/build.yml/badge.svg)](https://github.com/eliasku/unit/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/eliasku/unit/branch/master/graph/badge.svg?token=NFTrtCHQ2r)](https://codecov.io/gh/eliasku/unit)

## 🥼 Tiny unit testing library for C language 🥼

[![Standard](https://img.shields.io/badge/C-11/14/17-pink.svg)](https://en.wikipedia.org/wiki/C_(programming_language))
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Download](https://img.shields.io/badge/Download%20%20-unit.h-lightgreen.svg)](https://raw.githubusercontent.com/eliasku/unit/master/include/unit.h)
[![Documentation](https://img.shields.io/badge/docs-latest-white)](http://unit.rtfd.io/)
[![Twitter](https://img.shields.io/twitter/follow/eliaskuvoice.svg?style=flat&label=Follow&logoColor=white&color=1da1f2&logo=twitter)](https://twitter.com/eliaskuvoice)
[![Try it online](https://img.shields.io/badge/Try%20it-online-orange.svg)](https://godbolt.org/z/17vjqsnca)

![output](docs/output.gif)

## Example

Compile executable with `-D UNIT_TESTING` to enable tests

```c
#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!**

---
_Source: https://npm.io/package/@ekx/unit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
