-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_vne.go
53 lines (45 loc) · 1012 Bytes
/
check_vne.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package done
import "github.com/pkg/errors"
type numType interface {
int | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | uint | float32 | float64
}
type Vne[V numType] struct {
V V
E error
*Vce[V]
}
func VNE[V numType](val V, err error) *Vne[V] {
return &Vne[V]{
V: val,
E: err,
Vce: VCE[V](val, err),
}
}
func (a *Vne[V]) Gt(base V) V {
if x := a.Done(); x > base {
return x
} else {
panic(errors.Errorf("SHOULD BE x > BASE BUT NOT. x=%v BASE=%v", x, base))
}
}
func (a *Vne[V]) Lt(base V) V {
if x := a.Done(); x < base {
return x
} else {
panic(errors.Errorf("SHOULD BE x < BASE BUT NOT. x=%v BASE=%v", x, base))
}
}
func (a *Vne[V]) Gte(base V) V {
if x := a.Done(); x >= base {
return x
} else {
panic(errors.Errorf("SHOULD BE x >= BASE BUT NOT. x=%v BASE=%v", x, base))
}
}
func (a *Vne[V]) Lte(base V) V {
if x := a.Done(); x <= base {
return x
} else {
panic(errors.Errorf("SHOULD BE x <= BASE BUT NOT. x=%v BASE=%v", x, base))
}
}