package main import ( "testing" ) func TestReportSafety(t *testing.T) { safe := []struct { Name string Report []int }{ {"Safe 1", []int{7, 6, 4, 2, 1}}, {"Safe 2", []int{1, 3, 6, 7, 9}}, } unsafe := []struct { Name string Report []int }{ {"Exceeds local bound 1", []int{1, 2, 7, 8, 9}}, {"Exceeds local bound 2", []int{9, 7, 6, 2, 1}}, {"Not monotonic", []int{1, 3, 2, 4, 5}}, {"Not strict monotonic", []int{8, 6, 4, 4, 1}}, } for _, s := range safe { if !isSafe(s.Report) { t.Errorf("Safe report %#v found unsafe", s.Name) } } for _, u := range unsafe { if isSafe(u.Report) { t.Errorf("Unsafe report %#v found safe", u.Name) } } }