File: base62_test.go

package info (click to toggle)
golang-gitlab-gitlab-org-labkit 1.17.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,092 kB
  • sloc: sh: 210; javascript: 49; makefile: 4
file content (28 lines) | stat: -rw-r--r-- 546 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package correlation

import (
	"fmt"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestReverseBase62Conversion(t *testing.T) {
	tests := []struct {
		n        int64
		expected string
	}{
		{n: 0, expected: "0"},
		{n: 5, expected: "5"},
		{n: 10, expected: "a"},
		{n: 62, expected: "01"},
		{n: 620, expected: "0a"},
		{n: 6200, expected: "0C1"},
	}

	for _, test := range tests {
		t.Run(fmt.Sprintf("%d_to_%s", test.n, test.expected), func(t *testing.T) {
			require.Equal(t, test.expected, encodeReverseBase62(test.n))
		})
	}
}