-
Notifications
You must be signed in to change notification settings - Fork 556
/
numerics_example_test.go
73 lines (61 loc) · 1.6 KB
/
numerics_example_test.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package govalidator
func ExampleAbs() {
_ = Abs(-123.3e1) // 123.3e1
_ = Abs(+0) // 0
_ = Abs(321) // 321
}
func ExampleSign() {
_ = Sign(-123) // -1
_ = Sign(123) // 1
_ = Sign(0) // 0
}
func ExampleIsNegative() {
_ = IsNegative(-123) // true
_ = IsNegative(0) // false
_ = IsNegative(123) // false
}
func ExampleIsPositive() {
_ = IsPositive(-123) // false
_ = IsPositive(0) // false
_ = IsPositive(123) // true
}
func ExampleIsNonNegative() {
_ = IsNonNegative(-123) // false
_ = IsNonNegative(0) // true
_ = IsNonNegative(123) // true
}
func ExampleIsNonPositive() {
_ = IsNonPositive(-123) // true
_ = IsNonPositive(0) // true
_ = IsNonPositive(123) // false
}
func ExampleInRangeInt() {
_ = InRangeInt(10, -10, 10) // true
_ = InRangeInt(10, 10, 20) // true
_ = InRangeInt(10, 11, 20) // false
}
func ExampleInRangeFloat32() {
_ = InRangeFloat32(10.02, -10.124, 10.234) // true
_ = InRangeFloat32(10.123, 10.123, 20.431) // true
_ = InRangeFloat32(10.235, 11.124, 20.235) // false
}
func ExampleInRangeFloat64() {
_ = InRangeFloat64(10.02, -10.124, 10.234) // true
_ = InRangeFloat64(10.123, 10.123, 20.431) // true
_ = InRangeFloat64(10.235, 11.124, 20.235) // false
}
func ExampleInRange() {
_ = InRange(10, 11, 20) // false
_ = InRange(10.02, -10.124, 10.234) // true
_ = InRange("abc", "a", "cba") // true
}
func ExampleIsWhole() {
_ = IsWhole(1.123) // false
_ = IsWhole(1.0) // true
_ = IsWhole(10) // true
}
func ExampleIsNatural() {
_ = IsNatural(1.123) // false
_ = IsNatural(1.0) // true
_ = IsNatural(-10) // false
}