github.com/go-chrono/chrono@v0.0.0-20240102183611-532f0d0d7c34/utils_test.go (about)

     1  package chrono_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/go-chrono/chrono"
     7  )
     8  
     9  func TestDivideAndRoundInt(t *testing.T) {
    10  	t.Run("round up", func(t *testing.T) {
    11  		if rounded := chrono.DivideAndRoundIntFunc(123456, 1000); rounded != 123 {
    12  			t.Errorf("RoundInt() = %d, want %d", rounded, 123)
    13  		}
    14  	})
    15  
    16  	t.Run("round down", func(t *testing.T) {
    17  		if rounded := chrono.DivideAndRoundIntFunc(123456789, 1000); rounded != 123457 {
    18  			t.Errorf("RoundInt() = %d, want %d", rounded, 123457)
    19  		}
    20  	})
    21  }