| 32 | } |
| 33 | |
| 34 | func TestHost(t *testing.T) { |
| 35 | tests := []struct { |
| 36 | name string |
| 37 | host string |
| 38 | expected string |
| 39 | }{ |
| 40 | {"simple host", "example.com", "example.com"}, |
| 41 | {"host with port", "example.com:8080", "example.com:8080"}, |
| 42 | {"empty host", "", ""}, |
| 43 | {"IP address", "192.168.1.1", "192.168.1.1"}, |
| 44 | } |
| 45 | |
| 46 | for _, tt := range tests { |
| 47 | t.Run(tt.name, func(t *testing.T) { |
| 48 | u := NewURL().Host(tt.host) |
| 49 | if u.URL.Host != tt.expected { |
| 50 | t.Errorf("Expected host %q, got %q", tt.expected, u.URL.Host) |
| 51 | } |
| 52 | }) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestPath(t *testing.T) { |
| 57 | tests := []struct { |