Files
akvorado/common/helpers/tests_subnetmap.go
Vincent Bernat e2f1df9add tests: replace godebug by go-cmp for structure diffs
go-cmp is stricter and allow to catch more problems. Moreover, the
output is a bit nicer.
2025-08-23 16:03:09 +02:00

24 lines
526 B
Go

// SPDX-FileCopyrightText: 2022 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
//go:build !release
package helpers
import "github.com/google/go-cmp/cmp"
// RegisterSubnetMapCmp register a subnetmap to work with cmp.Equal()/cmp.Diff()
func RegisterSubnetMapCmp[T any]() {
RegisterCmpOption(
cmp.Transformer("subnetmap.Transform",
func(sm *SubnetMap[T]) map[string]T {
return sm.ToMap()
}))
}
func init() {
RegisterSubnetMapCmp[uint16]()
RegisterSubnetMapCmp[uint]()
RegisterSubnetMapCmp[string]()
}