Debian Codegraph @

td/equal_unsafe_test.go

raw
1 // Copyright (c) 2022, Maxime Soulé
2 // All rights reserved.
3 //
4 // This source code is licensed under the BSD-style license found in the
5 // LICENSE file in the root directory of this source tree.
6
7 //go:build !js && !appengine && !safe && !disableunsafe
8 // +build !js,!appengine,!safe,!disableunsafe
9
10 package td_test
11
12 import (
13 "testing"
14 )
15
16 // Map, unsafe access is mandatory here.
17 func TestEqualMapUnsafe(t *testing.T) {
18 type key struct{ k string }
19 type A struct{ x map[key]struct{} }
20
21 checkError(t, A{x: map[key]struct{}{{k: "z"}: {}}},
22 A{x: map[key]struct{}{{k: "x"}: {}}},
23 expectedError{
24 Message: mustBe("comparing map"),
25 Path: mustBe("DATA.x"),
26 Summary: mustBe(`Missing key: ((td_test.key) {
27 k: (string) (len=1) "x"
28 })
29 Extra key: ((td_test.key) {
30 k: (string) (len=1) "z"
31 })`),
32 })
33 }