12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #ifndef TWOBLUECUBES_CATCH_MATCHERS_FLOATING_H_INCLUDED
- #define TWOBLUECUBES_CATCH_MATCHERS_FLOATING_H_INCLUDED
- #include "catch_matchers.h"
- namespace Catch {
- namespace Matchers {
- namespace Floating {
- enum class FloatingPointKind : uint8_t;
- struct WithinAbsMatcher : MatcherBase<double> {
- WithinAbsMatcher(double target, double margin);
- bool match(double const& matchee) const override;
- std::string describe() const override;
- private:
- double m_target;
- double m_margin;
- };
- struct WithinUlpsMatcher : MatcherBase<double> {
- WithinUlpsMatcher(double target, uint64_t ulps, FloatingPointKind baseType);
- bool match(double const& matchee) const override;
- std::string describe() const override;
- private:
- double m_target;
- uint64_t m_ulps;
- FloatingPointKind m_type;
- };
-
-
-
-
-
-
- struct WithinRelMatcher : MatcherBase<double> {
- WithinRelMatcher(double target, double epsilon);
- bool match(double const& matchee) const override;
- std::string describe() const override;
- private:
- double m_target;
- double m_epsilon;
- };
- }
-
-
- Floating::WithinUlpsMatcher WithinULP(double target, uint64_t maxUlpDiff);
- Floating::WithinUlpsMatcher WithinULP(float target, uint64_t maxUlpDiff);
- Floating::WithinAbsMatcher WithinAbs(double target, double margin);
- Floating::WithinRelMatcher WithinRel(double target, double eps);
-
- Floating::WithinRelMatcher WithinRel(double target);
- Floating::WithinRelMatcher WithinRel(float target, float eps);
-
- Floating::WithinRelMatcher WithinRel(float target);
- }
- }
- #endif
|