github.com/hasnat/dolt/go@v0.0.0-20210628190320-9eb5d843fbb7/libraries/utils/mathutil/max_test.go (about) 1 // Copyright 2019 Dolthub, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package mathutil 16 17 import "testing" 18 19 func TestMax(t *testing.T) { 20 if MaxInt(1, 2) != 2 || MaxInt(2, 1) != 2 { 21 t.Error("MaxInt error") 22 } 23 if Max(1, 2) != 2 || Max(2, 1) != 2 { 24 t.Error("Max error") 25 } 26 if MaxInt64(1, 2) != 2 || MaxInt64(2, 1) != 2 { 27 t.Error("MaxInt64 error") 28 } 29 if MaxFloat(1, 2) != 2 || MaxFloat(2, 1) != 2 { 30 t.Error("MaxFloat error") 31 } 32 if MaxFloat64(1, 2) != 2 || MaxFloat64(2, 1) != 2 { 33 t.Error("MaxFloat64 error") 34 } 35 if MaxUint(1, 2) != 2 || MaxUint(2, 1) != 2 { 36 t.Error("MaxUint error") 37 } 38 if MaxUint64(1, 2) != 2 || MaxUint64(2, 1) != 2 { 39 t.Error("MaxUint error") 40 } 41 } 42 43 func TestMin(t *testing.T) { 44 if MinInt(1, 2) != 1 || MinInt(2, 1) != 1 { 45 t.Error("MinInt error") 46 } 47 if Min(1, 2) != 1 || Min(2, 1) != 1 { 48 t.Error("Min error") 49 } 50 if MinInt64(1, 2) != 1 || MinInt64(2, 1) != 1 { 51 t.Error("MinInt64 error") 52 } 53 if MinFloat(1, 2) != 1 || MinFloat(2, 1) != 1 { 54 t.Error("MinFloat error") 55 } 56 if MinFloat64(1, 2) != 1 || MinFloat64(2, 1) != 1 { 57 t.Error("MinFloat64 error") 58 } 59 if MinUint(1, 2) != 1 || MinUint(2, 1) != 1 { 60 t.Error("MaxUint error") 61 } 62 if MinUint64(1, 2) != 1 || MinUint64(2, 1) != 1 { 63 t.Error("MaxUint error") 64 } 65 }