github.com/searKing/golang/go@v1.2.117/math/abs_test.go (about) 1 // Copyright 2020 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package math_test 6 7 import ( 8 "testing" 9 10 "github.com/searKing/golang/go/math" 11 ) 12 13 var vf = []int64{ 14 5, 15 7, 16 -3, 17 -5, 18 10, 19 -8, 20 0, 21 } 22 23 var fabs = []int64{ 24 5, 25 7, 26 3, 27 5, 28 10, 29 8, 30 0, 31 } 32 33 func TestAbs(t *testing.T) { 34 for i := 0; i < len(vf); i++ { 35 if f := math.AbsInt64(vf[i]); fabs[i] != f { 36 t.Errorf("AbsInt64(%d) = %d, want %d", vf[i], f, fabs[i]) 37 } 38 } 39 }