项目作者: jdgarciauc3m

项目描述 :
Minimal contracts library
高级语言: C++
项目地址: git://github.com/jdgarciauc3m/min-contracts.git
创建时间: 2021-05-12T17:20:43Z
项目社区:https://github.com/jdgarciauc3m/min-contracts

开源协议:Apache License 2.0

下载


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:

  1. 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:

  1. mkdir build
  2. cd build
  3. cmake .. -D_CMAKE_BUILD_TYPE=Release # Configure build process
  4. make

Installing the library

You can install the library with the target install.

  1. 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.

  1. ctest

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

  1. ctest -VV

Acknowledgments

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