package internal

import (
	"net"
	"reflect"
	"testing"
)

func TestParseIP(t *testing.T) {
	tests := []struct {
		name    string
		input   string
		want    net.IP
		wantErr bool
	}{
		{"localhost", "127.0.0.1", net.IPv4(127, 0, 0, 1), false},
		{"Private#1", "10.4.0.11", net.IPv4(10, 4, 0, 11), false},
		{"Private#2", "192.168.1.12", net.IPv4(192, 168, 1, 12), false},
		{"Public#1", "82.249.10.254", net.IPv4(82, 249, 10, 254), false},
		{"Public#2", "57.167.50.222", net.IPv4(57, 167, 50, 222), false},
		{"Invalid", "xx", nil, true},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got, err := ParseIP(tt.input)
			if (err != nil) != tt.wantErr {
				t.Errorf("ParseIP() error = %v, wantErr %v", err, tt.wantErr)
				return
			}
			if !reflect.DeepEqual(got, tt.want) {
				t.Errorf("ParseIP() = %v, want %v", got, tt.want)
			}
		})
	}
}
