| // Copyright (C) 2016 The Android Open Source Project |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| package assert |
| |
| // OnFloat is the result of calling ThatFloat on an Assertion. |
| // It provides numeric assertion tests. |
| type OnFloat struct { |
| Assertion |
| value float64 |
| } |
| |
| // IsAtLeast asserts that the float is at least the supplied minimum. |
| func (o OnFloat) IsAtLeast(min float64) bool { |
| return o.Assertion.test(o.value >= min, unmatched, o.value, "Was less than", min) |
| } |
| |
| // IsAtMost asserts that the float is at most the supplied maximum. |
| func (o OnFloat) IsAtMost(max float64) bool { |
| return o.Assertion.test(o.value <= max, unmatched, o.value, "Was more than", max) |
| } |