Skip to content

jdgarciauc3m/min-contracts

Repository files navigation

min-contracts

Linux builds

MacOS builds

Windows builds

Minimal contracts library tries to offer a minimal library-only solution to support contracts in modern C++.

The library offers:

  • Preconditions
  • Postconditions
  • Assertions

Please, refer to library API description for more details.

Getting started

Prerequisites

The following requirements must be met to use the library:

  • CMake 3.16 or higher.
  • A C++20 compliant compiler. Note that the library has been tested with the following versions:
    • g++ (version 9, 10, 11) under Ubuntu Linux 20.
    • clang++ (version 11) under Ubuntu Linux 20.
    • AppleClang++ (version 12) under MacOS 10.
    • MSVC 2019 under Windows 2019.
    • MSVC 2017 under Windows 2017.

If you want to run the unit tests you will need:

  • Google Test (available at GitHub repo). Please, use the latest available version. If Google Test library is not found, the unit tests will not be available but you will be able to install the library.

Installing the sources

Clone the project:

git clone git@github.com:jdgarciauc3m/min-contracts.git

Building the library

To build the library out of source, create a directory and run cmake:

mkdir build
cd build
cmake .. -D_CMAKE_BUILD_TYPE=Release  # Configure build process
make

Installing the library

You can install the library with the target install.

make install

Running the tests

Unit tests can be disabled by setting the option mincontracts_TESTS to OFF.

To run the tests, simply use CTest, from the build directory, passing the desired configuration.

ctest

If you want more verbose output for the tests, you can use:

ctest -VV

Acknowledgments

Some ideas used here are inspired by the great series of blog posts by Herb Sutter: