github.com/tanqiangyes/govalidator@v0.0.5/numerics_example_test.go (about) 1 package govalidator 2 3 func ExampleAbs() { 4 _ = Abs(-123.3e1) // 123.3e1 5 _ = Abs(+0) // 0 6 _ = Abs(321) // 321 7 } 8 9 func ExampleSign() { 10 _ = Sign(-123) // -1 11 _ = Sign(123) // 1 12 _ = Sign(0) // 0 13 } 14 15 func ExampleIsNegative() { 16 _ = IsNegative(-123) // true 17 _ = IsNegative(0) // false 18 _ = IsNegative(123) // false 19 } 20 21 func ExampleIsPositive() { 22 _ = IsPositive(-123) // false 23 _ = IsPositive(0) // false 24 _ = IsPositive(123) // true 25 } 26 27 func ExampleIsNonNegative() { 28 _ = IsNonNegative(-123) // false 29 _ = IsNonNegative(0) // true 30 _ = IsNonNegative(123) // true 31 } 32 33 func ExampleIsNonPositive() { 34 _ = IsNonPositive(-123) // true 35 _ = IsNonPositive(0) // true 36 _ = IsNonPositive(123) // false 37 } 38 39 func ExampleInRange() { 40 _ = InRange(10, 11, 20) // false 41 _ = InRange(10.02, -10.124, 10.234) // true 42 _ = InRange("abc", "a", "cba") // true 43 } 44 45 func ExampleIsWhole() { 46 _ = IsWhole(1.123) // false 47 _ = IsWhole(1.0) // true 48 _ = IsWhole(10) // true 49 } 50 51 func ExampleIsNatural() { 52 _ = IsNatural(1.123) // false 53 _ = IsNatural(1.0) // true 54 _ = IsNatural(-10) // false 55 }