fusenapi/utils/collect/collect_test.go

43 lines
711 B
Go
Raw Normal View History

2023-06-26 10:19:51 +00:00
package collect
import (
"log"
"testing"
)
type ABC struct {
A int64 `json:"a"`
B string `json:"b"`
C interface{} `json:"c"`
}
func TestArray2MapByKey(t *testing.T) {
var abcs []*ABC = []*ABC{
{1, "2", 3},
{3, "1", 2},
}
a := Array2MapByKey[string](abcs, "B")
log.Printf("%##v", a)
log.Println(len(a))
}
func TestArray2MapByKeyTag(t *testing.T) {
var abcs []*ABC = []*ABC{
{1, "2", 3},
{3, "1", 2},
}
a := Array2MapByKeyTag[int64](abcs, "a")
log.Printf("%##v", a)
log.Println(len(a))
}
2023-06-26 11:51:59 +00:00
func TestArrayColumnTag(t *testing.T) {
var abcs []*ABC = []*ABC{
{1, "2", 3},
{3, "1", 2},
}
a := ArrayColumnTag[string](abcs, "b")
log.Printf("%##v", a)
log.Println(len(a))
}