| 1234567891011121314151617181920212223242526272829303132 |
- package common
- import "testing"
- func TestSnake2Orm(t *testing.T) {
- type A struct {
- Id int `json:"id" orm:"EntityId"`
- Name string `json:"name" orm:"Name"`
- Age int
- }
- type args struct {
- entity interface{}
- field string
- }
- tests := []struct {
- name string
- args args
- want string
- }{
- {"struct 类型测试", args{entity: A{}, field: "id"}, "EntityId"},
- {"ptr 类型测试", args{entity: &A{}, field: "id"}, "EntityId"},
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := Snake2Orm(tt.args.entity, tt.args.field); got != tt.want {
- t.Errorf("Snake2Orm() = %v, want %v", got, tt.want)
- }
- })
- }
- }
|