return r
}
-func keysForBenchmarking[M ~map[K]V, K comparable, V any](m M, s []K) {
- keys(m, unsafe.Pointer(&s))
-}
-
// values is implemented in the runtime package.
//
//go:noescape
return r
}
-func valuesForBenchmarking[M ~map[K]V, K comparable, V any](m M, s []V) {
- values(m, unsafe.Pointer(&s))
-}
-
// Equal reports whether two maps contain the same key/value pairs.
// Values are compared using ==.
func Equal[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool {
"sort"
"strconv"
"testing"
+ "unsafe"
)
var m1 = map[int]int{1: 2, 2: 4, 4: 8, 8: 16}
var m2 = map[int]string{1: "2", 2: "4", 4: "8", 8: "16"}
+func keysForBenchmarking[M ~map[K]V, K comparable, V any](m M, s []K) {
+ keys(m, unsafe.Pointer(&s))
+}
+
func TestKeys(t *testing.T) {
want := []int{1, 2, 4, 8}
}
}
+func valuesForBenchmarking[M ~map[K]V, K comparable, V any](m M, s []V) {
+ values(m, unsafe.Pointer(&s))
+}
+
func TestValues(t *testing.T) {
got1 := Values(m1)
want1 := []int{2, 4, 8, 16}