https://github.com/offa/matcher
C++11 Hamcrest like Matcher implementation.
https://github.com/offa/matcher
cpp cpp11 cpputest hamcrest
Last synced: 6 months ago
JSON representation
C++11 Hamcrest like Matcher implementation.
- Host: GitHub
- URL: https://github.com/offa/matcher
- Owner: offa
- License: gpl-3.0
- Created: 2016-03-30T14:23:15.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-11-16T12:15:21.000Z (over 5 years ago)
- Last Synced: 2025-03-13T12:17:30.691Z (about 1 year ago)
- Topics: cpp, cpp11, cpputest, hamcrest
- Language: C++
- Size: 74.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [Matcher](https://github.com/offa/matcher)
[](https://github.com/offa/matcher/actions)
[](https://github.com/offa/matcher/releases)
[](LICENSE)

C++11 Hamcrest like Matcher implementation.
## Requirements
- [**CMake**](http://www.cmake.org/) - for building tests *(Optional)*
- [**CppUTest**](https://github.com/cpputest/cpputest) - for testing *(Optional)*
## Installtion
Header only - no compilation / installation is required.
## Example
```cpp
#include
#include
#include "matcher/Matcher.h"
int main(int argc, char** argv)
{
using namespace matcher;
std::vector v = { 0, 1, 2, 3 };
auto res = expect(v).that(sizeIs(4));
assert(res.getResult());
auto res2 = expect(v).that(elementsAre({0, 1, 2, 3}));
assert(res2.getResult());
bool res3 = expect(123.456).match(doubleNear(123.45, 0.001));
assert(res3);
return 0;
}
```
## Testing
```
mkdir build && cd build
cmake ..
make
make unittest
```
It's also possible to use `make test` / `ctest` instead. For `unittest` it's possible to switch verbosity by CMake option.
## License
**GNU General Public License (GPL)**
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .