github.com/spotify/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/pkg/testing/benchmark_test.go (about) 1 // Copyright 2013 The Go Authors. 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 testing_test 6 7 import ( 8 "testing" 9 ) 10 11 var roundDownTests = []struct { 12 v, expected int 13 }{ 14 {1, 1}, 15 {9, 1}, 16 {10, 10}, 17 {11, 10}, 18 {100, 100}, 19 {101, 100}, 20 {999, 100}, 21 {1000, 1000}, 22 {1001, 1000}, 23 } 24 25 func TestRoundDown10(t *testing.T) { 26 for _, tt := range roundDownTests { 27 actual := testing.RoundDown10(tt.v) 28 if tt.expected != actual { 29 t.Errorf("roundDown10(%d): expected %d, actual %d", tt.v, tt.expected, actual) 30 } 31 } 32 } 33 34 var roundUpTests = []struct { 35 v, expected int 36 }{ 37 {0, 1}, 38 {1, 1}, 39 {2, 2}, 40 {5, 5}, 41 {9, 10}, 42 {999, 1000}, 43 {1000, 1000}, 44 {1400, 2000}, 45 {1700, 2000}, 46 {4999, 5000}, 47 {5000, 5000}, 48 {5001, 10000}, 49 } 50 51 func TestRoundUp(t *testing.T) { 52 for _, tt := range roundUpTests { 53 actual := testing.RoundUp(tt.v) 54 if tt.expected != actual { 55 t.Errorf("roundUp(%d): expected %d, actual %d", tt.v, tt.expected, actual) 56 } 57 } 58 }