package two import ( "testing" "github.com/stretchr/testify/assert" ) func TestIncreasedWithDampener(t *testing.T) { tt := map[string]struct { input []int want bool }{ "one violation: two numbers the same": { input: []int{72, 74, 74, 77, 78}, want: true, }, "one violation: not in order": { input: []int{72, 74, 75, 77, 63}, want: true, }, "two violations: three numbers the same": { input: []int{74, 74, 74, 77, 78}, want: false, }, "two violations: two numbers the same and not in order": { input: []int{72, 74, 74, 72, 78}, 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 := checkWithComparator(tc.input, cmp, 0) assert.Equal(t, tc.want, got) }) } } func TestDecreasedWithDampener(t *testing.T) { tt := map[string]struct { input []int want bool }{} 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 := checkWithComparator(tc.input, cmp, 0) assert.Equal(t, tc.want, got) }) } }