github.com/Mericusta/go-stp@v0.6.8/string_test.go (about) 1 package stp 2 3 import ( 4 "reflect" 5 "testing" 6 ) 7 8 type _s struct { 9 s1 string 10 s2 string 11 s3 string 12 s4 []string 13 s5 string 14 // ... 15 } 16 17 func TestConvertStringToStringStruct(t *testing.T) { 18 type args struct { 19 str string 20 splitter string 21 } 22 tests := []struct { 23 name string 24 args args 25 want *_s 26 }{ 27 // TODO: Add test cases. 28 { 29 "test case 1", 30 args{ 31 str: "I am a boy,You are a girl,We are human", 32 splitter: ",", 33 }, 34 &_s{ 35 s1: "I am a boy", 36 s2: "You are a girl", 37 s3: "We are human", 38 }, 39 }, 40 } 41 for _, tt := range tests { 42 t.Run(tt.name, func(t *testing.T) { 43 if got := ConvertStringToStringStruct[_s](tt.args.str, tt.args.splitter); !reflect.DeepEqual(got, tt.want) { 44 t.Errorf("ConvertStringToStringStruct() = %v, want %v", got, tt.want) 45 } 46 }) 47 } 48 }