An over-engineered C++ assertion library providing rich diagnostic information, automatic expression decomposition, and syntax highlighting.
libassert is an advanced C++ assertion library that enhances debugging by automatically decomposing assertion expressions and providing rich diagnostic information, including values, stack traces, and syntax highlighting. It solves the problem of vague assertion failures in standard C++ assertions by delivering detailed context to developers immediately upon failure.
C++ developers working on projects where debugging and verification of assumptions are critical, particularly those in need of more informative assertion failures than what `<cassert>` provides.
Developers choose libassert for its automatic expression decomposition, which eliminates the need for numerous specialized assertion macros, and its extensive diagnostic output that reduces time spent triaging bugs by providing stack traces, value displays, and customizable stringification.
The most over-engineered C++ assertion library
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Eliminates the need for specialized macros like ASSERT_EQ by parsing expressions such as `assert(vec.size() > 10)` to show values automatically, as showcased in the README screenshots.
Provides stack traces, syntax highlighting, and value displays on failure, reducing debugger re-runs; examples include formatted error messages with diff highlighting and automatic strerror for errno.
Offers _VAL variants that return values, enabling assertions to be used inline like `FILE* f = ASSERT_VAL(fopen(path, 'r') != nullptr)`, shown in the overview with optional diagnostic messages.
Supports custom stringification for user-defined types, failure handlers, and test framework integrations (Catch2/GoogleTest), detailed in the library documentation with configuration options.
The README admits 'there is some compile-time cost associated with the library's machinery,' which can slow down builds, especially when features like enum stringification are enabled.
Requires extra steps on Windows (DLL copying) and macOS (dSYM generation), and isn't a drop-in replacement for <cassert>, needing aliases or macro adjustments for seamless integration.
Not compatible with -pedantic due to compiler extensions, limiting use in strictly conforming C++ environments, and expression decomposition can cause subtle issues like compiling `ASSERT(1 = 2)`.
While integrated with Catch2 and GoogleTest, the README notes MSVC requires /Zc:preprocessor for wrappers, and the community is small (discord badge indicates 'very small' community), which may affect support.