Created
July 10, 2019 20:50
-
-
Save mottet-dev/bf625b5d9e12961ecd0a29b03840e7d5 to your computer and use it in GitHub Desktop.
Go Test - TestAreSlicesEqual
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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