Skip to content
Snippets Groups Projects
outbound_test.go 852 B
package traceroute

import (
	"strings"
	"testing"
)

func TestGetOutboundIPV6(t *testing.T) {
	ip, err := getOutboundIP(addressV6)

	if err != nil {

		if !strings.Contains(err.Error(), "no suitable interface was found") {
			t.Errorf("this call should not return an error " + err.Error())
		}
		return
	}
	
	if !ip.isV6() {
		t.Errorf("this call should not return an error " + err.Error())
	}
	
	
}

func TestGetOutboundIPV4(t *testing.T) {
	ip, err := getOutboundIP(addressV4)

	if err != nil {

		if !strings.Contains(err.Error(), "no suitable interface was found") {
			t.Errorf("this call should not return an error " + err.Error())
		}
		return

	}

	if !ip.isV4() {
		t.Errorf("this call should not return an error " + err.Error())
	}
	
}

func BenchmarkGetOutboundIP(b *testing.B) {
	for n := 0; n < b.N; n++ {
		getOutboundIP(addressV6)
	}
}