Support multiple expected errors in neverallow_test.go

Extracted some common code used by visibility_test.go and
neverallow_test.go into a new function CheckErrorsAgainstExpectations
in testing.go.

Bug: 138428610
Test: m nothing
Change-Id: I6996fa52968c387e38b4a67ffa59cd07c2d524e8
Merged-In: Iafbadf12c6ffdc4d9128fcfe7f15792df5cfd020
diff --git a/android/visibility_test.go b/android/visibility_test.go
index c44dc9e..d13fadf 100644
--- a/android/visibility_test.go
+++ b/android/visibility_test.go
@@ -860,23 +860,7 @@
 		t.Run(test.name, func(t *testing.T) {
 			_, errs := testVisibility(buildDir, test.fs)
 
-			expectedErrors := test.expectedErrors
-			if expectedErrors == nil {
-				FailIfErrored(t, errs)
-			} else {
-				for _, expectedError := range expectedErrors {
-					FailIfNoMatchingErrors(t, expectedError, errs)
-				}
-				if len(errs) > len(expectedErrors) {
-					t.Errorf("additional errors found, expected %d, found %d", len(expectedErrors), len(errs))
-					for i, expectedError := range expectedErrors {
-						t.Errorf("expectedErrors[%d] = %s", i, expectedError)
-					}
-					for i, err := range errs {
-						t.Errorf("errs[%d] = %s", i, err)
-					}
-				}
-			}
+			CheckErrorsAgainstExpectations(t, errs, test.expectedErrors)
 		})
 	}
 }