Skip to content

Commit

Permalink
mock: refactor TestIsArgsEqual
Browse files Browse the repository at this point in the history
Refactor tests to use 'append' to build copies of slices instead of
manual loops.

Thanks golangci-lint.
  • Loading branch information
dolmen committed Jul 30, 2023
1 parent 862e410 commit c740480
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions mock/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1616,17 +1616,14 @@ func Test_Mock_IsMethodCallable(t *testing.T) {

func TestIsArgsEqual(t *testing.T) {
var expected = Arguments{5, 3, 4, 6, 7, 2}
var args = make([]interface{}, 5)
for i := 1; i < len(expected); i++ {
args[i-1] = expected[i]
}

// Copy elements 1 to 5
args := append(([]interface{})(nil), expected[1:]...)
args[2] = expected[1]
assert.False(t, isArgsEqual(expected, args))

var arr = make([]interface{}, 6)
for i := 0; i < len(expected); i++ {
arr[i] = expected[i]
}
// Clone
arr := append(([]interface{})(nil), expected...)
assert.True(t, isArgsEqual(expected, arr))
}

Expand Down

0 comments on commit c740480

Please sign in to comment.