Skip to content

xiaoyuechen/minicut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minicut

MINImalist C Unit Test

Features

  • Header-only
  • Test discovery
  • Minimal code base
  • Minimal dependencies
  • Written in C, supports C++
  • Supports GCC and Clang
  • Modular and customisable

Getting started

Clone the repository, then take a look at example-mini.c

#include "minicut-main.h"

MC_test (test_a)
{
  MC_assert (1);
  MC_assert (3 == 3);
}

MC_test (test_b)
{
  MC_assert (0);
  MC_assert (1 == 3);
}

You only need to know 3 things to get started

  • Including minicut-main.h registers tests and provides a main
  • MC_test(NAME) declares a test case with NAME
  • MC_assert(EXP) asserts an EXPression

Build example-mini by running make. Executing ./example-mini gives the following output

minicut is testing ./example-mini
test_a PASS
test_b FAIL
example-mini.c:31: error: assertion failed: 0
example-mini.c:32: error: assertion failed: 1 == 3
TOTAL 2 PASS 1 FAIL 1

Now you have understood the basic usage of minicut. Simply include minicut-main.h and you are ready to unit test (minicut-mini.h must also be in your include path).

The rest of the sections are for those who would like to customise or hack minicut.

How minicut works

Hacking minicut

Contributing