Skip to content

Commit

Permalink
refactor: standardize/simplify code
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Soulé <[email protected]>
  • Loading branch information
maxatome committed Jun 23, 2023
1 parent 2bd8c57 commit dd14546
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions td/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,9 @@ func checkOK(t *testing.T, got, expected any,

func checkOKOrPanicIfUnsafeDisabled(t *testing.T, got, expected any,
args ...any,
) bool {
) (ret bool) {
t.Helper()

var ret bool
cmp := func() {
t.Helper()
ret = _checkOK(t, got, expected, args...)
Expand All @@ -385,7 +384,7 @@ func checkOKOrPanicIfUnsafeDisabled(t *testing.T, got, expected any,
}

cmp()
return ret
return
}

func checkOKForEach(t *testing.T, gotList []any, expected any,
Expand All @@ -406,9 +405,7 @@ func checkOKForEach(t *testing.T, gotList []any, expected any,
return
}

func equalTypes(t *testing.T, got td.TestDeep, expected any,
args ...any,
) bool {
func equalTypes(t *testing.T, got td.TestDeep, expected any, args ...any) bool {
gotType := got.TypeBehind()

expectedType, ok := expected.(reflect.Type)
Expand Down
4 changes: 2 additions & 2 deletions td/td_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func mergeStructFields(sfs ...StructFields) StructFields {
}
}

func newStruct(model any, strict bool) (*tdStruct, reflect.Value) {
func newStruct(model any) (*tdStruct, reflect.Value) {
vmodel := reflect.ValueOf(model)

st := tdStruct{
Expand Down Expand Up @@ -237,7 +237,7 @@ func newStruct(model any, strict bool) (*tdStruct, reflect.Value) {
}

func anyStruct(model any, expectedFields StructFields, strict bool) *tdStruct {
st, vmodel := newStruct(model, strict)
st, vmodel := newStruct(model)
if st.err != nil {
return st
}
Expand Down

0 comments on commit dd14546

Please sign in to comment.