package one import ( "testing" "github.com/stretchr/testify/assert" ) func TestCheckIncreased(t *testing.T) { tt := map[string]struct { input []int want bool }{ "nominal": { input: []int{1, 3, 6, 7, 9}, want: true, }, "unsafe": { input: []int{1, 3, 2, 4, 8}, want: false, }, "two numbers the same": { input: []int{1, 3, 3, 4, 8}, want: false, }, } cmp := func(nums []int, i int) bool { return nums[i-1] >= nums[i] } for name, tc := range tt { t.Run(name, func(t *testing.T) { got := check(tc.input, cmp) assert.Equal(t, tc.want, got) }) } } func TestCheckDecreased(t *testing.T) { tt := map[string]struct { input []int want bool }{ "nominal": { input: []int{7, 6, 4, 2, 1}, want: true, }, "unsafe": { input: []int{9, 7, 6, 2, 1}, want: false, }, "two numbers the same": { input: []int{8, 6, 4, 4, 1}, want: false, }, } cmp := func(nums []int, i int) bool { return nums[i-1] <= nums[i] } for name, tc := range tt { t.Run(name, func(t *testing.T) { got := check(tc.input, cmp) assert.Equal(t, tc.want, got) }) } }