catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Add ops == and != for Optional
- Commit
f0a89b7345f84436c2af142e39ba304189d3851f- Author
- Martin Jeřábek ·
- Committer
- Martin Hořeňovský
- Parents
f00b6e2019a9
Changes
src/catch2/internal/catch_optional.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/catch2/internal/catch_optional.hpp b/src/catch2/internal/catch_optional.hpp index e2d7b057..fb7ebbb6 100644 --- a/src/catch2/internal/catch_optional.hpp +++ b/src/catch2/internal/catch_optional.hpp @@ -75,6 +75,19 @@ namespace Catch { return some(); } + friend bool operator==(Optional const& a, Optional const& b) { + if (a.none() && b.none()) { + return true; + } else if (a.some() && b.some()) { + return *a == *b; + } else { + return false; + } + } + friend bool operator!=(Optional const& a, Optional const& b) { + return !( a == b ); + } + private: T *nullableValue; alignas(alignof(T)) char storage[sizeof(T)];