func TestIsFloat64Integer(t *testing.T) { // fails. MaxUint64 is to large for JS anyway, so we can ignore it here. //assert.True(t, isFloat64AnInteger(float64(math.MaxUint64))) assert.False(t, isFloat64AnInteger(math.MaxInt64)) assert.False(t, isFloat64AnInteger(1<<62)) assert.False(t, isFloat64AnInteger(math.MinInt64)) assert.True(t, isFloat64AnInteger(100100100100)) assert.True(t, isFloat64AnInteger(-100100100100)) assert.True(t, isFloat64AnInteger(100100100)) assert.True(t, isFloat64AnInteger(-100100100)) assert.True(t, isFloat64AnInteger(100100)) assert.True(t, isFloat64AnInteger(-100100)) assert.True(t, isFloat64AnInteger(100)) assert.True(t, isFloat64AnInteger(-100)) assert.True(t, isFloat64AnInteger(-0)) assert.True(t, isFloat64AnInteger(-1)) assert.True(t, isFloat64AnInteger(1)) assert.True(t, isFloat64AnInteger(0)) assert.True(t, isFloat64AnInteger(77)) assert.True(t, isFloat64AnInteger(-77)) assert.True(t, isFloat64AnInteger(1e10)) assert.True(t, isFloat64AnInteger(-1e10)) assert.True(t, isFloat64AnInteger(100100100.0)) assert.True(t, isFloat64AnInteger(-100100100.0)) assert.False(t, isFloat64AnInteger(100100100100.1)) assert.False(t, isFloat64AnInteger(-100100100100.1)) assert.False(t, isFloat64AnInteger(math.MaxFloat64)) assert.False(t, isFloat64AnInteger(-math.MaxFloat64)) assert.False(t, isFloat64AnInteger(1.1)) assert.False(t, isFloat64AnInteger(-1.1)) assert.False(t, isFloat64AnInteger(1.000000000001)) assert.False(t, isFloat64AnInteger(-1.000000000001)) assert.False(t, isFloat64AnInteger(1e-10)) assert.False(t, isFloat64AnInteger(-1e-10)) assert.False(t, isFloat64AnInteger(1.001)) assert.False(t, isFloat64AnInteger(-1.001)) assert.False(t, isFloat64AnInteger(0.0001)) assert.False(t, isFloat64AnInteger(1<<62)) assert.False(t, isFloat64AnInteger(math.MinInt64)) assert.False(t, isFloat64AnInteger(math.MaxInt64)) assert.False(t, isFloat64AnInteger(-1<<62)) assert.False(t, isFloat64AnInteger(1e-10)) assert.False(t, isFloat64AnInteger(-1e-10)) assert.False(t, isFloat64AnInteger(1.000000000001)) assert.False(t, isFloat64AnInteger(-1.000000000001)) assert.False(t, isFloat64AnInteger(4.611686018427387904e7)) assert.False(t, isFloat64AnInteger(-4.611686018427387904e7)) }
func TestIsFloat64IntegerA(t *testing.T) { assert.False(t, isFloat64AnInteger(math.Inf(+1))) assert.False(t, isFloat64AnInteger(math.Inf(-1))) assert.False(t, isFloat64AnInteger(math.NaN())) assert.False(t, isFloat64AnInteger(math.Float64frombits((1<<11-1)<<52|1))) assert.True(t, isFloat64AnInteger(float64(0.0))) assert.True(t, isFloat64AnInteger(-float64(0.0))) assert.False(t, isFloat64AnInteger(float64(0.5))) assert.True(t, isFloat64AnInteger(float64(1.0))) assert.True(t, isFloat64AnInteger(-float64(1.0))) assert.False(t, isFloat64AnInteger(float64(1.1))) assert.True(t, isFloat64AnInteger(float64(131.0))) assert.True(t, isFloat64AnInteger(-float64(131.0))) assert.True(t, isFloat64AnInteger(float64(1<<52-1))) assert.True(t, isFloat64AnInteger(-float64(1<<52-1))) assert.True(t, isFloat64AnInteger(float64(1<<52))) assert.True(t, isFloat64AnInteger(-float64(1<<52))) assert.True(t, isFloat64AnInteger(float64(1<<53-1))) assert.True(t, isFloat64AnInteger(-float64(1<<53-1))) assert.True(t, isFloat64AnInteger(float64(1<<53-1))) assert.False(t, isFloat64AnInteger(float64(1<<53))) assert.False(t, isFloat64AnInteger(-float64(1<<53))) assert.False(t, isFloat64AnInteger(float64(1<<63))) assert.False(t, isFloat64AnInteger(-float64(1<<63))) assert.False(t, isFloat64AnInteger(math.Nextafter(float64(1<<63), math.MaxFloat64))) assert.False(t, isFloat64AnInteger(-math.Nextafter(float64(1<<63), math.MaxFloat64))) assert.False(t, isFloat64AnInteger(float64(1<<70+3<<21))) assert.False(t, isFloat64AnInteger(-float64(1<<70+3<<21))) assert.False(t, isFloat64AnInteger(math.Nextafter(float64(9007199254740991.0), math.MaxFloat64))) assert.True(t, isFloat64AnInteger(float64(9007199254740991.0))) assert.True(t, isFloat64AnInteger(float64(-9007199254740991.0))) assert.False(t, isFloat64AnInteger(math.Nextafter(float64(-9007199254740991.0), -math.MaxFloat64))) }