GithubHelp home page GithubHelp logo

henry4k / dummy Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 83 KB

A small and flexible (unit) testing framework for C and C++.

License: The Unlicense

C++ 23.63% C 57.15% Shell 1.65% Python 11.74% Meson 5.83%

dummy's Introduction

dummy

A small and flexible (unit) testing framework for C and C++.

Features:

  • small core: Everything except core.h/c is optional.
  • portable: It just depends on the C standard library.
  • extensible: Reporters, API porcelain and sandboxes can be customized.

Description

At its core, it just consists of a small set of functions, written in C.
Since small things tend to break less often than big contraptions.
And a test system is not the kind of code that may break.

  [porcelain]
      ||
      \/
    [core] => [sandbox] => [test]
      ||
      \/
  [reporter]

At first, you need to initialize dummy and register some tests.
Then you can tell it to run those tests:
A sandbox is created for every test and catches errors during the execution.
Any events that happen while running the tests are passed to the reporter.
And that's all there is to it - everything else is under your control.

Reporters, API porcelain and sandboxes can be plugged onto it, just as you need it.
Some are already provided, but it shouldn't be hard to write your own.

These are currently provided by dummy:

Reporters:

  • xml_reporter: Prints a report in an JUnit complatible XML format.
  • tap_reporter: Reports using Perls 'test anything protocol' (TAP).

Sandboxes:

  • signal_sandbox: Catches fatal errors like segmentation violation or illegal instruction.
  • exception_sandbox: Besides signals, this also catches C++ exceptions.

API porcelain:

  • bdd: "Behaviour driven design" - Lets you define tests BDD style. See test/bdd.cpp for example.
  • inline: Register tests as you define their functions. See test/inline.c for example.
  • require: Check if an expression is true. (Like assert(), but tailored for dummy.)

Usage

Just copy the parts you need into your project, since anything except core.h/c is optional.

When testing C++ code using the exception_sandbox, you need to compile core.c with a C++ compiler.
Because C++ exceptions can't be thrown through C code.

For code examples, just take a look at the test directory.

Author

Licence

This is free and unencumbered public domain software.
For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.

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.