...

Source file src/edge-infra.dev/pkg/lib/kernel/netlink/ip/ip_test.go

Documentation: edge-infra.dev/pkg/lib/kernel/netlink/ip

     1  package ip
     2  
     3  import (
     4  	"context"
     5  	"net"
     6  	"os"
     7  	"testing"
     8  
     9  	"gotest.tools/v3/assert"
    10  
    11  	"edge-infra.dev/test/f2"
    12  )
    13  
    14  var f f2.Framework
    15  
    16  func TestMain(m *testing.M) {
    17  	f = f2.New(context.Background(), f2.WithExtensions()).
    18  		Setup().
    19  		Teardown()
    20  	os.Exit(f.Run(m))
    21  }
    22  
    23  func TestConvertIPToUint32(t *testing.T) {
    24  	feature := f2.NewFeature("convert ip to uint32").
    25  		Test("convert ip to uint32", func(ctx f2.Context, t *testing.T) f2.Context {
    26  			ip, _, err := net.ParseCIDR("10.10.12.1/32")
    27  			assert.NilError(t, err)
    28  
    29  			unsignedInt := IPv4ToUInt32(ip)
    30  			assert.Equal(t, uint32(168430593), unsignedInt)
    31  
    32  			return ctx
    33  		}).Feature()
    34  
    35  	f.Test(t, feature)
    36  }
    37  

View as plain text