forked from asaskevich/govalidator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
numerics_example_test.go
55 lines (46 loc) · 1.09 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
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 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
}