frostfs-api-go/status/test/codes.go
Anton Nikiforov a3a5046ecc [#28] Replace interface{} with any
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
2023-05-15 17:25:04 +03:00

28 lines
593 B
Go

package statustest
import (
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status"
"github.com/stretchr/testify/require"
)
// TestCodes checks mapping of status codes to the numbers.
// Args must be pairs (status.Code, int).
func TestCodes(t *testing.T,
localizer func(*status.Code) bool,
globalizer func(code *status.Code),
vals ...any,
) {
for i := 0; i < len(vals); i += 2 {
c := vals[i].(status.Code)
cp := c
globalizer(&cp)
require.True(t, cp.EqualNumber(uint32(vals[i+1].(int))), c)
require.True(t, localizer(&cp), c)
require.Equal(t, cp, c, c)
}
}