diff --git a/static-array/static-array_test.go b/static-array/static-array_test.go index fac39fb..08db07d 100644 --- a/static-array/static-array_test.go +++ b/static-array/static-array_test.go @@ -1,16 +1,35 @@ package main import ( - "testing" "reflect" + "testing" ) -func TestCreateArr(t *testing.T) { - got := CreateArr() - want:= []int{1,2,5,7,9} +var tests = []struct { + name string + out []int + want bool +}{ + { + name: "equals", + out: []int{1, 2, 5, 7, 9}, + want: true, + }, + { + name: "not equals", + out: []int{1, 1, 4, 7, 9}, + want: false, + }, +} - if !reflect.DeepEqual(got, want) { - t.Errorf("got %q want %q", got,want) +func TestCreateArr(t *testing.T) { + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := CreateArr() + equals := reflect.DeepEqual(got, tt.out) + if equals != tt.want { + t.Errorf("test failed") + } + }) } } -