You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
stardb/reflect_test.go

50 lines
1014 B
Go

3 years ago
package stardb
import (
"fmt"
"testing"
)
type Useless struct {
3 years ago
Leader string `db:"leader"`
Usable bool `db:"use"`
O *Whoami `db:"---"`
3 years ago
}
type Whoami struct {
Hehe string `db:"hehe"`
3 years ago
}
3 years ago
func TestUpInOrm(t *testing.T) {
var hehe = Useless{
Leader: "no",
Usable: false,
}
sqlstr, param, err := getUpdateSentence(hehe, "ryz", "leader")
fmt.Println(sqlstr, param, err)
sqlstr, param, err = getInsertSentence(hehe, "ryz", "use")
fmt.Println(sqlstr, param, err)
}
3 years ago
func Test_SetRefVal(t *testing.T) {
var hehe = Useless{
Leader: "no",
}
fmt.Printf("%+v\n", hehe)
fmt.Println(setRefValue(&hehe, "db", "leader", "sb"))
fmt.Printf("%+v\n", hehe)
fmt.Printf("%+v\n", hehe)
fmt.Println(getAllRefKey(hehe, "db"))
3 years ago
fmt.Println(getAllRefValue(hehe, "db"))
3 years ago
}
func Test_Ref(t *testing.T) {
3 years ago
oooooo := Useless{
Leader: "Heheeee",
3 years ago
}
3 years ago
oooooo.O = &Whoami{"fuck"}
3 years ago
fmt.Println(getAllRefKey(oooooo, "db"))
fmt.Println(getAllRefValue(oooooo, "db"))
fmt.Println(getAllRefValue(&oooooo, "db"))
3 years ago
}