Skip to content

kube/cut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cut

C Unit Testing Framework

Cut is a simple C Unit Testing Framework composed by a bunch of macros in a single header file. Its syntax is inpired by Node testing framework Mocha.

SUITE(hitchhiker, {
    DESCRIBE("Deep Thought", {
        IT("returns meaning of life", {
            ASSERT(deep_thought() == 42)
        })
    })
})

Signals

Cut will catch signals thrown during execution of each it block. If an unexpected signal appears, the block status will be passed to the signal name.

Describe Marvin
    It segfaults when asked to be happy [SIGSEGV]

But sometimes, you will expect this behaviour. In this case, simply use an EXPECT_SIGNAL wrapper :

IT("segfaults when asked to be happy", {
    EXPECT_SIGNAL(SIGSEGV, {
        marvin_be_happy()
    })
})

Your test will then pass succesfully, ONLY if block emitted the expected signal, or will fail otherwise:

Describe Marvin
    It segfaults when asked to be happy [OK]

CutRun

CutRun is a simple tool that will permit you to run your tests easily without having to create a Makefile or call the compiler from the command-line. It will handle everything for you.

CutRun

Directives

All compilation properties are passed to CutRun through a simple set of directives, directly in the test source file:

///CUTRUN:LINK_LIBRARY      ft
///CUTRUN:LIBRARY_FOLDER    ../
///CUTRUN:INCLUDE_FOLDER    ../include

SUITE(hello {
    DESCRIBE("world", {
        ...
    })
})

You can also pass these directives directly to cutrun executable:

cutrun tests/hashmap.c -I../include -L../ -lft

Install

curl -fsSL https://rawgit.com/kube/cut/master/install.sh | sh -s remote

Uninstall

rm -rf $(cutrun --print-install-path) $(which cutrun)

About

C Unit Testing Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published