10 Star 35 Fork 8

bigpigeon / toyorm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
thread_safe_test.go 973 Bytes
一键复制 编辑 原始数据 按行查看 历史
bigpigeon 提交于 2018-12-09 22:06 . 1. improve custom table name
/*
* Copyright 2018. bigpigeon. All rights reserved.
* Use of this source code is governed by a MIT style
* license that can be found in the LICENSE file.
*/
package toyorm
import (
"encoding/json"
"reflect"
"testing"
)
func TestSameModel(t *testing.T) {
tab := reflect.ValueOf(TestPreloadTable{})
m1 := NewModel(tab)
m2 := NewModel(tab)
m1Value := reflect.ValueOf(*m1)
m2Value := reflect.ValueOf(*m2)
mType := m1Value.Type()
for i := 0; i < mType.NumField(); i++ {
isSame := reflect.DeepEqual(m1Value.Field(i).Interface(), m2Value.Field(i).Interface())
t.Logf("compare field %s is same? %v", mType.Field(i).Name, isSame)
if !isSame {
t.Fail()
f1, err := json.MarshalIndent(m1Value.Field(i).Interface(), "", " ")
if err != nil {
t.Errorf("err %s", err)
}
f2, err := json.MarshalIndent(m2Value.Field(i).Interface(), "", " ")
if err != nil {
t.Errorf("err %s", err)
}
t.Log(string(f1))
t.Log(string(f2))
}
}
}
Go
1
https://gitee.com/bigpigeon/toyorm.git
git@gitee.com:bigpigeon/toyorm.git
bigpigeon
toyorm
toyorm
master

搜索帮助