go_subnetter/netsplit/tcache_test.go

38 lines
798 B
Go

package netsplit
import (
`fmt`
`net/netip`
"testing"
)
func TestCache(t *testing.T) {
var err error
var ip4 IANARegistry
var ip6 IANARegistry
var reserved map[netip.Prefix]*IANAAddrNetResRecord
if err = SetCachePath("/tmp/subnetter_cache_test"); err != nil {
return
}
if err = EnableCache(true); err != nil {
return
}
if ip4, ip6, reserved, err = RetrieveReserved(); err != nil {
t.Fatal(err)
}
fmt.Printf("IPv4: '%s'\n", ip4.Title)
fmt.Printf("IPv6: '%s'\n", ip6.Title)
fmt.Printf("IPv4 (Internal): '%s'\n", ianaReserved4.Title)
fmt.Printf("IPv6 (Internal): '%s'\n", ianaReserved6.Title)
fmt.Printf("%d Reserved Networks\n", len(reserved))
fmt.Printf("%d Reserved Networks (Internal)\n", len(reservedNets))
if err = CleanCache(); err != nil {
t.Fatal(err)
}
}