gitlab.com/gitlab-org/labkit@v1.21.0/correlation/base62_test.go (about) 1 package correlation 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/stretchr/testify/require" 8 ) 9 10 func TestReverseBase62Conversion(t *testing.T) { 11 tests := []struct { 12 n int64 13 expected string 14 }{ 15 {n: 0, expected: "0"}, 16 {n: 5, expected: "5"}, 17 {n: 10, expected: "a"}, 18 {n: 62, expected: "01"}, 19 {n: 620, expected: "0a"}, 20 {n: 6200, expected: "0C1"}, 21 } 22 23 for _, test := range tests { 24 t.Run(fmt.Sprintf("%d_to_%s", test.n, test.expected), func(t *testing.T) { 25 require.Equal(t, test.expected, encodeReverseBase62(test.n)) 26 }) 27 } 28 }