miller/internal/pkg/bifs/bits_test.go
Stephen Kitt d536318ed6
Use int64 wherever "64-bit integer" is assumed (#902)
Miller assumes 64-bit integers, but in Go, the int type varies in size
depending on the architecture: 32-bit architectures have int
equivalent to int32. As a result, the supported range of integer
values is greatly reduced on 32-bit architectures compared to what is
suggested by the documentation.

This patch explicitly uses int64 wherever 64-bit integers are
assumed.

Test cases affected by the behaviour of the random generator are
updated to reflect the new values (the existing seed doesn't produce
the same behaviour since the way random values are generated has
changed).

Signed-off-by: Stephen Kitt <steve@sk2.org>
2022-01-27 12:06:25 -05:00

19 lines
410 B
Go

package bifs
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/johnkerl/miller/internal/pkg/mlrval"
)
func TestBIF_bitcount(t *testing.T) {
input1 := mlrval.FromDeferredType("0xcafe")
output := BIF_bitcount(input1)
intval, ok := output.GetIntValue()
assert.True(t, ok)
assert.Equal(t, int64(11), intval)
}
// TODO: copy in more unit-test cases from existing regression-test data