mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
go-cmp is stricter and allow to catch more problems. Moreover, the output is a bit nicer.
24 lines
526 B
Go
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]()
|
|
}
|