- no platform dependency in sync.go
This commit is contained in:
41
business/jxutils/jxutils_reflect_test.go
Normal file
41
business/jxutils/jxutils_reflect_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package jxutils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
func TestObjFieldByName(t *testing.T) {
|
||||
kk := struct {
|
||||
ID int8
|
||||
Name string
|
||||
}{
|
||||
ID: 1,
|
||||
Name: "hello",
|
||||
}
|
||||
if GetObjFieldByName(kk, "ID").(int8) != 1 {
|
||||
t.Fatal("value is not ok")
|
||||
}
|
||||
if GetObjFieldByName(kk, "Name").(string) != "hello" {
|
||||
t.Fatal("value is not ok")
|
||||
}
|
||||
|
||||
pKK := &kk
|
||||
if GetObjFieldByName(pKK, "ID").(int8) != 1 {
|
||||
t.Fatal("value is not ok")
|
||||
}
|
||||
if GetObjFieldByName(pKK, "Name").(string) != "hello" {
|
||||
t.Fatal("value is not ok")
|
||||
}
|
||||
|
||||
SetObjFieldByName(pKK, "ID", int8(100))
|
||||
SetObjFieldByName(pKK, "Name", "world")
|
||||
if GetObjFieldByName(pKK, "ID").(int8) != 100 {
|
||||
t.Fatal("value is not ok")
|
||||
}
|
||||
if GetObjFieldByName(pKK, "Name").(string) != "world" {
|
||||
t.Fatal("value is not ok")
|
||||
}
|
||||
t.Log(utils.Format4Output(pKK, false))
|
||||
}
|
||||
Reference in New Issue
Block a user