https://github.com/huijari/metacarpal
tap-producing test harness for cpp
https://github.com/huijari/metacarpal
cpp tap testing
Last synced: 5 months ago
JSON representation
tap-producing test harness for cpp
- Host: GitHub
- URL: https://github.com/huijari/metacarpal
- Owner: huijari
- License: gpl-3.0
- Created: 2019-05-15T02:05:30.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-19T15:25:53.000Z (almost 7 years ago)
- Last Synced: 2023-10-20T20:16:15.362Z (over 2 years ago)
- Topics: cpp, tap, testing
- Language: C++
- Size: 30.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# metacarpal
> tap-producing test harness for cpp
## Installation
To get started you need to download the [latest version](https://raw.githubusercontent.com/huijari/metacarpal/master/metacarpal.hpp)
which is just a single header and include it in your test file.
## Example usage
```cpp
#include
int main() {
Metacarpal::Producer p;
p.test("sum");
p.equal(1 + 1, 2, "one plus one should be 2");
p.test("logic");
p.ok(true && true, "true and true should be truthy");
if (false || true)
p.pass("or is working");
else
p.fail("or isn't working");
p.test("failing");
p.equal("this string should be", "that");
return p.end();
}
```
## Example output
```
# sum
ok 1 1 plus 1 should be 2
# logic
ok 2 true and true should be truthy
ok 3 or is working
# failing
not ok 4
---
operator: equal
expected: that
actual: this string should be
...
1..4
# tests 4
# pass 3
# fail 1
```
## Reporters
The TAP output is somewhat good even for humans,
but if you want a more colorful/pretty output there are lots of [custom reporters](https://github.com/sindresorhus/awesome-tap#reporters).
## API
### test(string name)
- @param name - test name
Create a new test
### pass(string message)
- @param message - optional message
- @returns true
Generate a passing assertion with an optional message
### fail(string message)
- @param message - optional message
- @returns false
Generate a failing assertion with an optional message
### ok(bool value, string message)
- @param value - value to be asserted
- @param message - optional description message
- @returns true if ok
Assert that value is truthy with an optional description message
### equal(T value, T expected, string message)
- @param value - actual value
- @param expected - expected value
- @param message - optional description message
- @returns true if equal
Assert that both values are equal with an optional description message
### end()
- @returns the number of failed tests capped at 254
Declare the end of the tests, finalizing the producer's output
## License
GPL-3.0