package traceroute

import (
	"fmt"
	"net"
	"testing"
)

func TestNewAddress(t *testing.T) {

	testCases := []struct {
		name           string
		mode int
	}{
		{"127.0.0.1",addressV4},
		{"unsupported", unknown},
		{"::ffff:192.0.2.1", addressV4}, 
		{"2001:4860:4860::8888", addressV6},
		{"2606:2800:220:1:248:1893:25c8:1946", addressV6},
	}
	for _, tc := range testCases {

		t.Run(fmt.Sprintf("%s should fail %d", tc.name, tc.mode), func(t *testing.T) {
			a:= newAddress(net.ParseIP(tc.name))

			if a.isV4()&&tc.mode!=addressV4 {
				t.Errorf("an error has occurred")
			} else if a.isV6()&&tc.mode!=addressV6 {
				t.Errorf("an error has occurred")
			} else if a.isUnknow() &&tc.mode!=unknown{
				t.Errorf("an error has occurred")
			}

		})

	}

}