netutil_test.go 674 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (C) 2023 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package netutil
  7. import "testing"
  8. func TestAddress(t *testing.T) {
  9. tests := []struct {
  10. network string
  11. host string
  12. result string
  13. }{
  14. {"tcp", "google.com", "tcp://google.com"},
  15. {"foo", "google", "foo://google"},
  16. {"123", "456", "123://456"},
  17. }
  18. for _, test := range tests {
  19. result := AddressURL(test.network, test.host)
  20. if result != test.result {
  21. t.Errorf("%s != %s", result, test.result)
  22. }
  23. }
  24. }