2022-02-21 17:57:27 +00:00
|
|
|
package statustest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-12-09 11:16:24 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/status"
|
2022-02-21 17:57:27 +00:00
|
|
|
"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 ...interface{},
|
|
|
|
) {
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|