mirror of
https://github.com/langgenius/dify-plugin-daemon.git
synced 2026-07-22 01:35:24 -04:00
35 lines
351 B
Go
35 lines
351 B
Go
package parser
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestStruct2Map(t *testing.T) {
|
|
type Base struct {
|
|
A int `json:"a"`
|
|
}
|
|
|
|
type p struct {
|
|
Base
|
|
|
|
B int `json:"b"`
|
|
}
|
|
|
|
d := p{
|
|
Base: Base{
|
|
A: 1,
|
|
},
|
|
B: 2,
|
|
}
|
|
|
|
result := StructToMap(d)
|
|
|
|
if result["a"] != 1 {
|
|
t.Error("a should be 1")
|
|
}
|
|
|
|
if result["b"] != 2 {
|
|
t.Error("b should be 2")
|
|
}
|
|
}
|