Skip to content
Snippets Groups Projects
Select Git revision
  • d6a983aa3d50fe8979fb68a4d233d1654e5c55d2
  • master default protected
  • renovate/configure
  • 2-create-ospf-example
  • feature/isis
  • migrate-to-github-actions
  • aspath/convenience
  • hashroute/public
  • cmd/rismirror
  • riscli/vrf
  • fix/bmp_down
  • ris/logging
  • fix/ris_race
  • fix/bmp_metrics
  • please-go-vet
  • fix/lock_copy
  • fix/dedup_mem
  • add-get-routers-rpc
  • feature/bgp_md5
  • is-is/srv
  • feature/ris/lpm_any
  • v0.0.3-pre4
  • v0.0.3-pre3
  • v0.0.3-pre2
  • v0.0.3-pre1
  • v0.0.2-pre9
  • v0.0.2-pre8
  • v0.0.2-pre7
  • v0.0.2-pre6
  • v0.0.2-pre5
  • v0.0.2-pre4
  • v0.0.2-pre3
  • v0.0.2-pre2
  • v0.0.2-pre1
  • v0.0.1-pre10
  • v0.0.1-pre9
  • v0.0.1-pre7
  • v0.0.1-pre8
  • v0.0.1-pre6
  • v0.0.1-pre4
  • v0.0.1-pre5
41 results

ip_test.go

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    information_tlv_test.go 1008 B
    package packet
    
    import (
    	"bytes"
    	"testing"
    
    	"github.com/stretchr/testify/assert"
    )
    
    func TestDecodeInformationTLV(t *testing.T) {
    	tests := []struct {
    		name     string
    		input    []byte
    		wantFail bool
    		expected *InformationTLV
    	}{
    		{
    			name: "Full",
    			input: []byte{
    				0, 10, 0, 5,
    				1, 2, 3, 4, 5,
    			},
    			wantFail: false,
    			expected: &InformationTLV{
    				InformationType:   10,
    				InformationLength: 5,
    				Information:       []byte{1, 2, 3, 4, 5},
    			},
    		},
    		{
    			name: "Incomplete",
    			input: []byte{
    				0, 10, 0, 5,
    				1, 2, 3, 4,
    			},
    			wantFail: true,
    		},
    	}
    
    	for _, test := range tests {
    		buf := bytes.NewBuffer(test.input)
    		infoTLV, err := decodeInformationTLV(buf)
    		if err != nil {
    			if test.wantFail {
    				continue
    			}
    
    			t.Errorf("Unexpected failure for test %q: %v", test.name, err)
    			continue
    		}
    
    		if test.wantFail {
    			t.Errorf("Unexpected success for test %q", test.name)
    			continue
    		}
    
    		assert.Equalf(t, test.expected, infoTLV, "Test %q", test.name)
    	}
    }