Skip to content

progsource/exa

Repository files navigation

exa

License: MIT Version: 0.1.1 Build Status

exa is a short name for extended assert.

It is using the {fmt} library for formatting output messages.

supported OS

It actually should work on any OS, that supports the C++14 standard library.

It is tested to work on:

  • Linux (without exceptions and without RTTI)

dependencies

assert levels

Currently there is DEBUG, WARNING, DEFAULT, ERROR and FATAL.

DEBUG will only output something, if exa was compiled with NDEBUG defined.

DEBUG and WARNING should run into a breakpoint, while DEFAULT, ERROR and FATAL are going to abort the program.

At the moment there is then no other difference with the levels, only the output message, which is written to std::cerr, differs based on the level.

how to use

Clone the repository and run git submodule update --init --recursive to get the dependencies.

with cmake

Add it as a submodule itself, initialize it recursively and add it to your CMakeLists.txt with add_subdirectory(exa) + adding the fmtlib and exa header to your include directories with the variable ${EXA_INCLUDE_DIRS}.

without cmake

Add libs/fmt files, include/exa/exa.h and src/exa/exa.cpp to your files to compile.

in code

You can use it for example like:

#include "exa/exa.h"

// some code would surround the following lines ;)
// so this example code is not directly compile-able

EXA_DEBUG(2 == myVar, "myVar should be 2 and not {}", myVar);
EXA_WARNING(a < b);
EXA(1 == 0, "There {} something wrong.", "went");
EXA_ERROR(!myVector.empty(), "the vector is empty");
EXA_FATAL(a / 0, "really bad zero-devision");

how to run tests

Tested on linux:

git clone https://github.com/progsource/exa.git
cd exa
git submodule update --init --recursive
mkdir tmp
cd tmp
cmake ..
make
make test # or run the tests directly with: ../build/ExaTests

If you want to see the output of the asserts during the test runs, you need to set EXA_DEBUG_TESTS in the CMakeLists.txt to true, so it will still write everything to cerr.

set(EXA_DEBUG_TESTS true)

how to contribute

There are different possibilities:

  • Create a GitHub issue
  • Create a pull request with an own branch (don't forget to put yourself in the AUTHORS file)

thanks to

in no particular order

About

c++ extended assert

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published