// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package cryptotest

import (
	
	
	
	
)

// NoExtraMethods checks that the concrete type of *ms has no exported methods
// beyond the methods of the interface type of *ms, and any others specified in
// the allowed list.
//
// These methods are accessible through interface upgrades, so they end up part
// of the API even if undocumented per Hyrum's Law.
//
// ms must be a pointer to a non-nil interface.
func ( *testing.T,  interface{},  ...string) {
	.Helper()
	,  := extraMethods()
	if  != nil {
		.Fatal()
	}
	for ,  := range  {
		if slices.Contains(, ) {
			continue
		}
		.Errorf("unexpected method %q", )
	}
}

func extraMethods( interface{}) ([]string, error) {
	 := reflect.ValueOf()
	if .Kind() != reflect.Ptr || .Elem().Kind() != reflect.Interface || .Elem().IsNil() {
		return nil, fmt.Errorf("argument must be a pointer to a non-nil interface")
	}

	 := .Elem().Type()
	 := .Elem().Elem().Type()

	 := make(map[string]bool)
	for  := range .NumMethod() {
		[.Method().Name] = true
	}

	var  []string
	for  := range .NumMethod() {
		 := .Method()
		if !.IsExported() {
			continue
		}
		if ![.Name] {
			 = append(, .Name)
		}
	}

	return , nil
}