Giter Site home page Giter Site logo

jamo42 / miniunit Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 3 KB

A very small unit testing framework for C/C++ based on MinUnit.

Home Page: http://www.jera.com/techinfo/jtns/jtn002.html

C 97.13% Shell 2.87%
c cpp unit-testing unit-testing-framework minimal header-only single-header

miniunit's Introduction

miniunit

A very small unit testing framework based on MinUnit.

Usage

Example:

#include "miniunit"
#include "foo.h"

/* Define a test
 * Instead of the TEST macro, the function can also
 * just be declared a `const char *test()`.
 */
TEST(my_test) {
  /* Assert an expression to be true */
  mu_assert("message", foo());
  /* Test cases must return 0 on success */
  return 0;
}

TEST(will_fail) {
  mu_assert("this test failed", 0);
  return 0;
}

TEST(wont_run) {
  mu_assert("message", 1);
  return 0;
}

/* This function must be defined and runs all of the tests */
const char * all_tests() {
  mu_run_test(my_test);
  mu_run_test(will_fail);
  mu_run_test(wont_run);
  return 0;
}

Output

Output of the above example (assuming foo returns true):

RUNNING TESTS
-- my_test
-- will_fail
this test failed
ABORT
Tests run: 2

Successful output:

RUNNING TESTS
-- test_1
-- test_2
...
-- test_16
ALL TESTS PASSED
Tests run: 16

Installation

Running sudo ./install.sh will copy the file to /usr/local/include.

miniunit's People

Contributors

jamo42 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.