Skip to content

Instantly share code, notes, and snippets.

@mottet-dev
Created July 10, 2019 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mottet-dev/bf625b5d9e12961ecd0a29b03840e7d5 to your computer and use it in GitHub Desktop.
Save mottet-dev/bf625b5d9e12961ecd0a29b03840e7d5 to your computer and use it in GitHub Desktop.
Go Test - TestAreSlicesEqual
func TestAreSlicesEqual(t *testing.T) {
type args struct {
a []int
b []int
}
tests := []struct {
name string
args args
want bool
}{
{
name: "Compare similar slices",
args: args{
a: []int{1, 2, 3, 4},
b: []int{1, 2, 3, 4},
},
want: true,
},
{
name: "Compare slices with same elements but different order",
args: args{
a: []int{1, 2, 3, 4},
b: []int{3, 2, 4, 1},
},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := AreSlicesEqual(tt.args.a, tt.args.b); got != tt.want {
t.Errorf("AreSlicesEqual() = %v, want %v", got, tt.want)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment