@@ -7,18 +7,18 @@ import (
7
7
"github.com/fluentassert/verify/constraints"
8
8
)
9
9
10
- // NumberFloat encapsulates assertions for numbers.
11
- type NumberFloat [T constraints.Number ] struct {
10
+ // FluentNumber encapsulates assertions for numbers.
11
+ type FluentNumber [T constraints.Number ] struct {
12
12
FluentOrdered [T ]
13
13
}
14
14
15
15
// Number is used for testing numbers.
16
- func Number [T constraints.Number ](got T ) NumberFloat [T ] {
17
- return NumberFloat [T ]{FluentOrdered [T ]{FluentObj [T ]{FluentAny [T ]{got }}}}
16
+ func Number [T constraints.Number ](got T ) FluentNumber [T ] {
17
+ return FluentNumber [T ]{FluentOrdered [T ]{FluentObj [T ]{FluentAny [T ]{got }}}}
18
18
}
19
19
20
20
// InDelta tests that the numbers have an absolute error (distance) less or equal than delta.
21
- func (x NumberFloat [T ]) InDelta (want T , delta float64 ) FailureMessage {
21
+ func (x FluentNumber [T ]) InDelta (want T , delta float64 ) FailureMessage {
22
22
distance , msg := x .calcDistance (want , delta )
23
23
if msg != "" {
24
24
return msg
@@ -30,7 +30,7 @@ func (x NumberFloat[T]) InDelta(want T, delta float64) FailureMessage {
30
30
}
31
31
32
32
// NotInDelta tests that the numbers have an absolute error (distance) greater than delta.
33
- func (x NumberFloat [T ]) NotInDelta (want T , delta float64 ) FailureMessage {
33
+ func (x FluentNumber [T ]) NotInDelta (want T , delta float64 ) FailureMessage {
34
34
distance , msg := x .calcDistance (want , delta )
35
35
if msg != "" {
36
36
return msg
@@ -41,7 +41,7 @@ func (x NumberFloat[T]) NotInDelta(want T, delta float64) FailureMessage {
41
41
return FailureMessage (fmt .Sprintf ("absolute error (distance) between numbers is lesser or equal than delta\n relative error: %v\n delta: %g\n got: %v\n want: %v" , distance , delta , x .Got , want ))
42
42
}
43
43
44
- func (x NumberFloat [T ]) calcDistance (want T , delta float64 ) (float64 , FailureMessage ) {
44
+ func (x FluentNumber [T ]) calcDistance (want T , delta float64 ) (float64 , FailureMessage ) {
45
45
if math .IsNaN (delta ) || delta < 0 {
46
46
return 0 , "delta must be a non-negative number"
47
47
}
@@ -57,7 +57,7 @@ func (x NumberFloat[T]) calcDistance(want T, delta float64) (float64, FailureMes
57
57
}
58
58
59
59
// InEpsilon tests that the numbers have a relative error less or equal than epsilon.
60
- func (x NumberFloat [T ]) InEpsilon (want T , epsilon float64 ) FailureMessage {
60
+ func (x FluentNumber [T ]) InEpsilon (want T , epsilon float64 ) FailureMessage {
61
61
relativeError , msg := x .calcRelativeError (want , epsilon )
62
62
if msg != "" {
63
63
return msg
@@ -69,7 +69,7 @@ func (x NumberFloat[T]) InEpsilon(want T, epsilon float64) FailureMessage {
69
69
}
70
70
71
71
// NotInEpsilon tests that the numbers have a relative error greater than epsilon.
72
- func (x NumberFloat [T ]) NotInEpsilon (want T , epsilon float64 ) FailureMessage {
72
+ func (x FluentNumber [T ]) NotInEpsilon (want T , epsilon float64 ) FailureMessage {
73
73
relativeError , msg := x .calcRelativeError (want , epsilon )
74
74
if msg != "" {
75
75
return msg
@@ -80,7 +80,7 @@ func (x NumberFloat[T]) NotInEpsilon(want T, epsilon float64) FailureMessage {
80
80
return FailureMessage (fmt .Sprintf ("relative error between numbers is lesser or equal than epsilon\n relative error: %g\n epsilon: %g\n got: %v\n to: %v" , relativeError , epsilon , x .Got , want ))
81
81
}
82
82
83
- func (x NumberFloat [T ]) calcRelativeError (want T , epsilon float64 ) (float64 , FailureMessage ) {
83
+ func (x FluentNumber [T ]) calcRelativeError (want T , epsilon float64 ) (float64 , FailureMessage ) {
84
84
if math .IsNaN (epsilon ) || epsilon < 0 {
85
85
return 0 , "epsilon must be a non-negative number"
86
86
}
0 commit comments