base62json/base62json_test.go

58 lines
1.8 KiB
Go
Raw Normal View History

2023-04-15 00:13:07 +08:00
package base62json
import (
"testing"
)
func main() {
}
func TestEcode(t *testing.T) {
a := []any{"ab", "啊啊", 1, -2, 11111111111, -222222222222, true, false, nil, 0, 1.22, 1.222222222, -1.222222222}
b1 := "5MQOdKtsl8sXRDOMO5Jq7vTWsq2KQwq4CE2sCyqIPm0XZ4uDq9cil9d4Cu2Y9RxusgfuoSGSPLiX5LaT1iQ7V483R6SCUXPlfVCgVg2XlQEPetPO9lokLkTWmQFOpsSr"
b, _ := Encode(a)
if b == b1 {
t.Logf("\n 输入=>%d \n 输出=>%s", a, b)
} else {
t.Fatalf("\n 输入=>%s \n 预计输出=>%s \n 实际输出=>%s", a, b1, b)
}
}
func TestDecode(t *testing.T) {
a := "5MQOdKtsl8sXRDOMO5Jq7vTWsq2KQwq4CE2sCyqIPm0XZ4uDq9cil9d4Cu2Y9RxusgfuoSGSPLiX5LaT1iQ7V483R6SCUXPlfVCgVg2XlQEPetPO9lokLkTWmQFOpsSr"
b1 := `["ab","啊啊",1,-2,11111111111,-222222222222,true,false,null,0,1.22,1.222222222,-1.222222222]`
b, _ := Decode(a)
if b == b1 {
t.Logf("\n 输入=>%s \n 输出=>%s", a, b)
} else {
t.Fatalf("\n 输入=>%s \n 预计输出=>%s \n 实际输出=>%s", a, b1, b)
}
}
func TestGenerateProjectSecret(t *testing.T) {
// PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK 数据库
// PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK 加密后
// PrV4uZReFpWOjkYIoNCJ1wdU6cDyXzh5Asi2xb3QM70SmEvLl8HgqtBGfnT9aK
2024-11-28 11:16:26 +08:00
res, _ := GenerateProjectSecret("demo", "PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK")
2023-04-15 00:13:07 +08:00
t.Log(string(res))
res1, _ := GenerateProjectSecret("demo", "PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK")
t.Log(string(res1))
// PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK
// PrV4uZReFpWOjkYIoNCJ1wdU6cDyXzh5Asi2xb3QM70SmEvLl8HgqtBGfnT9aK
}
2024-11-28 11:16:26 +08:00
func TestAlphabetEncode(t *testing.T) {
t.Log(SetCharacters("PrV4uZRqFHWOjkYIo07J1wdU6cDyXzh5Asi2xb3QMCNSmEvLl8pgetBGfnT9aK"))
t.Log(Encode(map[string]any{"isDebug": 1}))
}