From e6fe1b4a290ebc80673335910577670038674efa Mon Sep 17 00:00:00 2001 From: Jason Song Date: Wed, 6 May 2020 16:45:35 +0800 Subject: [PATCH] test: add cases --- test/internal/regular/empty_tag_test.go | 40 +++++++ test/internal/regular/user_tag_test.go | 132 ++++++++++++++++++++++++ 2 files changed, 172 insertions(+) diff --git a/test/internal/regular/empty_tag_test.go b/test/internal/regular/empty_tag_test.go index e45e5b1..a3aad28 100644 --- a/test/internal/regular/empty_tag_test.go +++ b/test/internal/regular/empty_tag_test.go @@ -31,3 +31,43 @@ func TestEmpty_Tags(t *testing.T) { }) } } + +func TestEmpty_TagsJson(t *testing.T) { + tests := []struct { + name string + want EmptyTags + }{ + { + name: "regular", + want: EmptyTags{}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := Empty{} + if got := v.TagsJson(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("TagsJson() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestEmpty_TagsBson(t *testing.T) { + tests := []struct { + name string + want EmptyTags + }{ + { + name: "regular", + want: EmptyTags{}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := Empty{} + if got := v.TagsBson(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("TagsBson() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/test/internal/regular/user_tag_test.go b/test/internal/regular/user_tag_test.go index 37dc436..425d69f 100644 --- a/test/internal/regular/user_tag_test.go +++ b/test/internal/regular/user_tag_test.go @@ -99,3 +99,135 @@ func TestUserName_Tags(t *testing.T) { }) } } + +func TestUserName_TagsJson(t *testing.T) { + type fields struct { + First string + Last string + } + tests := []struct { + name string + fields fields + want UserNameTags + }{ + { + name: "regular", + fields: fields{}, + want: UserNameTags{ + First: "first", + Last: "last", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := UserName{ + First: tt.fields.First, + Last: tt.fields.Last, + } + if got := v.TagsJson(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("TagsJson() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestUserName_TagsBson(t *testing.T) { + type fields struct { + First string + Last string + } + tests := []struct { + name string + fields fields + want UserNameTags + }{ + { + name: "regular", + fields: fields{}, + want: UserNameTags{}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := UserName{ + First: tt.fields.First, + Last: tt.fields.Last, + } + if got := v.TagsBson(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("TagsBson() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestUser_TagsJson(t *testing.T) { + type fields struct { + Id int + Name UserName + Email string + age int + } + tests := []struct { + name string + fields fields + want UserTags + }{ + { + name: "regular", + fields: fields{}, + want: UserTags{ + Id: "id", + Name: "name", + Email: "email", + age: "", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := User{ + Id: tt.fields.Id, + Name: tt.fields.Name, + Email: tt.fields.Email, + age: tt.fields.age, + } + if got := v.TagsJson(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("TagsJson() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestUser_TagsBson(t *testing.T) { + type fields struct { + Id int + Name UserName + Email string + age int + } + tests := []struct { + name string + fields fields + want UserTags + }{ + { + name: "regular", + fields: fields{}, + want: UserTags{}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v := User{ + Id: tt.fields.Id, + Name: tt.fields.Name, + Email: tt.fields.Email, + age: tt.fields.age, + } + if got := v.TagsBson(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("TagsBson() = %v, want %v", got, tt.want) + } + }) + } +}