Giter Club home page Giter Club logo

check-cmake-example's Introduction

Simple unit testing example with Check and CMake

This project is a complete C unit test with the Check library, using CMake as a build tool.

Status

BSD licensed Build Status codecov

Installing

To run this project the following programs need to be installed on your system:

  • Cmake
  • Check
  • Gcov
  • Lcov
  • Valgrind

Then, do as follows:

$ mkdir build && cd build
$ cmake ..
$ make
$ make test

Don't do make install unless you want to install the sample library.

sample.c and sample.h are built as a library. src/main.c:main() is a client of libsample.a, just as tests/test_sample.c:main().

After running make test, you will find the test files into Testing folder.

Code Coverage Support

This example implements Code Coverage Reports using either using either gcov or lcov. If you want to check them, you should run the following command after make test:

$ make gcov
$ make lcov

The coverage reports will be into Coverage folder. In the case of lcov, you can see into the browser, opening the index.html file on the folder above.

Valgrind Support

This example also implements a memory leak check with valgrind, thus allowing a full test of the application. If you want to check them, you should run the following command after make:

$ make test_sample_valgrind

It is important to note that, unlike code coverage generation, for each add_executable in the build, you will need to create a specific target for the valgrind with add_custom_target.

In the future, we plan to make a macro to simplify this task. At this moment, we only provide the means to add valgrind into build script.

Thanks

We have done our best to keep the code as simple as possible, both in the building scripts and in the test scripts, in order to be very straightforward and easy to understand.

Corrections and suggestions are welcome. Feel free to fork this project and propose suggestions through issues and pull requests.

check-cmake-example's People

Watchers

James Cloos 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.