1 Star 0 Fork 8

jqmtony/toyorm

forked from 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))
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jqmtony/toyorm.git
git@gitee.com:jqmtony/toyorm.git
jqmtony
toyorm
toyorm
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385