https://github.com/eggs-cpp/test
Eggs.Test is a C++23 test library
https://github.com/eggs-cpp/test
Last synced: 1 day ago
JSON representation
Eggs.Test is a C++23 test library
- Host: GitHub
- URL: https://github.com/eggs-cpp/test
- Owner: eggs-cpp
- License: bsl-1.0
- Created: 2026-05-19T15:22:59.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-06-25T18:35:22.000Z (4 days ago)
- Last Synced: 2026-06-25T19:13:12.583Z (4 days ago)
- Language: C++
- Homepage:
- Size: 73.2 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Eggs.Test
A minimal C++ test framework. Requires C++23.
## Usage
```cpp
#include
TEST_CASE(my_test, "adds two integers") {
CHECK(1 + 1 == 2);
REQUIRE(1 + 1 == 2); // stops the test case on failure
}
int main() {
return eggs::test::run();
}
```
### Assertion macros
`CHECK(expr)` — evaluates *expr*; reports failure and continues.
`REQUIRE(expr)` — like `CHECK`, but stops the current test case on failure.
`CHECK_THROWS(expr)` — passes if *expr* throws any exception.
`CHECK_THROWS_AS(ExcType, expr)` — passes if *expr* throws an exception of type *ExcType*; returns `std::exception_ptr` on success.
`CHECK_CATCHES_AS(ExcType, expr) { }` — like `CHECK_THROWS_AS`; the body runs on success with the caught exception bound to `exc`.
`CHECK_NOTHROW(expr)` — passes if *expr* does not throw.
Every `CHECK_*` macro has a `REQUIRE_*` variant that stops the test case on failure.
## Build
```bash
cmake --preset dev-gcc # or dev-clang, dev-clang-libcxx, dev-msvc
cmake --build --preset dev-gcc-debug
ctest --preset dev-gcc-debug
```
See `CMakePresets.json` for the full list of presets (GCC, Clang, Clang+libc++, MSVC, ASan, TSan).
## CMake integration
```cmake
find_package(eggs.test REQUIRED)
target_link_libraries(my_tests PRIVATE Eggs::TestMain)
```
`Eggs::Test` provides the test macros and the `eggs::test::run()` entry point.
`Eggs::TestMain` additionally supplies a `main()` with CLI argument handling.
## License
See [LICENSE.txt](LICENSE.txt).