Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
# Willow

A unit testing library for modern c++23

# How to use
Currently, willow only supports CMake for distribution, although if you know
what you're doing, feel free to clone the repo and do what you need yourself.

```cmake
include(FetchContent)
fetchcontent_declare(
rawterm
GIT_REPOSITORY https://github.com/ttibsi/willow
GIT_TAG v0.0.1
)
fetchcontent_makeavailable(rawterm)
```

# Example
A minimal usage looks like the below code. However, willow dogfoods itself,
meaning that it's tested with itself. To see more usage, see the `src/main.cpp`
file -- anything in the `src/` directory are the tests for this project,
`src/willow` is the source code.

```cpp
#include "willow/reporters.h"
#include "willow/willow.h"

auto add(int x, int y) -> int { return x + y; }

// Any test must follow this signature. It's return code is used to mark if
// it succeeded or not. Alerts print on function failure
auto test_add(Willow::Test* test) -> int {
if (add(3, 2) != 5) {
Willow::alert(test, "3 + 2 does not equal 5");
return 1;
}

return 0;
}

auto main() -> int {
// Select which reporter to use to display output. A number of reporters
// are available
Willow::DefaultReporter reporter = {};

// Your executable will exit with a return code displaying the number of
// failed tests
return Willow::runTests({
// Each test function is given a name to display as output. you can also
// mark tests for skipping
{"addition test", test_add},
{"skipped test", test_add, Willow::Status::Skip},
}, reporter);
}
```
2 changes: 2 additions & 0 deletions src/willow/reporters.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef WILLOW_REPORTER_H
#define WILLOW_REPORTER_H

// TODO: Implement JSONReporter

#include <print>

#include "test.h"
Expand Down
Loading