View Source Machete.FloatMatcher (Machete v0.3.8)
Defines a matcher that matches float values
Summary
Types
Describes the arguments that can be passed to this matcher
Describes an instance of this matcher
Functions
Matches against float values
Types
Functions
Matches against float values
Takes the following arguments:
positive
: Whentrue
, requires the matched float be positive or zerostrictly_positive
: Whentrue
, requires the matched float be positive and nonzeronegative
: Whentrue
, requires the matched float be negative or zerostrictly_negative
: Whentrue
, requires the matched float be negative and nonzerononzero
: Whentrue
, requires the matched float be nonzeromin
: Requires the matched float be greater than or equal to the specified valuemax
: Requires the matched float be less than or equal to the specified valueroughly
: Requires the matched float be within 5% of the specified value. Raises if set to0.0
Examples:
iex> assert 1.0 ~> float()
true
iex> assert 1.0 ~> float(positive: true)
true
iex> assert 0.0 ~> float(positive: true)
true
iex> assert -1.0 ~> float(positive: false)
true
iex> refute 0.0 ~> float(positive: false)
false
iex> assert 1.0 ~> float(strictly_positive: true)
true
iex> refute 0.0 ~> float(strictly_positive: true)
false
iex> assert -1.0 ~> float(strictly_positive: false)
true
iex> assert 0.0 ~> float(strictly_positive: false)
true
iex> assert -1.0 ~> float(negative: true)
true
iex> assert 0.0 ~> float(negative: true)
true
iex> assert 1.0 ~> float(negative: false)
true
iex> refute 0.0 ~> float(negative: false)
false
iex> assert -1.0 ~> float(strictly_negative: true)
true
iex> refute 0.0 ~> float(strictly_negative: true)
false
iex> assert 1.0 ~> float(strictly_negative: false)
true
iex> assert 0.0 ~> float(strictly_negative: false)
true
iex> assert 1.0 ~> float(nonzero: true)
true
iex> assert 0.0 ~> float(nonzero: false)
true
iex> assert 2.0 ~> float(min: 2.0)
true
iex> assert 2.0 ~> float(max: 2.0)
true
iex> assert 95.0 ~> float(roughly: 100.0)
true
iex> refute 94.0 ~> float(roughly: 100.0)
false