github.com/go-eden/common@v0.1.15-0.20210617133546-059099253264/emath/math_calc_test.go (about)

     1  package emath
     2  
     3  import (
     4  	"github.com/stretchr/testify/assert"
     5  	"testing"
     6  )
     7  
     8  func TestDivCeil(t *testing.T) {
     9  	assert.True(t, DivCeil(0, 4) == 0)
    10  	assert.True(t, DivCeil(1, 4) == 1)
    11  	assert.True(t, DivCeil(2, 4) == 1)
    12  	assert.True(t, DivCeil(3, 4) == 1)
    13  	assert.True(t, DivCeil(4, 4) == 1)
    14  	assert.True(t, DivCeil(5, 4) == 2)
    15  	assert.True(t, DivCeil(6, 4) == 2)
    16  	assert.True(t, DivCeil(7, 4) == 2)
    17  	assert.True(t, DivCeil(8, 4) == 2)
    18  	assert.True(t, DivCeil(9, 4) == 3)
    19  }
    20  
    21  func TestDivRound(t *testing.T) {
    22  	assert.True(t, DivRound(0, 4) == 0)
    23  	assert.True(t, DivRound(1, 4) == 0)
    24  	assert.True(t, DivRound(2, 4) == 1)
    25  	assert.True(t, DivRound(3, 4) == 1)
    26  	assert.True(t, DivRound(4, 4) == 1)
    27  	assert.True(t, DivRound(5, 4) == 1)
    28  	assert.True(t, DivRound(6, 4) == 2)
    29  	assert.True(t, DivRound(7, 4) == 2)
    30  	assert.True(t, DivRound(8, 4) == 2)
    31  	assert.True(t, DivRound(9, 4) == 2)
    32  }