github.com/TrueCloudLab/frostfs-api-go/v2@v2.0.0-20230228134343-196241c4e79a/status/test/codes.go (about)

     1  package statustest
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/TrueCloudLab/frostfs-api-go/v2/status"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  // TestCodes checks mapping of status codes to the numbers.
    11  // Args must be pairs (status.Code, int).
    12  func TestCodes(t *testing.T,
    13  	localizer func(*status.Code) bool,
    14  	globalizer func(code *status.Code),
    15  	vals ...interface{},
    16  ) {
    17  	for i := 0; i < len(vals); i += 2 {
    18  		c := vals[i].(status.Code)
    19  		cp := c
    20  
    21  		globalizer(&cp)
    22  		require.True(t, cp.EqualNumber(uint32(vals[i+1].(int))), c)
    23  
    24  		require.True(t, localizer(&cp), c)
    25  
    26  		require.Equal(t, cp, c, c)
    27  	}
    28  }