(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func TestNewStructMap(t *testing.T) { |
| 9 | type emptyStruct struct{} |
| 10 | |
| 11 | type args struct { |
| 12 | s interface{} |
| 13 | } |
| 14 | tests := []struct { |
| 15 | name string |
| 16 | args args |
| 17 | expected *StructMap |
| 18 | expectedErr bool |
| 19 | }{ |
| 20 | {"Non Struct", args{make(map[string]string)}, nil, true}, |
| 21 | {"Empty Struct", args{emptyStruct{}}, &StructMap{ |
| 22 | size: 0, |
| 23 | keys: []string{}, |
| 24 | val: reflect.ValueOf(emptyStruct{}), |
| 25 | }, false}, |
| 26 | } |
| 27 | for _, tt := range tests { |
| 28 | t.Run(tt.name, func(t *testing.T) { |
| 29 | actual, err := NewStructMap(tt.args.s) |
| 30 | if (err != nil) != tt.expectedErr { |
| 31 | t.Errorf("NewStructMap() error = %v, expectedErr %v", err, tt.expectedErr) |
| 32 | return |
| 33 | } |
| 34 | if !reflect.DeepEqual(actual, tt.expected) { |
| 35 | t.Errorf("NewStructMap() actual = %v, expected %v", actual, tt.expected) |
| 36 | } |
| 37 | }) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func TestStructMapGet(t *testing.T) { |
| 42 | type testCase struct { |
nothing calls this directly
no test coverage detected