2015-11-16 01:55:15 +08:00
|
|
|
package server
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestConfigAddress(t *testing.T) {
|
|
|
|
cfg := Config{Host: "foobar", Port: "1234"}
|
|
|
|
if actual, expected := cfg.Address(), "foobar:1234"; expected != actual {
|
|
|
|
t.Errorf("Expected '%s' but got '%s'", expected, actual)
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg = Config{Host: "", Port: "1234"}
|
|
|
|
if actual, expected := cfg.Address(), ":1234"; expected != actual {
|
|
|
|
t.Errorf("Expected '%s' but got '%s'", expected, actual)
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg = Config{Host: "foobar", Port: ""}
|
|
|
|
if actual, expected := cfg.Address(), "foobar:"; expected != actual {
|
|
|
|
t.Errorf("Expected '%s' but got '%s'", expected, actual)
|
|
|
|
}
|
|
|
|
|
2016-01-04 07:41:29 +08:00
|
|
|
cfg = Config{Host: "::1", Port: "443"}
|
|
|
|
if actual, expected := cfg.Address(), "[::1]:443"; expected != actual {
|
2015-11-16 01:55:15 +08:00
|
|
|
t.Errorf("Expected '%s' but got '%s'", expected, actual)
|
|
|
|
}
|
|
|
|
}
|