Files
waf-platform/EdgePlus/pkg/utils/encoder_test.go
2026-02-04 20:27:13 +08:00

47 lines
805 B
Go

// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package utils
import (
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
"testing"
)
func TestEncodeMap(t *testing.T) {
{
t.Log(Encode([]byte("123")))
}
{
s, err := EncodeMap(maps.Map{"a": 1})
if err != nil {
t.Fatal(err)
}
t.Log(s)
t.Log(Decode([]byte(s)))
}
}
func TestEncodeKey(t *testing.T) {
var key = &Key{
DayFrom: "2020-10-10",
DayTo: "2022-10-10",
MacAddresses: []string{"*"},
Hostname: "web001",
Company: "STILL",
Nodes: 10,
}
encodedString, err := EncodeKey(key)
if err != nil {
t.Fatal(err)
}
t.Log("encoded:", encodedString)
key, err = DecodeKey([]byte(encodedString))
if err != nil {
t.Fatal(err)
}
logs.PrintAsJSON(key, t)
}