mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-26 08:39:03 +01:00
32 lines
439 B
Go
32 lines
439 B
Go
package util
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestEncodeDecode(t *testing.T) {
|
|
tests := []struct {
|
|
num uint32
|
|
}{
|
|
{0},
|
|
{1},
|
|
{42},
|
|
{12345},
|
|
{99999},
|
|
{123456789},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
encoded := EncodeBase62(tt.num)
|
|
decoded, err := DecodeBase62(encoded)
|
|
|
|
if err != nil {
|
|
t.Errorf("Decode error: %v", err)
|
|
}
|
|
|
|
if decoded != tt.num {
|
|
t.Errorf("Decode(%v) = %v, want %v", encoded, decoded, tt.num)
|
|
}
|
|
}
|
|
}
|