| 1 | package matchersscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/ |
| 2 | |
| 3 | import "fmtscip-go gomod github.com/golang/go/src go1.21.4 fmt/" |
| 4 | |
| 5 | // BeAboveMatcher accepts a float64. It succeeds if the |
| 6 | // actual is greater than the expected. |
| 7 | type BeAboveMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher# struct { |
| 8 | expectedscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher#expected. float64 |
| 9 | } |
| 10 | |
| 11 | // BeAbove returns a BeAboveMatcher with the expected value. |
| 12 | func BeAbovescip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAbove().(expected float64) BeAboveMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher# { |
| 13 | return BeAboveMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher#{ |
| 14 | expectedscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher#expected.: expected, |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | func (m BeAboveMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher#) Matchscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher#Match().(actual any) (any, error) { |
| 19 | f, err := m.toFloatscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher#toFloat().(actual) |
| 20 | if err != nil { |
| 21 | return nil, err |
| 22 | } |
| 23 | |
| 24 | if f <= m.expectedscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher#expected. { |
| 25 | return nil, fmtscip-go gomod github.com/golang/go/src go1.21.4 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21.4 fmt/Errorf().("%v is not above %f", actual, m.expectedscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher#expected.) |
| 26 | } |
| 27 | |
| 28 | return actual, nil |
| 29 | } |
| 30 | |
| 31 | func (m BeAboveMatcherscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher#) toFloatscip-go gomod github.com/poy/onpar . `github.com/poy/onpar/matchers`/BeAboveMatcher#toFloat().(actual any) (float64, error) { |
| 32 | switch x := actual.(type) { |
| 33 | case int: |
| 34 | return float64(x), nil |
| 35 | case int32: |
| 36 | return float64(x), nil |
| 37 | case int64: |
| 38 | return float64(x), nil |
| 39 | case float32: |
| 40 | return float64(x), nil |
| 41 | case float64: |
| 42 | return x, nil |
| 43 | default: |
| 44 | return 0, fmtscip-go gomod github.com/golang/go/src go1.21.4 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.21.4 fmt/Errorf().("Unsupported type %T", actual) |
| 45 | } |
| 46 | } |