package aretheythesame import "testing" type check struct { name string one, two []int expected bool } func TestComp(t *testing.T) { checks := []check{ { "Good", []int{121, 144, 19, 161, 19, 144, 19, 11}, []int{121, 14641, 20736, 361, 25921, 361, 20736, 361}, true, }, { "132 is not 11^2", []int{121, 144, 19, 161, 19, 144, 19, 11}, []int{132, 14641, 20736, 361, 25921, 361, 20736, 361}, false, }, { "36100 is not the square of any member of a", []int{121, 144, 19, 161, 19, 144, 19, 11}, []int{121, 14641, 20736, 36100, 25921, 361, 20736, 361}, false, }, { "Bad pair", []int{4, 4}, []int{1, 31}, false, }, { "Empty and null", []int{}, nil, false, }, } for _, check := range checks { actual := Comp(check.one, check.two); if actual != check.expected { t.Errorf("%s: expected %v got %v", check.name, check.expected, actual) } } }